Deleted Added
full compact
xmltok.c (104349) xmltok.c (178848)
1/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
3*/
4
1/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
3*/
4
5#include <stddef.h>
6
5#ifdef COMPILED_FROM_DSP
6#include "winconfig.h"
7#elif defined(MACOS_CLASSIC)
8#include "macconfig.h"
7#ifdef COMPILED_FROM_DSP
8#include "winconfig.h"
9#elif defined(MACOS_CLASSIC)
10#include "macconfig.h"
11#elif defined(__amigaos4__)
12#include "amigaconfig.h"
13#elif defined(__WATCOMC__)
14#include "watcomconfig.h"
9#else
15#else
16#ifdef HAVE_EXPAT_CONFIG_H
10#include <expat_config.h>
17#include <expat_config.h>
18#endif
11#endif /* ndef COMPILED_FROM_DSP */
12
19#endif /* ndef COMPILED_FROM_DSP */
20
21#include "expat_external.h"
13#include "internal.h"
14#include "xmltok.h"
15#include "nametab.h"
16
17#ifdef XML_DTD
18#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
19#else
20#define IGNORE_SECTION_TOK_VTABLE /* as nothing */

--- 86 unchanged lines hidden (view full) ---

107 ((*p) == 0xF0 \
108 ? \
109 (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
110 : \
111 ((p)[1] & 0x80) == 0 \
112 || \
113 ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))
114
22#include "internal.h"
23#include "xmltok.h"
24#include "nametab.h"
25
26#ifdef XML_DTD
27#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
28#else
29#define IGNORE_SECTION_TOK_VTABLE /* as nothing */

--- 86 unchanged lines hidden (view full) ---

116 ((*p) == 0xF0 \
117 ? \
118 (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
119 : \
120 ((p)[1] & 0x80) == 0 \
121 || \
122 ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))
123
115static int FASTCALL
124static int PTRFASTCALL
116isNever(const ENCODING *enc, const char *p)
117{
118 return 0;
119}
120
125isNever(const ENCODING *enc, const char *p)
126{
127 return 0;
128}
129
121static int FASTCALL
130static int PTRFASTCALL
122utf8_isName2(const ENCODING *enc, const char *p)
123{
124 return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
125}
126
131utf8_isName2(const ENCODING *enc, const char *p)
132{
133 return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
134}
135
127static int FASTCALL
136static int PTRFASTCALL
128utf8_isName3(const ENCODING *enc, const char *p)
129{
130 return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
131}
132
133#define utf8_isName4 isNever
134
137utf8_isName3(const ENCODING *enc, const char *p)
138{
139 return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
140}
141
142#define utf8_isName4 isNever
143
135static int FASTCALL
144static int PTRFASTCALL
136utf8_isNmstrt2(const ENCODING *enc, const char *p)
137{
138 return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
139}
140
145utf8_isNmstrt2(const ENCODING *enc, const char *p)
146{
147 return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
148}
149
141static int FASTCALL
150static int PTRFASTCALL
142utf8_isNmstrt3(const ENCODING *enc, const char *p)
143{
144 return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
145}
146
147#define utf8_isNmstrt4 isNever
148
151utf8_isNmstrt3(const ENCODING *enc, const char *p)
152{
153 return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
154}
155
156#define utf8_isNmstrt4 isNever
157
149static int FASTCALL
158static int PTRFASTCALL
150utf8_isInvalid2(const ENCODING *enc, const char *p)
151{
152 return UTF8_INVALID2((const unsigned char *)p);
153}
154
159utf8_isInvalid2(const ENCODING *enc, const char *p)
160{
161 return UTF8_INVALID2((const unsigned char *)p);
162}
163
155static int FASTCALL
164static int PTRFASTCALL
156utf8_isInvalid3(const ENCODING *enc, const char *p)
157{
158 return UTF8_INVALID3((const unsigned char *)p);
159}
160
165utf8_isInvalid3(const ENCODING *enc, const char *p)
166{
167 return UTF8_INVALID3((const unsigned char *)p);
168}
169
161static int FASTCALL
170static int PTRFASTCALL
162utf8_isInvalid4(const ENCODING *enc, const char *p)
163{
164 return UTF8_INVALID4((const unsigned char *)p);
165}
166
167struct normal_encoding {
168 ENCODING enc;
169 unsigned char type[256];
170#ifdef XML_MIN_SIZE
171utf8_isInvalid4(const ENCODING *enc, const char *p)
172{
173 return UTF8_INVALID4((const unsigned char *)p);
174}
175
176struct normal_encoding {
177 ENCODING enc;
178 unsigned char type[256];
179#ifdef XML_MIN_SIZE
171 int (FASTCALL *byteType)(const ENCODING *, const char *);
172 int (FASTCALL *isNameMin)(const ENCODING *, const char *);
173 int (FASTCALL *isNmstrtMin)(const ENCODING *, const char *);
174 int (FASTCALL *byteToAscii)(const ENCODING *, const char *);
175 int (FASTCALL *charMatches)(const ENCODING *, const char *, int);
180 int (PTRFASTCALL *byteType)(const ENCODING *, const char *);
181 int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *);
182 int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *);
183 int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *);
184 int (PTRCALL *charMatches)(const ENCODING *, const char *, int);
176#endif /* XML_MIN_SIZE */
185#endif /* XML_MIN_SIZE */
177 int (FASTCALL *isName2)(const ENCODING *, const char *);
178 int (FASTCALL *isName3)(const ENCODING *, const char *);
179 int (FASTCALL *isName4)(const ENCODING *, const char *);
180 int (FASTCALL *isNmstrt2)(const ENCODING *, const char *);
181 int (FASTCALL *isNmstrt3)(const ENCODING *, const char *);
182 int (FASTCALL *isNmstrt4)(const ENCODING *, const char *);
183 int (FASTCALL *isInvalid2)(const ENCODING *, const char *);
184 int (FASTCALL *isInvalid3)(const ENCODING *, const char *);
185 int (FASTCALL *isInvalid4)(const ENCODING *, const char *);
186 int (PTRFASTCALL *isName2)(const ENCODING *, const char *);
187 int (PTRFASTCALL *isName3)(const ENCODING *, const char *);
188 int (PTRFASTCALL *isName4)(const ENCODING *, const char *);
189 int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *);
190 int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *);
191 int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *);
192 int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *);
193 int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *);
194 int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *);
186};
187
188#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc))
189
190#ifdef XML_MIN_SIZE
191
192#define STANDARD_VTABLE(E) \
193 E ## byteType, \

--- 35 unchanged lines hidden (view full) ---

229/* minimum bytes per character */
230#define MINBPC(enc) 1
231#endif
232
233#define SB_BYTE_TYPE(enc, p) \
234 (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
235
236#ifdef XML_MIN_SIZE
195};
196
197#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc))
198
199#ifdef XML_MIN_SIZE
200
201#define STANDARD_VTABLE(E) \
202 E ## byteType, \

--- 35 unchanged lines hidden (view full) ---

238/* minimum bytes per character */
239#define MINBPC(enc) 1
240#endif
241
242#define SB_BYTE_TYPE(enc, p) \
243 (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
244
245#ifdef XML_MIN_SIZE
237static int FASTCALL
246static int PTRFASTCALL
238sb_byteType(const ENCODING *enc, const char *p)
239{
240 return SB_BYTE_TYPE(enc, p);
241}
242#define BYTE_TYPE(enc, p) \
243 (AS_NORMAL_ENCODING(enc)->byteType(enc, p))
244#else
245#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
246#endif
247
248#ifdef XML_MIN_SIZE
249#define BYTE_TO_ASCII(enc, p) \
250 (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p))
247sb_byteType(const ENCODING *enc, const char *p)
248{
249 return SB_BYTE_TYPE(enc, p);
250}
251#define BYTE_TYPE(enc, p) \
252 (AS_NORMAL_ENCODING(enc)->byteType(enc, p))
253#else
254#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
255#endif
256
257#ifdef XML_MIN_SIZE
258#define BYTE_TO_ASCII(enc, p) \
259 (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p))
251static int FASTCALL
260static int PTRFASTCALL
252sb_byteToAscii(const ENCODING *enc, const char *p)
253{
254 return *p;
255}
256#else
257#define BYTE_TO_ASCII(enc, p) (*(p))
258#endif
259

--- 12 unchanged lines hidden (view full) ---

272#else
273#define IS_NAME_CHAR_MINBPC(enc, p) (0)
274#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
275#endif
276
277#ifdef XML_MIN_SIZE
278#define CHAR_MATCHES(enc, p, c) \
279 (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c))
261sb_byteToAscii(const ENCODING *enc, const char *p)
262{
263 return *p;
264}
265#else
266#define BYTE_TO_ASCII(enc, p) (*(p))
267#endif
268

--- 12 unchanged lines hidden (view full) ---

281#else
282#define IS_NAME_CHAR_MINBPC(enc, p) (0)
283#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
284#endif
285
286#ifdef XML_MIN_SIZE
287#define CHAR_MATCHES(enc, p, c) \
288 (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c))
280static int FASTCALL
289static int PTRCALL
281sb_charMatches(const ENCODING *enc, const char *p, int c)
282{
283 return *p == c;
284}
285#else
286/* c is an ASCII character */
287#define CHAR_MATCHES(enc, p, c) (*(p) == c)
288#endif
289
290#define PREFIX(ident) normal_ ## ident
290sb_charMatches(const ENCODING *enc, const char *p, int c)
291{
292 return *p == c;
293}
294#else
295/* c is an ASCII character */
296#define CHAR_MATCHES(enc, p, c) (*(p) == c)
297#endif
298
299#define PREFIX(ident) normal_ ## ident
300#define XML_TOK_IMPL_C
291#include "xmltok_impl.c"
301#include "xmltok_impl.c"
302#undef XML_TOK_IMPL_C
292
293#undef MINBPC
294#undef BYTE_TYPE
295#undef BYTE_TO_ASCII
296#undef CHAR_MATCHES
297#undef IS_NAME_CHAR
298#undef IS_NAME_CHAR_MINBPC
299#undef IS_NMSTRT_CHAR
300#undef IS_NMSTRT_CHAR_MINBPC
301#undef IS_INVALID_CHAR
302
303enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
304 UTF8_cval1 = 0x00,
305 UTF8_cval2 = 0xc0,
306 UTF8_cval3 = 0xe0,
307 UTF8_cval4 = 0xf0
308};
309
303
304#undef MINBPC
305#undef BYTE_TYPE
306#undef BYTE_TO_ASCII
307#undef CHAR_MATCHES
308#undef IS_NAME_CHAR
309#undef IS_NAME_CHAR_MINBPC
310#undef IS_NMSTRT_CHAR
311#undef IS_NMSTRT_CHAR_MINBPC
312#undef IS_INVALID_CHAR
313
314enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
315 UTF8_cval1 = 0x00,
316 UTF8_cval2 = 0xc0,
317 UTF8_cval3 = 0xe0,
318 UTF8_cval4 = 0xf0
319};
320
310static void FASTCALL
321static void PTRCALL
311utf8_toUtf8(const ENCODING *enc,
312 const char **fromP, const char *fromLim,
313 char **toP, const char *toLim)
314{
315 char *to;
316 const char *from;
317 if (fromLim - *fromP > toLim - *toP) {
318 /* Avoid copying partial characters. */
319 for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
320 if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
321 break;
322 }
323 for (to = *toP, from = *fromP; from != fromLim; from++, to++)
324 *to = *from;
325 *fromP = from;
326 *toP = to;
327}
328
322utf8_toUtf8(const ENCODING *enc,
323 const char **fromP, const char *fromLim,
324 char **toP, const char *toLim)
325{
326 char *to;
327 const char *from;
328 if (fromLim - *fromP > toLim - *toP) {
329 /* Avoid copying partial characters. */
330 for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
331 if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
332 break;
333 }
334 for (to = *toP, from = *fromP; from != fromLim; from++, to++)
335 *to = *from;
336 *fromP = from;
337 *toP = to;
338}
339
329static void FASTCALL
340static void PTRCALL
330utf8_toUtf16(const ENCODING *enc,
331 const char **fromP, const char *fromLim,
332 unsigned short **toP, const unsigned short *toLim)
333{
334 unsigned short *to = *toP;
335 const char *from = *fromP;
336 while (from != fromLim && to != toLim) {
337 switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {

--- 71 unchanged lines hidden (view full) ---

409#define BT_COLON BT_NMSTRT
410#include "iasciitab.h"
411#undef BT_COLON
412#include "utf8tab.h"
413 },
414 STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
415};
416
341utf8_toUtf16(const ENCODING *enc,
342 const char **fromP, const char *fromLim,
343 unsigned short **toP, const unsigned short *toLim)
344{
345 unsigned short *to = *toP;
346 const char *from = *fromP;
347 while (from != fromLim && to != toLim) {
348 switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {

--- 71 unchanged lines hidden (view full) ---

420#define BT_COLON BT_NMSTRT
421#include "iasciitab.h"
422#undef BT_COLON
423#include "utf8tab.h"
424 },
425 STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
426};
427
417static void FASTCALL
428static void PTRCALL
418latin1_toUtf8(const ENCODING *enc,
419 const char **fromP, const char *fromLim,
420 char **toP, const char *toLim)
421{
422 for (;;) {
423 unsigned char c;
424 if (*fromP == fromLim)
425 break;

--- 8 unchanged lines hidden (view full) ---

434 else {
435 if (*toP == toLim)
436 break;
437 *(*toP)++ = *(*fromP)++;
438 }
439 }
440}
441
429latin1_toUtf8(const ENCODING *enc,
430 const char **fromP, const char *fromLim,
431 char **toP, const char *toLim)
432{
433 for (;;) {
434 unsigned char c;
435 if (*fromP == fromLim)
436 break;

--- 8 unchanged lines hidden (view full) ---

445 else {
446 if (*toP == toLim)
447 break;
448 *(*toP)++ = *(*fromP)++;
449 }
450 }
451}
452
442static void FASTCALL
453static void PTRCALL
443latin1_toUtf16(const ENCODING *enc,
444 const char **fromP, const char *fromLim,
445 unsigned short **toP, const unsigned short *toLim)
446{
447 while (*fromP != fromLim && *toP != toLim)
448 *(*toP)++ = (unsigned char)*(*fromP)++;
449}
450

--- 16 unchanged lines hidden (view full) ---

467#define BT_COLON BT_NMSTRT
468#include "asciitab.h"
469#undef BT_COLON
470#include "latin1tab.h"
471 },
472 STANDARD_VTABLE(sb_)
473};
474
454latin1_toUtf16(const ENCODING *enc,
455 const char **fromP, const char *fromLim,
456 unsigned short **toP, const unsigned short *toLim)
457{
458 while (*fromP != fromLim && *toP != toLim)
459 *(*toP)++ = (unsigned char)*(*fromP)++;
460}
461

--- 16 unchanged lines hidden (view full) ---

478#define BT_COLON BT_NMSTRT
479#include "asciitab.h"
480#undef BT_COLON
481#include "latin1tab.h"
482 },
483 STANDARD_VTABLE(sb_)
484};
485
475static void FASTCALL
486static void PTRCALL
476ascii_toUtf8(const ENCODING *enc,
477 const char **fromP, const char *fromLim,
478 char **toP, const char *toLim)
479{
480 while (*fromP != fromLim && *toP != toLim)
481 *(*toP)++ = *(*fromP)++;
482}
483

--- 16 unchanged lines hidden (view full) ---

500#define BT_COLON BT_NMSTRT
501#include "asciitab.h"
502#undef BT_COLON
503/* BT_NONXML == 0 */
504 },
505 STANDARD_VTABLE(sb_)
506};
507
487ascii_toUtf8(const ENCODING *enc,
488 const char **fromP, const char *fromLim,
489 char **toP, const char *toLim)
490{
491 while (*fromP != fromLim && *toP != toLim)
492 *(*toP)++ = *(*fromP)++;
493}
494

--- 16 unchanged lines hidden (view full) ---

511#define BT_COLON BT_NMSTRT
512#include "asciitab.h"
513#undef BT_COLON
514/* BT_NONXML == 0 */
515 },
516 STANDARD_VTABLE(sb_)
517};
518
508static int FASTCALL
519static int PTRFASTCALL
509unicode_byte_type(char hi, char lo)
510{
511 switch ((unsigned char)hi) {
512 case 0xD8: case 0xD9: case 0xDA: case 0xDB:
513 return BT_LEAD4;
514 case 0xDC: case 0xDD: case 0xDE: case 0xDF:
515 return BT_TRAIL;
516 case 0xFF:
517 switch ((unsigned char)lo) {
518 case 0xFF:
519 case 0xFE:
520 return BT_NONXML;
521 }
522 break;
523 }
524 return BT_NONASCII;
525}
526
527#define DEFINE_UTF16_TO_UTF8(E) \
520unicode_byte_type(char hi, char lo)
521{
522 switch ((unsigned char)hi) {
523 case 0xD8: case 0xD9: case 0xDA: case 0xDB:
524 return BT_LEAD4;
525 case 0xDC: case 0xDD: case 0xDE: case 0xDF:
526 return BT_TRAIL;
527 case 0xFF:
528 switch ((unsigned char)lo) {
529 case 0xFF:
530 case 0xFE:
531 return BT_NONXML;
532 }
533 break;
534 }
535 return BT_NONASCII;
536}
537
538#define DEFINE_UTF16_TO_UTF8(E) \
528static void FASTCALL \
539static void PTRCALL \
529E ## toUtf8(const ENCODING *enc, \
530 const char **fromP, const char *fromLim, \
531 char **toP, const char *toLim) \
532{ \
533 const char *from; \
534 for (from = *fromP; from != fromLim; from += 2) { \
535 int plane; \
536 unsigned char lo2; \

--- 46 unchanged lines hidden (view full) ---

583 *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
584 break; \
585 } \
586 } \
587 *fromP = from; \
588}
589
590#define DEFINE_UTF16_TO_UTF16(E) \
540E ## toUtf8(const ENCODING *enc, \
541 const char **fromP, const char *fromLim, \
542 char **toP, const char *toLim) \
543{ \
544 const char *from; \
545 for (from = *fromP; from != fromLim; from += 2) { \
546 int plane; \
547 unsigned char lo2; \

--- 46 unchanged lines hidden (view full) ---

594 *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
595 break; \
596 } \
597 } \
598 *fromP = from; \
599}
600
601#define DEFINE_UTF16_TO_UTF16(E) \
591static void FASTCALL \
602static void PTRCALL \
592E ## toUtf16(const ENCODING *enc, \
593 const char **fromP, const char *fromLim, \
594 unsigned short **toP, const unsigned short *toLim) \
595{ \
596 /* Avoid copying first half only of surrogate */ \
597 if (fromLim - *fromP > ((toLim - *toP) << 1) \
598 && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \
599 fromLim -= 2; \

--- 33 unchanged lines hidden (view full) ---

633#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c)
634#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \
635 UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
636#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
637 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
638
639#ifdef XML_MIN_SIZE
640
603E ## toUtf16(const ENCODING *enc, \
604 const char **fromP, const char *fromLim, \
605 unsigned short **toP, const unsigned short *toLim) \
606{ \
607 /* Avoid copying first half only of surrogate */ \
608 if (fromLim - *fromP > ((toLim - *toP) << 1) \
609 && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \
610 fromLim -= 2; \

--- 33 unchanged lines hidden (view full) ---

644#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c)
645#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \
646 UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
647#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
648 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
649
650#ifdef XML_MIN_SIZE
651
641static int FASTCALL
652static int PTRFASTCALL
642little2_byteType(const ENCODING *enc, const char *p)
643{
644 return LITTLE2_BYTE_TYPE(enc, p);
645}
646
653little2_byteType(const ENCODING *enc, const char *p)
654{
655 return LITTLE2_BYTE_TYPE(enc, p);
656}
657
647static int FASTCALL
658static int PTRFASTCALL
648little2_byteToAscii(const ENCODING *enc, const char *p)
649{
650 return LITTLE2_BYTE_TO_ASCII(enc, p);
651}
652
659little2_byteToAscii(const ENCODING *enc, const char *p)
660{
661 return LITTLE2_BYTE_TO_ASCII(enc, p);
662}
663
653static int FASTCALL
664static int PTRCALL
654little2_charMatches(const ENCODING *enc, const char *p, int c)
655{
656 return LITTLE2_CHAR_MATCHES(enc, p, c);
657}
658
665little2_charMatches(const ENCODING *enc, const char *p, int c)
666{
667 return LITTLE2_CHAR_MATCHES(enc, p, c);
668}
669
659static int FASTCALL
670static int PTRFASTCALL
660little2_isNameMin(const ENCODING *enc, const char *p)
661{
662 return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
663}
664
671little2_isNameMin(const ENCODING *enc, const char *p)
672{
673 return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
674}
675
665static int FASTCALL
676static int PTRFASTCALL
666little2_isNmstrtMin(const ENCODING *enc, const char *p)
667{
668 return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
669}
670
671#undef VTABLE
672#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
673
674#else /* not XML_MIN_SIZE */
675
676#undef PREFIX
677#define PREFIX(ident) little2_ ## ident
678#define MINBPC(enc) 2
679/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
680#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
677little2_isNmstrtMin(const ENCODING *enc, const char *p)
678{
679 return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
680}
681
682#undef VTABLE
683#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
684
685#else /* not XML_MIN_SIZE */
686
687#undef PREFIX
688#define PREFIX(ident) little2_ ## ident
689#define MINBPC(enc) 2
690/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
691#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
681#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
692#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
682#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
683#define IS_NAME_CHAR(enc, p, n) 0
684#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
685#define IS_NMSTRT_CHAR(enc, p, n) (0)
686#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
687
693#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
694#define IS_NAME_CHAR(enc, p, n) 0
695#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
696#define IS_NMSTRT_CHAR(enc, p, n) (0)
697#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
698
699#define XML_TOK_IMPL_C
688#include "xmltok_impl.c"
700#include "xmltok_impl.c"
701#undef XML_TOK_IMPL_C
689
690#undef MINBPC
691#undef BYTE_TYPE
692#undef BYTE_TO_ASCII
693#undef CHAR_MATCHES
694#undef IS_NAME_CHAR
695#undef IS_NAME_CHAR_MINBPC
696#undef IS_NMSTRT_CHAR
697#undef IS_NMSTRT_CHAR_MINBPC
698#undef IS_INVALID_CHAR
699
700#endif /* not XML_MIN_SIZE */
701
702#ifdef XML_NS
703
702
703#undef MINBPC
704#undef BYTE_TYPE
705#undef BYTE_TO_ASCII
706#undef CHAR_MATCHES
707#undef IS_NAME_CHAR
708#undef IS_NAME_CHAR_MINBPC
709#undef IS_NMSTRT_CHAR
710#undef IS_NMSTRT_CHAR_MINBPC
711#undef IS_INVALID_CHAR
712
713#endif /* not XML_MIN_SIZE */
714
715#ifdef XML_NS
716
704static const struct normal_encoding little2_encoding_ns = {
717static const struct normal_encoding little2_encoding_ns = {
705 { VTABLE, 2, 0,
706#if BYTEORDER == 1234
707 1
708#else
709 0
710#endif
711 },
712 {
713#include "asciitab.h"
714#include "latin1tab.h"
715 },
716 STANDARD_VTABLE(little2_)
717};
718
719#endif
720
718 { VTABLE, 2, 0,
719#if BYTEORDER == 1234
720 1
721#else
722 0
723#endif
724 },
725 {
726#include "asciitab.h"
727#include "latin1tab.h"
728 },
729 STANDARD_VTABLE(little2_)
730};
731
732#endif
733
721static const struct normal_encoding little2_encoding = {
734static const struct normal_encoding little2_encoding = {
722 { VTABLE, 2, 0,
723#if BYTEORDER == 1234
724 1
725#else
726 0
727#endif
728 },
729 {

--- 4 unchanged lines hidden (view full) ---

734 },
735 STANDARD_VTABLE(little2_)
736};
737
738#if BYTEORDER != 4321
739
740#ifdef XML_NS
741
735 { VTABLE, 2, 0,
736#if BYTEORDER == 1234
737 1
738#else
739 0
740#endif
741 },
742 {

--- 4 unchanged lines hidden (view full) ---

747 },
748 STANDARD_VTABLE(little2_)
749};
750
751#if BYTEORDER != 4321
752
753#ifdef XML_NS
754
742static const struct normal_encoding internal_little2_encoding_ns = {
755static const struct normal_encoding internal_little2_encoding_ns = {
743 { VTABLE, 2, 0, 1 },
744 {
745#include "iasciitab.h"
746#include "latin1tab.h"
747 },
748 STANDARD_VTABLE(little2_)
749};
750
751#endif
752
756 { VTABLE, 2, 0, 1 },
757 {
758#include "iasciitab.h"
759#include "latin1tab.h"
760 },
761 STANDARD_VTABLE(little2_)
762};
763
764#endif
765
753static const struct normal_encoding internal_little2_encoding = {
766static const struct normal_encoding internal_little2_encoding = {
754 { VTABLE, 2, 0, 1 },
755 {
756#define BT_COLON BT_NMSTRT
757#include "iasciitab.h"
758#undef BT_COLON
759#include "latin1tab.h"
760 },
761 STANDARD_VTABLE(little2_)

--- 10 unchanged lines hidden (view full) ---

772#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c)
773#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \
774 UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
775#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
776 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
777
778#ifdef XML_MIN_SIZE
779
767 { VTABLE, 2, 0, 1 },
768 {
769#define BT_COLON BT_NMSTRT
770#include "iasciitab.h"
771#undef BT_COLON
772#include "latin1tab.h"
773 },
774 STANDARD_VTABLE(little2_)

--- 10 unchanged lines hidden (view full) ---

785#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c)
786#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \
787 UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
788#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
789 UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
790
791#ifdef XML_MIN_SIZE
792
780static int FASTCALL
793static int PTRFASTCALL
781big2_byteType(const ENCODING *enc, const char *p)
782{
783 return BIG2_BYTE_TYPE(enc, p);
784}
785
794big2_byteType(const ENCODING *enc, const char *p)
795{
796 return BIG2_BYTE_TYPE(enc, p);
797}
798
786static int FASTCALL
799static int PTRFASTCALL
787big2_byteToAscii(const ENCODING *enc, const char *p)
788{
789 return BIG2_BYTE_TO_ASCII(enc, p);
790}
791
800big2_byteToAscii(const ENCODING *enc, const char *p)
801{
802 return BIG2_BYTE_TO_ASCII(enc, p);
803}
804
792static int FASTCALL
805static int PTRCALL
793big2_charMatches(const ENCODING *enc, const char *p, int c)
794{
795 return BIG2_CHAR_MATCHES(enc, p, c);
796}
797
806big2_charMatches(const ENCODING *enc, const char *p, int c)
807{
808 return BIG2_CHAR_MATCHES(enc, p, c);
809}
810
798static int FASTCALL
811static int PTRFASTCALL
799big2_isNameMin(const ENCODING *enc, const char *p)
800{
801 return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
802}
803
812big2_isNameMin(const ENCODING *enc, const char *p)
813{
814 return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
815}
816
804static int FASTCALL
817static int PTRFASTCALL
805big2_isNmstrtMin(const ENCODING *enc, const char *p)
806{
807 return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
808}
809
810#undef VTABLE
811#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
812
813#else /* not XML_MIN_SIZE */
814
815#undef PREFIX
816#define PREFIX(ident) big2_ ## ident
817#define MINBPC(enc) 2
818/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
819#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
818big2_isNmstrtMin(const ENCODING *enc, const char *p)
819{
820 return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
821}
822
823#undef VTABLE
824#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
825
826#else /* not XML_MIN_SIZE */
827
828#undef PREFIX
829#define PREFIX(ident) big2_ ## ident
830#define MINBPC(enc) 2
831/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
832#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
820#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
833#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
821#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
822#define IS_NAME_CHAR(enc, p, n) 0
823#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
824#define IS_NMSTRT_CHAR(enc, p, n) (0)
825#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
826
834#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
835#define IS_NAME_CHAR(enc, p, n) 0
836#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
837#define IS_NMSTRT_CHAR(enc, p, n) (0)
838#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
839
840#define XML_TOK_IMPL_C
827#include "xmltok_impl.c"
841#include "xmltok_impl.c"
842#undef XML_TOK_IMPL_C
828
829#undef MINBPC
830#undef BYTE_TYPE
831#undef BYTE_TO_ASCII
832#undef CHAR_MATCHES
833#undef IS_NAME_CHAR
834#undef IS_NAME_CHAR_MINBPC
835#undef IS_NMSTRT_CHAR

--- 81 unchanged lines hidden (view full) ---

917 if (c1 != c2)
918 return 0;
919 if (!c1)
920 break;
921 }
922 return 1;
923}
924
843
844#undef MINBPC
845#undef BYTE_TYPE
846#undef BYTE_TO_ASCII
847#undef CHAR_MATCHES
848#undef IS_NAME_CHAR
849#undef IS_NAME_CHAR_MINBPC
850#undef IS_NMSTRT_CHAR

--- 81 unchanged lines hidden (view full) ---

932 if (c1 != c2)
933 return 0;
934 if (!c1)
935 break;
936 }
937 return 1;
938}
939
925static void FASTCALL
940static void PTRCALL
926initUpdatePosition(const ENCODING *enc, const char *ptr,
927 const char *end, POSITION *pos)
928{
929 normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
930}
931
941initUpdatePosition(const ENCODING *enc, const char *ptr,
942 const char *end, POSITION *pos)
943{
944 normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
945}
946
932static int FASTCALL
947static int
933toAscii(const ENCODING *enc, const char *ptr, const char *end)
934{
935 char buf[1];
936 char *p = buf;
937 XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
938 if (p == buf)
939 return -1;
940 else
941 return buf[0];
942}
943
944static int FASTCALL
945isSpace(int c)
946{
947 switch (c) {
948 case 0x20:
949 case 0xD:
950 case 0xA:
948toAscii(const ENCODING *enc, const char *ptr, const char *end)
949{
950 char buf[1];
951 char *p = buf;
952 XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
953 if (p == buf)
954 return -1;
955 else
956 return buf[0];
957}
958
959static int FASTCALL
960isSpace(int c)
961{
962 switch (c) {
963 case 0x20:
964 case 0xD:
965 case 0xA:
951 case 0x9:
966 case 0x9:
952 return 1;
953 }
954 return 0;
955}
956
957/* Return 1 if there's just optional white space or there's an S
958 followed by name=val.
959*/
967 return 1;
968 }
969 return 0;
970}
971
972/* Return 1 if there's just optional white space or there's an S
973 followed by name=val.
974*/
960static int FASTCALL
975static int
961parsePseudoAttribute(const ENCODING *enc,
962 const char *ptr,
963 const char *end,
964 const char **namePtr,
965 const char **nameEndPtr,
966 const char **valPtr,
967 const char **nextTokPtr)
968{

--- 200 unchanged lines hidden (view full) ---

1169 case 0xFF:
1170 if (result == 0xFFFE || result == 0xFFFF)
1171 return -1;
1172 break;
1173 }
1174 return result;
1175}
1176
976parsePseudoAttribute(const ENCODING *enc,
977 const char *ptr,
978 const char *end,
979 const char **namePtr,
980 const char **nameEndPtr,
981 const char **valPtr,
982 const char **nextTokPtr)
983{

--- 200 unchanged lines hidden (view full) ---

1184 case 0xFF:
1185 if (result == 0xFFFE || result == 0xFFFF)
1186 return -1;
1187 break;
1188 }
1189 return result;
1190}
1191
1177int
1192int FASTCALL
1178XmlUtf8Encode(int c, char *buf)
1179{
1180 enum {
1181 /* minN is minimum legal resulting value for N byte sequence */
1182 min2 = 0x80,
1183 min3 = 0x800,
1184 min4 = 0x10000
1185 };

--- 20 unchanged lines hidden (view full) ---

1206 buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
1207 buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
1208 buf[3] = (char)((c & 0x3f) | 0x80);
1209 return 4;
1210 }
1211 return 0;
1212}
1213
1193XmlUtf8Encode(int c, char *buf)
1194{
1195 enum {
1196 /* minN is minimum legal resulting value for N byte sequence */
1197 min2 = 0x80,
1198 min3 = 0x800,
1199 min4 = 0x10000
1200 };

--- 20 unchanged lines hidden (view full) ---

1221 buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
1222 buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
1223 buf[3] = (char)((c & 0x3f) | 0x80);
1224 return 4;
1225 }
1226 return 0;
1227}
1228
1214int
1229int FASTCALL
1215XmlUtf16Encode(int charNum, unsigned short *buf)
1216{
1217 if (charNum < 0)
1218 return 0;
1219 if (charNum < 0x10000) {
1220 buf[0] = (unsigned short)charNum;
1221 return 1;
1222 }
1223 if (charNum < 0x110000) {
1224 charNum -= 0x10000;
1225 buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
1226 buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
1227 return 2;
1228 }
1229 return 0;
1230}
1231
1232struct unknown_encoding {
1233 struct normal_encoding normal;
1230XmlUtf16Encode(int charNum, unsigned short *buf)
1231{
1232 if (charNum < 0)
1233 return 0;
1234 if (charNum < 0x10000) {
1235 buf[0] = (unsigned short)charNum;
1236 return 1;
1237 }
1238 if (charNum < 0x110000) {
1239 charNum -= 0x10000;
1240 buf[0] = (unsigned short)((charNum >> 10) + 0xD800);
1241 buf[1] = (unsigned short)((charNum & 0x3FF) + 0xDC00);
1242 return 2;
1243 }
1244 return 0;
1245}
1246
1247struct unknown_encoding {
1248 struct normal_encoding normal;
1234 int (*convert)(void *userData, const char *p);
1249 CONVERTER convert;
1235 void *userData;
1236 unsigned short utf16[256];
1237 char utf8[256][4];
1238};
1239
1240#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc))
1241
1242int
1243XmlSizeOfUnknownEncoding(void)
1244{
1245 return sizeof(struct unknown_encoding);
1246}
1247
1250 void *userData;
1251 unsigned short utf16[256];
1252 char utf8[256][4];
1253};
1254
1255#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc))
1256
1257int
1258XmlSizeOfUnknownEncoding(void)
1259{
1260 return sizeof(struct unknown_encoding);
1261}
1262
1248static int FASTCALL
1263static int PTRFASTCALL
1249unknown_isName(const ENCODING *enc, const char *p)
1250{
1251 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1252 int c = uenc->convert(uenc->userData, p);
1253 if (c & ~0xFFFF)
1254 return 0;
1255 return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
1256}
1257
1264unknown_isName(const ENCODING *enc, const char *p)
1265{
1266 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1267 int c = uenc->convert(uenc->userData, p);
1268 if (c & ~0xFFFF)
1269 return 0;
1270 return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
1271}
1272
1258static int FASTCALL
1273static int PTRFASTCALL
1259unknown_isNmstrt(const ENCODING *enc, const char *p)
1260{
1261 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1262 int c = uenc->convert(uenc->userData, p);
1263 if (c & ~0xFFFF)
1264 return 0;
1265 return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
1266}
1267
1274unknown_isNmstrt(const ENCODING *enc, const char *p)
1275{
1276 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1277 int c = uenc->convert(uenc->userData, p);
1278 if (c & ~0xFFFF)
1279 return 0;
1280 return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
1281}
1282
1268static int FASTCALL
1283static int PTRFASTCALL
1269unknown_isInvalid(const ENCODING *enc, const char *p)
1270{
1271 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1272 int c = uenc->convert(uenc->userData, p);
1273 return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
1274}
1275
1284unknown_isInvalid(const ENCODING *enc, const char *p)
1285{
1286 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1287 int c = uenc->convert(uenc->userData, p);
1288 return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
1289}
1290
1276static void FASTCALL
1291static void PTRCALL
1277unknown_toUtf8(const ENCODING *enc,
1278 const char **fromP, const char *fromLim,
1279 char **toP, const char *toLim)
1280{
1281 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1282 char buf[XML_UTF8_ENCODE_MAX];
1283 for (;;) {
1284 const char *utf8;

--- 17 unchanged lines hidden (view full) ---

1302 (*fromP)++;
1303 }
1304 do {
1305 *(*toP)++ = *utf8++;
1306 } while (--n != 0);
1307 }
1308}
1309
1292unknown_toUtf8(const ENCODING *enc,
1293 const char **fromP, const char *fromLim,
1294 char **toP, const char *toLim)
1295{
1296 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1297 char buf[XML_UTF8_ENCODE_MAX];
1298 for (;;) {
1299 const char *utf8;

--- 17 unchanged lines hidden (view full) ---

1317 (*fromP)++;
1318 }
1319 do {
1320 *(*toP)++ = *utf8++;
1321 } while (--n != 0);
1322 }
1323}
1324
1310static void FASTCALL
1325static void PTRCALL
1311unknown_toUtf16(const ENCODING *enc,
1312 const char **fromP, const char *fromLim,
1313 unsigned short **toP, const unsigned short *toLim)
1314{
1315 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1316 while (*fromP != fromLim && *toP != toLim) {
1317 unsigned short c = uenc->utf16[(unsigned char)**fromP];
1318 if (c == 0) {

--- 6 unchanged lines hidden (view full) ---

1325 (*fromP)++;
1326 *(*toP)++ = c;
1327 }
1328}
1329
1330ENCODING *
1331XmlInitUnknownEncoding(void *mem,
1332 int *table,
1326unknown_toUtf16(const ENCODING *enc,
1327 const char **fromP, const char *fromLim,
1328 unsigned short **toP, const unsigned short *toLim)
1329{
1330 const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
1331 while (*fromP != fromLim && *toP != toLim) {
1332 unsigned short c = uenc->utf16[(unsigned char)**fromP];
1333 if (c == 0) {

--- 6 unchanged lines hidden (view full) ---

1340 (*fromP)++;
1341 *(*toP)++ = c;
1342 }
1343}
1344
1345ENCODING *
1346XmlInitUnknownEncoding(void *mem,
1347 int *table,
1333 int (*convert)(void *userData, const char *p),
1348 CONVERTER convert,
1334 void *userData)
1335{
1336 int i;
1349 void *userData)
1350{
1351 int i;
1337 struct unknown_encoding *e = mem;
1352 struct unknown_encoding *e = (struct unknown_encoding *)mem;
1338 for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
1339 ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
1340 for (i = 0; i < 128; i++)
1341 if (latin1_encoding.type[i] != BT_OTHER
1342 && latin1_encoding.type[i] != BT_NONXML
1343 && table[i] != i)
1344 return 0;
1345 for (i = 0; i < 256; i++) {

--- 95 unchanged lines hidden (view full) ---

1441static const char KW_UTF_16LE[] = {
1442 ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E,
1443 '\0'
1444};
1445
1446static int FASTCALL
1447getEncodingIndex(const char *name)
1448{
1353 for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
1354 ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
1355 for (i = 0; i < 128; i++)
1356 if (latin1_encoding.type[i] != BT_OTHER
1357 && latin1_encoding.type[i] != BT_NONXML
1358 && table[i] != i)
1359 return 0;
1360 for (i = 0; i < 256; i++) {

--- 95 unchanged lines hidden (view full) ---

1456static const char KW_UTF_16LE[] = {
1457 ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E,
1458 '\0'
1459};
1460
1461static int FASTCALL
1462getEncodingIndex(const char *name)
1463{
1449 static const char *encodingNames[] = {
1464 static const char * const encodingNames[] = {
1450 KW_ISO_8859_1,
1451 KW_US_ASCII,
1452 KW_UTF_8,
1453 KW_UTF_16,
1454 KW_UTF_16BE,
1455 KW_UTF_16LE,
1456 };
1457 int i;

--- 15 unchanged lines hidden (view full) ---

1473/* This is what detects the encoding. encodingTable maps from
1474 encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of
1475 the external (protocol) specified encoding; state is
1476 XML_CONTENT_STATE if we're parsing an external text entity, and
1477 XML_PROLOG_STATE otherwise.
1478*/
1479
1480
1465 KW_ISO_8859_1,
1466 KW_US_ASCII,
1467 KW_UTF_8,
1468 KW_UTF_16,
1469 KW_UTF_16BE,
1470 KW_UTF_16LE,
1471 };
1472 int i;

--- 15 unchanged lines hidden (view full) ---

1488/* This is what detects the encoding. encodingTable maps from
1489 encoding indices to encodings; INIT_ENC_INDEX(enc) is the index of
1490 the external (protocol) specified encoding; state is
1491 XML_CONTENT_STATE if we're parsing an external text entity, and
1492 XML_PROLOG_STATE otherwise.
1493*/
1494
1495
1481static int FASTCALL
1482initScan(const ENCODING **encodingTable,
1496static int
1497initScan(const ENCODING * const *encodingTable,
1483 const INIT_ENCODING *enc,
1484 int state,
1485 const char *ptr,
1486 const char *end,
1487 const char **nextTokPtr)
1488{
1489 const ENCODING **encPtr;
1490

--- 107 unchanged lines hidden (view full) ---

1598 }
1599 *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
1600 return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
1601}
1602
1603
1604#define NS(x) x
1605#define ns(x) x
1498 const INIT_ENCODING *enc,
1499 int state,
1500 const char *ptr,
1501 const char *end,
1502 const char **nextTokPtr)
1503{
1504 const ENCODING **encPtr;
1505

--- 107 unchanged lines hidden (view full) ---

1613 }
1614 *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
1615 return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
1616}
1617
1618
1619#define NS(x) x
1620#define ns(x) x
1621#define XML_TOK_NS_C
1606#include "xmltok_ns.c"
1622#include "xmltok_ns.c"
1623#undef XML_TOK_NS_C
1607#undef NS
1608#undef ns
1609
1610#ifdef XML_NS
1611
1612#define NS(x) x ## NS
1613#define ns(x) x ## _ns
1614
1624#undef NS
1625#undef ns
1626
1627#ifdef XML_NS
1628
1629#define NS(x) x ## NS
1630#define ns(x) x ## _ns
1631
1632#define XML_TOK_NS_C
1615#include "xmltok_ns.c"
1633#include "xmltok_ns.c"
1634#undef XML_TOK_NS_C
1616
1617#undef NS
1618#undef ns
1619
1620ENCODING *
1621XmlInitUnknownEncodingNS(void *mem,
1622 int *table,
1635
1636#undef NS
1637#undef ns
1638
1639ENCODING *
1640XmlInitUnknownEncodingNS(void *mem,
1641 int *table,
1623 int (*convert)(void *userData, const char *p),
1642 CONVERTER convert,
1624 void *userData)
1625{
1626 ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
1627 if (enc)
1628 ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON;
1629 return enc;
1630}
1631
1632#endif /* XML_NS */
1643 void *userData)
1644{
1645 ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
1646 if (enc)
1647 ((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON;
1648 return enc;
1649}
1650
1651#endif /* XML_NS */