diff options
author | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-08 15:39:03 -0400 |
commit | 5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch) | |
tree | 4470480d904b65cf14ca524f96f79eca818c3eaf /REORG.TODO/iconvdata/bug-iconv9.c | |
parent | 199fc19d3aaaf57944ef036e15904febe877fc93 (diff) | |
download | glibc-zack/build-layout-experiment.tar.gz glibc-zack/build-layout-experiment.tar.xz glibc-zack/build-layout-experiment.zip |
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'REORG.TODO/iconvdata/bug-iconv9.c')
-rw-r--r-- | REORG.TODO/iconvdata/bug-iconv9.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/REORG.TODO/iconvdata/bug-iconv9.c b/REORG.TODO/iconvdata/bug-iconv9.c new file mode 100644 index 0000000000..28f88d22e9 --- /dev/null +++ b/REORG.TODO/iconvdata/bug-iconv9.c @@ -0,0 +1,68 @@ +// BZ 12814 +#include <errno.h> +#include <iconv.h> +#include <stdio.h> +#include <string.h> + +static int +do_test (void) +{ + iconv_t h = iconv_open ("ISO-2022-JP-2", "UTF-8"); + if (h == (iconv_t) -1) + { + printf ("cannot load iconv module: %m\n"); + return 1; + } + + // Euro sign + static const char inbuf[] = "\xe2\x82\xac"; + char *in = (char *) inbuf; + size_t inlen = sizeof (inbuf) - 1; + + char outbuf[100]; + char *out = outbuf; + size_t outlen = sizeof (outbuf); + + int res = 0; + size_t n = iconv (h, &in, &inlen, &out, &outlen); + if (n == (size_t) -1) + { + printf ("iconv failed with %d: %m\n", errno); + return 1; + } + if (n != 0) + { + printf ("iconv returned %zu, expected zero\n", n); + res = 1; + } + if (in != inbuf + sizeof (inbuf) - 1) + { + printf ("in advanced by %td, expected %zu\n", + in - inbuf, sizeof (inbuf) - 1); + res = 1; + } + static const char expected[] = "\x1b\x2e\x46\x1b\x4e\x24"; + if (out - outbuf != sizeof (expected) - 1 + || memcmp (outbuf, expected, sizeof (expected) - 1) != 0) + { + fputs ("generated sequence is: \"", stdout); + for (size_t i = 0; i < out - outbuf; ++i) + printf ("\\x%02hhx", outbuf[i]); + fputs ("\", expected \"", stdout); + for (size_t i = 0; i < sizeof (expected) - 1; ++i) + printf ("\\x%02hhx", expected[i]); + puts ("\""); + res = 1; + } + + if (iconv_close (h) != 0) + { + puts ("failed closing iconv module"); + res = 1; + } + + return res; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |