b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | --- a/src/locale/iconv.c |
| 2 | +++ b/src/locale/iconv.c |
| 3 | @@ -48,6 +48,7 @@ static const unsigned char charmaps[] = |
| 4 | "utf16\0\0\312" |
| 5 | "ucs4\0utf32\0\0\313" |
| 6 | "ucs2\0\0\314" |
| 7 | +#ifdef FULL_ICONV |
| 8 | "eucjp\0\0\320" |
| 9 | "shiftjis\0sjis\0cp932\0\0\321" |
| 10 | "iso2022jp\0\0\322" |
| 11 | @@ -56,6 +57,7 @@ static const unsigned char charmaps[] = |
| 12 | "gb2312\0\0\332" |
| 13 | "big5\0bigfive\0cp950\0big5hkscs\0\0\340" |
| 14 | "euckr\0ksc5601\0ksx1001\0cp949\0\0\350" |
| 15 | +#endif |
| 16 | #include "codepages.h" |
| 17 | ; |
| 18 | |
| 19 | @@ -66,6 +68,7 @@ static const unsigned short legacy_chars |
| 20 | #include "legacychars.h" |
| 21 | }; |
| 22 | |
| 23 | +#ifdef FULL_ICONV |
| 24 | static const unsigned short jis0208[84][94] = { |
| 25 | #include "jis0208.h" |
| 26 | }; |
| 27 | @@ -85,6 +88,7 @@ static const unsigned short hkscs[] = { |
| 28 | static const unsigned short ksc[93][94] = { |
| 29 | #include "ksc.h" |
| 30 | }; |
| 31 | +#endif |
| 32 | |
| 33 | static const unsigned short rev_jis[] = { |
| 34 | #include "revjis.h" |
| 35 | @@ -205,6 +209,7 @@ static unsigned legacy_map(const unsigne |
| 36 | return x < 256 ? x : legacy_chars[x-256]; |
| 37 | } |
| 38 | |
| 39 | +#ifdef FULL_ICONV |
| 40 | static unsigned uni_to_jis(unsigned c) |
| 41 | { |
| 42 | unsigned nel = sizeof rev_jis / sizeof *rev_jis; |
| 43 | @@ -223,6 +228,7 @@ static unsigned uni_to_jis(unsigned c) |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | +#endif |
| 48 | |
| 49 | size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restrict out, size_t *restrict outb) |
| 50 | { |
| 51 | @@ -319,6 +325,7 @@ size_t iconv(iconv_t cd, char **restrict |
| 52 | } |
| 53 | type = scd->state; |
| 54 | continue; |
| 55 | +#ifdef FULL_ICONV |
| 56 | case SHIFT_JIS: |
| 57 | if (c < 128) break; |
| 58 | if (c-0xa1 <= 0xdf-0xa1) { |
| 59 | @@ -518,6 +525,7 @@ size_t iconv(iconv_t cd, char **restrict |
| 60 | c = ksc[c][d]; |
| 61 | if (!c) goto ilseq; |
| 62 | break; |
| 63 | +#endif |
| 64 | default: |
| 65 | if (!c) break; |
| 66 | c = legacy_map(map, c); |
| 67 | @@ -559,6 +567,7 @@ size_t iconv(iconv_t cd, char **restrict |
| 68 | } |
| 69 | } |
| 70 | goto subst; |
| 71 | +#ifdef FULL_ICONV |
| 72 | case SHIFT_JIS: |
| 73 | if (c < 128) goto revout; |
| 74 | if (c == 0xa5) { |
| 75 | @@ -632,6 +641,7 @@ size_t iconv(iconv_t cd, char **restrict |
| 76 | *(*out)++ = 'B'; |
| 77 | *outb -= 8; |
| 78 | break; |
| 79 | +#endif |
| 80 | case UCS2: |
| 81 | totype = UCS2BE; |
| 82 | case UCS2BE: |
| 83 | --- a/src/locale/codepages.h |
| 84 | +++ b/src/locale/codepages.h |
| 85 | @@ -129,6 +129,7 @@ |
| 86 | "\340\204\43\316\100\344\34\144\316\71\350\244\243\316\72\354\264\343\316\73" |
| 87 | "\21\361\44\317\74\364\30\145\17\124\146\345\243\317\76\374\134\304\327\77" |
| 88 | |
| 89 | +#ifdef FULL_ICONV |
| 90 | "cp1250\0" |
| 91 | "windows1250\0" |
| 92 | "\0\40" |
| 93 | @@ -239,6 +240,7 @@ |
| 94 | "\20\105\163\330\64\324\324\145\315\65\330\144\243\315\66\334\334\145\330\67" |
| 95 | "\340\204\43\316\100\344\224\143\316\71\350\244\243\316\72\205\265\343\316\73" |
| 96 | "\21\305\203\330\74\364\330\145\317\75\370\344\243\317\76\374\340\65\362\77" |
| 97 | +#endif |
| 98 | |
| 99 | "koi8r\0" |
| 100 | "\0\40" |