summaryrefslogtreecommitdiff
path: root/iconvdata/bug-iconv1.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-08-23 05:52:43 +0000
committerUlrich Drepper <drepper@redhat.com>2000-08-23 05:52:43 +0000
commitcf970a32156e60e8842c5e9e82a3cb147dacaf64 (patch)
tree7c8300ee994a7c0cf9d4c67b41d464f29972d4c3 /iconvdata/bug-iconv1.c
parentdc63ee35750ed8db3e0d7938e74bbadb8cff8446 (diff)
Update.
* iconvdata/sjis.c: In conversion from UCS4, correct test for enough room in target buffer. Patch by KUSANO Takayuki <AE5T-KSN@asahi-net.or.jp> [PR libc/1865]. * iconvdata/bug-iconv1.c: New file. * iconvdata/Makefile (tests): Add bug-iconv1.
Diffstat (limited to 'iconvdata/bug-iconv1.c')
-rw-r--r--iconvdata/bug-iconv1.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/iconvdata/bug-iconv1.c b/iconvdata/bug-iconv1.c
new file mode 100644
index 0000000000..76bcee9183
--- /dev/null
+++ b/iconvdata/bug-iconv1.c
@@ -0,0 +1,40 @@
+/* Test program by Satoru Takabayashi. */
+#include <errno.h>
+#include <iconv.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main (int argc, char **argv)
+{
+ const char in[] = "\x41\x42\x43\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa";
+ /* valid eucJP string */
+ const char exp[] = "\x41\x42\x43\x82\xa0\x82\xa2\x82\xa4";
+ size_t outbufsize = 10;
+ /* 10 is too small to store full result (intentional) */
+ size_t inleft, outleft;
+ char *in_p = (char *) in;
+ char out[outbufsize];
+ char *out_p = out;
+ iconv_t cd;
+ int i;
+
+ inleft = strlen (in);
+ outleft = outbufsize;
+
+ cd = iconv_open ("SJIS", "eucJP");
+ if (cd == (iconv_t) -1)
+ {
+ puts ("iconv_open failed");
+ exit (1);
+ }
+
+ iconv (cd, &in_p, &inleft, &out_p, &outleft); /* this returns E2BIG */
+ for (i = 0; i < outbufsize - outleft; ++i)
+ printf (" %02x", (unsigned char) out[i]);
+ puts ("");
+ iconv_close (cd);
+
+ return outbufsize - outleft != 9 || memcmp (out, exp, 9) != 0;
+}