diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-02-06 04:20:37 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-02-06 04:20:37 +0000 |
commit | 403cb8a19cb457b7f830520a06b0da5a2b846812 (patch) | |
tree | 1e1991305bb711f5d31bc4fc50e417a30d71c3c2 /localedata | |
parent | 5a35dfca75ee7f2e3b650f2d80a3f1b4802e21e1 (diff) | |
download | glibc-403cb8a19cb457b7f830520a06b0da5a2b846812.tar.gz glibc-403cb8a19cb457b7f830520a06b0da5a2b846812.tar.xz glibc-403cb8a19cb457b7f830520a06b0da5a2b846812.zip |
Update.
* localedata/Makefile (tests): Add bug-iconv-trans. Define bug-iconv-trans-ENV. * localedata/bug-iconv-trans.c: New file. 2001-02-04 Bruno Haible <haible@clisp.cons.org> * iconv/gconv_trans.c (__gconv_transliterate): Use a temporary output pointer, to avoid accumulating output from incomplete (unsuccessful) transliteration attempts. 2001-02-05 Ulrich Drepper <drepper@redhat.com>
Diffstat (limited to 'localedata')
-rw-r--r-- | localedata/Makefile | 4 | ||||
-rw-r--r-- | localedata/bug-iconv-trans.c | 65 |
2 files changed, 68 insertions, 1 deletions
diff --git a/localedata/Makefile b/localedata/Makefile index 235c7b962a..90a7d818f2 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -90,7 +90,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \ tst_wcsxfrm tst_wctob tst_wctomb tst_wctrans \ tst_wctype tst_wcwidth -tests = $(locale_test_suite) tst-digits tst-setlocale +tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans endif # Files to install. @@ -256,3 +256,5 @@ tst_wcwidth-ENV = $(TEST_MBWC_ENV) tst-digits-ENV = $(TEST_MBWC_ENV) tst-setlocale-ENV = LOCPATH=$(common-objpfx)localedata LC_ALL=ja_JP.EUC-JP + +bug-iconv-trans-ENV = LOCPATH=$(common-objpfx)localedata diff --git a/localedata/bug-iconv-trans.c b/localedata/bug-iconv-trans.c new file mode 100644 index 0000000000..83876994df --- /dev/null +++ b/localedata/bug-iconv-trans.c @@ -0,0 +1,65 @@ +#include <iconv.h> +#include <locale.h> +#include <stdio.h> +#include <string.h> + +int +main (void) +{ + iconv_t cd; + const char str[] = "ÄäÖöÜüß"; + const char expected[] = "AEaeOEoeUEuess"; + char *inptr = (char *) str; + size_t inlen = strlen (str) + 1; + char outbuf[500]; + char *outptr = outbuf; + size_t outlen = sizeof (outbuf); + int result = 0; + size_t n; + + if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL) + { + puts ("setlocale failed"); + return 1; + } + + cd = iconv_open ("ANSI_X3.4-1968//TRANSLIT", "ISO-8859-1"); + if (cd == (iconv_t) -1) + { + puts ("iconv_open failed"); + return 1; + } + + n = iconv (cd, &inptr, &inlen, &outptr, &outlen); + if (n != 7) + { + printf ("iconv() returned %Zd, expected 7\n", n); + result = 1; + } + if (inlen != 0) + { + puts ("not all input consumed"); + result = 1; + } + else if (inptr - str != strlen (str) + 1) + { + printf ("inptr wrong, advanced by %td\n", inptr - str); + result = 1; + } + if (memcmp (outbuf, expected, sizeof (expected)) != 0) + { + printf ("result wrong: \"%.*s\", expected: \"%s\"\n", + (int) (sizeof (outbuf) - outlen), outbuf, expected); + result = 1; + } + else if (outlen != sizeof (outbuf) - sizeof (expected)) + { + printf ("outlen wrong: %Zd, expected %Zd\n", outlen, + sizeof (outbuf) - 15); + result = 1; + } + else + printf ("output is \"%s\" which is OK\n", outbuf); + + return result; +} |