Index: parser.c =================================================================== RCS file: /cvs/gnome/gnome-xml/parser.c,v retrieving revision 1.324 diff -c -r1.324 parser.c *** parser.c 7 Oct 2003 21:25:07 -0000 1.324 --- parser.c 9 Oct 2003 19:41:39 -0000 *************** *** 102,107 **** --- 102,108 ---- NULL }; + /* DEPR void xmlParserHandleReference(xmlParserCtxtPtr ctxt); */ xmlEntityPtr xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str); *************** *** 1194,1199 **** --- 1195,1218 ---- #define NXT(val) ctxt->input->cur[(val)] #define CUR_PTR ctxt->input->cur + #define CMP4( s, c1, c2, c3, c4 ) \ + ( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \ + ((unsigned char *) s)[ 2 ] == c3 && ((unsigned char *) s)[ 3 ] == c4 ) + #define CMP5( s, c1, c2, c3, c4, c5 ) \ + ( CMP4( s, c1, c2, c3, c4 ) && ((unsigned char *) s)[ 4 ] == c5 ) + #define CMP6( s, c1, c2, c3, c4, c5, c6 ) \ + ( CMP5( s, c1, c2, c3, c4, c5 ) && ((unsigned char *) s)[ 5 ] == c6 ) + #define CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) \ + ( CMP6( s, c1, c2, c3, c4, c5, c6 ) && ((unsigned char *) s)[ 6 ] == c7 ) + #define CMP8( s, c1, c2, c3, c4, c5, c6, c7, c8 ) \ + ( CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) && ((unsigned char *) s)[ 7 ] == c8 ) + #define CMP9( s, c1, c2, c3, c4, c5, c6, c7, c8, c9 ) \ + ( CMP8( s, c1, c2, c3, c4, c5, c6, c7, c8 ) && \ + ((unsigned char *) s)[ 8 ] == c9 ) + #define CMP10( s, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 ) \ + ( CMP9( s, c1, c2, c3, c4, c5, c6, c7, c8, c9 ) && \ + ((unsigned char *) s)[ 9 ] == c10 ) + #define SKIP(val) do { \ ctxt->nbChars += (val),ctxt->input->cur += (val),ctxt->input->col+=(val); \ if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt); \ *************** *** 1766,1772 **** } if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && ! (memcmp(CUR_PTR, "etype == XML_EXTERNAL_PARAMETER_ENTITY) && ! (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l' )) && (IS_BLANK(NXT(5)))) { xmlParseTextDecl(ctxt); } } else { *************** *** 3707,3713 **** SHRINK; *publicID = NULL; ! if (memcmp(CUR_PTR, "SYSTEM", 6) == 0) { SKIP(6); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, --- 3726,3732 ---- SHRINK; *publicID = NULL; ! if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) { SKIP(6); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, *************** *** 3718,3724 **** if (URI == NULL) { xmlFatalErr(ctxt, XML_ERR_URI_REQUIRED, NULL); } ! } else if (memcmp(CUR_PTR, "PUBLIC", 6) == 0) { SKIP(6); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, --- 3737,3743 ---- if (URI == NULL) { xmlFatalErr(ctxt, XML_ERR_URI_REQUIRED, NULL); } ! } else if (CMP6(CUR_PTR, 'P', 'U', 'B', 'L', 'I', 'C')) { SKIP(6); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, *************** *** 4115,4121 **** xmlChar *Pubid; xmlChar *Systemid; ! if (memcmp(CUR_PTR, "input; SHRINK; SKIP(10); --- 4134,4140 ---- xmlChar *Pubid; xmlChar *Systemid; ! if (CMP10(CUR_PTR, '<', '!', 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) { xmlParserInputPtr input = ctxt->input; SHRINK; SKIP(10); *************** *** 4194,4200 **** int skipped; GROW; ! if (memcmp(CUR_PTR, "input; SHRINK; SKIP(8); --- 4213,4219 ---- int skipped; GROW; ! if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) { xmlParserInputPtr input = ctxt->input; SHRINK; SKIP(8); *************** *** 4332,4338 **** "Space required before 'NDATA'\n"); } SKIP_BLANKS; ! if (memcmp(CUR_PTR, "NDATA", 5) == 0) { SKIP(5); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, --- 4351,4357 ---- "Space required before 'NDATA'\n"); } SKIP_BLANKS; ! if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) { SKIP(5); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, *************** *** 4449,4464 **** xmlChar *ret; *value = NULL; ! if (memcmp(CUR_PTR, "#REQUIRED", 9) == 0) { SKIP(9); return(XML_ATTRIBUTE_REQUIRED); } ! if (memcmp(CUR_PTR, "#IMPLIED", 8) == 0) { SKIP(8); return(XML_ATTRIBUTE_IMPLIED); } val = XML_ATTRIBUTE_NONE; ! if (memcmp(CUR_PTR, "#FIXED", 6) == 0) { SKIP(6); val = XML_ATTRIBUTE_FIXED; if (!IS_BLANK(CUR)) { --- 4468,4483 ---- xmlChar *ret; *value = NULL; ! if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) { SKIP(9); return(XML_ATTRIBUTE_REQUIRED); } ! if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) { SKIP(8); return(XML_ATTRIBUTE_IMPLIED); } val = XML_ATTRIBUTE_NONE; ! if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) { SKIP(6); val = XML_ATTRIBUTE_FIXED; if (!IS_BLANK(CUR)) { *************** *** 4600,4606 **** int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) { ! if (memcmp(CUR_PTR, "NOTATION", 8) == 0) { SKIP(8); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, --- 4619,4625 ---- int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) { ! if (CMP8(CUR_PTR, 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) { SKIP(8); if (!IS_BLANK(CUR)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, *************** *** 4665,4692 **** int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) { SHRINK; ! if (memcmp(CUR_PTR, "CDATA", 5) == 0) { SKIP(5); return(XML_ATTRIBUTE_CDATA); ! } else if (memcmp(CUR_PTR, "IDREFS", 6) == 0) { SKIP(6); return(XML_ATTRIBUTE_IDREFS); ! } else if (memcmp(CUR_PTR, "IDREF", 5) == 0) { SKIP(5); return(XML_ATTRIBUTE_IDREF); } else if ((RAW == 'I') && (NXT(1) == 'D')) { SKIP(2); return(XML_ATTRIBUTE_ID); ! } else if (memcmp(CUR_PTR, "ENTITY", 6) == 0) { SKIP(6); return(XML_ATTRIBUTE_ENTITY); ! } else if (memcmp(CUR_PTR, "ENTITIES", 8) == 0) { SKIP(8); return(XML_ATTRIBUTE_ENTITIES); ! } else if (memcmp(CUR_PTR, "NMTOKENS", 8) == 0) { SKIP(8); return(XML_ATTRIBUTE_NMTOKENS); ! } else if (memcmp(CUR_PTR, "NMTOKEN", 7) == 0) { SKIP(7); return(XML_ATTRIBUTE_NMTOKEN); } --- 4684,4711 ---- int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) { SHRINK; ! if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) { SKIP(5); return(XML_ATTRIBUTE_CDATA); ! } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) { SKIP(6); return(XML_ATTRIBUTE_IDREFS); ! } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) { SKIP(5); return(XML_ATTRIBUTE_IDREF); } else if ((RAW == 'I') && (NXT(1) == 'D')) { SKIP(2); return(XML_ATTRIBUTE_ID); ! } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) { SKIP(6); return(XML_ATTRIBUTE_ENTITY); ! } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) { SKIP(8); return(XML_ATTRIBUTE_ENTITIES); ! } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) { SKIP(8); return(XML_ATTRIBUTE_NMTOKENS); ! } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) { SKIP(7); return(XML_ATTRIBUTE_NMTOKEN); } *************** *** 4710,4716 **** const xmlChar *attrName; xmlEnumerationPtr tree; ! if (memcmp(CUR_PTR, "input; SKIP(9); --- 4729,4735 ---- const xmlChar *attrName; xmlEnumerationPtr tree; ! if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) { xmlParserInputPtr input = ctxt->input; SKIP(9); *************** *** 4855,4861 **** const xmlChar *elem = NULL; GROW; ! if (memcmp(CUR_PTR, "#PCDATA", 7) == 0) { SKIP(7); SKIP_BLANKS; SHRINK; --- 4874,4880 ---- const xmlChar *elem = NULL; GROW; ! if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) { SKIP(7); SKIP_BLANKS; SHRINK; *************** *** 5237,5243 **** NEXT; GROW; SKIP_BLANKS; ! if (memcmp(CUR_PTR, "#PCDATA", 7) == 0) { tree = xmlParseElementMixedContentDecl(ctxt, inputid); res = XML_ELEMENT_TYPE_MIXED; } else { --- 5256,5262 ---- NEXT; GROW; SKIP_BLANKS; ! if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) { tree = xmlParseElementMixedContentDecl(ctxt, inputid); res = XML_ELEMENT_TYPE_MIXED; } else { *************** *** 5269,5275 **** xmlElementContentPtr content = NULL; GROW; ! if (memcmp(CUR_PTR, "input; SKIP(9); --- 5288,5294 ---- xmlElementContentPtr content = NULL; GROW; ! if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) { xmlParserInputPtr input = ctxt->input; SKIP(9); *************** *** 5291,5297 **** "Space required after the element name\n"); } SKIP_BLANKS; ! if (memcmp(CUR_PTR, "EMPTY", 5) == 0) { SKIP(5); /* * Element must always be empty. --- 5310,5316 ---- "Space required after the element name\n"); } SKIP_BLANKS; ! if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) { SKIP(5); /* * Element must always be empty. *************** *** 5365,5371 **** xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { SKIP(3); SKIP_BLANKS; ! if (memcmp(CUR_PTR, "INCLUDE", 7) == 0) { SKIP(7); SKIP_BLANKS; if (RAW != '[') { --- 5384,5390 ---- xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { SKIP(3); SKIP_BLANKS; ! if (CMP7(CUR_PTR, 'I', 'N', 'C', 'L', 'U', 'D', 'E')) { SKIP(7); SKIP_BLANKS; if (RAW != '[') { *************** *** 5416,5422 **** "Leaving INCLUDE Conditional Section\n"); } ! } else if (memcmp(CUR_PTR, "IGNORE", 6) == 0) { int state; xmlParserInputState instate; int depth = 0; --- 5435,5441 ---- "Leaving INCLUDE Conditional Section\n"); } ! } else if (CMP6(CUR_PTR, 'I', 'G', 'N', 'O', 'R', 'E')) { int state; xmlParserInputState instate; int depth = 0; *************** *** 5555,5561 **** /* * We know that 'errNo == XML_ERR_UNSUPPORTED_ENCODING) { /* --- 5643,5649 ---- const xmlChar *SystemID) { xmlDetectSAX2(ctxt); GROW; ! if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) { xmlParseTextDecl(ctxt); if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) { /* *************** *** 5981,5987 **** input = xmlNewEntityInputStream(ctxt, ent); xmlPushInput(ctxt, input); if ((ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) && ! (memcmp(CUR_PTR, "errNo == XML_ERR_UNSUPPORTED_ENCODING) { /* --- 6000,6006 ---- input = xmlNewEntityInputStream(ctxt, ent); xmlPushInput(ctxt, input); if ((ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) && ! (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK(NXT(5)))) { xmlParseTextDecl(ctxt); if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) { /* *************** *** 6437,6443 **** input = xmlNewEntityInputStream(ctxt, entity); xmlPushInput(ctxt, input); if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && ! (memcmp(CUR_PTR, "errNo == --- 6456,6462 ---- input = xmlNewEntityInputStream(ctxt, entity); xmlPushInput(ctxt, input); if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) && ! (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK(NXT(5)))) { xmlParseTextDecl(ctxt); if (ctxt->errNo == *************** *** 7988,7994 **** int count = 0; /* Check 2.6.0 was NXT(0) not RAW */ ! if (memcmp(CUR_PTR, "inSubset = 1; xmlParseDocTypeDecl(ctxt); --- 8842,8848 ---- * (doctypedecl Misc*)? */ GROW; ! if (CMP9(CUR_PTR, '<', '!', 'D', 'O', 'C', 'T', 'Y', 'P', 'E')) { ctxt->inSubset = 1; xmlParseDocTypeDecl(ctxt); *************** *** 8947,8953 **** * Check for the XMLDecl in the Prolog. */ GROW; ! if ((memcmp(CUR_PTR, "