OLD | NEW |
1 /* | 1 /* |
2 * parser.c : an XML 1.0 parser, namespaces and validity support are mostly | 2 * parser.c : an XML 1.0 parser, namespaces and validity support are mostly |
3 * implemented on top of the SAX interfaces | 3 * implemented on top of the SAX interfaces |
4 * | 4 * |
5 * References: | 5 * References: |
6 * The XML specification: | 6 * The XML specification: |
7 * http://www.w3.org/TR/REC-xml | 7 * http://www.w3.org/TR/REC-xml |
8 * Original 1.0 version: | 8 * Original 1.0 version: |
9 * http://www.w3.org/TR/1998/REC-xml-19980210 | 9 * http://www.w3.org/TR/1998/REC-xml-19980210 |
10 * XML second edition working draft | 10 * XML second edition working draft |
(...skipping 4809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4820 } | 4820 } |
4821 SKIP(2); | 4821 SKIP(2); |
4822 | 4822 |
4823 /* | 4823 /* |
4824 * SAX: PI detected. | 4824 * SAX: PI detected. |
4825 */ | 4825 */ |
4826 if ((ctxt->sax) && (!ctxt->disableSAX) && | 4826 if ((ctxt->sax) && (!ctxt->disableSAX) && |
4827 (ctxt->sax->processingInstruction != NULL)) | 4827 (ctxt->sax->processingInstruction != NULL)) |
4828 ctxt->sax->processingInstruction(ctxt->userData, | 4828 ctxt->sax->processingInstruction(ctxt->userData, |
4829 target, NULL); | 4829 target, NULL); |
4830 » » ctxt->instate = state; | 4830 » » if (ctxt->instate != XML_PARSER_EOF) |
| 4831 » » ctxt->instate = state; |
4831 return; | 4832 return; |
4832 } | 4833 } |
4833 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); | 4834 buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); |
4834 if (buf == NULL) { | 4835 if (buf == NULL) { |
4835 xmlErrMemory(ctxt, NULL); | 4836 xmlErrMemory(ctxt, NULL); |
4836 ctxt->instate = state; | 4837 ctxt->instate = state; |
4837 return; | 4838 return; |
4838 } | 4839 } |
4839 cur = CUR; | 4840 cur = CUR; |
4840 if (!IS_BLANK(cur)) { | 4841 if (!IS_BLANK(cur)) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4900 */ | 4901 */ |
4901 if ((ctxt->sax) && (!ctxt->disableSAX) && | 4902 if ((ctxt->sax) && (!ctxt->disableSAX) && |
4902 (ctxt->sax->processingInstruction != NULL)) | 4903 (ctxt->sax->processingInstruction != NULL)) |
4903 ctxt->sax->processingInstruction(ctxt->userData, | 4904 ctxt->sax->processingInstruction(ctxt->userData, |
4904 target, buf); | 4905 target, buf); |
4905 } | 4906 } |
4906 xmlFree(buf); | 4907 xmlFree(buf); |
4907 } else { | 4908 } else { |
4908 xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); | 4909 xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL); |
4909 } | 4910 } |
4910 » ctxt->instate = state; | 4911 » if (ctxt->instate != XML_PARSER_EOF) |
| 4912 » ctxt->instate = state; |
4911 } | 4913 } |
4912 } | 4914 } |
4913 | 4915 |
4914 /** | 4916 /** |
4915 * xmlParseNotationDecl: | 4917 * xmlParseNotationDecl: |
4916 * @ctxt: an XML parser context | 4918 * @ctxt: an XML parser context |
4917 * | 4919 * |
4918 * parse a notation declaration | 4920 * parse a notation declaration |
4919 * | 4921 * |
4920 * [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>' | 4922 * [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? '>' |
(...skipping 4538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9459 | 9461 |
9460 line = ctxt->input->line; | 9462 line = ctxt->input->line; |
9461 #ifdef LIBXML_SAX1_ENABLED | 9463 #ifdef LIBXML_SAX1_ENABLED |
9462 if (ctxt->sax2) | 9464 if (ctxt->sax2) |
9463 #endif /* LIBXML_SAX1_ENABLED */ | 9465 #endif /* LIBXML_SAX1_ENABLED */ |
9464 name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen); | 9466 name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen); |
9465 #ifdef LIBXML_SAX1_ENABLED | 9467 #ifdef LIBXML_SAX1_ENABLED |
9466 else | 9468 else |
9467 name = xmlParseStartTag(ctxt); | 9469 name = xmlParseStartTag(ctxt); |
9468 #endif /* LIBXML_SAX1_ENABLED */ | 9470 #endif /* LIBXML_SAX1_ENABLED */ |
| 9471 if (ctxt->instate == XML_PARSER_EOF) |
| 9472 return; |
9469 if (name == NULL) { | 9473 if (name == NULL) { |
9470 spacePop(ctxt); | 9474 spacePop(ctxt); |
9471 return; | 9475 return; |
9472 } | 9476 } |
9473 namePush(ctxt, name); | 9477 namePush(ctxt, name); |
9474 ret = ctxt->node; | 9478 ret = ctxt->node; |
9475 | 9479 |
9476 #ifdef LIBXML_VALID_ENABLED | 9480 #ifdef LIBXML_VALID_ENABLED |
9477 /* | 9481 /* |
9478 * [ VC: Root Element Type ] | 9482 * [ VC: Root Element Type ] |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10838 else | 10842 else |
10839 spacePush(ctxt, *ctxt->space); | 10843 spacePush(ctxt, *ctxt->space); |
10840 #ifdef LIBXML_SAX1_ENABLED | 10844 #ifdef LIBXML_SAX1_ENABLED |
10841 if (ctxt->sax2) | 10845 if (ctxt->sax2) |
10842 #endif /* LIBXML_SAX1_ENABLED */ | 10846 #endif /* LIBXML_SAX1_ENABLED */ |
10843 name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen); | 10847 name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen); |
10844 #ifdef LIBXML_SAX1_ENABLED | 10848 #ifdef LIBXML_SAX1_ENABLED |
10845 else | 10849 else |
10846 name = xmlParseStartTag(ctxt); | 10850 name = xmlParseStartTag(ctxt); |
10847 #endif /* LIBXML_SAX1_ENABLED */ | 10851 #endif /* LIBXML_SAX1_ENABLED */ |
| 10852 if (ctxt->instate == XML_PARSER_EOF) |
| 10853 goto done; |
10848 if (name == NULL) { | 10854 if (name == NULL) { |
10849 spacePop(ctxt); | 10855 spacePop(ctxt); |
10850 ctxt->instate = XML_PARSER_EOF; | 10856 ctxt->instate = XML_PARSER_EOF; |
10851 if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) | 10857 if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) |
10852 ctxt->sax->endDocument(ctxt->userData); | 10858 ctxt->sax->endDocument(ctxt->userData); |
10853 goto done; | 10859 goto done; |
10854 } | 10860 } |
10855 #ifdef LIBXML_VALID_ENABLED | 10861 #ifdef LIBXML_VALID_ENABLED |
10856 /* | 10862 /* |
10857 * [ VC: Root Element Type ] | 10863 * [ VC: Root Element Type ] |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11024 xmlParseEndTag2(ctxt, | 11030 xmlParseEndTag2(ctxt, |
11025 (void *) ctxt->pushTab[ctxt->nameNr * 3 - 3], | 11031 (void *) ctxt->pushTab[ctxt->nameNr * 3 - 3], |
11026 (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0, | 11032 (void *) ctxt->pushTab[ctxt->nameNr * 3 - 2], 0, |
11027 (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1], 0); | 11033 (int) (long) ctxt->pushTab[ctxt->nameNr * 3 - 1], 0); |
11028 nameNsPop(ctxt); | 11034 nameNsPop(ctxt); |
11029 } | 11035 } |
11030 #ifdef LIBXML_SAX1_ENABLED | 11036 #ifdef LIBXML_SAX1_ENABLED |
11031 else | 11037 else |
11032 xmlParseEndTag1(ctxt, 0); | 11038 xmlParseEndTag1(ctxt, 0); |
11033 #endif /* LIBXML_SAX1_ENABLED */ | 11039 #endif /* LIBXML_SAX1_ENABLED */ |
11034 » » if (ctxt->nameNr == 0) { | 11040 » » if (ctxt->instate == XML_PARSER_EOF) { |
| 11041 » » /* Nothing */ |
| 11042 » » } else if (ctxt->nameNr == 0) { |
11035 ctxt->instate = XML_PARSER_EPILOG; | 11043 ctxt->instate = XML_PARSER_EPILOG; |
11036 } else { | 11044 } else { |
11037 ctxt->instate = XML_PARSER_CONTENT; | 11045 ctxt->instate = XML_PARSER_CONTENT; |
11038 } | 11046 } |
11039 break; | 11047 break; |
11040 case XML_PARSER_CDATA_SECTION: { | 11048 case XML_PARSER_CDATA_SECTION: { |
11041 /* | 11049 /* |
11042 * The Push mode need to have the SAX callback for | 11050 * The Push mode need to have the SAX callback for |
11043 * cdataBlock merge back contiguous callbacks. | 11051 * cdataBlock merge back contiguous callbacks. |
11044 */ | 11052 */ |
(...skipping 3805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14850 if (stream == NULL) { | 14858 if (stream == NULL) { |
14851 xmlFreeParserInputBuffer(input); | 14859 xmlFreeParserInputBuffer(input); |
14852 return (NULL); | 14860 return (NULL); |
14853 } | 14861 } |
14854 inputPush(ctxt, stream); | 14862 inputPush(ctxt, stream); |
14855 return (xmlDoRead(ctxt, URL, encoding, options, 1)); | 14863 return (xmlDoRead(ctxt, URL, encoding, options, 1)); |
14856 } | 14864 } |
14857 | 14865 |
14858 #define bottom_parser | 14866 #define bottom_parser |
14859 #include "elfgcchack.h" | 14867 #include "elfgcchack.h" |
OLD | NEW |