1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-08 17:42:14 +03:00

handling of PIs and <?sgml-declaration in entities. Daniel

* DOCBparser.c: handling of PIs and <?sgml-declaration in entities.
Daniel
This commit is contained in:
Daniel Veillard
2001-06-11 17:31:08 +00:00
parent 8bdd220eb1
commit 84666b3831
2 changed files with 93 additions and 80 deletions

View File

@@ -1,3 +1,7 @@
Mon Jun 11 19:29:40 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* DOCBparser.c: handling of PIs and <?sgml-declaration in entities.
Tue Jun 12 08:46:28 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Tue Jun 12 08:46:28 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* valid.c: fixed bug #56049, forgot one check in the * valid.c: fixed bug #56049, forgot one check in the

View File

@@ -4135,104 +4135,113 @@ docbParseReference(docbParserCtxtPtr ctxt) {
* Parse a content: comment, sub-element, reference or text. * Parse a content: comment, sub-element, reference or text.
* *
*/ */
static void static void
docbParseContent(docbParserCtxtPtr ctxt) { docbParseContent(docbParserCtxtPtr ctxt)
{
xmlChar *currentNode; xmlChar *currentNode;
int depth; int depth;
currentNode = xmlStrdup(ctxt->name); currentNode = xmlStrdup(ctxt->name);
depth = ctxt->nameNr; depth = ctxt->nameNr;
while (1) { while (1) {
long cons = ctxt->nbChars; long cons = ctxt->nbChars;
GROW; GROW;
/* /*
* Our tag or one of it's parent or children is ending. * Our tag or one of it's parent or children is ending.
*/ */
if ((CUR == '<') && (NXT(1) == '/')) { if ((CUR == '<') && (NXT(1) == '/')) {
docbParseEndTag(ctxt); docbParseEndTag(ctxt);
if (currentNode != NULL) xmlFree(currentNode); if (currentNode != NULL)
return; xmlFree(currentNode);
return;
} }
/* /*
* Has this node been popped out during parsing of * Has this node been popped out during parsing of
* the next element * the next element
*/ */
if ((!xmlStrEqual(currentNode, ctxt->name)) && if ((!xmlStrEqual(currentNode, ctxt->name)) &&
(depth >= ctxt->nameNr)) { (depth >= ctxt->nameNr)) {
if (currentNode != NULL) xmlFree(currentNode); if (currentNode != NULL)
return; xmlFree(currentNode);
} return;
}
/* /*
* Sometimes DOCTYPE arrives in the middle of the document * Sometimes DOCTYPE arrives in the middle of the document
*/ */
if ((CUR == '<') && (NXT(1) == '!') && if ((CUR == '<') && (NXT(1) == '!') &&
(UPP(2) == 'D') && (UPP(3) == 'O') && (UPP(2) == 'D') && (UPP(3) == 'O') &&
(UPP(4) == 'C') && (UPP(5) == 'T') && (UPP(4) == 'C') && (UPP(5) == 'T') &&
(UPP(6) == 'Y') && (UPP(7) == 'P') && (UPP(6) == 'Y') && (UPP(7) == 'P') && (UPP(8) == 'E')) {
(UPP(8) == 'E')) { if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) ctxt->sax->error(ctxt->userData,
ctxt->sax->error(ctxt->userData, "Misplaced DOCTYPE declaration\n");
"Misplaced DOCTYPE declaration\n"); ctxt->wellFormed = 0;
ctxt->wellFormed = 0; docbParseDocTypeDecl(ctxt);
docbParseDocTypeDecl(ctxt); }
}
/* /*
* First case : a comment * First case : a comment
*/ */
if ((CUR == '<') && (NXT(1) == '!') && if ((CUR == '<') && (NXT(1) == '!') &&
(NXT(2) == '-') && (NXT(3) == '-')) { (NXT(2) == '-') && (NXT(3) == '-')) {
docbParseComment(ctxt); docbParseComment(ctxt);
} }
/*
* Second case : a PI
*/
else if ((RAW == '<') && (NXT(1) == '?')) {
docbParsePI(ctxt);
}
/* /*
* Second case : a sub-element. * Third case : a sub-element.
*/ */
else if (CUR == '<') { else if (CUR == '<') {
docbParseElement(ctxt); docbParseElement(ctxt);
} }
/* /*
* Third case : a reference. If if has not been resolved, * Fourth case : a reference. If if has not been resolved,
* parsing returns it's Name, create the node * parsing returns it's Name, create the node
*/ */
else if (CUR == '&') { else if (CUR == '&') {
docbParseReference(ctxt); docbParseReference(ctxt);
} }
/* /*
* Fourth : end of the resource * Fifth : end of the resource
*/ */
else if (CUR == 0) { else if (CUR == 0) {
docbAutoClose(ctxt, NULL); docbAutoClose(ctxt, NULL);
if (ctxt->nameNr == 0) if (ctxt->nameNr == 0)
break; break;
} }
/* /*
* Last case, text. Note that References are handled directly. * Last case, text. Note that References are handled directly.
*/ */
else { else {
docbParseCharData(ctxt); docbParseCharData(ctxt);
} }
if (cons == ctxt->nbChars) { if (cons == ctxt->nbChars) {
if (ctxt->node != NULL) { if (ctxt->node != NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData, ctxt->sax->error(ctxt->userData,
"detected an error in element content\n"); "detected an error in element content\n");
ctxt->wellFormed = 0; ctxt->wellFormed = 0;
} }
break; break;
} }
GROW; GROW;
} }
if (currentNode != NULL) xmlFree(currentNode); if (currentNode != NULL)
xmlFree(currentNode);
} }
/** /**
@@ -4822,11 +4831,11 @@ docbParseMisc(xmlParserCtxtPtr ctxt) {
(NXT(2) == '-') && (NXT(3) == '-')) || (NXT(2) == '-') && (NXT(3) == '-')) ||
IS_BLANK(CUR)) { IS_BLANK(CUR)) {
if ((RAW == '<') && (NXT(1) == '?')) { if ((RAW == '<') && (NXT(1) == '?')) {
docbParsePI(ctxt); /* TODO: SGML PIs differs */ docbParsePI(ctxt);
} else if (IS_BLANK(CUR)) { } else if (IS_BLANK(CUR)) {
NEXT; NEXT;
} else } else
xmlParseComment(ctxt); xmlParseComment(ctxt);
} }
} }