universally apply our cflags (no vsx, no altivec..)
[glibc.git] / iconvdata / bug-iconv2.c
1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <iconv.h>
5
6 int
7 main (void)
8 {
9 const char *dummy_codesets[] =
10 {
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"
13 };
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;
19
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);
24
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);
30
31 /* unload dummy modules */
32 for (i = 0; i < 8; i++)
33 iconv_close (dummy_cd[i]);
34
35 /* load the module again */
36 if ((cd_a = iconv_open ("EUC-JP", "UTF8")) == (iconv_t) -1)
37 exit (1);
38
39 puts ("This used to crash");
40 printf ("%zd\n", iconv (cd_a, &from, &from_left, &to, &to_left));
41 iconv_close (cd_a);
42
43 puts ("works now");
44
45 return 0;
46 }