|
2 | 2 | * _codecs_iso2022.c: Codecs collection for ISO-2022 encodings. |
3 | 3 | * |
4 | 4 | * Written by Hye-Shik Chang <[email protected]> |
5 | | - * $CJKCodecs: _codecs_iso2022.c,v 1.18 2004/07/07 18:30:17 perky Exp $ |
| 5 | + * $CJKCodecs: _codecs_iso2022.c,v 1.22 2004/08/19 17:08:13 perky Exp $ |
6 | 6 | */ |
7 | 7 |
|
8 | 8 | #define USING_IMPORTED_MAPS |
@@ -117,7 +117,7 @@ struct iso2022_designation { |
117 | 117 |
|
118 | 118 | struct iso2022_config { |
119 | 119 | int flags; |
120 | | - const struct iso2022_designation designations[]; /* non-ascii desigs */ |
| 120 | + const struct iso2022_designation *designations; /* non-ascii desigs */ |
121 | 121 | }; |
122 | 122 |
|
123 | 123 | /*-*- iso-2022 codec implementation -*-*/ |
@@ -197,7 +197,9 @@ ENCODER(iso2022) |
197 | 197 | length = 2; |
198 | 198 | #if Py_UNICODE_SIZE == 2 |
199 | 199 | if (length == 2) { |
200 | | - ucs4_t u4in[2] = {IN1, IN2}; |
| 200 | + ucs4_t u4in[2]; |
| 201 | + u4in[0] = (ucs4_t)IN1; |
| 202 | + u4in[1] = (ucs4_t)IN2; |
201 | 203 | encoded = dsg->encoder(u4in, &length); |
202 | 204 | } else |
203 | 205 | encoded = dsg->encoder(&c, &length); |
@@ -420,7 +422,7 @@ iso2022processg2(const void *config, MultibyteCodec_State *state, |
420 | 422 | DECODER(iso2022) |
421 | 423 | { |
422 | 424 | const struct iso2022_designation *dsgcache = NULL; |
423 | | - |
| 425 | + |
424 | 426 | while (inleft > 0) { |
425 | 427 | unsigned char c = IN1; |
426 | 428 | int err; |
@@ -1047,50 +1049,52 @@ dummy_encoder(const ucs4_t *data, int *length) |
1047 | 1049 | #define REGISTRY_ISO8859_7 { CHARSET_ISO8859_7, 2, 1, \ |
1048 | 1050 | NULL, dummy_decoder, dummy_encoder } |
1049 | 1051 | #define REGISTRY_SENTINEL { 0, } |
| 1052 | +#define CONFIGDEF(var, attrs) \ |
| 1053 | + static const struct iso2022_config iso2022_##var##_config = { \ |
| 1054 | + attrs, iso2022_##var##_designations \ |
| 1055 | + }; |
1050 | 1056 |
|
1051 | | -static const struct iso2022_config iso2022_kr_config = { |
1052 | | - 0, |
1053 | | - { REGISTRY_KSX1001, REGISTRY_SENTINEL }, |
| 1057 | +static const struct iso2022_designation iso2022_kr_designations[] = { |
| 1058 | + REGISTRY_KSX1001, REGISTRY_SENTINEL |
1054 | 1059 | }; |
| 1060 | +CONFIGDEF(kr, 0) |
1055 | 1061 |
|
1056 | | -static const struct iso2022_config iso2022_jp_config = { |
1057 | | - NO_SHIFT | USE_JISX0208_EXT, |
1058 | | - { REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
1059 | | - REGISTRY_SENTINEL }, |
| 1062 | +static const struct iso2022_designation iso2022_jp_designations[] = { |
| 1063 | + REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
| 1064 | + REGISTRY_SENTINEL |
1060 | 1065 | }; |
| 1066 | +CONFIGDEF(jp, NO_SHIFT | USE_JISX0208_EXT) |
1061 | 1067 |
|
1062 | | -static const struct iso2022_config iso2022_jp_1_config = { |
1063 | | - NO_SHIFT | USE_JISX0208_EXT, |
1064 | | - { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
1065 | | - REGISTRY_JISX0208_O, REGISTRY_SENTINEL }, |
| 1068 | +static const struct iso2022_designation iso2022_jp_1_designations[] = { |
| 1069 | + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
| 1070 | + REGISTRY_JISX0208_O, REGISTRY_SENTINEL |
1066 | 1071 | }; |
| 1072 | +CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) |
1067 | 1073 |
|
1068 | | -static const struct iso2022_config iso2022_jp_2_config = { |
1069 | | - NO_SHIFT | USE_G2 | USE_JISX0208_EXT, |
1070 | | - { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, |
1071 | | - REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
1072 | | - REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }, |
| 1074 | +static const struct iso2022_designation iso2022_jp_2_designations[] = { |
| 1075 | + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, |
| 1076 | + REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
| 1077 | + REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL |
1073 | 1078 | }; |
| 1079 | +CONFIGDEF(jp_2, NO_SHIFT | USE_G2 | USE_JISX0208_EXT) |
1074 | 1080 |
|
1075 | | -static const struct iso2022_config iso2022_jp_2004_config = { |
1076 | | - NO_SHIFT | USE_G2 | USE_JISX0208_EXT, |
1077 | | - { REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, |
1078 | | - REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, |
1079 | | - REGISTRY_SENTINEL }, |
| 1081 | +static const struct iso2022_designation iso2022_jp_2004_designations[] = { |
| 1082 | + REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, |
| 1083 | + REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, REGISTRY_SENTINEL |
1080 | 1084 | }; |
| 1085 | +CONFIGDEF(jp_2004, NO_SHIFT | USE_JISX0208_EXT) |
1081 | 1086 |
|
1082 | | -static const struct iso2022_config iso2022_jp_3_config = { |
1083 | | - NO_SHIFT | USE_JISX0208_EXT, |
1084 | | - { REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, |
1085 | | - REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, |
1086 | | - REGISTRY_SENTINEL }, |
| 1087 | +static const struct iso2022_designation iso2022_jp_3_designations[] = { |
| 1088 | + REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, |
| 1089 | + REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, REGISTRY_SENTINEL |
1087 | 1090 | }; |
| 1091 | +CONFIGDEF(jp_3, NO_SHIFT | USE_JISX0208_EXT) |
1088 | 1092 |
|
1089 | | -static const struct iso2022_config iso2022_jp_ext_config = { |
1090 | | - NO_SHIFT | USE_JISX0208_EXT, |
1091 | | - { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
1092 | | - REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL }, |
| 1093 | +static const struct iso2022_designation iso2022_jp_ext_designations[] = { |
| 1094 | + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
| 1095 | + REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL |
1093 | 1096 | }; |
| 1097 | +CONFIGDEF(jp_ext, NO_SHIFT | USE_JISX0208_EXT) |
1094 | 1098 |
|
1095 | 1099 |
|
1096 | 1100 | BEGIN_MAPPINGS_LIST |
|
0 commit comments