8 #ifndef IS_INVALID_CHAR
9 #define IS_INVALID_CHAR(enc, ptr, n) (0)
12 #define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
15 return XML_TOK_PARTIAL_CHAR; \
16 if (IS_INVALID_CHAR(enc, ptr, n)) { \
17 *(nextTokPtr) = (ptr); \
18 return XML_TOK_INVALID; \
23 #define INVALID_CASES(ptr, nextTokPtr) \
24 INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
25 INVALID_LEAD_CASE(3, ptr, nextTokPtr) \
26 INVALID_LEAD_CASE(4, ptr, nextTokPtr) \
30 *(nextTokPtr) = (ptr); \
31 return XML_TOK_INVALID;
33 #define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \
36 return XML_TOK_PARTIAL_CHAR; \
37 if (!IS_NAME_CHAR(enc, ptr, n)) { \
39 return XML_TOK_INVALID; \
44 #define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \
46 if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \
48 return XML_TOK_INVALID; \
57 CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \
58 CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \
59 CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr)
61 #define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
64 return XML_TOK_PARTIAL_CHAR; \
65 if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \
67 return XML_TOK_INVALID; \
72 #define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \
74 if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \
76 return XML_TOK_INVALID; \
82 CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \
83 CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \
84 CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr)
87 #define PREFIX(ident) ident
93 PREFIX(scanComment)(
const ENCODING *
enc,
const char *ptr,
94 const char *end,
const char **nextTokPtr)
99 return XML_TOK_INVALID;
104 INVALID_CASES(ptr, nextTokPtr)
107 return XML_TOK_PARTIAL;
109 if ((ptr +=
MINBPC(enc)) == end)
110 return XML_TOK_PARTIAL;
113 return XML_TOK_INVALID;
115 *nextTokPtr = ptr +
MINBPC(enc);
116 return XML_TOK_COMMENT;
125 return XML_TOK_PARTIAL;
131 PREFIX(scanDecl)(
const ENCODING *
enc,
const char *ptr,
132 const char *end,
const char **nextTokPtr)
135 return XML_TOK_PARTIAL;
140 *nextTokPtr = ptr +
MINBPC(enc);
141 return XML_TOK_COND_SECT_OPEN;
148 return XML_TOK_INVALID;
153 if (ptr +
MINBPC(enc) == end)
154 return XML_TOK_PARTIAL;
157 case BT_S:
case BT_CR:
case BT_LF:
case BT_PERCNT:
159 return XML_TOK_INVALID;
162 case BT_S:
case BT_CR:
case BT_LF:
164 return XML_TOK_DECL_OPEN;
171 return XML_TOK_INVALID;
174 return XML_TOK_PARTIAL;
178 PREFIX(checkPiTarget)(
const ENCODING *
enc,
const char *ptr,
179 const char *end,
int *tokPtr)
182 *tokPtr = XML_TOK_PI;
183 if (end - ptr !=
MINBPC(enc)*3)
216 *tokPtr = XML_TOK_XML_DECL;
223 PREFIX(scanPi)(
const ENCODING *
enc,
const char *ptr,
224 const char *end,
const char **nextTokPtr)
227 const char *target = ptr;
229 return XML_TOK_PARTIAL;
231 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
234 return XML_TOK_INVALID;
238 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
239 case BT_S: case BT_CR: case BT_LF:
240 if (!
PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
242 return XML_TOK_INVALID;
247 INVALID_CASES(ptr, nextTokPtr)
251 return XML_TOK_PARTIAL;
253 *nextTokPtr = ptr +
MINBPC(enc);
262 return XML_TOK_PARTIAL;
264 if (!
PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
266 return XML_TOK_INVALID;
270 return XML_TOK_PARTIAL;
272 *nextTokPtr = ptr +
MINBPC(enc);
278 return XML_TOK_INVALID;
281 return XML_TOK_PARTIAL;
285 PREFIX(scanCdataSection)(
const ENCODING *
enc,
const char *ptr,
286 const char *end,
const char **nextTokPtr)
288 static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A,
289 ASCII_T, ASCII_A, ASCII_LSQB };
292 if (end - ptr < 6 *
MINBPC(enc))
293 return XML_TOK_PARTIAL;
294 for (i = 0; i < 6; i++, ptr +=
MINBPC(enc)) {
297 return XML_TOK_INVALID;
301 return XML_TOK_CDATA_SECT_OPEN;
305 PREFIX(cdataSectionTok)(
const ENCODING *
enc,
const char *ptr,
306 const char *end,
const char **nextTokPtr)
311 size_t n = end - ptr;
312 if (n & (
MINBPC(enc) - 1)) {
315 return XML_TOK_PARTIAL;
323 return XML_TOK_PARTIAL;
328 return XML_TOK_PARTIAL;
333 *nextTokPtr = ptr +
MINBPC(enc);
334 return XML_TOK_CDATA_SECT_CLOSE;
338 return XML_TOK_PARTIAL;
342 return XML_TOK_DATA_NEWLINE;
344 *nextTokPtr = ptr +
MINBPC(enc);
345 return XML_TOK_DATA_NEWLINE;
346 INVALID_CASES(ptr, nextTokPtr)
353 #define LEAD_CASE(n) \
355 if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
357 return XML_TOK_DATA_CHARS; \
361 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
370 return XML_TOK_DATA_CHARS;
377 return XML_TOK_DATA_CHARS;
383 PREFIX(scanEndTag)(
const ENCODING *
enc,
const char *ptr,
384 const char *end,
const char **nextTokPtr)
387 return XML_TOK_PARTIAL;
389 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
392 return XML_TOK_INVALID;
396 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
397 case BT_S: case BT_CR: case BT_LF:
398 for (ptr +=
MINBPC(enc); ptr != end; ptr +=
MINBPC(enc)) {
400 case BT_S:
case BT_CR:
case BT_LF:
403 *nextTokPtr = ptr +
MINBPC(enc);
404 return XML_TOK_END_TAG;
407 return XML_TOK_INVALID;
410 return XML_TOK_PARTIAL;
419 *nextTokPtr = ptr +
MINBPC(enc);
420 return XML_TOK_END_TAG;
423 return XML_TOK_INVALID;
426 return XML_TOK_PARTIAL;
432 PREFIX(scanHexCharRef)(
const ENCODING *
enc,
const char *ptr,
433 const char *end,
const char **nextTokPtr)
442 return XML_TOK_INVALID;
444 for (ptr +=
MINBPC(enc); ptr != end; ptr +=
MINBPC(enc)) {
450 *nextTokPtr = ptr +
MINBPC(enc);
451 return XML_TOK_CHAR_REF;
454 return XML_TOK_INVALID;
458 return XML_TOK_PARTIAL;
464 PREFIX(scanCharRef)(
const ENCODING *
enc,
const char *ptr,
465 const char *end,
const char **nextTokPtr)
469 return PREFIX(scanHexCharRef)(
enc, ptr +
MINBPC(enc), end, nextTokPtr);
475 return XML_TOK_INVALID;
477 for (ptr +=
MINBPC(enc); ptr != end; ptr +=
MINBPC(enc)) {
482 *nextTokPtr = ptr +
MINBPC(enc);
483 return XML_TOK_CHAR_REF;
486 return XML_TOK_INVALID;
490 return XML_TOK_PARTIAL;
496 PREFIX(scanRef)(
const ENCODING *
enc,
const char *ptr,
const char *end,
497 const char **nextTokPtr)
500 return XML_TOK_PARTIAL;
502 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
504 return
PREFIX(scanCharRef)(enc, ptr +
MINBPC(enc), end, nextTokPtr);
507 return XML_TOK_INVALID;
511 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
513 *nextTokPtr = ptr +
MINBPC(enc);
514 return XML_TOK_ENTITY_REF;
517 return XML_TOK_INVALID;
520 return XML_TOK_PARTIAL;
526 PREFIX(scanAtts)(const ENCODING *enc, const
char *ptr, const
char *end,
527 const
char **nextTokPtr)
534 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
539 return XML_TOK_INVALID;
544 return XML_TOK_PARTIAL;
546 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
549 return XML_TOK_INVALID;
553 case BT_S:
case BT_CR:
case BT_LF:
559 return XML_TOK_PARTIAL;
570 return XML_TOK_INVALID;
583 return XML_TOK_PARTIAL;
585 if (open == BT_QUOT || open == BT_APOS)
594 return XML_TOK_INVALID;
602 return XML_TOK_PARTIAL;
607 INVALID_CASES(ptr, nextTokPtr)
612 if (tok == XML_TOK_INVALID)
620 return XML_TOK_INVALID;
628 return XML_TOK_PARTIAL;
640 return XML_TOK_INVALID;
646 return XML_TOK_PARTIAL;
648 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
649 case BT_S: case BT_CR: case BT_LF:
653 *nextTokPtr = ptr +
MINBPC(enc);
654 return XML_TOK_START_TAG_WITH_ATTS;
659 return XML_TOK_PARTIAL;
662 return XML_TOK_INVALID;
664 *nextTokPtr = ptr +
MINBPC(enc);
665 return XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
668 return XML_TOK_INVALID;
676 return XML_TOK_INVALID;
679 return XML_TOK_PARTIAL;
685 PREFIX(scanLt)(
const ENCODING *
enc,
const char *ptr,
const char *end,
686 const char **nextTokPtr)
692 return XML_TOK_PARTIAL;
694 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
696 if ((ptr +=
MINBPC(enc)) == end)
697 return XML_TOK_PARTIAL;
706 return XML_TOK_INVALID;
713 return XML_TOK_INVALID;
721 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
726 return XML_TOK_INVALID;
731 return XML_TOK_PARTIAL;
733 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
736 return XML_TOK_INVALID;
740 case BT_S:
case BT_CR:
case BT_LF:
745 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
750 case BT_S: case BT_CR: case BT_LF:
755 return XML_TOK_INVALID;
757 return
PREFIX(scanAtts)(enc, ptr, end, nextTokPtr);
759 return XML_TOK_PARTIAL;
763 *nextTokPtr = ptr +
MINBPC(enc);
764 return XML_TOK_START_TAG_NO_ATTS;
769 return XML_TOK_PARTIAL;
772 return XML_TOK_INVALID;
774 *nextTokPtr = ptr +
MINBPC(enc);
775 return XML_TOK_EMPTY_ELEMENT_NO_ATTS;
778 return XML_TOK_INVALID;
781 return XML_TOK_PARTIAL;
785 PREFIX(contentTok)(
const ENCODING *
enc,
const char *ptr,
const char *end,
786 const char **nextTokPtr)
791 size_t n = end - ptr;
792 if (n & (
MINBPC(enc) - 1)) {
795 return XML_TOK_PARTIAL;
807 return XML_TOK_TRAILING_CR;
811 return XML_TOK_DATA_NEWLINE;
813 *nextTokPtr = ptr +
MINBPC(enc);
814 return XML_TOK_DATA_NEWLINE;
818 return XML_TOK_TRAILING_RSQB;
823 return XML_TOK_TRAILING_RSQB;
829 return XML_TOK_INVALID;
830 INVALID_CASES(ptr, nextTokPtr)
837 #define LEAD_CASE(n) \
839 if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
841 return XML_TOK_DATA_CHARS; \
845 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
848 if (ptr +
MINBPC(enc) != end) {
853 if (ptr + 2*
MINBPC(enc) != end) {
858 *nextTokPtr = ptr + 2*
MINBPC(enc);
859 return XML_TOK_INVALID;
871 return XML_TOK_DATA_CHARS;
878 return XML_TOK_DATA_CHARS;
884 PREFIX(scanPercent)(
const ENCODING *
enc,
const char *ptr,
const char *end,
885 const char **nextTokPtr)
888 return XML_TOK_PARTIAL;
890 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
891 case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
893 return XML_TOK_PERCENT;
896 return XML_TOK_INVALID;
900 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
902 *nextTokPtr = ptr +
MINBPC(enc);
903 return XML_TOK_PARAM_ENTITY_REF;
906 return XML_TOK_INVALID;
909 return XML_TOK_PARTIAL;
913 PREFIX(scanPoundName)(const ENCODING *enc, const
char *ptr, const
char *end,
914 const
char **nextTokPtr)
917 return XML_TOK_PARTIAL;
919 CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
922 return XML_TOK_INVALID;
926 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
927 case BT_CR: case BT_LF: case BT_S:
928 case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR:
930 return XML_TOK_POUND_NAME;
933 return XML_TOK_INVALID;
936 return -XML_TOK_POUND_NAME;
940 PREFIX(scanLit)(
int open, const ENCODING *enc,
941 const
char *ptr, const
char *end,
942 const
char **nextTokPtr)
947 INVALID_CASES(ptr, nextTokPtr)
954 return -XML_TOK_LITERAL;
957 case BT_S:
case BT_CR:
case BT_LF:
958 case BT_GT:
case BT_PERCNT:
case BT_LSQB:
959 return XML_TOK_LITERAL;
961 return XML_TOK_INVALID;
968 return XML_TOK_PARTIAL;
972 PREFIX(prologTok)(
const ENCODING *
enc,
const char *ptr,
const char *end,
973 const char **nextTokPtr)
979 size_t n = end - ptr;
980 if (n & (
MINBPC(enc) - 1)) {
983 return XML_TOK_PARTIAL;
989 return PREFIX(scanLit)(BT_QUOT,
enc, ptr +
MINBPC(enc), end, nextTokPtr);
991 return PREFIX(scanLit)(BT_APOS,
enc, ptr +
MINBPC(enc), end, nextTokPtr);
996 return XML_TOK_PARTIAL;
1008 *nextTokPtr = ptr -
MINBPC(enc);
1009 return XML_TOK_INSTANCE_START;
1012 return XML_TOK_INVALID;
1015 if (ptr +
MINBPC(enc) == end) {
1018 return -XML_TOK_PROLOG_S;
1021 case BT_S:
case BT_LF:
1027 case BT_S:
case BT_LF:
1031 if (ptr +
MINBPC(enc) != end)
1036 return XML_TOK_PROLOG_S;
1040 return XML_TOK_PROLOG_S;
1044 *nextTokPtr = ptr +
MINBPC(enc);
1045 return XML_TOK_COMMA;
1047 *nextTokPtr = ptr +
MINBPC(enc);
1048 return XML_TOK_OPEN_BRACKET;
1052 return -XML_TOK_CLOSE_BRACKET;
1054 if (ptr +
MINBPC(enc) == end)
1055 return XML_TOK_PARTIAL;
1057 *nextTokPtr = ptr + 2*
MINBPC(enc);
1058 return XML_TOK_COND_SECT_CLOSE;
1062 return XML_TOK_CLOSE_BRACKET;
1064 *nextTokPtr = ptr +
MINBPC(enc);
1065 return XML_TOK_OPEN_PAREN;
1069 return -XML_TOK_CLOSE_PAREN;
1072 *nextTokPtr = ptr +
MINBPC(enc);
1073 return XML_TOK_CLOSE_PAREN_ASTERISK;
1075 *nextTokPtr = ptr +
MINBPC(enc);
1076 return XML_TOK_CLOSE_PAREN_QUESTION;
1078 *nextTokPtr = ptr +
MINBPC(enc);
1079 return XML_TOK_CLOSE_PAREN_PLUS;
1080 case BT_CR:
case BT_LF:
case BT_S:
1081 case BT_GT:
case BT_COMMA:
case BT_VERBAR:
1084 return XML_TOK_CLOSE_PAREN;
1087 return XML_TOK_INVALID;
1089 *nextTokPtr = ptr +
MINBPC(enc);
1092 *nextTokPtr = ptr +
MINBPC(enc);
1093 return XML_TOK_DECL_CLOSE;
1095 return PREFIX(scanPoundName)(
enc, ptr +
MINBPC(enc), end, nextTokPtr);
1096 #define LEAD_CASE(n) \
1097 case BT_LEAD ## n: \
1098 if (end - ptr < n) \
1099 return XML_TOK_PARTIAL_CHAR; \
1100 if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
1102 tok = XML_TOK_NAME; \
1105 if (IS_NAME_CHAR(enc, ptr, n)) { \
1107 tok = XML_TOK_NMTOKEN; \
1110 *nextTokPtr = ptr; \
1111 return XML_TOK_INVALID;
1112 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
1125 tok = XML_TOK_NMTOKEN;
1136 tok = XML_TOK_NMTOKEN;
1142 return XML_TOK_INVALID;
1144 while (ptr != end) {
1146 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
1147 case BT_GT: case BT_RPAR: case BT_COMMA:
1148 case BT_VERBAR: case BT_LSQB: case BT_PERCNT:
1149 case BT_S: case BT_CR: case BT_LF:
1158 return XML_TOK_PARTIAL;
1159 tok = XML_TOK_PREFIXED_NAME;
1161 CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
1163 tok = XML_TOK_NMTOKEN;
1167 case XML_TOK_PREFIXED_NAME:
1168 tok = XML_TOK_NMTOKEN;
1174 if (tok == XML_TOK_NMTOKEN) {
1176 return XML_TOK_INVALID;
1178 *nextTokPtr = ptr +
MINBPC(enc);
1179 return XML_TOK_NAME_PLUS;
1181 if (tok == XML_TOK_NMTOKEN) {
1183 return XML_TOK_INVALID;
1185 *nextTokPtr = ptr +
MINBPC(enc);
1186 return XML_TOK_NAME_ASTERISK;
1188 if (tok == XML_TOK_NMTOKEN) {
1190 return XML_TOK_INVALID;
1192 *nextTokPtr = ptr +
MINBPC(enc);
1193 return XML_TOK_NAME_QUESTION;
1196 return XML_TOK_INVALID;
1203 PREFIX(attributeValueTok)(
const ENCODING *
enc,
const char *ptr,
1204 const char *end,
const char **nextTokPtr)
1208 return XML_TOK_NONE;
1210 while (ptr != end) {
1212 #define LEAD_CASE(n) \
1213 case BT_LEAD ## n: ptr += n; break;
1214 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
1220 return XML_TOK_DATA_CHARS;
1224 return XML_TOK_INVALID;
1227 *nextTokPtr = ptr +
MINBPC(enc);
1228 return XML_TOK_DATA_NEWLINE;
1231 return XML_TOK_DATA_CHARS;
1236 return XML_TOK_TRAILING_CR;
1240 return XML_TOK_DATA_NEWLINE;
1243 return XML_TOK_DATA_CHARS;
1246 *nextTokPtr = ptr +
MINBPC(enc);
1247 return XML_TOK_ATTRIBUTE_VALUE_S;
1250 return XML_TOK_DATA_CHARS;
1257 return XML_TOK_DATA_CHARS;
1261 PREFIX(entityValueTok)(
const ENCODING *
enc,
const char *ptr,
1262 const char *end,
const char **nextTokPtr)
1266 return XML_TOK_NONE;
1268 while (ptr != end) {
1270 #define LEAD_CASE(n) \
1271 case BT_LEAD ## n: ptr += n; break;
1272 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
1278 return XML_TOK_DATA_CHARS;
1283 return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
1286 return XML_TOK_DATA_CHARS;
1289 *nextTokPtr = ptr +
MINBPC(enc);
1290 return XML_TOK_DATA_NEWLINE;
1293 return XML_TOK_DATA_CHARS;
1298 return XML_TOK_TRAILING_CR;
1302 return XML_TOK_DATA_NEWLINE;
1305 return XML_TOK_DATA_CHARS;
1312 return XML_TOK_DATA_CHARS;
1318 PREFIX(ignoreSectionTok)(
const ENCODING *
enc,
const char *ptr,
1319 const char *end,
const char **nextTokPtr)
1323 size_t n = end - ptr;
1324 if (n & (
MINBPC(enc) - 1)) {
1329 while (ptr != end) {
1331 INVALID_CASES(ptr, nextTokPtr)
1333 if ((ptr +=
MINBPC(enc)) == end)
1334 return XML_TOK_PARTIAL;
1336 if ((ptr +=
MINBPC(enc)) == end)
1337 return XML_TOK_PARTIAL;
1345 if ((ptr +=
MINBPC(enc)) == end)
1346 return XML_TOK_PARTIAL;
1348 if ((ptr +=
MINBPC(enc)) == end)
1349 return XML_TOK_PARTIAL;
1354 return XML_TOK_IGNORE_SECT;
1365 return XML_TOK_PARTIAL;
1371 PREFIX(isPublicId)(
const ENCODING *
enc,
const char *ptr,
const char *end,
1372 const char **badPtr)
1376 for (; ptr != end; ptr +=
MINBPC(enc)) {
1431 PREFIX(getAtts)(
const ENCODING *
enc,
const char *ptr,
1432 int attsMax, ATTRIBUTE *
atts)
1434 enum { other, inName, inValue } state = inName;
1441 #define START_NAME \
1442 if (state == other) { \
1443 if (nAtts < attsMax) { \
1444 atts[nAtts].name = ptr; \
1445 atts[nAtts].normalized = 1; \
1449 #define LEAD_CASE(n) \
1450 case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break;
1451 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
1460 if (state != inValue) {
1461 if (nAtts < attsMax)
1466 else if (open == BT_QUOT) {
1468 if (nAtts < attsMax)
1469 atts[nAtts].valueEnd = ptr;
1474 if (state != inValue) {
1475 if (nAtts < attsMax)
1480 else if (open == BT_APOS) {
1482 if (nAtts < attsMax)
1483 atts[nAtts].valueEnd = ptr;
1488 if (nAtts < attsMax)
1489 atts[nAtts].normalized = 0;
1492 if (state == inName)
1494 else if (state == inValue
1496 &&
atts[nAtts].normalized
1497 && (ptr ==
atts[nAtts].valuePtr
1501 atts[nAtts].normalized = 0;
1503 case BT_CR:
case BT_LF:
1506 if (state == inName)
1508 else if (state == inValue && nAtts < attsMax)
1509 atts[nAtts].normalized = 0;
1513 if (state != inValue)
1523 static int PTRFASTCALL
1524 PREFIX(charRefNumber)(
const ENCODING *
enc,
const char *ptr)
1535 case ASCII_0:
case ASCII_1:
case ASCII_2:
case ASCII_3:
case ASCII_4:
1536 case ASCII_5:
case ASCII_6:
case ASCII_7:
case ASCII_8:
case ASCII_9:
1538 result |= (c - ASCII_0);
1540 case ASCII_A:
case ASCII_B:
case ASCII_C:
1541 case ASCII_D:
case ASCII_E:
case ASCII_F:
1543 result += 10 + (c - ASCII_A);
1545 case ASCII_a:
case ASCII_b:
case ASCII_c:
1546 case ASCII_d:
case ASCII_e:
case ASCII_f:
1548 result += 10 + (c - ASCII_a);
1551 if (result >= 0x110000)
1559 result += (c - ASCII_0);
1560 if (result >= 0x110000)
1568 PREFIX(predefinedEntityName)(
const ENCODING *
enc,
const char *ptr,
1571 switch ((end - ptr)/
MINBPC(enc)) {
1622 PREFIX(sameName)(
const ENCODING *
enc,
const char *ptr1,
const char *ptr2)
1626 #define LEAD_CASE(n) \
1627 case BT_LEAD ## n: \
1628 if (*ptr1++ != *ptr2++) \
1630 LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
1633 if (*ptr1++ != *ptr2++)
1645 if (*ptr2++ != *ptr1++)
1648 if (*ptr2++ != *ptr1++)
1651 if (*ptr2++ != *ptr1++)
1654 if (*ptr2++ != *ptr1++)
1661 if (
MINBPC(enc) == 1 && *ptr1 == *ptr2)
1686 PREFIX(nameMatchesAscii)(
const ENCODING *
enc,
const char *ptr1,
1687 const char *end1,
const char *ptr2)
1689 for (; *ptr2; ptr1 +=
MINBPC(enc), ptr2++) {
1695 return ptr1 == end1;
1698 static int PTRFASTCALL
1699 PREFIX(nameLength)(
const ENCODING *
enc,
const char *ptr)
1701 const char *start = ptr;
1704 #define LEAD_CASE(n) \
1705 case BT_LEAD ## n: ptr += n; break;
1706 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
1720 return (
int)(ptr - start);
1725 static const char * PTRFASTCALL
1726 PREFIX(skipS)(
const ENCODING *
enc,
const char *ptr)
1742 PREFIX(updatePosition)(
const ENCODING *
enc,
1749 #define LEAD_CASE(n) \
1750 case BT_LEAD ## n: \
1753 LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
1756 pos->columnNumber = (XML_Size)-1;
1763 if (ptr != end &&
BYTE_TYPE(enc, ptr) == BT_LF)
1765 pos->columnNumber = (XML_Size)-1;
1771 pos->columnNumber++;
1776 #undef MULTIBYTE_CASES
1777 #undef INVALID_CASES
1778 #undef CHECK_NAME_CASE
1779 #undef CHECK_NAME_CASES
1780 #undef CHECK_NMSTRT_CASE
1781 #undef CHECK_NMSTRT_CASES
#define BYTE_TYPE(enc, p)
#define IS_NAME_CHAR_MINBPC(enc, p)
#define IS_NMSTRT_CHAR_MINBPC(enc, p)
#define CHAR_MATCHES(enc, p, c)
static int FASTCALL checkCharRefNumber(int)
static const G4double pos
#define BYTE_TO_ASCII(enc, p)