]>
Commit | Line | Data |
---|---|---|
c7c3b0e9 UD |
1 | /* Test case by Akira Higuchi <a@kondara.org>. */ |
2 | ||
3 | #include <stdio.h> | |
4 | #include <stdlib.h> | |
5 | #include <iconv.h> | |
6 | ||
7 | int | |
8 | main (void) | |
9 | { | |
10 | const char *dummy_codesets[] = | |
11 | { | |
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" | |
14 | }; | |
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; | |
20 | ||
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); | |
25 | ||
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); | |
31 | ||
32 | /* unload dummy modules */ | |
33 | for (i = 0; i < 8; i++) | |
34 | iconv_close (dummy_cd[i]); | |
35 | ||
36 | /* load the module again */ | |
37 | if ((cd_a = iconv_open ("EUC-JP", "UTF8")) == (iconv_t) -1) | |
38 | exit (1); | |
39 | ||
40 | puts ("This used to crash"); | |
59553897 | 41 | printf ("%zd\n", iconv (cd_a, &from, &from_left, &to, &to_left)); |
c7c3b0e9 UD |
42 | iconv_close (cd_a); |
43 | ||
44 | puts ("works now"); | |
45 | ||
46 | return 0; | |
47 | } |