|
|
| version 1.1.1.1, 2012/02/21 22:57:48 | version 1.1.1.3, 2021/03/17 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * Copyright (C) 2000-2002, 2005-2006, 2008 Free Software Foundation, Inc. | * Copyright (C) 2000-2002, 2005-2006, 2008-2009, 2011 Free Software Foundation, Inc. |
| * This file is part of the GNU LIBICONV Library. | * This file is part of the GNU LIBICONV Library. |
| * | * |
| * The GNU LIBICONV Library is free software; you can redistribute it | * The GNU LIBICONV Library is free software; you can redistribute it |
| Line 14 | Line 14 |
| * | * |
| * You should have received a copy of the GNU Library General Public | * You should have received a copy of the GNU Library General Public |
| * License along with the GNU LIBICONV Library; see the file COPYING.LIB. | * License along with the GNU LIBICONV Library; see the file COPYING.LIB. |
| * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, | * If not, see <https://www.gnu.org/licenses/>. |
| * Fifth Floor, Boston, MA 02110-1301, USA. | |
| */ | */ |
| /* This file defines three conversion loops: | /* This file defines three conversion loops: |
| Line 25 | Line 24 |
| */ | */ |
| #if HAVE_WCRTOMB || HAVE_MBRTOWC | #if HAVE_WCRTOMB || HAVE_MBRTOWC |
| /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before | |
| <wchar.h>. | |
| BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be | |
| included before <wchar.h>. | |
| In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined | |
| by <stddef.h>. */ | |
| # include <stddef.h> | |
| # include <stdio.h> | |
| # include <time.h> | |
| # include <wchar.h> | # include <wchar.h> |
| # define BUF_SIZE 64 /* assume MB_LEN_MAX <= 64 */ | # define BUF_SIZE 64 /* assume MB_LEN_MAX <= 64 */ |
| /* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ | /* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ |
| Line 321 static size_t wchar_to_loop_convert (iconv_t icd, | Line 329 static size_t wchar_to_loop_convert (iconv_t icd, |
| size_t result = 0; | size_t result = 0; |
| while (*inbytesleft > 0) { | while (*inbytesleft > 0) { |
| size_t incount; | size_t incount; |
| for (incount = 1; incount <= *inbytesleft; incount++) { | for (incount = 1; ; ) { |
| /* Here incount <= *inbytesleft. */ | |
| char buf[BUF_SIZE]; | char buf[BUF_SIZE]; |
| const char* inptr = *inbuf; | const char* inptr = *inbuf; |
| size_t inleft = incount; | size_t inleft = incount; |
| Line 402 static size_t wchar_to_loop_convert (iconv_t icd, | Line 411 static size_t wchar_to_loop_convert (iconv_t icd, |
| result += res; | result += res; |
| break; | break; |
| } | } |
| } | |
| incount++; | |
| if (incount > *inbytesleft) { | |
| /* Incomplete input. */ | |
| errno = EINVAL; | |
| return -1; | |
| } | } |
| } | } |
| } | } |