Lines 1-123
Link Here
|
1 |
--- Modules/cjkcodecs/_codecs_iso2022.c.orig Sun Jul 18 13:34:33 2004 |
|
|
2 |
+++ Modules/cjkcodecs/_codecs_iso2022.c Sat Aug 21 09:07:17 2004 |
3 |
@@ -2,7 +2,7 @@ |
4 |
* _codecs_iso2022.c: Codecs collection for ISO-2022 encodings. |
5 |
* |
6 |
* Written by Hye-Shik Chang <perky@FreeBSD.org> |
7 |
- * $CJKCodecs: _codecs_iso2022.c,v 1.18 2004/07/07 18:30:17 perky Exp $ |
8 |
+ * $CJKCodecs: _codecs_iso2022.c,v 1.22 2004/08/19 17:08:13 perky Exp $ |
9 |
*/ |
10 |
|
11 |
#define USING_IMPORTED_MAPS |
12 |
@@ -117,7 +117,7 @@ |
13 |
|
14 |
struct iso2022_config { |
15 |
int flags; |
16 |
- const struct iso2022_designation designations[]; /* non-ascii desigs */ |
17 |
+ const struct iso2022_designation *designations; /* non-ascii desigs */ |
18 |
}; |
19 |
|
20 |
/*-*- iso-2022 codec implementation -*-*/ |
21 |
@@ -197,7 +197,9 @@ |
22 |
length = 2; |
23 |
#if Py_UNICODE_SIZE == 2 |
24 |
if (length == 2) { |
25 |
- ucs4_t u4in[2] = {IN1, IN2}; |
26 |
+ ucs4_t u4in[2]; |
27 |
+ u4in[0] = (ucs4_t)IN1; |
28 |
+ u4in[1] = (ucs4_t)IN2; |
29 |
encoded = dsg->encoder(u4in, &length); |
30 |
} else |
31 |
encoded = dsg->encoder(&c, &length); |
32 |
@@ -420,7 +422,7 @@ |
33 |
DECODER(iso2022) |
34 |
{ |
35 |
const struct iso2022_designation *dsgcache = NULL; |
36 |
- |
37 |
+ |
38 |
while (inleft > 0) { |
39 |
unsigned char c = IN1; |
40 |
int err; |
41 |
@@ -1047,50 +1049,52 @@ |
42 |
#define REGISTRY_ISO8859_7 { CHARSET_ISO8859_7, 2, 1, \ |
43 |
NULL, dummy_decoder, dummy_encoder } |
44 |
#define REGISTRY_SENTINEL { 0, } |
45 |
+#define CONFIGDEF(var, attrs) \ |
46 |
+ static const struct iso2022_config iso2022_##var##_config = { \ |
47 |
+ attrs, iso2022_##var##_designations \ |
48 |
+ }; |
49 |
|
50 |
-static const struct iso2022_config iso2022_kr_config = { |
51 |
- 0, |
52 |
- { REGISTRY_KSX1001, REGISTRY_SENTINEL }, |
53 |
+static const struct iso2022_designation iso2022_kr_designations[] = { |
54 |
+ REGISTRY_KSX1001, REGISTRY_SENTINEL |
55 |
}; |
56 |
+CONFIGDEF(kr, 0) |
57 |
|
58 |
-static const struct iso2022_config iso2022_jp_config = { |
59 |
- NO_SHIFT | USE_JISX0208_EXT, |
60 |
- { REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
61 |
- REGISTRY_SENTINEL }, |
62 |
+static const struct iso2022_designation iso2022_jp_designations[] = { |
63 |
+ REGISTRY_JISX0208, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
64 |
+ REGISTRY_SENTINEL |
65 |
}; |
66 |
+CONFIGDEF(jp, NO_SHIFT | USE_JISX0208_EXT) |
67 |
|
68 |
-static const struct iso2022_config iso2022_jp_1_config = { |
69 |
- NO_SHIFT | USE_JISX0208_EXT, |
70 |
- { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
71 |
- REGISTRY_JISX0208_O, REGISTRY_SENTINEL }, |
72 |
+static const struct iso2022_designation iso2022_jp_1_designations[] = { |
73 |
+ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
74 |
+ REGISTRY_JISX0208_O, REGISTRY_SENTINEL |
75 |
}; |
76 |
+CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) |
77 |
|
78 |
-static const struct iso2022_config iso2022_jp_2_config = { |
79 |
- NO_SHIFT | USE_G2 | USE_JISX0208_EXT, |
80 |
- { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, |
81 |
- REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
82 |
- REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }, |
83 |
+static const struct iso2022_designation iso2022_jp_2_designations[] = { |
84 |
+ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, |
85 |
+ REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, |
86 |
+ REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL |
87 |
}; |
88 |
+CONFIGDEF(jp_2, NO_SHIFT | USE_G2 | USE_JISX0208_EXT) |
89 |
|
90 |
-static const struct iso2022_config iso2022_jp_2004_config = { |
91 |
- NO_SHIFT | USE_G2 | USE_JISX0208_EXT, |
92 |
- { REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, |
93 |
- REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, |
94 |
- REGISTRY_SENTINEL }, |
95 |
+static const struct iso2022_designation iso2022_jp_2004_designations[] = { |
96 |
+ REGISTRY_JISX0213_2004_1_PAIRONLY, REGISTRY_JISX0208, |
97 |
+ REGISTRY_JISX0213_2004_1, REGISTRY_JISX0213_2004_2, REGISTRY_SENTINEL |
98 |
}; |
99 |
+CONFIGDEF(jp_2004, NO_SHIFT | USE_JISX0208_EXT) |
100 |
|
101 |
-static const struct iso2022_config iso2022_jp_3_config = { |
102 |
- NO_SHIFT | USE_JISX0208_EXT, |
103 |
- { REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, |
104 |
- REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, |
105 |
- REGISTRY_SENTINEL }, |
106 |
+static const struct iso2022_designation iso2022_jp_3_designations[] = { |
107 |
+ REGISTRY_JISX0213_2000_1_PAIRONLY, REGISTRY_JISX0208, |
108 |
+ REGISTRY_JISX0213_2000_1, REGISTRY_JISX0213_2000_2, REGISTRY_SENTINEL |
109 |
}; |
110 |
+CONFIGDEF(jp_3, NO_SHIFT | USE_JISX0208_EXT) |
111 |
|
112 |
-static const struct iso2022_config iso2022_jp_ext_config = { |
113 |
- NO_SHIFT | USE_JISX0208_EXT, |
114 |
- { REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
115 |
- REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL }, |
116 |
+static const struct iso2022_designation iso2022_jp_ext_designations[] = { |
117 |
+ REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_JISX0201_R, |
118 |
+ REGISTRY_JISX0201_K, REGISTRY_JISX0208_O, REGISTRY_SENTINEL |
119 |
}; |
120 |
+CONFIGDEF(jp_ext, NO_SHIFT | USE_JISX0208_EXT) |
121 |
|
122 |
|
123 |
BEGIN_MAPPINGS_LIST |