1 | n/a | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd |
---|
2 | n/a | See the file COPYING for copying permission. |
---|
3 | n/a | */ |
---|
4 | n/a | |
---|
5 | n/a | #include <stddef.h> |
---|
6 | n/a | |
---|
7 | n/a | #ifdef COMPILED_FROM_DSP |
---|
8 | n/a | #include "winconfig.h" |
---|
9 | n/a | #elif defined(MACOS_CLASSIC) |
---|
10 | n/a | #include "macconfig.h" |
---|
11 | n/a | #elif defined(__amigaos__) |
---|
12 | n/a | #include "amigaconfig.h" |
---|
13 | n/a | #elif defined(__WATCOMC__) |
---|
14 | n/a | #include "watcomconfig.h" |
---|
15 | n/a | #else |
---|
16 | n/a | #ifdef HAVE_EXPAT_CONFIG_H |
---|
17 | n/a | #include <expat_config.h> |
---|
18 | n/a | #endif |
---|
19 | n/a | #endif /* ndef COMPILED_FROM_DSP */ |
---|
20 | n/a | |
---|
21 | n/a | #include "expat_external.h" |
---|
22 | n/a | #include "internal.h" |
---|
23 | n/a | #include "xmltok.h" |
---|
24 | n/a | #include "nametab.h" |
---|
25 | n/a | |
---|
26 | n/a | #ifdef XML_DTD |
---|
27 | n/a | #define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) |
---|
28 | n/a | #else |
---|
29 | n/a | #define IGNORE_SECTION_TOK_VTABLE /* as nothing */ |
---|
30 | n/a | #endif |
---|
31 | n/a | |
---|
32 | n/a | #define VTABLE1 \ |
---|
33 | n/a | { PREFIX(prologTok), PREFIX(contentTok), \ |
---|
34 | n/a | PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ |
---|
35 | n/a | { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ |
---|
36 | n/a | PREFIX(sameName), \ |
---|
37 | n/a | PREFIX(nameMatchesAscii), \ |
---|
38 | n/a | PREFIX(nameLength), \ |
---|
39 | n/a | PREFIX(skipS), \ |
---|
40 | n/a | PREFIX(getAtts), \ |
---|
41 | n/a | PREFIX(charRefNumber), \ |
---|
42 | n/a | PREFIX(predefinedEntityName), \ |
---|
43 | n/a | PREFIX(updatePosition), \ |
---|
44 | n/a | PREFIX(isPublicId) |
---|
45 | n/a | |
---|
46 | n/a | #define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16) |
---|
47 | n/a | |
---|
48 | n/a | #define UCS2_GET_NAMING(pages, hi, lo) \ |
---|
49 | n/a | (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F))) |
---|
50 | n/a | |
---|
51 | n/a | /* A 2 byte UTF-8 representation splits the characters 11 bits between |
---|
52 | n/a | the bottom 5 and 6 bits of the bytes. We need 8 bits to index into |
---|
53 | n/a | pages, 3 bits to add to that index and 5 bits to generate the mask. |
---|
54 | n/a | */ |
---|
55 | n/a | #define UTF8_GET_NAMING2(pages, byte) \ |
---|
56 | n/a | (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ |
---|
57 | n/a | + ((((byte)[0]) & 3) << 1) \ |
---|
58 | n/a | + ((((byte)[1]) >> 5) & 1)] \ |
---|
59 | n/a | & (1 << (((byte)[1]) & 0x1F))) |
---|
60 | n/a | |
---|
61 | n/a | /* A 3 byte UTF-8 representation splits the characters 16 bits between |
---|
62 | n/a | the bottom 4, 6 and 6 bits of the bytes. We need 8 bits to index |
---|
63 | n/a | into pages, 3 bits to add to that index and 5 bits to generate the |
---|
64 | n/a | mask. |
---|
65 | n/a | */ |
---|
66 | n/a | #define UTF8_GET_NAMING3(pages, byte) \ |
---|
67 | n/a | (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \ |
---|
68 | n/a | + ((((byte)[1]) >> 2) & 0xF)] \ |
---|
69 | n/a | << 3) \ |
---|
70 | n/a | + ((((byte)[1]) & 3) << 1) \ |
---|
71 | n/a | + ((((byte)[2]) >> 5) & 1)] \ |
---|
72 | n/a | & (1 << (((byte)[2]) & 0x1F))) |
---|
73 | n/a | |
---|
74 | n/a | #define UTF8_GET_NAMING(pages, p, n) \ |
---|
75 | n/a | ((n) == 2 \ |
---|
76 | n/a | ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ |
---|
77 | n/a | : ((n) == 3 \ |
---|
78 | n/a | ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \ |
---|
79 | n/a | : 0)) |
---|
80 | n/a | |
---|
81 | n/a | /* Detection of invalid UTF-8 sequences is based on Table 3.1B |
---|
82 | n/a | of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/ |
---|
83 | n/a | with the additional restriction of not allowing the Unicode |
---|
84 | n/a | code points 0xFFFF and 0xFFFE (sequences EF,BF,BF and EF,BF,BE). |
---|
85 | n/a | Implementation details: |
---|
86 | n/a | (A & 0x80) == 0 means A < 0x80 |
---|
87 | n/a | and |
---|
88 | n/a | (A & 0xC0) == 0xC0 means A > 0xBF |
---|
89 | n/a | */ |
---|
90 | n/a | |
---|
91 | n/a | #define UTF8_INVALID2(p) \ |
---|
92 | n/a | ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0) |
---|
93 | n/a | |
---|
94 | n/a | #define UTF8_INVALID3(p) \ |
---|
95 | n/a | (((p)[2] & 0x80) == 0 \ |
---|
96 | n/a | || \ |
---|
97 | n/a | ((*p) == 0xEF && (p)[1] == 0xBF \ |
---|
98 | n/a | ? \ |
---|
99 | n/a | (p)[2] > 0xBD \ |
---|
100 | n/a | : \ |
---|
101 | n/a | ((p)[2] & 0xC0) == 0xC0) \ |
---|
102 | n/a | || \ |
---|
103 | n/a | ((*p) == 0xE0 \ |
---|
104 | n/a | ? \ |
---|
105 | n/a | (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \ |
---|
106 | n/a | : \ |
---|
107 | n/a | ((p)[1] & 0x80) == 0 \ |
---|
108 | n/a | || \ |
---|
109 | n/a | ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0))) |
---|
110 | n/a | |
---|
111 | n/a | #define UTF8_INVALID4(p) \ |
---|
112 | n/a | (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \ |
---|
113 | n/a | || \ |
---|
114 | n/a | ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \ |
---|
115 | n/a | || \ |
---|
116 | n/a | ((*p) == 0xF0 \ |
---|
117 | n/a | ? \ |
---|
118 | n/a | (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \ |
---|
119 | n/a | : \ |
---|
120 | n/a | ((p)[1] & 0x80) == 0 \ |
---|
121 | n/a | || \ |
---|
122 | n/a | ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) |
---|
123 | n/a | |
---|
124 | n/a | static int PTRFASTCALL |
---|
125 | n/a | isNever(const ENCODING *enc, const char *p) |
---|
126 | n/a | { |
---|
127 | n/a | return 0; |
---|
128 | n/a | } |
---|
129 | n/a | |
---|
130 | n/a | static int PTRFASTCALL |
---|
131 | n/a | utf8_isName2(const ENCODING *enc, const char *p) |
---|
132 | n/a | { |
---|
133 | n/a | return UTF8_GET_NAMING2(namePages, (const unsigned char *)p); |
---|
134 | n/a | } |
---|
135 | n/a | |
---|
136 | n/a | static int PTRFASTCALL |
---|
137 | n/a | utf8_isName3(const ENCODING *enc, const char *p) |
---|
138 | n/a | { |
---|
139 | n/a | return UTF8_GET_NAMING3(namePages, (const unsigned char *)p); |
---|
140 | n/a | } |
---|
141 | n/a | |
---|
142 | n/a | #define utf8_isName4 isNever |
---|
143 | n/a | |
---|
144 | n/a | static int PTRFASTCALL |
---|
145 | n/a | utf8_isNmstrt2(const ENCODING *enc, const char *p) |
---|
146 | n/a | { |
---|
147 | n/a | return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p); |
---|
148 | n/a | } |
---|
149 | n/a | |
---|
150 | n/a | static int PTRFASTCALL |
---|
151 | n/a | utf8_isNmstrt3(const ENCODING *enc, const char *p) |
---|
152 | n/a | { |
---|
153 | n/a | return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p); |
---|
154 | n/a | } |
---|
155 | n/a | |
---|
156 | n/a | #define utf8_isNmstrt4 isNever |
---|
157 | n/a | |
---|
158 | n/a | static int PTRFASTCALL |
---|
159 | n/a | utf8_isInvalid2(const ENCODING *enc, const char *p) |
---|
160 | n/a | { |
---|
161 | n/a | return UTF8_INVALID2((const unsigned char *)p); |
---|
162 | n/a | } |
---|
163 | n/a | |
---|
164 | n/a | static int PTRFASTCALL |
---|
165 | n/a | utf8_isInvalid3(const ENCODING *enc, const char *p) |
---|
166 | n/a | { |
---|
167 | n/a | return UTF8_INVALID3((const unsigned char *)p); |
---|
168 | n/a | } |
---|
169 | n/a | |
---|
170 | n/a | static int PTRFASTCALL |
---|
171 | n/a | utf8_isInvalid4(const ENCODING *enc, const char *p) |
---|
172 | n/a | { |
---|
173 | n/a | return UTF8_INVALID4((const unsigned char *)p); |
---|
174 | n/a | } |
---|
175 | n/a | |
---|
176 | n/a | struct normal_encoding { |
---|
177 | n/a | ENCODING enc; |
---|
178 | n/a | unsigned char type[256]; |
---|
179 | n/a | #ifdef XML_MIN_SIZE |
---|
180 | n/a | int (PTRFASTCALL *byteType)(const ENCODING *, const char *); |
---|
181 | n/a | int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *); |
---|
182 | n/a | int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *); |
---|
183 | n/a | int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *); |
---|
184 | n/a | int (PTRCALL *charMatches)(const ENCODING *, const char *, int); |
---|
185 | n/a | #endif /* XML_MIN_SIZE */ |
---|
186 | n/a | int (PTRFASTCALL *isName2)(const ENCODING *, const char *); |
---|
187 | n/a | int (PTRFASTCALL *isName3)(const ENCODING *, const char *); |
---|
188 | n/a | int (PTRFASTCALL *isName4)(const ENCODING *, const char *); |
---|
189 | n/a | int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *); |
---|
190 | n/a | int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *); |
---|
191 | n/a | int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *); |
---|
192 | n/a | int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *); |
---|
193 | n/a | int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *); |
---|
194 | n/a | int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *); |
---|
195 | n/a | }; |
---|
196 | n/a | |
---|
197 | n/a | #define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc)) |
---|
198 | n/a | |
---|
199 | n/a | #ifdef XML_MIN_SIZE |
---|
200 | n/a | |
---|
201 | n/a | #define STANDARD_VTABLE(E) \ |
---|
202 | n/a | E ## byteType, \ |
---|
203 | n/a | E ## isNameMin, \ |
---|
204 | n/a | E ## isNmstrtMin, \ |
---|
205 | n/a | E ## byteToAscii, \ |
---|
206 | n/a | E ## charMatches, |
---|
207 | n/a | |
---|
208 | n/a | #else |
---|
209 | n/a | |
---|
210 | n/a | #define STANDARD_VTABLE(E) /* as nothing */ |
---|
211 | n/a | |
---|
212 | n/a | #endif |
---|
213 | n/a | |
---|
214 | n/a | #define NORMAL_VTABLE(E) \ |
---|
215 | n/a | E ## isName2, \ |
---|
216 | n/a | E ## isName3, \ |
---|
217 | n/a | E ## isName4, \ |
---|
218 | n/a | E ## isNmstrt2, \ |
---|
219 | n/a | E ## isNmstrt3, \ |
---|
220 | n/a | E ## isNmstrt4, \ |
---|
221 | n/a | E ## isInvalid2, \ |
---|
222 | n/a | E ## isInvalid3, \ |
---|
223 | n/a | E ## isInvalid4 |
---|
224 | n/a | |
---|
225 | n/a | static int FASTCALL checkCharRefNumber(int); |
---|
226 | n/a | |
---|
227 | n/a | #include "xmltok_impl.h" |
---|
228 | n/a | #include "ascii.h" |
---|
229 | n/a | |
---|
230 | n/a | #ifdef XML_MIN_SIZE |
---|
231 | n/a | #define sb_isNameMin isNever |
---|
232 | n/a | #define sb_isNmstrtMin isNever |
---|
233 | n/a | #endif |
---|
234 | n/a | |
---|
235 | n/a | #ifdef XML_MIN_SIZE |
---|
236 | n/a | #define MINBPC(enc) ((enc)->minBytesPerChar) |
---|
237 | n/a | #else |
---|
238 | n/a | /* minimum bytes per character */ |
---|
239 | n/a | #define MINBPC(enc) 1 |
---|
240 | n/a | #endif |
---|
241 | n/a | |
---|
242 | n/a | #define SB_BYTE_TYPE(enc, p) \ |
---|
243 | n/a | (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) |
---|
244 | n/a | |
---|
245 | n/a | #ifdef XML_MIN_SIZE |
---|
246 | n/a | static int PTRFASTCALL |
---|
247 | n/a | sb_byteType(const ENCODING *enc, const char *p) |
---|
248 | n/a | { |
---|
249 | n/a | return SB_BYTE_TYPE(enc, p); |
---|
250 | n/a | } |
---|
251 | n/a | #define BYTE_TYPE(enc, p) \ |
---|
252 | n/a | (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) |
---|
253 | n/a | #else |
---|
254 | n/a | #define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) |
---|
255 | n/a | #endif |
---|
256 | n/a | |
---|
257 | n/a | #ifdef XML_MIN_SIZE |
---|
258 | n/a | #define BYTE_TO_ASCII(enc, p) \ |
---|
259 | n/a | (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) |
---|
260 | n/a | static int PTRFASTCALL |
---|
261 | n/a | sb_byteToAscii(const ENCODING *enc, const char *p) |
---|
262 | n/a | { |
---|
263 | n/a | return *p; |
---|
264 | n/a | } |
---|
265 | n/a | #else |
---|
266 | n/a | #define BYTE_TO_ASCII(enc, p) (*(p)) |
---|
267 | n/a | #endif |
---|
268 | n/a | |
---|
269 | n/a | #define IS_NAME_CHAR(enc, p, n) \ |
---|
270 | n/a | (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p)) |
---|
271 | n/a | #define IS_NMSTRT_CHAR(enc, p, n) \ |
---|
272 | n/a | (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p)) |
---|
273 | n/a | #define IS_INVALID_CHAR(enc, p, n) \ |
---|
274 | n/a | (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p)) |
---|
275 | n/a | |
---|
276 | n/a | #ifdef XML_MIN_SIZE |
---|
277 | n/a | #define IS_NAME_CHAR_MINBPC(enc, p) \ |
---|
278 | n/a | (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) |
---|
279 | n/a | #define IS_NMSTRT_CHAR_MINBPC(enc, p) \ |
---|
280 | n/a | (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) |
---|
281 | n/a | #else |
---|
282 | n/a | #define IS_NAME_CHAR_MINBPC(enc, p) (0) |
---|
283 | n/a | #define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) |
---|
284 | n/a | #endif |
---|
285 | n/a | |
---|
286 | n/a | #ifdef XML_MIN_SIZE |
---|
287 | n/a | #define CHAR_MATCHES(enc, p, c) \ |
---|
288 | n/a | (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) |
---|
289 | n/a | static int PTRCALL |
---|
290 | n/a | sb_charMatches(const ENCODING *enc, const char *p, int c) |
---|
291 | n/a | { |
---|
292 | n/a | return *p == c; |
---|
293 | n/a | } |
---|
294 | n/a | #else |
---|
295 | n/a | /* c is an ASCII character */ |
---|
296 | n/a | #define CHAR_MATCHES(enc, p, c) (*(p) == c) |
---|
297 | n/a | #endif |
---|
298 | n/a | |
---|
299 | n/a | #define PREFIX(ident) normal_ ## ident |
---|
300 | n/a | #define XML_TOK_IMPL_C |
---|
301 | n/a | #include "xmltok_impl.c" |
---|
302 | n/a | #undef XML_TOK_IMPL_C |
---|
303 | n/a | |
---|
304 | n/a | #undef MINBPC |
---|
305 | n/a | #undef BYTE_TYPE |
---|
306 | n/a | #undef BYTE_TO_ASCII |
---|
307 | n/a | #undef CHAR_MATCHES |
---|
308 | n/a | #undef IS_NAME_CHAR |
---|
309 | n/a | #undef IS_NAME_CHAR_MINBPC |
---|
310 | n/a | #undef IS_NMSTRT_CHAR |
---|
311 | n/a | #undef IS_NMSTRT_CHAR_MINBPC |
---|
312 | n/a | #undef IS_INVALID_CHAR |
---|
313 | n/a | |
---|
314 | n/a | enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ |
---|
315 | n/a | UTF8_cval1 = 0x00, |
---|
316 | n/a | UTF8_cval2 = 0xc0, |
---|
317 | n/a | UTF8_cval3 = 0xe0, |
---|
318 | n/a | UTF8_cval4 = 0xf0 |
---|
319 | n/a | }; |
---|
320 | n/a | |
---|
321 | n/a | static void PTRCALL |
---|
322 | n/a | utf8_toUtf8(const ENCODING *enc, |
---|
323 | n/a | const char **fromP, const char *fromLim, |
---|
324 | n/a | char **toP, const char *toLim) |
---|
325 | n/a | { |
---|
326 | n/a | char *to; |
---|
327 | n/a | const char *from; |
---|
328 | n/a | if (fromLim - *fromP > toLim - *toP) { |
---|
329 | n/a | /* Avoid copying partial characters. */ |
---|
330 | n/a | for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--) |
---|
331 | n/a | if (((unsigned char)fromLim[-1] & 0xc0) != 0x80) |
---|
332 | n/a | break; |
---|
333 | n/a | } |
---|
334 | n/a | for (to = *toP, from = *fromP; from != fromLim; from++, to++) |
---|
335 | n/a | *to = *from; |
---|
336 | n/a | *fromP = from; |
---|
337 | n/a | *toP = to; |
---|
338 | n/a | } |
---|
339 | n/a | |
---|
340 | n/a | static void PTRCALL |
---|
341 | n/a | utf8_toUtf16(const ENCODING *enc, |
---|
342 | n/a | const char **fromP, const char *fromLim, |
---|
343 | n/a | unsigned short **toP, const unsigned short *toLim) |
---|
344 | n/a | { |
---|
345 | n/a | unsigned short *to = *toP; |
---|
346 | n/a | const char *from = *fromP; |
---|
347 | n/a | while (from != fromLim && to != toLim) { |
---|
348 | n/a | switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) { |
---|
349 | n/a | case BT_LEAD2: |
---|
350 | n/a | *to++ = (unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f)); |
---|
351 | n/a | from += 2; |
---|
352 | n/a | break; |
---|
353 | n/a | case BT_LEAD3: |
---|
354 | n/a | *to++ = (unsigned short)(((from[0] & 0xf) << 12) |
---|
355 | n/a | | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f)); |
---|
356 | n/a | from += 3; |
---|
357 | n/a | break; |
---|
358 | n/a | case BT_LEAD4: |
---|
359 | n/a | { |
---|
360 | n/a | unsigned long n; |
---|
361 | n/a | if (to + 1 == toLim) |
---|
362 | n/a | goto after; |
---|
363 | n/a | n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) |
---|
364 | n/a | | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f); |
---|
365 | n/a | n -= 0x10000; |
---|
366 | n/a | to[0] = (unsigned short)((n >> 10) | 0xD800); |
---|
367 | n/a | to[1] = (unsigned short)((n & 0x3FF) | 0xDC00); |
---|
368 | n/a | to += 2; |
---|
369 | n/a | from += 4; |
---|
370 | n/a | } |
---|
371 | n/a | break; |
---|
372 | n/a | default: |
---|
373 | n/a | *to++ = *from++; |
---|
374 | n/a | break; |
---|
375 | n/a | } |
---|
376 | n/a | } |
---|
377 | n/a | after: |
---|
378 | n/a | *fromP = from; |
---|
379 | n/a | *toP = to; |
---|
380 | n/a | } |
---|
381 | n/a | |
---|
382 | n/a | #ifdef XML_NS |
---|
383 | n/a | static const struct normal_encoding utf8_encoding_ns = { |
---|
384 | n/a | { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, |
---|
385 | n/a | { |
---|
386 | n/a | #include "asciitab.h" |
---|
387 | n/a | #include "utf8tab.h" |
---|
388 | n/a | }, |
---|
389 | n/a | STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) |
---|
390 | n/a | }; |
---|
391 | n/a | #endif |
---|
392 | n/a | |
---|
393 | n/a | static const struct normal_encoding utf8_encoding = { |
---|
394 | n/a | { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, |
---|
395 | n/a | { |
---|
396 | n/a | #define BT_COLON BT_NMSTRT |
---|
397 | n/a | #include "asciitab.h" |
---|
398 | n/a | #undef BT_COLON |
---|
399 | n/a | #include "utf8tab.h" |
---|
400 | n/a | }, |
---|
401 | n/a | STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) |
---|
402 | n/a | }; |
---|
403 | n/a | |
---|
404 | n/a | #ifdef XML_NS |
---|
405 | n/a | |
---|
406 | n/a | static const struct normal_encoding internal_utf8_encoding_ns = { |
---|
407 | n/a | { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, |
---|
408 | n/a | { |
---|
409 | n/a | #include "iasciitab.h" |
---|
410 | n/a | #include "utf8tab.h" |
---|
411 | n/a | }, |
---|
412 | n/a | STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) |
---|
413 | n/a | }; |
---|
414 | n/a | |
---|
415 | n/a | #endif |
---|
416 | n/a | |
---|
417 | n/a | static const struct normal_encoding internal_utf8_encoding = { |
---|
418 | n/a | { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 }, |
---|
419 | n/a | { |
---|
420 | n/a | #define BT_COLON BT_NMSTRT |
---|
421 | n/a | #include "iasciitab.h" |
---|
422 | n/a | #undef BT_COLON |
---|
423 | n/a | #include "utf8tab.h" |
---|
424 | n/a | }, |
---|
425 | n/a | STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_) |
---|
426 | n/a | }; |
---|
427 | n/a | |
---|
428 | n/a | static void PTRCALL |
---|
429 | n/a | latin1_toUtf8(const ENCODING *enc, |
---|
430 | n/a | const char **fromP, const char *fromLim, |
---|
431 | n/a | char **toP, const char *toLim) |
---|
432 | n/a | { |
---|
433 | n/a | for (;;) { |
---|
434 | n/a | unsigned char c; |
---|
435 | n/a | if (*fromP == fromLim) |
---|
436 | n/a | break; |
---|
437 | n/a | c = (unsigned char)**fromP; |
---|
438 | n/a | if (c & 0x80) { |
---|
439 | n/a | if (toLim - *toP < 2) |
---|
440 | n/a | break; |
---|
441 | n/a | *(*toP)++ = (char)((c >> 6) | UTF8_cval2); |
---|
442 | n/a | *(*toP)++ = (char)((c & 0x3f) | 0x80); |
---|
443 | n/a | (*fromP)++; |
---|
444 | n/a | } |
---|
445 | n/a | else { |
---|
446 | n/a | if (*toP == toLim) |
---|
447 | n/a | break; |
---|
448 | n/a | *(*toP)++ = *(*fromP)++; |
---|
449 | n/a | } |
---|
450 | n/a | } |
---|
451 | n/a | } |
---|
452 | n/a | |
---|
453 | n/a | static void PTRCALL |
---|
454 | n/a | latin1_toUtf16(const ENCODING *enc, |
---|
455 | n/a | const char **fromP, const char *fromLim, |
---|
456 | n/a | unsigned short **toP, const unsigned short *toLim) |
---|
457 | n/a | { |
---|
458 | n/a | while (*fromP != fromLim && *toP != toLim) |
---|
459 | n/a | *(*toP)++ = (unsigned char)*(*fromP)++; |
---|
460 | n/a | } |
---|
461 | n/a | |
---|
462 | n/a | #ifdef XML_NS |
---|
463 | n/a | |
---|
464 | n/a | static const struct normal_encoding latin1_encoding_ns = { |
---|
465 | n/a | { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, |
---|
466 | n/a | { |
---|
467 | n/a | #include "asciitab.h" |
---|
468 | n/a | #include "latin1tab.h" |
---|
469 | n/a | }, |
---|
470 | n/a | STANDARD_VTABLE(sb_) |
---|
471 | n/a | }; |
---|
472 | n/a | |
---|
473 | n/a | #endif |
---|
474 | n/a | |
---|
475 | n/a | static const struct normal_encoding latin1_encoding = { |
---|
476 | n/a | { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 }, |
---|
477 | n/a | { |
---|
478 | n/a | #define BT_COLON BT_NMSTRT |
---|
479 | n/a | #include "asciitab.h" |
---|
480 | n/a | #undef BT_COLON |
---|
481 | n/a | #include "latin1tab.h" |
---|
482 | n/a | }, |
---|
483 | n/a | STANDARD_VTABLE(sb_) |
---|
484 | n/a | }; |
---|
485 | n/a | |
---|
486 | n/a | static void PTRCALL |
---|
487 | n/a | ascii_toUtf8(const ENCODING *enc, |
---|
488 | n/a | const char **fromP, const char *fromLim, |
---|
489 | n/a | char **toP, const char *toLim) |
---|
490 | n/a | { |
---|
491 | n/a | while (*fromP != fromLim && *toP != toLim) |
---|
492 | n/a | *(*toP)++ = *(*fromP)++; |
---|
493 | n/a | } |
---|
494 | n/a | |
---|
495 | n/a | #ifdef XML_NS |
---|
496 | n/a | |
---|
497 | n/a | static const struct normal_encoding ascii_encoding_ns = { |
---|
498 | n/a | { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, |
---|
499 | n/a | { |
---|
500 | n/a | #include "asciitab.h" |
---|
501 | n/a | /* BT_NONXML == 0 */ |
---|
502 | n/a | }, |
---|
503 | n/a | STANDARD_VTABLE(sb_) |
---|
504 | n/a | }; |
---|
505 | n/a | |
---|
506 | n/a | #endif |
---|
507 | n/a | |
---|
508 | n/a | static const struct normal_encoding ascii_encoding = { |
---|
509 | n/a | { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 }, |
---|
510 | n/a | { |
---|
511 | n/a | #define BT_COLON BT_NMSTRT |
---|
512 | n/a | #include "asciitab.h" |
---|
513 | n/a | #undef BT_COLON |
---|
514 | n/a | /* BT_NONXML == 0 */ |
---|
515 | n/a | }, |
---|
516 | n/a | STANDARD_VTABLE(sb_) |
---|
517 | n/a | }; |
---|
518 | n/a | |
---|
519 | n/a | static int PTRFASTCALL |
---|
520 | n/a | unicode_byte_type(char hi, char lo) |
---|
521 | n/a | { |
---|
522 | n/a | switch ((unsigned char)hi) { |
---|
523 | n/a | case 0xD8: case 0xD9: case 0xDA: case 0xDB: |
---|
524 | n/a | return BT_LEAD4; |
---|
525 | n/a | case 0xDC: case 0xDD: case 0xDE: case 0xDF: |
---|
526 | n/a | return BT_TRAIL; |
---|
527 | n/a | case 0xFF: |
---|
528 | n/a | switch ((unsigned char)lo) { |
---|
529 | n/a | case 0xFF: |
---|
530 | n/a | case 0xFE: |
---|
531 | n/a | return BT_NONXML; |
---|
532 | n/a | } |
---|
533 | n/a | break; |
---|
534 | n/a | } |
---|
535 | n/a | return BT_NONASCII; |
---|
536 | n/a | } |
---|
537 | n/a | |
---|
538 | n/a | #define DEFINE_UTF16_TO_UTF8(E) \ |
---|
539 | n/a | static void PTRCALL \ |
---|
540 | n/a | E ## toUtf8(const ENCODING *enc, \ |
---|
541 | n/a | const char **fromP, const char *fromLim, \ |
---|
542 | n/a | char **toP, const char *toLim) \ |
---|
543 | n/a | { \ |
---|
544 | n/a | const char *from; \ |
---|
545 | n/a | for (from = *fromP; from != fromLim; from += 2) { \ |
---|
546 | n/a | int plane; \ |
---|
547 | n/a | unsigned char lo2; \ |
---|
548 | n/a | unsigned char lo = GET_LO(from); \ |
---|
549 | n/a | unsigned char hi = GET_HI(from); \ |
---|
550 | n/a | switch (hi) { \ |
---|
551 | n/a | case 0: \ |
---|
552 | n/a | if (lo < 0x80) { \ |
---|
553 | n/a | if (*toP == toLim) { \ |
---|
554 | n/a | *fromP = from; \ |
---|
555 | n/a | return; \ |
---|
556 | n/a | } \ |
---|
557 | n/a | *(*toP)++ = lo; \ |
---|
558 | n/a | break; \ |
---|
559 | n/a | } \ |
---|
560 | n/a | /* fall through */ \ |
---|
561 | n/a | case 0x1: case 0x2: case 0x3: \ |
---|
562 | n/a | case 0x4: case 0x5: case 0x6: case 0x7: \ |
---|
563 | n/a | if (toLim - *toP < 2) { \ |
---|
564 | n/a | *fromP = from; \ |
---|
565 | n/a | return; \ |
---|
566 | n/a | } \ |
---|
567 | n/a | *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \ |
---|
568 | n/a | *(*toP)++ = ((lo & 0x3f) | 0x80); \ |
---|
569 | n/a | break; \ |
---|
570 | n/a | default: \ |
---|
571 | n/a | if (toLim - *toP < 3) { \ |
---|
572 | n/a | *fromP = from; \ |
---|
573 | n/a | return; \ |
---|
574 | n/a | } \ |
---|
575 | n/a | /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \ |
---|
576 | n/a | *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ |
---|
577 | n/a | *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ |
---|
578 | n/a | *(*toP)++ = ((lo & 0x3f) | 0x80); \ |
---|
579 | n/a | break; \ |
---|
580 | n/a | case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ |
---|
581 | n/a | if (toLim - *toP < 4) { \ |
---|
582 | n/a | *fromP = from; \ |
---|
583 | n/a | return; \ |
---|
584 | n/a | } \ |
---|
585 | n/a | plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ |
---|
586 | n/a | *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ |
---|
587 | n/a | *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ |
---|
588 | n/a | from += 2; \ |
---|
589 | n/a | lo2 = GET_LO(from); \ |
---|
590 | n/a | *(*toP)++ = (((lo & 0x3) << 4) \ |
---|
591 | n/a | | ((GET_HI(from) & 0x3) << 2) \ |
---|
592 | n/a | | (lo2 >> 6) \ |
---|
593 | n/a | | 0x80); \ |
---|
594 | n/a | *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ |
---|
595 | n/a | break; \ |
---|
596 | n/a | } \ |
---|
597 | n/a | } \ |
---|
598 | n/a | *fromP = from; \ |
---|
599 | n/a | } |
---|
600 | n/a | |
---|
601 | n/a | #define DEFINE_UTF16_TO_UTF16(E) \ |
---|
602 | n/a | static void PTRCALL \ |
---|
603 | n/a | E ## toUtf16(const ENCODING *enc, \ |
---|
604 | n/a | const char **fromP, const char *fromLim, \ |
---|
605 | n/a | unsigned short **toP, const unsigned short *toLim) \ |
---|
606 | n/a | { \ |
---|
607 | n/a | /* Avoid copying first half only of surrogate */ \ |
---|
608 | n/a | if (fromLim - *fromP > ((toLim - *toP) << 1) \ |
---|
609 | n/a | && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \ |
---|
610 | n/a | fromLim -= 2; \ |
---|
611 | n/a | for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \ |
---|
612 | n/a | *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ |
---|
613 | n/a | } |
---|
614 | n/a | |
---|
615 | n/a | #define SET2(ptr, ch) \ |
---|
616 | n/a | (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8))) |
---|
617 | n/a | #define GET_LO(ptr) ((unsigned char)(ptr)[0]) |
---|
618 | n/a | #define GET_HI(ptr) ((unsigned char)(ptr)[1]) |
---|
619 | n/a | |
---|
620 | n/a | DEFINE_UTF16_TO_UTF8(little2_) |
---|
621 | n/a | DEFINE_UTF16_TO_UTF16(little2_) |
---|
622 | n/a | |
---|
623 | n/a | #undef SET2 |
---|
624 | n/a | #undef GET_LO |
---|
625 | n/a | #undef GET_HI |
---|
626 | n/a | |
---|
627 | n/a | #define SET2(ptr, ch) \ |
---|
628 | n/a | (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF))) |
---|
629 | n/a | #define GET_LO(ptr) ((unsigned char)(ptr)[1]) |
---|
630 | n/a | #define GET_HI(ptr) ((unsigned char)(ptr)[0]) |
---|
631 | n/a | |
---|
632 | n/a | DEFINE_UTF16_TO_UTF8(big2_) |
---|
633 | n/a | DEFINE_UTF16_TO_UTF16(big2_) |
---|
634 | n/a | |
---|
635 | n/a | #undef SET2 |
---|
636 | n/a | #undef GET_LO |
---|
637 | n/a | #undef GET_HI |
---|
638 | n/a | |
---|
639 | n/a | #define LITTLE2_BYTE_TYPE(enc, p) \ |
---|
640 | n/a | ((p)[1] == 0 \ |
---|
641 | n/a | ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ |
---|
642 | n/a | : unicode_byte_type((p)[1], (p)[0])) |
---|
643 | n/a | #define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1) |
---|
644 | n/a | #define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c) |
---|
645 | n/a | #define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \ |
---|
646 | n/a | UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0]) |
---|
647 | n/a | #define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ |
---|
648 | n/a | UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0]) |
---|
649 | n/a | |
---|
650 | n/a | #ifdef XML_MIN_SIZE |
---|
651 | n/a | |
---|
652 | n/a | static int PTRFASTCALL |
---|
653 | n/a | little2_byteType(const ENCODING *enc, const char *p) |
---|
654 | n/a | { |
---|
655 | n/a | return LITTLE2_BYTE_TYPE(enc, p); |
---|
656 | n/a | } |
---|
657 | n/a | |
---|
658 | n/a | static int PTRFASTCALL |
---|
659 | n/a | little2_byteToAscii(const ENCODING *enc, const char *p) |
---|
660 | n/a | { |
---|
661 | n/a | return LITTLE2_BYTE_TO_ASCII(enc, p); |
---|
662 | n/a | } |
---|
663 | n/a | |
---|
664 | n/a | static int PTRCALL |
---|
665 | n/a | little2_charMatches(const ENCODING *enc, const char *p, int c) |
---|
666 | n/a | { |
---|
667 | n/a | return LITTLE2_CHAR_MATCHES(enc, p, c); |
---|
668 | n/a | } |
---|
669 | n/a | |
---|
670 | n/a | static int PTRFASTCALL |
---|
671 | n/a | little2_isNameMin(const ENCODING *enc, const char *p) |
---|
672 | n/a | { |
---|
673 | n/a | return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p); |
---|
674 | n/a | } |
---|
675 | n/a | |
---|
676 | n/a | static int PTRFASTCALL |
---|
677 | n/a | little2_isNmstrtMin(const ENCODING *enc, const char *p) |
---|
678 | n/a | { |
---|
679 | n/a | return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p); |
---|
680 | n/a | } |
---|
681 | n/a | |
---|
682 | n/a | #undef VTABLE |
---|
683 | n/a | #define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 |
---|
684 | n/a | |
---|
685 | n/a | #else /* not XML_MIN_SIZE */ |
---|
686 | n/a | |
---|
687 | n/a | #undef PREFIX |
---|
688 | n/a | #define PREFIX(ident) little2_ ## ident |
---|
689 | n/a | #define MINBPC(enc) 2 |
---|
690 | n/a | /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ |
---|
691 | n/a | #define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) |
---|
692 | n/a | #define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) |
---|
693 | n/a | #define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c) |
---|
694 | n/a | #define IS_NAME_CHAR(enc, p, n) 0 |
---|
695 | n/a | #define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) |
---|
696 | n/a | #define IS_NMSTRT_CHAR(enc, p, n) (0) |
---|
697 | n/a | #define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) |
---|
698 | n/a | |
---|
699 | n/a | #define XML_TOK_IMPL_C |
---|
700 | n/a | #include "xmltok_impl.c" |
---|
701 | n/a | #undef XML_TOK_IMPL_C |
---|
702 | n/a | |
---|
703 | n/a | #undef MINBPC |
---|
704 | n/a | #undef BYTE_TYPE |
---|
705 | n/a | #undef BYTE_TO_ASCII |
---|
706 | n/a | #undef CHAR_MATCHES |
---|
707 | n/a | #undef IS_NAME_CHAR |
---|
708 | n/a | #undef IS_NAME_CHAR_MINBPC |
---|
709 | n/a | #undef IS_NMSTRT_CHAR |
---|
710 | n/a | #undef IS_NMSTRT_CHAR_MINBPC |
---|
711 | n/a | #undef IS_INVALID_CHAR |
---|
712 | n/a | |
---|
713 | n/a | #endif /* not XML_MIN_SIZE */ |
---|
714 | n/a | |
---|
715 | n/a | #ifdef XML_NS |
---|
716 | n/a | |
---|
717 | n/a | static const struct normal_encoding little2_encoding_ns = { |
---|
718 | n/a | { VTABLE, 2, 0, |
---|
719 | n/a | #if BYTEORDER == 1234 |
---|
720 | n/a | 1 |
---|
721 | n/a | #else |
---|
722 | n/a | 0 |
---|
723 | n/a | #endif |
---|
724 | n/a | }, |
---|
725 | n/a | { |
---|
726 | n/a | #include "asciitab.h" |
---|
727 | n/a | #include "latin1tab.h" |
---|
728 | n/a | }, |
---|
729 | n/a | STANDARD_VTABLE(little2_) |
---|
730 | n/a | }; |
---|
731 | n/a | |
---|
732 | n/a | #endif |
---|
733 | n/a | |
---|
734 | n/a | static const struct normal_encoding little2_encoding = { |
---|
735 | n/a | { VTABLE, 2, 0, |
---|
736 | n/a | #if BYTEORDER == 1234 |
---|
737 | n/a | 1 |
---|
738 | n/a | #else |
---|
739 | n/a | 0 |
---|
740 | n/a | #endif |
---|
741 | n/a | }, |
---|
742 | n/a | { |
---|
743 | n/a | #define BT_COLON BT_NMSTRT |
---|
744 | n/a | #include "asciitab.h" |
---|
745 | n/a | #undef BT_COLON |
---|
746 | n/a | #include "latin1tab.h" |
---|
747 | n/a | }, |
---|
748 | n/a | STANDARD_VTABLE(little2_) |
---|
749 | n/a | }; |
---|
750 | n/a | |
---|
751 | n/a | #if BYTEORDER != 4321 |
---|
752 | n/a | |
---|
753 | n/a | #ifdef XML_NS |
---|
754 | n/a | |
---|
755 | n/a | static const struct normal_encoding internal_little2_encoding_ns = { |
---|
756 | n/a | { VTABLE, 2, 0, 1 }, |
---|
757 | n/a | { |
---|
758 | n/a | #include "iasciitab.h" |
---|
759 | n/a | #include "latin1tab.h" |
---|
760 | n/a | }, |
---|
761 | n/a | STANDARD_VTABLE(little2_) |
---|
762 | n/a | }; |
---|
763 | n/a | |
---|
764 | n/a | #endif |
---|
765 | n/a | |
---|
766 | n/a | static const struct normal_encoding internal_little2_encoding = { |
---|
767 | n/a | { VTABLE, 2, 0, 1 }, |
---|
768 | n/a | { |
---|
769 | n/a | #define BT_COLON BT_NMSTRT |
---|
770 | n/a | #include "iasciitab.h" |
---|
771 | n/a | #undef BT_COLON |
---|
772 | n/a | #include "latin1tab.h" |
---|
773 | n/a | }, |
---|
774 | n/a | STANDARD_VTABLE(little2_) |
---|
775 | n/a | }; |
---|
776 | n/a | |
---|
777 | n/a | #endif |
---|
778 | n/a | |
---|
779 | n/a | |
---|
780 | n/a | #define BIG2_BYTE_TYPE(enc, p) \ |
---|
781 | n/a | ((p)[0] == 0 \ |
---|
782 | n/a | ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ |
---|
783 | n/a | : unicode_byte_type((p)[0], (p)[1])) |
---|
784 | n/a | #define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1) |
---|
785 | n/a | #define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c) |
---|
786 | n/a | #define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \ |
---|
787 | n/a | UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1]) |
---|
788 | n/a | #define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \ |
---|
789 | n/a | UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1]) |
---|
790 | n/a | |
---|
791 | n/a | #ifdef XML_MIN_SIZE |
---|
792 | n/a | |
---|
793 | n/a | static int PTRFASTCALL |
---|
794 | n/a | big2_byteType(const ENCODING *enc, const char *p) |
---|
795 | n/a | { |
---|
796 | n/a | return BIG2_BYTE_TYPE(enc, p); |
---|
797 | n/a | } |
---|
798 | n/a | |
---|
799 | n/a | static int PTRFASTCALL |
---|
800 | n/a | big2_byteToAscii(const ENCODING *enc, const char *p) |
---|
801 | n/a | { |
---|
802 | n/a | return BIG2_BYTE_TO_ASCII(enc, p); |
---|
803 | n/a | } |
---|
804 | n/a | |
---|
805 | n/a | static int PTRCALL |
---|
806 | n/a | big2_charMatches(const ENCODING *enc, const char *p, int c) |
---|
807 | n/a | { |
---|
808 | n/a | return BIG2_CHAR_MATCHES(enc, p, c); |
---|
809 | n/a | } |
---|
810 | n/a | |
---|
811 | n/a | static int PTRFASTCALL |
---|
812 | n/a | big2_isNameMin(const ENCODING *enc, const char *p) |
---|
813 | n/a | { |
---|
814 | n/a | return BIG2_IS_NAME_CHAR_MINBPC(enc, p); |
---|
815 | n/a | } |
---|
816 | n/a | |
---|
817 | n/a | static int PTRFASTCALL |
---|
818 | n/a | big2_isNmstrtMin(const ENCODING *enc, const char *p) |
---|
819 | n/a | { |
---|
820 | n/a | return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p); |
---|
821 | n/a | } |
---|
822 | n/a | |
---|
823 | n/a | #undef VTABLE |
---|
824 | n/a | #define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 |
---|
825 | n/a | |
---|
826 | n/a | #else /* not XML_MIN_SIZE */ |
---|
827 | n/a | |
---|
828 | n/a | #undef PREFIX |
---|
829 | n/a | #define PREFIX(ident) big2_ ## ident |
---|
830 | n/a | #define MINBPC(enc) 2 |
---|
831 | n/a | /* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */ |
---|
832 | n/a | #define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) |
---|
833 | n/a | #define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) |
---|
834 | n/a | #define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c) |
---|
835 | n/a | #define IS_NAME_CHAR(enc, p, n) 0 |
---|
836 | n/a | #define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p) |
---|
837 | n/a | #define IS_NMSTRT_CHAR(enc, p, n) (0) |
---|
838 | n/a | #define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) |
---|
839 | n/a | |
---|
840 | n/a | #define XML_TOK_IMPL_C |
---|
841 | n/a | #include "xmltok_impl.c" |
---|
842 | n/a | #undef XML_TOK_IMPL_C |
---|
843 | n/a | |
---|
844 | n/a | #undef MINBPC |
---|
845 | n/a | #undef BYTE_TYPE |
---|
846 | n/a | #undef BYTE_TO_ASCII |
---|
847 | n/a | #undef CHAR_MATCHES |
---|
848 | n/a | #undef IS_NAME_CHAR |
---|
849 | n/a | #undef IS_NAME_CHAR_MINBPC |
---|
850 | n/a | #undef IS_NMSTRT_CHAR |
---|
851 | n/a | #undef IS_NMSTRT_CHAR_MINBPC |
---|
852 | n/a | #undef IS_INVALID_CHAR |
---|
853 | n/a | |
---|
854 | n/a | #endif /* not XML_MIN_SIZE */ |
---|
855 | n/a | |
---|
856 | n/a | #ifdef XML_NS |
---|
857 | n/a | |
---|
858 | n/a | static const struct normal_encoding big2_encoding_ns = { |
---|
859 | n/a | { VTABLE, 2, 0, |
---|
860 | n/a | #if BYTEORDER == 4321 |
---|
861 | n/a | 1 |
---|
862 | n/a | #else |
---|
863 | n/a | 0 |
---|
864 | n/a | #endif |
---|
865 | n/a | }, |
---|
866 | n/a | { |
---|
867 | n/a | #include "asciitab.h" |
---|
868 | n/a | #include "latin1tab.h" |
---|
869 | n/a | }, |
---|
870 | n/a | STANDARD_VTABLE(big2_) |
---|
871 | n/a | }; |
---|
872 | n/a | |
---|
873 | n/a | #endif |
---|
874 | n/a | |
---|
875 | n/a | static const struct normal_encoding big2_encoding = { |
---|
876 | n/a | { VTABLE, 2, 0, |
---|
877 | n/a | #if BYTEORDER == 4321 |
---|
878 | n/a | 1 |
---|
879 | n/a | #else |
---|
880 | n/a | 0 |
---|
881 | n/a | #endif |
---|
882 | n/a | }, |
---|
883 | n/a | { |
---|
884 | n/a | #define BT_COLON BT_NMSTRT |
---|
885 | n/a | #include "asciitab.h" |
---|
886 | n/a | #undef BT_COLON |
---|
887 | n/a | #include "latin1tab.h" |
---|
888 | n/a | }, |
---|
889 | n/a | STANDARD_VTABLE(big2_) |
---|
890 | n/a | }; |
---|
891 | n/a | |
---|
892 | n/a | #if BYTEORDER != 1234 |
---|
893 | n/a | |
---|
894 | n/a | #ifdef XML_NS |
---|
895 | n/a | |
---|
896 | n/a | static const struct normal_encoding internal_big2_encoding_ns = { |
---|
897 | n/a | { VTABLE, 2, 0, 1 }, |
---|
898 | n/a | { |
---|
899 | n/a | #include "iasciitab.h" |
---|
900 | n/a | #include "latin1tab.h" |
---|
901 | n/a | }, |
---|
902 | n/a | STANDARD_VTABLE(big2_) |
---|
903 | n/a | }; |
---|
904 | n/a | |
---|
905 | n/a | #endif |
---|
906 | n/a | |
---|
907 | n/a | static const struct normal_encoding internal_big2_encoding = { |
---|
908 | n/a | { VTABLE, 2, 0, 1 }, |
---|
909 | n/a | { |
---|
910 | n/a | #define BT_COLON BT_NMSTRT |
---|
911 | n/a | #include "iasciitab.h" |
---|
912 | n/a | #undef BT_COLON |
---|
913 | n/a | #include "latin1tab.h" |
---|
914 | n/a | }, |
---|
915 | n/a | STANDARD_VTABLE(big2_) |
---|
916 | n/a | }; |
---|
917 | n/a | |
---|
918 | n/a | #endif |
---|
919 | n/a | |
---|
920 | n/a | #undef PREFIX |
---|
921 | n/a | |
---|
922 | n/a | static int FASTCALL |
---|
923 | n/a | streqci(const char *s1, const char *s2) |
---|
924 | n/a | { |
---|
925 | n/a | for (;;) { |
---|
926 | n/a | char c1 = *s1++; |
---|
927 | n/a | char c2 = *s2++; |
---|
928 | n/a | if (ASCII_a <= c1 && c1 <= ASCII_z) |
---|
929 | n/a | c1 += ASCII_A - ASCII_a; |
---|
930 | n/a | if (ASCII_a <= c2 && c2 <= ASCII_z) |
---|
931 | n/a | c2 += ASCII_A - ASCII_a; |
---|
932 | n/a | if (c1 != c2) |
---|
933 | n/a | return 0; |
---|
934 | n/a | if (!c1) |
---|
935 | n/a | break; |
---|
936 | n/a | } |
---|
937 | n/a | return 1; |
---|
938 | n/a | } |
---|
939 | n/a | |
---|
940 | n/a | static void PTRCALL |
---|
941 | n/a | initUpdatePosition(const ENCODING *enc, const char *ptr, |
---|
942 | n/a | const char *end, POSITION *pos) |
---|
943 | n/a | { |
---|
944 | n/a | normal_updatePosition(&utf8_encoding.enc, ptr, end, pos); |
---|
945 | n/a | } |
---|
946 | n/a | |
---|
947 | n/a | static int |
---|
948 | n/a | toAscii(const ENCODING *enc, const char *ptr, const char *end) |
---|
949 | n/a | { |
---|
950 | n/a | char buf[1]; |
---|
951 | n/a | char *p = buf; |
---|
952 | n/a | XmlUtf8Convert(enc, &ptr, end, &p, p + 1); |
---|
953 | n/a | if (p == buf) |
---|
954 | n/a | return -1; |
---|
955 | n/a | else |
---|
956 | n/a | return buf[0]; |
---|
957 | n/a | } |
---|
958 | n/a | |
---|
959 | n/a | static int FASTCALL |
---|
960 | n/a | isSpace(int c) |
---|
961 | n/a | { |
---|
962 | n/a | switch (c) { |
---|
963 | n/a | case 0x20: |
---|
964 | n/a | case 0xD: |
---|
965 | n/a | case 0xA: |
---|
966 | n/a | case 0x9: |
---|
967 | n/a | return 1; |
---|
968 | n/a | } |
---|
969 | n/a | return 0; |
---|
970 | n/a | } |
---|
971 | n/a | |
---|
972 | n/a | /* Return 1 if there's just optional white space or there's an S |
---|
973 | n/a | followed by name=val. |
---|
974 | n/a | */ |
---|
975 | n/a | static int |
---|
976 | n/a | parsePseudoAttribute(const ENCODING *enc, |
---|
977 | n/a | const char *ptr, |
---|
978 | n/a | const char *end, |
---|
979 | n/a | const char **namePtr, |
---|
980 | n/a | const char **nameEndPtr, |
---|
981 | n/a | const char **valPtr, |
---|
982 | n/a | const char **nextTokPtr) |
---|
983 | n/a | { |
---|
984 | n/a | int c; |
---|
985 | n/a | char open; |
---|
986 | n/a | if (ptr == end) { |
---|
987 | n/a | *namePtr = NULL; |
---|
988 | n/a | return 1; |
---|
989 | n/a | } |
---|
990 | n/a | if (!isSpace(toAscii(enc, ptr, end))) { |
---|
991 | n/a | *nextTokPtr = ptr; |
---|
992 | n/a | return 0; |
---|
993 | n/a | } |
---|
994 | n/a | do { |
---|
995 | n/a | ptr += enc->minBytesPerChar; |
---|
996 | n/a | } while (isSpace(toAscii(enc, ptr, end))); |
---|
997 | n/a | if (ptr == end) { |
---|
998 | n/a | *namePtr = NULL; |
---|
999 | n/a | return 1; |
---|
1000 | n/a | } |
---|
1001 | n/a | *namePtr = ptr; |
---|
1002 | n/a | for (;;) { |
---|
1003 | n/a | c = toAscii(enc, ptr, end); |
---|
1004 | n/a | if (c == -1) { |
---|
1005 | n/a | *nextTokPtr = ptr; |
---|
1006 | n/a | return 0; |
---|
1007 | n/a | } |
---|
1008 | n/a | if (c == ASCII_EQUALS) { |
---|
1009 | n/a | *nameEndPtr = ptr; |
---|
1010 | n/a | break; |
---|
1011 | n/a | } |
---|
1012 | n/a | if (isSpace(c)) { |
---|
1013 | n/a | *nameEndPtr = ptr; |
---|
1014 | n/a | do { |
---|
1015 | n/a | ptr += enc->minBytesPerChar; |
---|
1016 | n/a | } while (isSpace(c = toAscii(enc, ptr, end))); |
---|
1017 | n/a | if (c != ASCII_EQUALS) { |
---|
1018 | n/a | *nextTokPtr = ptr; |
---|
1019 | n/a | return 0; |
---|
1020 | n/a | } |
---|
1021 | n/a | break; |
---|
1022 | n/a | } |
---|
1023 | n/a | ptr += enc->minBytesPerChar; |
---|
1024 | n/a | } |
---|
1025 | n/a | if (ptr == *namePtr) { |
---|
1026 | n/a | *nextTokPtr = ptr; |
---|
1027 | n/a | return 0; |
---|
1028 | n/a | } |
---|
1029 | n/a | ptr += enc->minBytesPerChar; |
---|
1030 | n/a | c = toAscii(enc, ptr, end); |
---|
1031 | n/a | while (isSpace(c)) { |
---|
1032 | n/a | ptr += enc->minBytesPerChar; |
---|
1033 | n/a | c = toAscii(enc, ptr, end); |
---|
1034 | n/a | } |
---|
1035 | n/a | if (c != ASCII_QUOT && c != ASCII_APOS) { |
---|
1036 | n/a | *nextTokPtr = ptr; |
---|
1037 | n/a | return 0; |
---|
1038 | n/a | } |
---|
1039 | n/a | open = (char)c; |
---|
1040 | n/a | ptr += enc->minBytesPerChar; |
---|
1041 | n/a | *valPtr = ptr; |
---|
1042 | n/a | for (;; ptr += enc->minBytesPerChar) { |
---|
1043 | n/a | c = toAscii(enc, ptr, end); |
---|
1044 | n/a | if (c == open) |
---|
1045 | n/a | break; |
---|
1046 | n/a | if (!(ASCII_a <= c && c <= ASCII_z) |
---|
1047 | n/a | && !(ASCII_A <= c && c <= ASCII_Z) |
---|
1048 | n/a | && !(ASCII_0 <= c && c <= ASCII_9) |
---|
1049 | n/a | && c != ASCII_PERIOD |
---|
1050 | n/a | && c != ASCII_MINUS |
---|
1051 | n/a | && c != ASCII_UNDERSCORE) { |
---|
1052 | n/a | *nextTokPtr = ptr; |
---|
1053 | n/a | return 0; |
---|
1054 | n/a | } |
---|
1055 | n/a | } |
---|
1056 | n/a | *nextTokPtr = ptr + enc->minBytesPerChar; |
---|
1057 | n/a | return 1; |
---|
1058 | n/a | } |
---|
1059 | n/a | |
---|
1060 | n/a | static const char KW_version[] = { |
---|
1061 | n/a | ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0' |
---|
1062 | n/a | }; |
---|
1063 | n/a | |
---|
1064 | n/a | static const char KW_encoding[] = { |
---|
1065 | n/a | ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0' |
---|
1066 | n/a | }; |
---|
1067 | n/a | |
---|
1068 | n/a | static const char KW_standalone[] = { |
---|
1069 | n/a | ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o, |
---|
1070 | n/a | ASCII_n, ASCII_e, '\0' |
---|
1071 | n/a | }; |
---|
1072 | n/a | |
---|
1073 | n/a | static const char KW_yes[] = { |
---|
1074 | n/a | ASCII_y, ASCII_e, ASCII_s, '\0' |
---|
1075 | n/a | }; |
---|
1076 | n/a | |
---|
1077 | n/a | static const char KW_no[] = { |
---|
1078 | n/a | ASCII_n, ASCII_o, '\0' |
---|
1079 | n/a | }; |
---|
1080 | n/a | |
---|
1081 | n/a | static int |
---|
1082 | n/a | doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, |
---|
1083 | n/a | const char *, |
---|
1084 | n/a | const char *), |
---|
1085 | n/a | int isGeneralTextEntity, |
---|
1086 | n/a | const ENCODING *enc, |
---|
1087 | n/a | const char *ptr, |
---|
1088 | n/a | const char *end, |
---|
1089 | n/a | const char **badPtr, |
---|
1090 | n/a | const char **versionPtr, |
---|
1091 | n/a | const char **versionEndPtr, |
---|
1092 | n/a | const char **encodingName, |
---|
1093 | n/a | const ENCODING **encoding, |
---|
1094 | n/a | int *standalone) |
---|
1095 | n/a | { |
---|
1096 | n/a | const char *val = NULL; |
---|
1097 | n/a | const char *name = NULL; |
---|
1098 | n/a | const char *nameEnd = NULL; |
---|
1099 | n/a | ptr += 5 * enc->minBytesPerChar; |
---|
1100 | n/a | end -= 2 * enc->minBytesPerChar; |
---|
1101 | n/a | if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr) |
---|
1102 | n/a | || !name) { |
---|
1103 | n/a | *badPtr = ptr; |
---|
1104 | n/a | return 0; |
---|
1105 | n/a | } |
---|
1106 | n/a | if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) { |
---|
1107 | n/a | if (!isGeneralTextEntity) { |
---|
1108 | n/a | *badPtr = name; |
---|
1109 | n/a | return 0; |
---|
1110 | n/a | } |
---|
1111 | n/a | } |
---|
1112 | n/a | else { |
---|
1113 | n/a | if (versionPtr) |
---|
1114 | n/a | *versionPtr = val; |
---|
1115 | n/a | if (versionEndPtr) |
---|
1116 | n/a | *versionEndPtr = ptr; |
---|
1117 | n/a | if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { |
---|
1118 | n/a | *badPtr = ptr; |
---|
1119 | n/a | return 0; |
---|
1120 | n/a | } |
---|
1121 | n/a | if (!name) { |
---|
1122 | n/a | if (isGeneralTextEntity) { |
---|
1123 | n/a | /* a TextDecl must have an EncodingDecl */ |
---|
1124 | n/a | *badPtr = ptr; |
---|
1125 | n/a | return 0; |
---|
1126 | n/a | } |
---|
1127 | n/a | return 1; |
---|
1128 | n/a | } |
---|
1129 | n/a | } |
---|
1130 | n/a | if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) { |
---|
1131 | n/a | int c = toAscii(enc, val, end); |
---|
1132 | n/a | if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) { |
---|
1133 | n/a | *badPtr = val; |
---|
1134 | n/a | return 0; |
---|
1135 | n/a | } |
---|
1136 | n/a | if (encodingName) |
---|
1137 | n/a | *encodingName = val; |
---|
1138 | n/a | if (encoding) |
---|
1139 | n/a | *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar); |
---|
1140 | n/a | if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) { |
---|
1141 | n/a | *badPtr = ptr; |
---|
1142 | n/a | return 0; |
---|
1143 | n/a | } |
---|
1144 | n/a | if (!name) |
---|
1145 | n/a | return 1; |
---|
1146 | n/a | } |
---|
1147 | n/a | if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone) |
---|
1148 | n/a | || isGeneralTextEntity) { |
---|
1149 | n/a | *badPtr = name; |
---|
1150 | n/a | return 0; |
---|
1151 | n/a | } |
---|
1152 | n/a | if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) { |
---|
1153 | n/a | if (standalone) |
---|
1154 | n/a | *standalone = 1; |
---|
1155 | n/a | } |
---|
1156 | n/a | else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) { |
---|
1157 | n/a | if (standalone) |
---|
1158 | n/a | *standalone = 0; |
---|
1159 | n/a | } |
---|
1160 | n/a | else { |
---|
1161 | n/a | *badPtr = val; |
---|
1162 | n/a | return 0; |
---|
1163 | n/a | } |
---|
1164 | n/a | while (isSpace(toAscii(enc, ptr, end))) |
---|
1165 | n/a | ptr += enc->minBytesPerChar; |
---|
1166 | n/a | if (ptr != end) { |
---|
1167 | n/a | *badPtr = ptr; |
---|
1168 | n/a | return 0; |
---|
1169 | n/a | } |
---|
1170 | n/a | return 1; |
---|
1171 | n/a | } |
---|
1172 | n/a | |
---|
1173 | n/a | static int FASTCALL |
---|
1174 | n/a | checkCharRefNumber(int result) |
---|
1175 | n/a | { |
---|
1176 | n/a | switch (result >> 8) { |
---|
1177 | n/a | case 0xD8: case 0xD9: case 0xDA: case 0xDB: |
---|
1178 | n/a | case 0xDC: case 0xDD: case 0xDE: case 0xDF: |
---|
1179 | n/a | return -1; |
---|
1180 | n/a | case 0: |
---|
1181 | n/a | if (latin1_encoding.type[result] == BT_NONXML) |
---|
1182 | n/a | return -1; |
---|
1183 | n/a | break; |
---|
1184 | n/a | case 0xFF: |
---|
1185 | n/a | if (result == 0xFFFE || result == 0xFFFF) |
---|
1186 | n/a | return -1; |
---|
1187 | n/a | break; |
---|
1188 | n/a | } |
---|
1189 | n/a | return result; |
---|
1190 | n/a | } |
---|
1191 | n/a | |
---|
1192 | n/a | int FASTCALL |
---|
1193 | n/a | XmlUtf8Encode(int c, char *buf) |
---|
1194 | n/a | { |
---|
1195 | n/a | enum { |
---|
1196 | n/a | /* minN is minimum legal resulting value for N byte sequence */ |
---|
1197 | n/a | min2 = 0x80, |
---|
1198 | n/a | min3 = 0x800, |
---|
1199 | n/a | min4 = 0x10000 |
---|
1200 | n/a | }; |
---|
1201 | n/a | |
---|
1202 | n/a | if (c < 0) |
---|
1203 | n/a | return 0; |
---|
1204 | n/a | if (c < min2) { |
---|
1205 | n/a | buf[0] = (char)(c | UTF8_cval1); |
---|
1206 | n/a | return 1; |
---|
1207 | n/a | } |
---|
1208 | n/a | if (c < min3) { |
---|
1209 | n/a | buf[0] = (char)((c >> 6) | UTF8_cval2); |
---|
1210 | n/a | buf[1] = (char)((c & 0x3f) | 0x80); |
---|
1211 | n/a | return 2; |
---|
1212 | n/a | } |
---|
1213 | n/a | if (c < min4) { |
---|
1214 | n/a | buf[0] = (char)((c >> 12) | UTF8_cval3); |
---|
1215 | n/a | buf[1] = (char)(((c >> 6) & 0x3f) | 0x80); |
---|
1216 | n/a | buf[2] = (char)((c & 0x3f) | 0x80); |
---|
1217 | n/a | return 3; |
---|
1218 | n/a | } |
---|
1219 | n/a | if (c < 0x110000) { |
---|
1220 | n/a | buf[0] = (char)((c >> 18) | UTF8_cval4); |
---|
1221 | n/a | buf[1] = (char)(((c >> 12) & 0x3f) | 0x80); |
---|
1222 | n/a | buf[2] = (char)(((c >> 6) & 0x3f) | 0x80); |
---|
1223 | n/a | buf[3] = (char)((c & 0x3f) | 0x80); |
---|
1224 | n/a | return 4; |
---|
1225 | n/a | } |
---|
1226 | n/a | return 0; |
---|
1227 | n/a | } |
---|
1228 | n/a | |
---|
1229 | n/a | int FASTCALL |
---|
1230 | n/a | XmlUtf16Encode(int charNum, unsigned short *buf) |
---|
1231 | n/a | { |
---|
1232 | n/a | if (charNum < 0) |
---|
1233 | n/a | return 0; |
---|
1234 | n/a | if (charNum < 0x10000) { |
---|
1235 | n/a | buf[0] = (unsigned short)charNum; |
---|
1236 | n/a | return 1; |
---|
1237 | n/a | } |
---|
1238 | n/a | if (charNum < 0x110000) { |
---|
1239 | n/a | charNum -= 0x10000; |
---|
1240 | n/a | buf[0] = (unsigned short)((charNum >> 10) + 0xD800); |
---|
1241 | n/a | buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00); |
---|
1242 | n/a | return 2; |
---|
1243 | n/a | } |
---|
1244 | n/a | return 0; |
---|
1245 | n/a | } |
---|
1246 | n/a | |
---|
1247 | n/a | struct unknown_encoding { |
---|
1248 | n/a | struct normal_encoding normal; |
---|
1249 | n/a | CONVERTER convert; |
---|
1250 | n/a | void *userData; |
---|
1251 | n/a | unsigned short utf16[256]; |
---|
1252 | n/a | char utf8[256][4]; |
---|
1253 | n/a | }; |
---|
1254 | n/a | |
---|
1255 | n/a | #define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc)) |
---|
1256 | n/a | |
---|
1257 | n/a | int |
---|
1258 | n/a | XmlSizeOfUnknownEncoding(void) |
---|
1259 | n/a | { |
---|
1260 | n/a | return sizeof(struct unknown_encoding); |
---|
1261 | n/a | } |
---|
1262 | n/a | |
---|
1263 | n/a | static int PTRFASTCALL |
---|
1264 | n/a | unknown_isName(const ENCODING *enc, const char *p) |
---|
1265 | n/a | { |
---|
1266 | n/a | const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); |
---|
1267 | n/a | int c = uenc->convert(uenc->userData, p); |
---|
1268 | n/a | if (c & ~0xFFFF) |
---|
1269 | n/a | return 0; |
---|
1270 | n/a | return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF); |
---|
1271 | n/a | } |
---|
1272 | n/a | |
---|
1273 | n/a | static int PTRFASTCALL |
---|
1274 | n/a | unknown_isNmstrt(const ENCODING *enc, const char *p) |
---|
1275 | n/a | { |
---|
1276 | n/a | const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); |
---|
1277 | n/a | int c = uenc->convert(uenc->userData, p); |
---|
1278 | n/a | if (c & ~0xFFFF) |
---|
1279 | n/a | return 0; |
---|
1280 | n/a | return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF); |
---|
1281 | n/a | } |
---|
1282 | n/a | |
---|
1283 | n/a | static int PTRFASTCALL |
---|
1284 | n/a | unknown_isInvalid(const ENCODING *enc, const char *p) |
---|
1285 | n/a | { |
---|
1286 | n/a | const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); |
---|
1287 | n/a | int c = uenc->convert(uenc->userData, p); |
---|
1288 | n/a | return (c & ~0xFFFF) || checkCharRefNumber(c) < 0; |
---|
1289 | n/a | } |
---|
1290 | n/a | |
---|
1291 | n/a | static void PTRCALL |
---|
1292 | n/a | unknown_toUtf8(const ENCODING *enc, |
---|
1293 | n/a | const char **fromP, const char *fromLim, |
---|
1294 | n/a | char **toP, const char *toLim) |
---|
1295 | n/a | { |
---|
1296 | n/a | const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); |
---|
1297 | n/a | char buf[XML_UTF8_ENCODE_MAX]; |
---|
1298 | n/a | for (;;) { |
---|
1299 | n/a | const char *utf8; |
---|
1300 | n/a | int n; |
---|
1301 | n/a | if (*fromP == fromLim) |
---|
1302 | n/a | break; |
---|
1303 | n/a | utf8 = uenc->utf8[(unsigned char)**fromP]; |
---|
1304 | n/a | n = *utf8++; |
---|
1305 | n/a | if (n == 0) { |
---|
1306 | n/a | int c = uenc->convert(uenc->userData, *fromP); |
---|
1307 | n/a | n = XmlUtf8Encode(c, buf); |
---|
1308 | n/a | if (n > toLim - *toP) |
---|
1309 | n/a | break; |
---|
1310 | n/a | utf8 = buf; |
---|
1311 | n/a | *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] |
---|
1312 | n/a | - (BT_LEAD2 - 2)); |
---|
1313 | n/a | } |
---|
1314 | n/a | else { |
---|
1315 | n/a | if (n > toLim - *toP) |
---|
1316 | n/a | break; |
---|
1317 | n/a | (*fromP)++; |
---|
1318 | n/a | } |
---|
1319 | n/a | do { |
---|
1320 | n/a | *(*toP)++ = *utf8++; |
---|
1321 | n/a | } while (--n != 0); |
---|
1322 | n/a | } |
---|
1323 | n/a | } |
---|
1324 | n/a | |
---|
1325 | n/a | static void PTRCALL |
---|
1326 | n/a | unknown_toUtf16(const ENCODING *enc, |
---|
1327 | n/a | const char **fromP, const char *fromLim, |
---|
1328 | n/a | unsigned short **toP, const unsigned short *toLim) |
---|
1329 | n/a | { |
---|
1330 | n/a | const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc); |
---|
1331 | n/a | while (*fromP != fromLim && *toP != toLim) { |
---|
1332 | n/a | unsigned short c = uenc->utf16[(unsigned char)**fromP]; |
---|
1333 | n/a | if (c == 0) { |
---|
1334 | n/a | c = (unsigned short) |
---|
1335 | n/a | uenc->convert(uenc->userData, *fromP); |
---|
1336 | n/a | *fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP] |
---|
1337 | n/a | - (BT_LEAD2 - 2)); |
---|
1338 | n/a | } |
---|
1339 | n/a | else |
---|
1340 | n/a | (*fromP)++; |
---|
1341 | n/a | *(*toP)++ = c; |
---|
1342 | n/a | } |
---|
1343 | n/a | } |
---|
1344 | n/a | |
---|
1345 | n/a | ENCODING * |
---|
1346 | n/a | XmlInitUnknownEncoding(void *mem, |
---|
1347 | n/a | int *table, |
---|
1348 | n/a | CONVERTER convert, |
---|
1349 | n/a | void *userData) |
---|
1350 | n/a | { |
---|
1351 | n/a | int i; |
---|
1352 | n/a | struct unknown_encoding *e = (struct unknown_encoding *)mem; |
---|
1353 | n/a | for (i = 0; i < (int)sizeof(struct normal_encoding); i++) |
---|
1354 | n/a | ((char *)mem)[i] = ((char *)&latin1_encoding)[i]; |
---|
1355 | n/a | for (i = 0; i < 128; i++) |
---|
1356 | n/a | if (latin1_encoding.type[i] != BT_OTHER |
---|
1357 | n/a | && latin1_encoding.type[i] != BT_NONXML |
---|
1358 | n/a | && table[i] != i) |
---|
1359 | n/a | return 0; |
---|
1360 | n/a | for (i = 0; i < 256; i++) { |
---|
1361 | n/a | int c = table[i]; |
---|
1362 | n/a | if (c == -1) { |
---|
1363 | n/a | e->normal.type[i] = BT_MALFORM; |
---|
1364 | n/a | /* This shouldn't really get used. */ |
---|
1365 | n/a | e->utf16[i] = 0xFFFF; |
---|
1366 | n/a | e->utf8[i][0] = 1; |
---|
1367 | n/a | e->utf8[i][1] = 0; |
---|
1368 | n/a | } |
---|
1369 | n/a | else if (c < 0) { |
---|
1370 | n/a | if (c < -4) |
---|
1371 | n/a | return 0; |
---|
1372 | n/a | e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2)); |
---|
1373 | n/a | e->utf8[i][0] = 0; |
---|
1374 | n/a | e->utf16[i] = 0; |
---|
1375 | n/a | } |
---|
1376 | n/a | else if (c < 0x80) { |
---|
1377 | n/a | if (latin1_encoding.type[c] != BT_OTHER |
---|
1378 | n/a | && latin1_encoding.type[c] != BT_NONXML |
---|
1379 | n/a | && c != i) |
---|
1380 | n/a | return 0; |
---|
1381 | n/a | e->normal.type[i] = latin1_encoding.type[c]; |
---|
1382 | n/a | e->utf8[i][0] = 1; |
---|
1383 | n/a | e->utf8[i][1] = (char)c; |
---|
1384 | n/a | e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c); |
---|
1385 | n/a | } |
---|
1386 | n/a | else if (checkCharRefNumber(c) < 0) { |
---|
1387 | n/a | e->normal.type[i] = BT_NONXML; |
---|
1388 | n/a | /* This shouldn't really get used. */ |
---|
1389 | n/a | e->utf16[i] = 0xFFFF; |
---|
1390 | n/a | e->utf8[i][0] = 1; |
---|
1391 | n/a | e->utf8[i][1] = 0; |
---|
1392 | n/a | } |
---|
1393 | n/a | else { |
---|
1394 | n/a | if (c > 0xFFFF) |
---|
1395 | n/a | return 0; |
---|
1396 | n/a | if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff)) |
---|
1397 | n/a | e->normal.type[i] = BT_NMSTRT; |
---|
1398 | n/a | else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff)) |
---|
1399 | n/a | e->normal.type[i] = BT_NAME; |
---|
1400 | n/a | else |
---|
1401 | n/a | e->normal.type[i] = BT_OTHER; |
---|
1402 | n/a | e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1); |
---|
1403 | n/a | e->utf16[i] = (unsigned short)c; |
---|
1404 | n/a | } |
---|
1405 | n/a | } |
---|
1406 | n/a | e->userData = userData; |
---|
1407 | n/a | e->convert = convert; |
---|
1408 | n/a | if (convert) { |
---|
1409 | n/a | e->normal.isName2 = unknown_isName; |
---|
1410 | n/a | e->normal.isName3 = unknown_isName; |
---|
1411 | n/a | e->normal.isName4 = unknown_isName; |
---|
1412 | n/a | e->normal.isNmstrt2 = unknown_isNmstrt; |
---|
1413 | n/a | e->normal.isNmstrt3 = unknown_isNmstrt; |
---|
1414 | n/a | e->normal.isNmstrt4 = unknown_isNmstrt; |
---|
1415 | n/a | e->normal.isInvalid2 = unknown_isInvalid; |
---|
1416 | n/a | e->normal.isInvalid3 = unknown_isInvalid; |
---|
1417 | n/a | e->normal.isInvalid4 = unknown_isInvalid; |
---|
1418 | n/a | } |
---|
1419 | n/a | e->normal.enc.utf8Convert = unknown_toUtf8; |
---|
1420 | n/a | e->normal.enc.utf16Convert = unknown_toUtf16; |
---|
1421 | n/a | return &(e->normal.enc); |
---|
1422 | n/a | } |
---|
1423 | n/a | |
---|
1424 | n/a | /* If this enumeration is changed, getEncodingIndex and encodings |
---|
1425 | n/a | must also be changed. */ |
---|
1426 | n/a | enum { |
---|
1427 | n/a | UNKNOWN_ENC = -1, |
---|
1428 | n/a | ISO_8859_1_ENC = 0, |
---|
1429 | n/a | US_ASCII_ENC, |
---|
1430 | n/a | UTF_8_ENC, |
---|
1431 | n/a | UTF_16_ENC, |
---|
1432 | n/a | UTF_16BE_ENC, |
---|
1433 | n/a | UTF_16LE_ENC, |
---|
1434 | n/a | /* must match encodingNames up to here */ |
---|
1435 | n/a | NO_ENC |
---|
1436 | n/a | }; |
---|
1437 | n/a | |
---|
1438 | n/a | static const char KW_ISO_8859_1[] = { |
---|
1439 | n/a | ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9, |
---|
1440 | n/a | ASCII_MINUS, ASCII_1, '\0' |
---|
1441 | n/a | }; |
---|
1442 | n/a | static const char KW_US_ASCII[] = { |
---|
1443 | n/a | ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I, |
---|
1444 | n/a | '\0' |
---|
1445 | n/a | }; |
---|
1446 | n/a | static const char KW_UTF_8[] = { |
---|
1447 | n/a | ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0' |
---|
1448 | n/a | }; |
---|
1449 | n/a | static const char KW_UTF_16[] = { |
---|
1450 | n/a | ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0' |
---|
1451 | n/a | }; |
---|
1452 | n/a | static const char KW_UTF_16BE[] = { |
---|
1453 | n/a | ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E, |
---|
1454 | n/a | '\0' |
---|
1455 | n/a | }; |
---|
1456 | n/a | static const char KW_UTF_16LE[] = { |
---|
1457 | n/a | ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E, |
---|
1458 | n/a | '\0' |
---|
1459 | n/a | }; |
---|
1460 | n/a | |
---|
1461 | n/a | static int FASTCALL |
---|
1462 | n/a | getEncodingIndex(const char *name) |
---|
1463 | n/a | { |
---|
1464 | n/a | static const char * const encodingNames[] = { |
---|
1465 | n/a | KW_ISO_8859_1, |
---|
1466 | n/a | KW_US_ASCII, |
---|
1467 | n/a | KW_UTF_8, |
---|
1468 | n/a | KW_UTF_16, |
---|
1469 | n/a | KW_UTF_16BE, |
---|
1470 | n/a | KW_UTF_16LE, |
---|
1471 | n/a | }; |
---|
1472 | n/a | int i; |
---|
1473 | n/a | if (name == NULL) |
---|
1474 | n/a | return NO_ENC; |
---|
1475 | n/a | for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++) |
---|
1476 | n/a | if (streqci(name, encodingNames[i])) |
---|
1477 | n/a | return i; |
---|
1478 | n/a | return UNKNOWN_ENC; |
---|
1479 | n/a | } |
---|
1480 | n/a | |
---|
1481 | n/a | /* For binary compatibility, we store the index of the encoding |
---|
1482 | n/a | specified at initialization in the isUtf16 member. |
---|
1483 | n/a | */ |
---|
1484 | n/a | |
---|
1485 | n/a | #define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16) |
---|
1486 | n/a | #define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i) |
---|
1487 | n/a | |
---|
1488 | n/a | /* This is what detects the encoding. encodingTable maps from |
---|
1489 | n/a | encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of |
---|
1490 | n/a | the external (protocol) specified encoding; state is |
---|
1491 | n/a | XML_CONTENT_STATE if we're parsing an external text entity, and |
---|
1492 | n/a | XML_PROLOG_STATE otherwise. |
---|
1493 | n/a | */ |
---|
1494 | n/a | |
---|
1495 | n/a | |
---|
1496 | n/a | static int |
---|
1497 | n/a | initScan(const ENCODING * const *encodingTable, |
---|
1498 | n/a | const INIT_ENCODING *enc, |
---|
1499 | n/a | int state, |
---|
1500 | n/a | const char *ptr, |
---|
1501 | n/a | const char *end, |
---|
1502 | n/a | const char **nextTokPtr) |
---|
1503 | n/a | { |
---|
1504 | n/a | const ENCODING **encPtr; |
---|
1505 | n/a | |
---|
1506 | n/a | if (ptr == end) |
---|
1507 | n/a | return XML_TOK_NONE; |
---|
1508 | n/a | encPtr = enc->encPtr; |
---|
1509 | n/a | if (ptr + 1 == end) { |
---|
1510 | n/a | /* only a single byte available for auto-detection */ |
---|
1511 | n/a | #ifndef XML_DTD /* FIXME */ |
---|
1512 | n/a | /* a well-formed document entity must have more than one byte */ |
---|
1513 | n/a | if (state != XML_CONTENT_STATE) |
---|
1514 | n/a | return XML_TOK_PARTIAL; |
---|
1515 | n/a | #endif |
---|
1516 | n/a | /* so we're parsing an external text entity... */ |
---|
1517 | n/a | /* if UTF-16 was externally specified, then we need at least 2 bytes */ |
---|
1518 | n/a | switch (INIT_ENC_INDEX(enc)) { |
---|
1519 | n/a | case UTF_16_ENC: |
---|
1520 | n/a | case UTF_16LE_ENC: |
---|
1521 | n/a | case UTF_16BE_ENC: |
---|
1522 | n/a | return XML_TOK_PARTIAL; |
---|
1523 | n/a | } |
---|
1524 | n/a | switch ((unsigned char)*ptr) { |
---|
1525 | n/a | case 0xFE: |
---|
1526 | n/a | case 0xFF: |
---|
1527 | n/a | case 0xEF: /* possibly first byte of UTF-8 BOM */ |
---|
1528 | n/a | if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC |
---|
1529 | n/a | && state == XML_CONTENT_STATE) |
---|
1530 | n/a | break; |
---|
1531 | n/a | /* fall through */ |
---|
1532 | n/a | case 0x00: |
---|
1533 | n/a | case 0x3C: |
---|
1534 | n/a | return XML_TOK_PARTIAL; |
---|
1535 | n/a | } |
---|
1536 | n/a | } |
---|
1537 | n/a | else { |
---|
1538 | n/a | switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) { |
---|
1539 | n/a | case 0xFEFF: |
---|
1540 | n/a | if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC |
---|
1541 | n/a | && state == XML_CONTENT_STATE) |
---|
1542 | n/a | break; |
---|
1543 | n/a | *nextTokPtr = ptr + 2; |
---|
1544 | n/a | *encPtr = encodingTable[UTF_16BE_ENC]; |
---|
1545 | n/a | return XML_TOK_BOM; |
---|
1546 | n/a | /* 00 3C is handled in the default case */ |
---|
1547 | n/a | case 0x3C00: |
---|
1548 | n/a | if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC |
---|
1549 | n/a | || INIT_ENC_INDEX(enc) == UTF_16_ENC) |
---|
1550 | n/a | && state == XML_CONTENT_STATE) |
---|
1551 | n/a | break; |
---|
1552 | n/a | *encPtr = encodingTable[UTF_16LE_ENC]; |
---|
1553 | n/a | return XmlTok(*encPtr, state, ptr, end, nextTokPtr); |
---|
1554 | n/a | case 0xFFFE: |
---|
1555 | n/a | if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC |
---|
1556 | n/a | && state == XML_CONTENT_STATE) |
---|
1557 | n/a | break; |
---|
1558 | n/a | *nextTokPtr = ptr + 2; |
---|
1559 | n/a | *encPtr = encodingTable[UTF_16LE_ENC]; |
---|
1560 | n/a | return XML_TOK_BOM; |
---|
1561 | n/a | case 0xEFBB: |
---|
1562 | n/a | /* Maybe a UTF-8 BOM (EF BB BF) */ |
---|
1563 | n/a | /* If there's an explicitly specified (external) encoding |
---|
1564 | n/a | of ISO-8859-1 or some flavour of UTF-16 |
---|
1565 | n/a | and this is an external text entity, |
---|
1566 | n/a | don't look for the BOM, |
---|
1567 | n/a | because it might be a legal data. |
---|
1568 | n/a | */ |
---|
1569 | n/a | if (state == XML_CONTENT_STATE) { |
---|
1570 | n/a | int e = INIT_ENC_INDEX(enc); |
---|
1571 | n/a | if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC |
---|
1572 | n/a | || e == UTF_16LE_ENC || e == UTF_16_ENC) |
---|
1573 | n/a | break; |
---|
1574 | n/a | } |
---|
1575 | n/a | if (ptr + 2 == end) |
---|
1576 | n/a | return XML_TOK_PARTIAL; |
---|
1577 | n/a | if ((unsigned char)ptr[2] == 0xBF) { |
---|
1578 | n/a | *nextTokPtr = ptr + 3; |
---|
1579 | n/a | *encPtr = encodingTable[UTF_8_ENC]; |
---|
1580 | n/a | return XML_TOK_BOM; |
---|
1581 | n/a | } |
---|
1582 | n/a | break; |
---|
1583 | n/a | default: |
---|
1584 | n/a | if (ptr[0] == '\0') { |
---|
1585 | n/a | /* 0 isn't a legal data character. Furthermore a document |
---|
1586 | n/a | entity can only start with ASCII characters. So the only |
---|
1587 | n/a | way this can fail to be big-endian UTF-16 if it it's an |
---|
1588 | n/a | external parsed general entity that's labelled as |
---|
1589 | n/a | UTF-16LE. |
---|
1590 | n/a | */ |
---|
1591 | n/a | if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC) |
---|
1592 | n/a | break; |
---|
1593 | n/a | *encPtr = encodingTable[UTF_16BE_ENC]; |
---|
1594 | n/a | return XmlTok(*encPtr, state, ptr, end, nextTokPtr); |
---|
1595 | n/a | } |
---|
1596 | n/a | else if (ptr[1] == '\0') { |
---|
1597 | n/a | /* We could recover here in the case: |
---|
1598 | n/a | - parsing an external entity |
---|
1599 | n/a | - second byte is 0 |
---|
1600 | n/a | - no externally specified encoding |
---|
1601 | n/a | - no encoding declaration |
---|
1602 | n/a | by assuming UTF-16LE. But we don't, because this would mean when |
---|
1603 | n/a | presented just with a single byte, we couldn't reliably determine |
---|
1604 | n/a | whether we needed further bytes. |
---|
1605 | n/a | */ |
---|
1606 | n/a | if (state == XML_CONTENT_STATE) |
---|
1607 | n/a | break; |
---|
1608 | n/a | *encPtr = encodingTable[UTF_16LE_ENC]; |
---|
1609 | n/a | return XmlTok(*encPtr, state, ptr, end, nextTokPtr); |
---|
1610 | n/a | } |
---|
1611 | n/a | break; |
---|
1612 | n/a | } |
---|
1613 | n/a | } |
---|
1614 | n/a | *encPtr = encodingTable[INIT_ENC_INDEX(enc)]; |
---|
1615 | n/a | return XmlTok(*encPtr, state, ptr, end, nextTokPtr); |
---|
1616 | n/a | } |
---|
1617 | n/a | |
---|
1618 | n/a | |
---|
1619 | n/a | #define NS(x) x |
---|
1620 | n/a | #define ns(x) x |
---|
1621 | n/a | #define XML_TOK_NS_C |
---|
1622 | n/a | #include "xmltok_ns.c" |
---|
1623 | n/a | #undef XML_TOK_NS_C |
---|
1624 | n/a | #undef NS |
---|
1625 | n/a | #undef ns |
---|
1626 | n/a | |
---|
1627 | n/a | #ifdef XML_NS |
---|
1628 | n/a | |
---|
1629 | n/a | #define NS(x) x ## NS |
---|
1630 | n/a | #define ns(x) x ## _ns |
---|
1631 | n/a | |
---|
1632 | n/a | #define XML_TOK_NS_C |
---|
1633 | n/a | #include "xmltok_ns.c" |
---|
1634 | n/a | #undef XML_TOK_NS_C |
---|
1635 | n/a | |
---|
1636 | n/a | #undef NS |
---|
1637 | n/a | #undef ns |
---|
1638 | n/a | |
---|
1639 | n/a | ENCODING * |
---|
1640 | n/a | XmlInitUnknownEncodingNS(void *mem, |
---|
1641 | n/a | int *table, |
---|
1642 | n/a | CONVERTER convert, |
---|
1643 | n/a | void *userData) |
---|
1644 | n/a | { |
---|
1645 | n/a | ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData); |
---|
1646 | n/a | if (enc) |
---|
1647 | n/a | ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON; |
---|
1648 | n/a | return enc; |
---|
1649 | n/a | } |
---|
1650 | n/a | |
---|
1651 | n/a | #endif /* XML_NS */ |
---|