diff options
Diffstat (limited to 'tests/test-striconveh.c')
| -rw-r--r-- | tests/test-striconveh.c | 208 |
1 files changed, 105 insertions, 103 deletions
diff --git a/tests/test-striconveh.c b/tests/test-striconveh.c index 15627f3d..c5d06b43 100644 --- a/tests/test-striconveh.c +++ b/tests/test-striconveh.c @@ -1,5 +1,5 @@ /* Test of character set conversion with error handling. - Copyright (C) 2007-2022 Free Software Foundation, Inc. + Copyright (C) 2007-2026 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -52,10 +52,6 @@ main () iconveh_replacement_character, iconveh_escape_sequence }; - size_t indirect; - size_t h; - size_t o; - size_t i; /* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1, ISO-8859-2, UTF-8, and with libiconv or glibc also GB18030. */ @@ -68,7 +64,7 @@ main () iconv_t cd_88592_to_utf8 = iconv_open ("UTF-8", "ISO-8859-2"); iconv_t cd_utf8_to_88592 = iconv_open ("ISO-8859-2", "UTF-8"); iconv_t cd_utf7_to_utf8 = iconv_open ("UTF-8", "UTF-7"); -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) iconv_t cd_ascii_to_gb18030 = iconv_open ("GB18030", "ASCII"); iconv_t cd_utf8_to_gb18030 = iconv_open ("GB18030", "UTF-8"); iconv_t cd_88591_to_gb18030 = iconv_open ("GB18030", "ISO-8859-1"); @@ -82,7 +78,7 @@ main () iconveh_t cdeh_88591_to_utf8; iconveh_t cdeh_utf8_to_88591; iconveh_t cdeh_utf7_to_utf8; -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) iconveh_t cdeh_ascii_to_gb18030; iconveh_t cdeh_88591_to_gb18030; iconveh_t cdeh_utf7_to_gb18030; @@ -93,7 +89,7 @@ main () ASSERT (cd_utf8_to_88591 != (iconv_t)(-1)); ASSERT (cd_88592_to_utf8 != (iconv_t)(-1)); ASSERT (cd_utf8_to_88592 != (iconv_t)(-1)); -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) ASSERT (cd_ascii_to_gb18030 != (iconv_t)(-1)); ASSERT (cd_utf8_to_gb18030 != (iconv_t)(-1)); # endif @@ -130,7 +126,7 @@ main () cdeh_utf7_to_utf8.cd1 = cd_utf7_to_utf8; cdeh_utf7_to_utf8.cd2 = (iconv_t)(-1); -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) cdeh_ascii_to_gb18030.cd = cd_ascii_to_gb18030; cdeh_ascii_to_gb18030.cd1 = cd_ascii_to_utf8; cdeh_ascii_to_gb18030.cd2 = cd_utf8_to_gb18030; @@ -147,14 +143,14 @@ main () /* ------------------------ Test mem_cd_iconveh() ------------------------ */ /* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */ - for (indirect = 0; indirect <= 1; indirect++) + for (size_t indirect = 0; indirect <= 1; indirect++) { - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -171,7 +167,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) ASSERT (offsets[i] == i); ASSERT (offsets[37] == MAGIC); free (offsets); @@ -182,13 +178,13 @@ main () } /* Test conversion from ASCII to ISO-8859-1 with invalid input (EILSEQ). */ - for (indirect = 0; indirect <= 1; indirect++) + for (size_t indirect = 0; indirect <= 1; indirect++) { - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -218,7 +214,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == i); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -232,13 +228,13 @@ main () } /* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */ - for (indirect = 0; indirect <= 1; indirect++) + for (size_t indirect = 0; indirect <= 1; indirect++) { - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -267,7 +263,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == i); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -283,7 +279,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == (i < 5 ? i : i + 5)); ASSERT (offsets[16] == MAGIC); @@ -298,12 +294,12 @@ main () } /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -318,7 +314,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) ASSERT (offsets[i] == (i < 1 ? i : i < 12 ? i + 1 : i < 18 ? i + 2 : @@ -330,14 +326,14 @@ main () } } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) /* Test conversion from ISO-8859-1 to GB18030 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; static const char expected[] = "\2010\2072rger mit b\2010\2132sen B\250\271bchen ohne Augenma\2010\2118"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -352,7 +348,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) ASSERT (offsets[i] == (i < 1 ? i : i < 12 ? i + 3 : i < 18 ? i + 6 : @@ -366,12 +362,12 @@ main () # endif /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -386,7 +382,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 41; i++) + for (size_t i = 0; i < 41; i++) ASSERT (offsets[i] == (i < 1 ? i : i == 1 ? (size_t)(-1) : i < 13 ? i - 1 : @@ -403,11 +399,11 @@ main () } /* Test conversion from ASCII to UTF-8 with invalid input (EILSEQ). */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -434,7 +430,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == i); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -450,7 +446,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == (i < 5 ? i : i + 2)); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -462,13 +458,15 @@ main () } } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) - /* Test conversion from ASCII to GB18030 with invalid input (EILSEQ). */ - for (h = 0; h < SIZEOF (handlers); h++) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || ((__GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2) && !defined __UCLIBC__) + /* Test conversion from ASCII to GB18030 with invalid input (EILSEQ). + Note: glibc's GB18030 converter was buggy in glibc-2.15; fixed by + Andreas Schwab on 2012-02-06. */ + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -495,7 +493,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == i); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -511,7 +509,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == (i < 5 ? i : i + 3)); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -525,11 +523,11 @@ main () # endif /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -556,7 +554,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 17; i++) + for (size_t i = 0; i < 17; i++) ASSERT (offsets[i] == (i < 5 ? i : i == 5 ? (size_t)(-1) : i - 1)); @@ -574,7 +572,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 17; i++) + for (size_t i = 0; i < 17; i++) ASSERT (offsets[i] == (i < 5 ? i : i == 5 ? (size_t)(-1) : i + 4)); @@ -589,11 +587,11 @@ main () } /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\342"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -621,7 +619,7 @@ main () -1 / EILSEQ when converting the 7th byte of the input "+VDLYP9hA". */ # if !(defined __sun && !defined _LIBICONV_VERSION) /* Test conversion from UTF-7 to UTF-8 with EINVAL. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; /* This is base64 encoded 0x54 0x32 0xD8 0x3F 0xD8 0x40. It would @@ -646,9 +644,9 @@ main () free (result); } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) /* Test conversion from UTF-7 to GB18030 with EINVAL. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; /* This is base64 encoded 0x54 0x32 0xD8 0x3F 0xD8 0x40. It would @@ -678,7 +676,7 @@ main () the input "+2D/YQNhB" to U+1FED8 U+3FD8 U+40D8. */ # if !(defined __NetBSD__ && !defined _LIBICONV_VERSION) /* Test conversion from UTF-7 to UTF-8 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; /* This is base64 encoded 0xD8 0x3F 0xD8 0x40 0xD8 0x41. It would @@ -746,9 +744,11 @@ main () } } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) - /* Test conversion from UTF-7 to GB18030 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || ((__GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2) && !defined __UCLIBC__) + /* Test conversion from UTF-7 to GB18030 with EILSEQ. + Note: glibc's GB18030 converter was buggy in glibc-2.15; fixed by + Andreas Schwab on 2012-02-06. */ + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; /* This is base64 encoded 0xD8 0x3F 0xD8 0x40 0xD8 0x41. It would @@ -821,9 +821,9 @@ main () /* ------------------------ Test str_cd_iconveh() ------------------------ */ /* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */ - for (indirect = 0; indirect <= 1; indirect++) + for (size_t indirect = 0; indirect <= 1; indirect++) { - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; @@ -840,9 +840,9 @@ main () } /* Test conversion from ASCII to ISO-8859-1 with invalid input (EILSEQ). */ - for (indirect = 0; indirect <= 1; indirect++) + for (size_t indirect = 0; indirect <= 1; indirect++) { - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */ @@ -871,9 +871,9 @@ main () } /* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */ - for (indirect = 0; indirect <= 1; indirect++) + for (size_t indirect = 0; indirect <= 1; indirect++) { - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */ @@ -909,7 +909,7 @@ main () } /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; @@ -922,9 +922,9 @@ main () free (result); } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) /* Test conversion from ISO-8859-1 to GB18030 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; @@ -939,7 +939,7 @@ main () # endif /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; @@ -953,7 +953,7 @@ main () } /* Test conversion from ASCII to UTF-8 with invalid input (EILSEQ). */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */ @@ -985,9 +985,11 @@ main () } } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) - /* Test conversion from ASCII to GB18030 with invalid input (EILSEQ). */ - for (h = 0; h < SIZEOF (handlers); h++) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || ((__GLIBC__ + (__GLIBC_MINOR__ >= 16) > 2) && !defined __UCLIBC__) + /* Test conversion from ASCII to GB18030 with invalid input (EILSEQ). + Note: glibc's GB18030 converter was buggy in glibc-2.15; fixed by + Andreas Schwab on 2012-02-06. */ + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafa? Maszkowski */ @@ -1021,7 +1023,7 @@ main () # endif /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */ @@ -1054,7 +1056,7 @@ main () } /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\342"; @@ -1078,12 +1080,12 @@ main () /* ------------------------- Test mem_iconveh() ------------------------- */ /* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1098,7 +1100,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) ASSERT (offsets[i] == i); ASSERT (offsets[37] == MAGIC); free (offsets); @@ -1108,11 +1110,11 @@ main () } /* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1139,7 +1141,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == i); ASSERT (offsets[16] == MAGIC); free (offsets); @@ -1155,7 +1157,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) ASSERT (offsets[i] == (i < 5 ? i : i + 5)); ASSERT (offsets[16] == MAGIC); @@ -1169,12 +1171,12 @@ main () } /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1189,7 +1191,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) ASSERT (offsets[i] == (i < 1 ? i : i < 12 ? i + 1 : i < 18 ? i + 2 : @@ -1201,14 +1203,14 @@ main () } } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) /* Test conversion from ISO-8859-1 to GB18030 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; static const char expected[] = "\2010\2072rger mit b\2010\2132sen B\250\271bchen ohne Augenma\2010\2118"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1223,7 +1225,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 37; i++) + for (size_t i = 0; i < 37; i++) ASSERT (offsets[i] == (i < 1 ? i : i < 12 ? i + 3 : i < 18 ? i + 6 : @@ -1237,12 +1239,12 @@ main () # endif /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1257,7 +1259,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 41; i++) + for (size_t i = 0; i < 41; i++) ASSERT (offsets[i] == (i < 1 ? i : i == 1 ? (size_t)(-1) : i < 13 ? i - 1 : @@ -1274,11 +1276,11 @@ main () } /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\305\202 Maszkowski"; /* Rafał Maszkowski */ - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1305,7 +1307,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 17; i++) + for (size_t i = 0; i < 17; i++) ASSERT (offsets[i] == (i < 5 ? i : i == 5 ? (size_t)(-1) : i - 1)); @@ -1323,7 +1325,7 @@ main () ASSERT (result != NULL && memcmp (result, expected, strlen (expected)) == 0); if (o) { - for (i = 0; i < 17; i++) + for (size_t i = 0; i < 17; i++) ASSERT (offsets[i] == (i < 5 ? i : i == 5 ? (size_t)(-1) : i + 4)); @@ -1338,11 +1340,11 @@ main () } /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\342"; - for (o = 0; o < 2; o++) + for (size_t o = 0; o < 2; o++) { size_t *offsets = (o ? new_offsets (strlen (input)) : NULL); char *result = NULL; @@ -1367,7 +1369,7 @@ main () /* ------------------------- Test str_iconveh() ------------------------- */ /* Test conversion from ISO-8859-2 to ISO-8859-1 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; @@ -1379,7 +1381,7 @@ main () } /* Test conversion from ISO-8859-2 to ISO-8859-1 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Rafa\263 Maszkowski"; /* Rafał Maszkowski */ @@ -1410,7 +1412,7 @@ main () } /* Test conversion from ISO-8859-1 to UTF-8 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; @@ -1421,9 +1423,9 @@ main () free (result); } -# if defined _LIBICONV_VERSION || (defined __GLIBC__ && !defined __UCLIBC__) +# if (defined _LIBICONV_VERSION && !(_LIBICONV_VERSION == 0x10b && defined __APPLE__)) || (defined __GLIBC__ && !defined __UCLIBC__) /* Test conversion from ISO-8859-1 to GB18030 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; @@ -1436,7 +1438,7 @@ main () # endif /* Test conversion from UTF-8 to ISO-8859-1 with no errors. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237"; @@ -1448,7 +1450,7 @@ main () } /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "Costs: 27 \342\202\254"; /* EURO SIGN */ @@ -1479,7 +1481,7 @@ main () } /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL. */ - for (h = 0; h < SIZEOF (handlers); h++) + for (size_t h = 0; h < SIZEOF (handlers); h++) { enum iconv_ilseq_handler handler = handlers[h]; static const char input[] = "\342"; @@ -1499,5 +1501,5 @@ main () #endif - return 0; + return test_exit_status; } |
