Fix handling if newline in addmntent.
[glibc.git] / iconvdata / bug-iconv1.c
blob76bcee91838efbc069e9a76ff4d139a6c5687800
1 /* Test program by Satoru Takabayashi. */
2 #include <errno.h>
3 #include <iconv.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
8 int
9 main (int argc, char **argv)
11 const char in[] = "\x41\x42\x43\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa";
12 /* valid eucJP string */
13 const char exp[] = "\x41\x42\x43\x82\xa0\x82\xa2\x82\xa4";
14 size_t outbufsize = 10;
15 /* 10 is too small to store full result (intentional) */
16 size_t inleft, outleft;
17 char *in_p = (char *) in;
18 char out[outbufsize];
19 char *out_p = out;
20 iconv_t cd;
21 int i;
23 inleft = strlen (in);
24 outleft = outbufsize;
26 cd = iconv_open ("SJIS", "eucJP");
27 if (cd == (iconv_t) -1)
29 puts ("iconv_open failed");
30 exit (1);
33 iconv (cd, &in_p, &inleft, &out_p, &outleft); /* this returns E2BIG */
34 for (i = 0; i < outbufsize - outleft; ++i)
35 printf (" %02x", (unsigned char) out[i]);
36 puts ("");
37 iconv_close (cd);
39 return outbufsize - outleft != 9 || memcmp (out, exp, 9) != 0;