From f420ac55f8ddf2137f0b0a99e5639ea0e3a08fe4 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 4 Jul 2001 16:04:09 +0000 Subject: [PATCH] fixing a too early root closing problem raised byt Prashanth Naidu Daniel * HTMLparser.c: fixing a too early root closing problem raised byt Prashanth Naidu Daniel --- ChangeLog | 5 +++++ HTMLparser.c | 32 +++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9afee55e..b00fb4f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 4 18:02:58 CEST 2001 Daniel Veillard + + * HTMLparser.c: fixing a too early root closing problem raised + byt Prashanth Naidu + Wed Jul 4 01:42:01 CEST 2001 Daniel Veillard * xpath.c: fixed a missing copy in xmlXPathVariableLookupNS() diff --git a/HTMLparser.c b/HTMLparser.c index c49f561d..af9281b5 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -3084,24 +3084,26 @@ failed: * With namespace * * [NS 9] ETag ::= '' + * + * Returns 1 if the current level should be closed. */ -static void +static int htmlParseEndTag(htmlParserCtxtPtr ctxt) { xmlChar *name; xmlChar *oldname; - int i; + int i, ret; if ((CUR != '<') || (NXT(1) != '/')) { if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData, "htmlParseEndTag: 'wellFormed = 0; - return; + return(0); } SKIP(2); name = htmlParseHTMLName(ctxt); - if (name == NULL) return; + if (name == NULL) return(0); /* * We should definitely be at the ending "S? '>'" part @@ -3127,7 +3129,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) { "Unexpected end tag : %s\n", name); xmlFree(name); ctxt->wellFormed = 0; - return; + return(0); } @@ -3174,12 +3176,15 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) { xmlGenericError(xmlGenericErrorContext,"End of tag %s: stack empty !!!\n", name); #endif } + ret = 1; + } else { + ret = 0; } if (name != NULL) xmlFree(name); - return; + return(ret); } @@ -3285,17 +3290,22 @@ htmlParseContent(htmlParserCtxtPtr ctxt) { * Our tag or one of it's parent or children is ending. */ if ((CUR == '<') && (NXT(1) == '/')) { - htmlParseEndTag(ctxt); - if (currentNode != NULL) xmlFree(currentNode); - return; + if (htmlParseEndTag(ctxt) && + ((currentNode != NULL) || (ctxt->nameNr == 0))) { + if (currentNode != NULL) + xmlFree(currentNode); + return; + } + continue; /* while */ } /* * Has this node been popped out during parsing of * the next element */ - if ((!xmlStrEqual(currentNode, ctxt->name)) && - (depth >= ctxt->nameNr)) { + if ((ctxt->nameNr > 0) && (depth >= ctxt->nameNr) && + (!xmlStrEqual(currentNode, ctxt->name))) + { if (currentNode != NULL) xmlFree(currentNode); return; }