diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2003-03-27 14:55:52 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2003-03-27 14:55:52 +0000 |
commit | 6c5b2d3fff87ae143d30c6871200aaf489056a52 (patch) | |
tree | 3054c9f272bd2ee051dd042ac97c004c6dd4f43a /parser.c | |
parent | d9b72839b30d7a51791a1609444f69bcd3254a6c (diff) | |
download | android_external_libxml2-6c5b2d3fff87ae143d30c6871200aaf489056a52.tar.gz android_external_libxml2-6c5b2d3fff87ae143d30c6871200aaf489056a52.tar.bz2 android_external_libxml2-6c5b2d3fff87ae143d30c6871200aaf489056a52.zip |
fixing #109227 providing more context in case of start/end tag mismatch
* parser.c: fixing #109227 providing more context in case of
start/end tag mismatch
* python/tests/ctxterror.py python/tests/readererr.py: update the
tests accordingly
Daniel
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 52 |
1 files changed, 30 insertions, 22 deletions
@@ -6795,7 +6795,7 @@ failed: } /** - * xmlParseEndTag: + * xmlParseEndTagInternal: * @ctxt: an XML parser context * * parse an end of tag @@ -6807,8 +6807,8 @@ failed: * [NS 9] ETag ::= '</' QName S? '>' */ -void -xmlParseEndTag(xmlParserCtxtPtr ctxt) { +static void +xmlParseEndTagInternal(xmlParserCtxtPtr ctxt, int line) { xmlChar *name; xmlChar *oldname; @@ -6850,28 +6850,16 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) { if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) { if (name != NULL) { ctxt->sax->error(ctxt->userData, - "Opening and ending tag mismatch: %s and %s\n", - ctxt->name, name); + "Opening and ending tag mismatch: %s line %d and %s\n", + ctxt->name, line, name); } else { ctxt->sax->error(ctxt->userData, - "Ending tag error for: %s\n", ctxt->name); + "Ending tag error for: %s line %d\n", ctxt->name, line); } } ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; -#if 0 - else { - /* - * Recover in case of one missing close - */ - if ((ctxt->nameNr > 2) && - (xmlStrEqual(ctxt->nameTab[ctxt->nameNr -2], name))) { - namePop(ctxt); - spacePop(ctxt); - } - } -#endif if (name != NULL) xmlFree(name); } @@ -6895,6 +6883,24 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) { } /** + * xmlParseEndTag: + * @ctxt: an XML parser context + * + * parse an end of tag + * + * [42] ETag ::= '</' Name S? '>' + * + * With namespace + * + * [NS 9] ETag ::= '</' QName S? '>' + */ + +void +xmlParseEndTag(xmlParserCtxtPtr ctxt) { + xmlParseEndTagInternal(ctxt, 0); +} + +/** * xmlParseCDSect: * @ctxt: an XML parser context * @@ -7129,6 +7135,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { xmlChar *name; xmlChar *oldname; xmlParserNodeInfo node_info; + int line; xmlNodePtr ret; /* Capture start position */ @@ -7143,6 +7150,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { else spacePush(ctxt, *ctxt->space); + line = ctxt->input->line; name = xmlParseStartTag(ctxt); if (name == NULL) { spacePop(ctxt); @@ -7191,8 +7199,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { ctxt->errNo = XML_ERR_GT_REQUIRED; if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData, - "Couldn't find end of Start Tag %s\n", - name); + "Couldn't find end of Start Tag %s line %d\n", + name, line); ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; @@ -7230,7 +7238,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { ctxt->errNo = XML_ERR_TAG_NOT_FINISHED; if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData, - "Premature end of data in tag %s\n", name); + "Premature end of data in tag %s line %d\n", name, line); ctxt->wellFormed = 0; if (ctxt->recovery == 0) ctxt->disableSAX = 1; @@ -7252,7 +7260,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) { /* * parse the end of tag: '</' should be here. */ - xmlParseEndTag(ctxt); + xmlParseEndTagInternal(ctxt, line); /* * Capture end position and add node |