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