7 #ifdef COMPILED_FROM_DSP 
    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" 
   16 #ifdef HAVE_EXPAT_CONFIG_H 
   17 #include <expat_config.h> 
   21 #include "expat_external.h" 
   27 #define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok) 
   29 #define IGNORE_SECTION_TOK_VTABLE  
   33   { PREFIX(prologTok), PREFIX(contentTok), \ 
   34     PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ 
   35   { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ 
   37   PREFIX(nameMatchesAscii), \ 
   41   PREFIX(charRefNumber), \ 
   42   PREFIX(predefinedEntityName), \ 
   43   PREFIX(updatePosition), \ 
   46 #define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16) 
   48 #define UCS2_GET_NAMING(pages, hi, lo) \ 
   49    (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F))) 
   55 #define UTF8_GET_NAMING2(pages, byte) \ 
   56     (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \ 
   57                       + ((((byte)[0]) & 3) << 1) \ 
   58                       + ((((byte)[1]) >> 5) & 1)] \ 
   59          & (1 << (((byte)[1]) & 0x1F))) 
   66 #define UTF8_GET_NAMING3(pages, byte) \ 
   67   (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \ 
   68                              + ((((byte)[1]) >> 2) & 0xF)] \ 
   70                       + ((((byte)[1]) & 3) << 1) \ 
   71                       + ((((byte)[2]) >> 5) & 1)] \ 
   72          & (1 << (((byte)[2]) & 0x1F))) 
   74 #define UTF8_GET_NAMING(pages, p, n) \ 
   76   ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \ 
   78      ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \ 
   91 #define UTF8_INVALID2(p) \ 
   92   ((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0) 
   94 #define UTF8_INVALID3(p) \ 
   95   (((p)[2] & 0x80) == 0 \ 
   97   ((*p) == 0xEF && (p)[1] == 0xBF \ 
  101     ((p)[2] & 0xC0) == 0xC0) \ 
  105     (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \ 
  107     ((p)[1] & 0x80) == 0 \ 
  109     ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0))) 
  111 #define UTF8_INVALID4(p) \ 
  112   (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \ 
  114   ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \ 
  118     (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \ 
  120     ((p)[1] & 0x80) == 0 \ 
  122     ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0))) 
  124 static int PTRFASTCALL
 
  130 static int PTRFASTCALL
 
  136 static int PTRFASTCALL
 
  142 #define utf8_isName4 isNever 
  144 static int PTRFASTCALL
 
  150 static int PTRFASTCALL
 
  156 #define utf8_isNmstrt4 isNever 
  158 static int PTRFASTCALL
 
  164 static int PTRFASTCALL
 
  170 static int PTRFASTCALL
 
  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);
 
  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 *);
 
  197 #define AS_NORMAL_ENCODING(enc)   ((const struct normal_encoding *) (enc)) 
  201 #define STANDARD_VTABLE(E) \ 
  210 #define STANDARD_VTABLE(E)  
  214 #define NORMAL_VTABLE(E) \ 
  227 #include "xmltok_impl.h" 
  231 #define sb_isNameMin isNever 
  232 #define sb_isNmstrtMin isNever 
  236 #define MINBPC(enc) ((enc)->minBytesPerChar) 
  239 #define MINBPC(enc) 1 
  242 #define SB_BYTE_TYPE(enc, p) \ 
  243   (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)]) 
  246 static int PTRFASTCALL
 
  247 sb_byteType(
const ENCODING *enc, 
const char *p)
 
  251 #define BYTE_TYPE(enc, p) \ 
  252  (AS_NORMAL_ENCODING(enc)->byteType(enc, p)) 
  254 #define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p) 
  258 #define BYTE_TO_ASCII(enc, p) \ 
  259  (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p)) 
  260 static int PTRFASTCALL
 
  261 sb_byteToAscii(
const ENCODING *enc, 
const char *p)
 
  266 #define BYTE_TO_ASCII(enc, p) (*(p)) 
  269 #define IS_NAME_CHAR(enc, p, n) \ 
  270  (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p)) 
  271 #define IS_NMSTRT_CHAR(enc, p, n) \ 
  272  (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p)) 
  273 #define IS_INVALID_CHAR(enc, p, n) \ 
  274  (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p)) 
  277 #define IS_NAME_CHAR_MINBPC(enc, p) \ 
  278  (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p)) 
  279 #define IS_NMSTRT_CHAR_MINBPC(enc, p) \ 
  280  (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p)) 
  282 #define IS_NAME_CHAR_MINBPC(enc, p) (0) 
  283 #define IS_NMSTRT_CHAR_MINBPC(enc, p) (0) 
  287 #define CHAR_MATCHES(enc, p, c) \ 
  288  (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c)) 
  290 sb_charMatches(
const ENCODING *enc, 
const char *p, 
int c)
 
  296 #define CHAR_MATCHES(enc, p, c) (*(p) == c) 
  299 #define PREFIX(ident) normal_ ## ident 
  300 #define XML_TOK_IMPL_C 
  301 #include "xmltok_impl.c" 
  302 #undef XML_TOK_IMPL_C 
  309 #undef IS_NAME_CHAR_MINBPC 
  310 #undef IS_NMSTRT_CHAR 
  311 #undef IS_NMSTRT_CHAR_MINBPC 
  312 #undef IS_INVALID_CHAR 
  323             const char **fromP, 
const char *fromLim,
 
  324             char **toP, 
const char *toLim)
 
  328   if (fromLim - *fromP > toLim - *toP) {
 
  330     for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
 
  331       if (((
unsigned char)fromLim[-1] & 0xc0) != 0x80)
 
  334   for (to = *toP, from = *fromP; from != fromLim; from++, to++)
 
  342              const char **fromP, 
const char *fromLim,
 
  343              unsigned short **toP, 
const unsigned short *toLim)
 
  345   unsigned short *to = *toP;
 
  346   const char *from = *fromP;
 
  347   while (from != fromLim && to != toLim) {
 
  350       *to++ = (
unsigned short)(((from[0] & 0x1f) << 6) | (from[1] & 0x3f));
 
  354       *to++ = (
unsigned short)(((from[0] & 0xf) << 12)
 
  355                                | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f));
 
  363         n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12)
 
  364             | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
 
  366         to[0] = (
unsigned short)((n >> 10) | 0xD800);
 
  367         to[1] = (
unsigned short)((n & 0x3FF) | 0xDC00);
 
  386 #include "asciitab.h" 
  396 #define BT_COLON BT_NMSTRT 
  397 #include "asciitab.h" 
  409 #include "iasciitab.h" 
  420 #define BT_COLON BT_NMSTRT 
  421 #include "iasciitab.h" 
  430               const char **fromP, 
const char *fromLim,
 
  431               char **toP, 
const char *toLim)
 
  435     if (*fromP == fromLim)
 
  437     c = (
unsigned char)**fromP;
 
  439       if (toLim - *toP < 2)
 
  442       *(*toP)++ = (char)((c & 0x3f) | 0x80);
 
  448       *(*toP)++ = *(*fromP)++;
 
  455                const char **fromP, 
const char *fromLim,
 
  456                unsigned short **toP, 
const unsigned short *toLim)
 
  458   while (*fromP != fromLim && *toP != toLim)
 
  459     *(*toP)++ = (
unsigned char)*(*fromP)++;
 
  467 #include "asciitab.h" 
  468 #include "latin1tab.h" 
  478 #define BT_COLON BT_NMSTRT 
  479 #include "asciitab.h" 
  481 #include "latin1tab.h" 
  488              const char **fromP, 
const char *fromLim,
 
  489              char **toP, 
const char *toLim)
 
  491   while (*fromP != fromLim && *toP != toLim)
 
  492     *(*toP)++ = *(*fromP)++;
 
  500 #include "asciitab.h" 
  511 #define BT_COLON BT_NMSTRT 
  512 #include "asciitab.h" 
  519 static int PTRFASTCALL
 
  522   switch ((
unsigned char)hi) {
 
  523   case 0xD8: 
case 0xD9: 
case 0xDA: 
case 0xDB:
 
  525   case 0xDC: 
case 0xDD: 
case 0xDE: 
case 0xDF:
 
  528     switch ((
unsigned char)lo) {
 
  538 #define DEFINE_UTF16_TO_UTF8(E) \ 
  539 static void  PTRCALL \ 
  540 E ## toUtf8(const ENCODING *enc, \ 
  541             const char **fromP, const char *fromLim, \ 
  542             char **toP, const char *toLim) \ 
  545   for (from = *fromP; from != fromLim; from += 2) { \ 
  548     unsigned char lo = GET_LO(from); \ 
  549     unsigned char hi = GET_HI(from); \ 
  553         if (*toP == toLim) { \ 
  561     case 0x1: case 0x2: case 0x3: \ 
  562     case 0x4: case 0x5: case 0x6: case 0x7: \ 
  563       if (toLim -  *toP < 2) { \ 
  567       *(*toP)++ = ((lo >> 6) | (hi << 2) |  UTF8_cval2); \ 
  568       *(*toP)++ = ((lo & 0x3f) | 0x80); \ 
  571       if (toLim -  *toP < 3)  { \ 
  576       *(*toP)++ = ((hi >> 4) | UTF8_cval3); \ 
  577       *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \ 
  578       *(*toP)++ = ((lo & 0x3f) | 0x80); \ 
  580     case 0xD8: case 0xD9: case 0xDA: case 0xDB: \ 
  581       if (toLim -  *toP < 4) { \ 
  585       plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \ 
  586       *(*toP)++ = ((plane >> 2) | UTF8_cval4); \ 
  587       *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \ 
  589       lo2 = GET_LO(from); \ 
  590       *(*toP)++ = (((lo & 0x3) << 4) \ 
  591                    | ((GET_HI(from) & 0x3) << 2) \ 
  594       *(*toP)++ = ((lo2 & 0x3f) | 0x80); \ 
  601 #define DEFINE_UTF16_TO_UTF16(E) \ 
  602 static void  PTRCALL \ 
  603 E ## toUtf16(const ENCODING *enc, \ 
  604              const char **fromP, const char *fromLim, \ 
  605              unsigned short **toP, const unsigned short *toLim) \ 
  608   if (fromLim - *fromP > ((toLim - *toP) << 1) \ 
  609       && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \ 
  611   for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \ 
  612     *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \ 
  615 #define SET2(ptr, ch) \ 
  616   (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8))) 
  617 #define GET_LO(ptr) ((unsigned char)(ptr)[0]) 
  618 #define GET_HI(ptr) ((unsigned char)(ptr)[1]) 
  627 #define SET2(ptr, ch) \ 
  628   (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF))) 
  629 #define GET_LO(ptr) ((unsigned char)(ptr)[1]) 
  630 #define GET_HI(ptr) ((unsigned char)(ptr)[0]) 
  639 #define LITTLE2_BYTE_TYPE(enc, p) \ 
  641   ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \ 
  642   : unicode_byte_type((p)[1], (p)[0])) 
  643 #define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1) 
  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]) 
  652 static int PTRFASTCALL
 
  653 little2_byteType(
const ENCODING *
enc, 
const char *p)
 
  658 static int PTRFASTCALL
 
  659 little2_byteToAscii(
const ENCODING *
enc, 
const char *p)
 
  665 little2_charMatches(
const ENCODING *
enc, 
const char *p, 
int c)
 
  670 static int PTRFASTCALL
 
  671 little2_isNameMin(
const ENCODING *
enc, 
const char *p)
 
  676 static int PTRFASTCALL
 
  677 little2_isNmstrtMin(
const ENCODING *
enc, 
const char *p)
 
  683 #define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16 
  688 #define PREFIX(ident) little2_ ## ident 
  689 #define MINBPC(enc) 2 
  691 #define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p) 
  692 #define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p) 
  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) 
  699 #define XML_TOK_IMPL_C 
  700 #include "xmltok_impl.c" 
  701 #undef XML_TOK_IMPL_C 
  708 #undef IS_NAME_CHAR_MINBPC 
  709 #undef IS_NMSTRT_CHAR 
  710 #undef IS_NMSTRT_CHAR_MINBPC 
  711 #undef IS_INVALID_CHAR 
  719 #if BYTEORDER == 1234 
  726 #include "asciitab.h" 
  727 #include "latin1tab.h" 
  736 #if BYTEORDER == 1234 
  743 #define BT_COLON BT_NMSTRT 
  744 #include "asciitab.h" 
  746 #include "latin1tab.h" 
  751 #if BYTEORDER != 4321 
  758 #include "iasciitab.h" 
  759 #include "latin1tab.h" 
  769 #define BT_COLON BT_NMSTRT 
  770 #include "iasciitab.h" 
  772 #include "latin1tab.h" 
  780 #define BIG2_BYTE_TYPE(enc, p) \ 
  782   ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \ 
  783   : unicode_byte_type((p)[0], (p)[1])) 
  784 #define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1) 
  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]) 
  793 static int PTRFASTCALL
 
  794 big2_byteType(
const ENCODING *
enc, 
const char *p)
 
  799 static int PTRFASTCALL
 
  800 big2_byteToAscii(
const ENCODING *
enc, 
const char *p)
 
  806 big2_charMatches(
const ENCODING *
enc, 
const char *p, 
int c)
 
  811 static int PTRFASTCALL
 
  812 big2_isNameMin(
const ENCODING *
enc, 
const char *p)
 
  817 static int PTRFASTCALL
 
  818 big2_isNmstrtMin(
const ENCODING *
enc, 
const char *p)
 
  824 #define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16 
  829 #define PREFIX(ident) big2_ ## ident 
  830 #define MINBPC(enc) 2 
  832 #define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p) 
  833 #define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p) 
  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) 
  840 #define XML_TOK_IMPL_C 
  841 #include "xmltok_impl.c" 
  842 #undef XML_TOK_IMPL_C 
  849 #undef IS_NAME_CHAR_MINBPC 
  850 #undef IS_NMSTRT_CHAR 
  851 #undef IS_NMSTRT_CHAR_MINBPC 
  852 #undef IS_INVALID_CHAR 
  860 #if BYTEORDER == 4321 
  867 #include "asciitab.h" 
  868 #include "latin1tab.h" 
  877 #if BYTEORDER == 4321 
  884 #define BT_COLON BT_NMSTRT 
  885 #include "asciitab.h" 
  887 #include "latin1tab.h" 
  892 #if BYTEORDER != 1234 
  899 #include "iasciitab.h" 
  900 #include "latin1tab.h" 
  910 #define BT_COLON BT_NMSTRT 
  911 #include "iasciitab.h" 
  913 #include "latin1tab.h" 
  928     if (ASCII_a <= c1 && c1 <= ASCII_z)
 
  929       c1 += ASCII_A - ASCII_a;
 
  930     if (ASCII_a <= c2 && c2 <= ASCII_z)
 
  931       c2 += ASCII_A - ASCII_a;
 
  944   normal_updatePosition(&utf8_encoding.
enc, ptr, end, pos);
 
  948 toAscii(
const ENCODING *
enc, 
const char *ptr, 
const char *end)
 
  952   XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
 
  979                      const char **namePtr,
 
  980                      const char **nameEndPtr,
 
  982                      const char **nextTokPtr)
 
  995     ptr += enc->minBytesPerChar;
 
 1008     if (c == ASCII_EQUALS) {
 
 1015         ptr += enc->minBytesPerChar;
 
 1017       if (c != ASCII_EQUALS) {
 
 1023     ptr += enc->minBytesPerChar;
 
 1025   if (ptr == *namePtr) {
 
 1029   ptr += enc->minBytesPerChar;
 
 1032     ptr += enc->minBytesPerChar;
 
 1035   if (c != ASCII_QUOT && c != ASCII_APOS) {
 
 1040   ptr += enc->minBytesPerChar;
 
 1042   for (;; ptr += enc->minBytesPerChar) {
 
 1046     if (!(ASCII_a <= c && c <= ASCII_z)
 
 1047         && !(ASCII_A <= c && c <= ASCII_Z)
 
 1048         && !(ASCII_0 <= c && c <= ASCII_9)
 
 1049         && c != ASCII_PERIOD
 
 1051         && c != ASCII_UNDERSCORE) {
 
 1056   *nextTokPtr = ptr + enc->minBytesPerChar;
 
 1061   ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, 
'\0' 
 1065   ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, 
'\0' 
 1069   ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o,
 
 1070   ASCII_n, ASCII_e, 
'\0' 
 1074   ASCII_y, ASCII_e, ASCII_s,  
'\0' 
 1078   ASCII_n, ASCII_o,  
'\0' 
 1085                int isGeneralTextEntity,
 
 1086                const ENCODING *
enc,
 
 1089                const char **badPtr,
 
 1090                const char **versionPtr,
 
 1091                const char **versionEndPtr,
 
 1092                const char **encodingName,
 
 1096   const char *val = NULL;
 
 1097   const char *
name = NULL;
 
 1098   const char *nameEnd = NULL;
 
 1099   ptr += 5 * enc->minBytesPerChar;
 
 1100   end -= 2 * enc->minBytesPerChar;
 
 1106   if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
 
 1107     if (!isGeneralTextEntity) {
 
 1116       *versionEndPtr = ptr;
 
 1122       if (isGeneralTextEntity) {
 
 1130   if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) {
 
 1131     int c = 
toAscii(enc, val, end);
 
 1132     if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) {
 
 1137       *encodingName = val;
 
 1139       *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
 
 1147   if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone)
 
 1148       || isGeneralTextEntity) {
 
 1152   if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) {
 
 1156   else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
 
 1165     ptr += enc->minBytesPerChar;
 
 1176   switch (result >> 8) {
 
 1177   case 0xD8: 
case 0xD9: 
case 0xDA: 
case 0xDB:
 
 1178   case 0xDC: 
case 0xDD: 
case 0xDE: 
case 0xDF:
 
 1181     if (latin1_encoding.
type[result] == BT_NONXML)
 
 1185     if (result == 0xFFFE || result == 0xFFFF)
 
 1210     buf[1] = (char)((c & 0x3f) | 0x80);
 
 1215     buf[1] = (char)(((c >> 6) & 0x3f) | 0x80);
 
 1216     buf[2] = (char)((c & 0x3f) | 0x80);
 
 1221     buf[1] = (char)(((c >> 12) & 0x3f) | 0x80);
 
 1222     buf[2] = (char)(((c >> 6) & 0x3f) | 0x80);
 
 1223     buf[3] = (char)((c & 0x3f) | 0x80);
 
 1234   if (charNum < 0x10000) {
 
 1235     buf[0] = (
unsigned short)charNum;
 
 1238   if (charNum < 0x110000) {
 
 1240     buf[0] = (
unsigned short)((charNum >> 10) + 0xD800);
 
 1241     buf[1] = (
unsigned short)((charNum & 0x3FF) + 0xDC00);
 
 1255 #define AS_UNKNOWN_ENCODING(enc)  ((const struct unknown_encoding *) (enc)) 
 1263 static int PTRFASTCALL
 
 1273 static int PTRFASTCALL
 
 1283 static int PTRFASTCALL
 
 1293                const char **fromP, 
const char *fromLim,
 
 1294                char **toP, 
const char *toLim)
 
 1297   char buf[XML_UTF8_ENCODE_MAX];
 
 1301     if (*fromP == fromLim)
 
 1303     utf8 = uenc->
utf8[(
unsigned char)**fromP];
 
 1308       if (n > toLim - *toP)
 
 1315       if (n > toLim - *toP)
 
 1320       *(*toP)++ = *utf8++;
 
 1327                 const char **fromP, 
const char *fromLim,
 
 1328                 unsigned short **toP, 
const unsigned short *toLim)
 
 1331   while (*fromP != fromLim && *toP != toLim) {
 
 1332     unsigned short c = uenc->
utf16[(
unsigned char)**fromP];
 
 1334       c = (
unsigned short)
 
 1355   for (i = 0; i < 128; i++)
 
 1356     if (latin1_encoding.
type[i] != BT_OTHER
 
 1357         && latin1_encoding.
type[i] != BT_NONXML
 
 1360   for (i = 0; i < 256; i++) {
 
 1365       e->
utf16[i] = 0xFFFF;
 
 1372       e->
normal.
type[i] = (
unsigned char)(BT_LEAD2 - (c + 2));
 
 1376     else if (c < 0x80) {
 
 1377       if (latin1_encoding.
type[c] != BT_OTHER
 
 1378           && latin1_encoding.
type[c] != BT_NONXML
 
 1383       e->
utf8[i][1] = (char)c;
 
 1384       e->
utf16[i] = (
unsigned short)(c == 0 ? 0xFFFF : c);
 
 1389       e->
utf16[i] = 0xFFFF;
 
 1403       e->
utf16[i] = (
unsigned short)c;
 
 1439   ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9,
 
 1440   ASCII_MINUS, ASCII_1, 
'\0' 
 1443   ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I,
 
 1447   ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, 
'\0' 
 1450   ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, 
'\0' 
 1453   ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E,
 
 1457   ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E,
 
 1464   static const char * 
const encodingNames[] = {
 
 1475   for (i = 0; i < (int)(
sizeof(encodingNames)/
sizeof(encodingNames[0])); i++)
 
 1476     if (
streqci(name, encodingNames[i]))
 
 1485 #define INIT_ENC_INDEX(enc) ((int)(enc)->initEnc.isUtf16) 
 1486 #define SET_INIT_ENC_INDEX(enc, i) ((enc)->initEnc.isUtf16 = (char)i) 
 1498          const INIT_ENCODING *enc,
 
 1502          const char **nextTokPtr)
 
 1504   const ENCODING **encPtr;
 
 1507     return XML_TOK_NONE;
 
 1508   encPtr = enc->encPtr;
 
 1509   if (ptr + 1 == end) {
 
 1513     if (state != XML_CONTENT_STATE)
 
 1514       return XML_TOK_PARTIAL;
 
 1522       return XML_TOK_PARTIAL;
 
 1524     switch ((
unsigned char)*ptr) {
 
 1529           && state == XML_CONTENT_STATE)
 
 1534       return XML_TOK_PARTIAL;
 
 1538     switch (((
unsigned char)ptr[0] << 8) | (
unsigned char)ptr[1]) {
 
 1541           && state == XML_CONTENT_STATE)
 
 1543       *nextTokPtr = ptr + 2;
 
 1550           && state == XML_CONTENT_STATE)
 
 1553       return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
 
 1556           && state == XML_CONTENT_STATE)
 
 1558       *nextTokPtr = ptr + 2;
 
 1569       if (state == XML_CONTENT_STATE) {
 
 1576         return XML_TOK_PARTIAL;
 
 1577       if ((
unsigned char)ptr[2] == 0xBF) {
 
 1578         *nextTokPtr = ptr + 3;
 
 1584       if (ptr[0] == 
'\0') {
 
 1594         return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
 
 1596       else if (ptr[1] == 
'\0') {
 
 1606         if (state == XML_CONTENT_STATE)
 
 1609         return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
 
 1615   return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
 
 1621 #define XML_TOK_NS_C 
 1622 #include "xmltok_ns.c" 
 1629 #define NS(x) x ## NS 
 1630 #define ns(x) x ## _ns 
 1632 #define XML_TOK_NS_C 
 1633 #include "xmltok_ns.c" 
static const char KW_ISO_8859_1[]
 
static int PTRFASTCALL unicode_byte_type(char hi, char lo)
 
#define AS_NORMAL_ENCODING(enc)
 
static c2_factory< G4double > c2
 
#define INIT_ENC_INDEX(enc)
 
static void PTRCALL latin1_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static int PTRFASTCALL utf8_isNmstrt3(const ENCODING *enc, const char *p)
 
#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
 
static int toAscii(const ENCODING *enc, const char *ptr, const char *end)
 
static void PTRCALL initUpdatePosition(const ENCODING *enc, const char *ptr, const char *end, POSITION *pos)
 
#define LITTLE2_BYTE_TYPE(enc, p)
 
static const struct normal_encoding utf8_encoding
 
#define SB_BYTE_TYPE(enc, p)
 
static int PTRFASTCALL unknown_isName(const ENCODING *enc, const char *p)
 
static int initScan(const ENCODING *const *encodingTable, const INIT_ENCODING *enc, int state, const char *ptr, const char *end, const char **nextTokPtr)
 
#define UCS2_GET_NAMING(pages, hi, lo)
 
static const char KW_UTF_8[]
 
#define UTF8_GET_NAMING2(pages, byte)
 
#define AS_UNKNOWN_ENCODING(enc)
 
static int PTRFASTCALL unknown_isInvalid(const ENCODING *enc, const char *p)
 
static int FASTCALL checkCharRefNumber(int)
 
static const char KW_version[]
 
int FASTCALL XmlUtf16Encode(int charNum, unsigned short *buf)
 
int XmlSizeOfUnknownEncoding(void)
 
#define LITTLE2_BYTE_TO_ASCII(enc, p)
 
static int PTRFASTCALL utf8_isInvalid3(const ENCODING *enc, const char *p)
 
#define LITTLE2_CHAR_MATCHES(enc, p, c)
 
static const char KW_encoding[]
 
static const struct normal_encoding big2_encoding
 
int FASTCALL XmlUtf8Encode(int c, char *buf)
 
int(PTRFASTCALL *isName2)(const ENCODING *
 
static void PTRCALL unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static const struct normal_encoding internal_utf8_encoding
 
static const struct normal_encoding ascii_encoding
 
#define BIG2_IS_NAME_CHAR_MINBPC(enc, p)
 
#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
 
static int PTRFASTCALL unknown_isNmstrt(const ENCODING *enc, const char *p)
 
static int FASTCALL getEncodingIndex(const char *name)
 
static int FASTCALL isSpace(int c)
 
static const struct normal_encoding latin1_encoding
 
static const struct normal_encoding internal_little2_encoding
 
static const char KW_UTF_16[]
 
static int PTRFASTCALL utf8_isInvalid2(const ENCODING *enc, const char *p)
 
static int FASTCALL streqci(const char *s1, const char *s2)
 
static const struct normal_encoding internal_big2_encoding
 
#define BIG2_CHAR_MATCHES(enc, p, c)
 
static const char KW_no[]
 
static int doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *, const char *), int isGeneralTextEntity, const ENCODING *enc, const char *ptr, const char *end, const char **badPtr, const char **versionPtr, const char **versionEndPtr, const char **encodingName, const ENCODING **encoding, int *standalone)
 
#define BIG2_BYTE_TO_ASCII(enc, p)
 
static int PTRFASTCALL utf8_isInvalid4(const ENCODING *enc, const char *p)
 
static int PTRFASTCALL isNever(const ENCODING *enc, const char *p)
 
#define DEFINE_UTF16_TO_UTF8(E)
 
static int PTRFASTCALL utf8_isName3(const ENCODING *enc, const char *p)
 
static const char KW_yes[]
 
#define UTF8_GET_NAMING3(pages, byte)
 
static void PTRCALL utf8_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
static int PTRFASTCALL utf8_isNmstrt2(const ENCODING *enc, const char *p)
 
static void PTRCALL latin1_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
 
#define BIG2_BYTE_TYPE(enc, p)
 
#define XmlInitUnknownEncodingNS
 
struct normal_encoding normal
 
ENCODING * XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert, void *userData)
 
static const char KW_UTF_16BE[]
 
static int PTRFASTCALL utf8_isName2(const ENCODING *enc, const char *p)
 
unsigned short utf16[256]
 
static const char KW_US_ASCII[]
 
static const char KW_UTF_16LE[]
 
static void PTRCALL utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
 
static int parsePseudoAttribute(const ENCODING *enc, const char *ptr, const char *end, const char **namePtr, const char **nameEndPtr, const char **valPtr, const char **nextTokPtr)
 
static const struct normal_encoding little2_encoding
 
static void PTRCALL unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim, unsigned short **toP, const unsigned short *toLim)
 
#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
 
static const char KW_standalone[]
 
static void PTRCALL ascii_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim, char **toP, const char *toLim)
 
#define DEFINE_UTF16_TO_UTF16(E)
 
static const G4double pos
 
#define STANDARD_VTABLE(E)