(cache_addhst): Sync also negative results to disk.
[glibc.git] / iconvdata / bug-iconv2.c
blob4bd45507ab87b1a09767ee18c61c0210637fc5b6
1 /* Test case by Akira Higuchi <a@kondara.org>. */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <iconv.h>
7 int
8 main (void)
10 const char *dummy_codesets[] =
12 "ISO_8859-1", "ISO_8859-2", "ISO_8859-3", "ISO_8859-4",
13 "ISO_8859-5", "ISO_8859-6", "ISO_8859-7", "ISO_8859-8"
15 iconv_t dummy_cd[8], cd_a;
16 int i;
17 char buffer[1024], *to = buffer;
18 char *from = (char *) "foobar";
19 size_t to_left = 1024, from_left = 6;
21 /* load dummy modules */
22 for (i = 0; i < 8; i++)
23 if ((dummy_cd[i] = iconv_open (dummy_codesets[i], "UTF8")) == (iconv_t) -1)
24 exit (1);
26 /* load a module... */
27 if ((cd_a = iconv_open ("EUC-JP", "UTF8")) == (iconv_t) -1)
28 exit (1);
29 /* and close it once. we'll reload this later */
30 iconv_close (cd_a);
32 /* unload dummy modules */
33 for (i = 0; i < 8; i++)
34 iconv_close (dummy_cd[i]);
36 /* load the module again */
37 if ((cd_a = iconv_open ("EUC-JP", "UTF8")) == (iconv_t) -1)
38 exit (1);
40 puts ("This used to crash");
41 printf ("%zd\n", iconv (cd_a, &from, &from_left, &to, &to_left));
42 iconv_close (cd_a);
44 puts ("works now");
46 return 0;