Use binutils 2.41 branch in build-many-glibcs.py
[glibc.git] / iconvdata / bug-iconv2.c
blobd3c9641a1f68c0c42220a03ad927ece124554a05
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <iconv.h>
6 int
7 main (void)
9 const char *dummy_codesets[] =
11 "ISO_8859-1", "ISO_8859-2", "ISO_8859-3", "ISO_8859-4",
12 "ISO_8859-5", "ISO_8859-6", "ISO_8859-7", "ISO_8859-8"
14 iconv_t dummy_cd[8], cd_a;
15 int i;
16 char buffer[1024], *to = buffer;
17 char *from = (char *) "foobar";
18 size_t to_left = 1024, from_left = 6;
20 /* load dummy modules */
21 for (i = 0; i < 8; i++)
22 if ((dummy_cd[i] = iconv_open (dummy_codesets[i], "UTF8")) == (iconv_t) -1)
23 exit (1);
25 /* load a module... */
26 if ((cd_a = iconv_open ("EUC-JP", "UTF8")) == (iconv_t) -1)
27 exit (1);
28 /* and close it once. we'll reload this later */
29 iconv_close (cd_a);
31 /* unload dummy modules */
32 for (i = 0; i < 8; i++)
33 iconv_close (dummy_cd[i]);
35 /* load the module again */
36 if ((cd_a = iconv_open ("EUC-JP", "UTF8")) == (iconv_t) -1)
37 exit (1);
39 puts ("This used to crash");
40 printf ("%zd\n", iconv (cd_a, &from, &from_left, &to, &to_left));
41 iconv_close (cd_a);
43 puts ("works now");
45 return 0;