mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
patched to redirrect all "out of context" error messages to
a reconfigurable routine. The changes are: * xmlerror.h : added the export of an error context type (void *) an error handler type xmlGenericErrorFunc there is an interface xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler); to reset the error handling routine and its argument (by default it's equivalent to respectively fprintf and stderr. * all the c files: all wild accesses to stderr or stdout within the library have been replaced to calls to the handler. Daniel
This commit is contained in:
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Wed Oct 25 21:31:10 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
|
||||||
|
* patched to redirrect all "out of context" error messages to
|
||||||
|
a reconfigurable routine. The changes are:
|
||||||
|
* xmlerror.h : added the export of an error context type (void *)
|
||||||
|
an error handler type xmlGenericErrorFunc there is an interface
|
||||||
|
xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);
|
||||||
|
to reset the error handling routine and its argument
|
||||||
|
(by default it's equivalent to respectively fprintf and stderr.
|
||||||
|
* all the c files: all wild accesses to stderr or stdout within
|
||||||
|
the library have been replaced to calls to the handler.
|
||||||
|
|
||||||
Wed Oct 25 15:27:19 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
Wed Oct 25 15:27:19 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
|
||||||
* configure.in: release 2.2.6
|
* configure.in: release 2.2.6
|
||||||
|
291
HTMLparser.c
291
HTMLparser.c
@ -70,7 +70,8 @@ scope int html##name##Push(htmlParserCtxtPtr ctxt, type value) { \
|
|||||||
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
||||||
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
||||||
if (ctxt->name##Tab == NULL) { \
|
if (ctxt->name##Tab == NULL) { \
|
||||||
fprintf(stderr, "realloc failed !\n"); \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"realloc failed !\n"); \
|
||||||
return(0); \
|
return(0); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -689,9 +690,9 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Close of %s stack: %d elements\n", newtag, ctxt->nameNr);
|
xmlGenericError(xmlGenericErrorContext,"Close of %s stack: %d elements\n", newtag, ctxt->nameNr);
|
||||||
for (i = 0;i < ctxt->nameNr;i++)
|
for (i = 0;i < ctxt->nameNr;i++)
|
||||||
fprintf(stderr,"%d : %s\n", i, ctxt->nameTab[i]);
|
xmlGenericError(xmlGenericErrorContext,"%d : %s\n", i, ctxt->nameTab[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = (ctxt->nameNr - 1);i >= 0;i--) {
|
for (i = (ctxt->nameNr - 1);i >= 0;i--) {
|
||||||
@ -703,7 +704,7 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
info = htmlTagLookup(ctxt->name);
|
info = htmlTagLookup(ctxt->name);
|
||||||
if ((info == NULL) || (info->endTag == 1)) {
|
if ((info == NULL) || (info->endTag == 1)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"htmlAutoCloseOnClose: %s closes %s\n", newtag, ctxt->name);
|
xmlGenericError(xmlGenericErrorContext,"htmlAutoCloseOnClose: %s closes %s\n", newtag, ctxt->name);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
||||||
@ -717,7 +718,7 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"htmlAutoCloseOnClose: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"htmlAutoCloseOnClose: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -742,14 +743,14 @@ htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
while ((newtag != NULL) && (ctxt->name != NULL) &&
|
while ((newtag != NULL) && (ctxt->name != NULL) &&
|
||||||
(htmlCheckAutoClose(newtag, ctxt->name))) {
|
(htmlCheckAutoClose(newtag, ctxt->name))) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"htmlAutoClose: %s closes %s\n", newtag, ctxt->name);
|
xmlGenericError(xmlGenericErrorContext,"htmlAutoClose: %s closes %s\n", newtag, ctxt->name);
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
|
||||||
ctxt->sax->endElement(ctxt->userData, ctxt->name);
|
ctxt->sax->endElement(ctxt->userData, ctxt->name);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"htmlAutoClose: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"htmlAutoClose: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -764,14 +765,14 @@ htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
(xmlStrEqual(ctxt->name, BAD_CAST"body")) ||
|
(xmlStrEqual(ctxt->name, BAD_CAST"body")) ||
|
||||||
(xmlStrEqual(ctxt->name, BAD_CAST"html")))) {
|
(xmlStrEqual(ctxt->name, BAD_CAST"html")))) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"htmlAutoClose: EOF closes %s\n", ctxt->name);
|
xmlGenericError(xmlGenericErrorContext,"htmlAutoClose: EOF closes %s\n", ctxt->name);
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
|
||||||
ctxt->sax->endElement(ctxt->userData, ctxt->name);
|
ctxt->sax->endElement(ctxt->userData, ctxt->name);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"htmlAutoClose: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"htmlAutoClose: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -846,7 +847,7 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
return;
|
return;
|
||||||
if (ctxt->nameNr <= 0) {
|
if (ctxt->nameNr <= 0) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Implied element html: pushed html\n");
|
xmlGenericError(xmlGenericErrorContext,"Implied element html: pushed html\n");
|
||||||
#endif
|
#endif
|
||||||
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"html"));
|
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"html"));
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
||||||
@ -866,14 +867,14 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
|
|||||||
* assumed !
|
* assumed !
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Implied element head: pushed head\n");
|
xmlGenericError(xmlGenericErrorContext,"Implied element head: pushed head\n");
|
||||||
#endif
|
#endif
|
||||||
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"head"));
|
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"head"));
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
||||||
ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL);
|
ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Implied element body: pushed body\n");
|
xmlGenericError(xmlGenericErrorContext,"Implied element body: pushed body\n");
|
||||||
#endif
|
#endif
|
||||||
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"body"));
|
htmlnamePush(ctxt, xmlStrdup(BAD_CAST"body"));
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
||||||
@ -912,7 +913,7 @@ htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
|
|||||||
for (i = 0; htmlNoContentElements[i] != NULL; i++) {
|
for (i = 0; htmlNoContentElements[i] != NULL; i++) {
|
||||||
if (xmlStrEqual(tag, BAD_CAST htmlNoContentElements[i])) {
|
if (xmlStrEqual(tag, BAD_CAST htmlNoContentElements[i])) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Implied element paragraph\n");
|
xmlGenericError(xmlGenericErrorContext,"Implied element paragraph\n");
|
||||||
#endif
|
#endif
|
||||||
htmlAutoClose(ctxt, BAD_CAST"p");
|
htmlAutoClose(ctxt, BAD_CAST"p");
|
||||||
htmlCheckImplied(ctxt, BAD_CAST"p");
|
htmlCheckImplied(ctxt, BAD_CAST"p");
|
||||||
@ -1279,7 +1280,7 @@ htmlEntityLookup(const xmlChar *name) {
|
|||||||
sizeof(html40EntitiesTable[0]));i++) {
|
sizeof(html40EntitiesTable[0]));i++) {
|
||||||
if (xmlStrEqual(name, BAD_CAST html40EntitiesTable[i].name)) {
|
if (xmlStrEqual(name, BAD_CAST html40EntitiesTable[i].name)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Found entity %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
return(&html40EntitiesTable[i]);
|
return(&html40EntitiesTable[i]);
|
||||||
}
|
}
|
||||||
@ -1310,13 +1311,14 @@ htmlEntityValueLookup(int value) {
|
|||||||
if ((unsigned int) html40EntitiesTable[i].value > value)
|
if ((unsigned int) html40EntitiesTable[i].value > value)
|
||||||
break;
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Found entity %s\n", html40EntitiesTable[i].name);
|
xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name);
|
||||||
#endif
|
#endif
|
||||||
return(&html40EntitiesTable[i]);
|
return(&html40EntitiesTable[i]);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (lv > html40EntitiesTable[i].value) {
|
if (lv > html40EntitiesTable[i].value) {
|
||||||
fprintf(stderr, "html40EntitiesTable[] is not sorted (%d > %d)!\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"html40EntitiesTable[] is not sorted (%d > %d)!\n",
|
||||||
lv, html40EntitiesTable[i].value);
|
lv, html40EntitiesTable[i].value);
|
||||||
}
|
}
|
||||||
lv = html40EntitiesTable[i].value;
|
lv = html40EntitiesTable[i].value;
|
||||||
@ -1762,7 +1764,8 @@ htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc));
|
cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlNewDoc : malloc failed\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewDoc : malloc failed\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlDoc));
|
memset(cur, 0, sizeof(xmlDoc));
|
||||||
@ -1881,7 +1884,7 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
|
|||||||
buf[len++] = CUR;
|
buf[len++] = CUR;
|
||||||
NEXT;
|
NEXT;
|
||||||
if (len >= HTML_MAX_NAMELEN) {
|
if (len >= HTML_MAX_NAMELEN) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"htmlParseName: reached HTML_MAX_NAMELEN limit\n");
|
"htmlParseName: reached HTML_MAX_NAMELEN limit\n");
|
||||||
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
|
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
|
||||||
(CUR == '.') || (CUR == '-') ||
|
(CUR == '.') || (CUR == '-') ||
|
||||||
@ -2052,7 +2055,7 @@ htmlParseNmtoken(htmlParserCtxtPtr ctxt) {
|
|||||||
buf[len++] = CUR;
|
buf[len++] = CUR;
|
||||||
NEXT;
|
NEXT;
|
||||||
if (len >= HTML_MAX_NAMELEN) {
|
if (len >= HTML_MAX_NAMELEN) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"htmlParseNmtoken: reached HTML_MAX_NAMELEN limit\n");
|
"htmlParseNmtoken: reached HTML_MAX_NAMELEN limit\n");
|
||||||
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
|
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
|
||||||
(CUR == '.') || (CUR == '-') ||
|
(CUR == '.') || (CUR == '-') ||
|
||||||
@ -2490,7 +2493,8 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
|
|||||||
SKIP(4);
|
SKIP(4);
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
ctxt->instate = state;
|
ctxt->instate = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2507,7 +2511,8 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
ctxt->instate = state;
|
ctxt->instate = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2953,7 +2958,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
|||||||
maxatts = 10;
|
maxatts = 10;
|
||||||
atts = (const xmlChar **) xmlMalloc(maxatts * sizeof(xmlChar *));
|
atts = (const xmlChar **) xmlMalloc(maxatts * sizeof(xmlChar *));
|
||||||
if (atts == NULL) {
|
if (atts == NULL) {
|
||||||
fprintf(stderr, "malloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %ld byte failed\n",
|
||||||
maxatts * (long)sizeof(xmlChar *));
|
maxatts * (long)sizeof(xmlChar *));
|
||||||
if (name != NULL) xmlFree(name);
|
if (name != NULL) xmlFree(name);
|
||||||
return;
|
return;
|
||||||
@ -2963,7 +2969,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
|
|||||||
atts = (const xmlChar **) xmlRealloc((void *) atts,
|
atts = (const xmlChar **) xmlRealloc((void *) atts,
|
||||||
maxatts * sizeof(xmlChar *));
|
maxatts * sizeof(xmlChar *));
|
||||||
if (atts == NULL) {
|
if (atts == NULL) {
|
||||||
fprintf(stderr, "realloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %ld byte failed\n",
|
||||||
maxatts * (long)sizeof(xmlChar *));
|
maxatts * (long)sizeof(xmlChar *));
|
||||||
if (name != NULL) xmlFree(name);
|
if (name != NULL) xmlFree(name);
|
||||||
return;
|
return;
|
||||||
@ -3004,7 +3011,7 @@ failed:
|
|||||||
*/
|
*/
|
||||||
htmlnamePush(ctxt, xmlStrdup(name));
|
htmlnamePush(ctxt, xmlStrdup(name));
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Start of element %s: pushed %s\n", name, ctxt->name);
|
xmlGenericError(xmlGenericErrorContext,"Start of element %s: pushed %s\n", name, ctxt->name);
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
|
||||||
ctxt->sax->startElement(ctxt->userData, name, atts);
|
ctxt->sax->startElement(ctxt->userData, name, atts);
|
||||||
@ -3090,7 +3097,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) {
|
|||||||
*/
|
*/
|
||||||
if (!xmlStrEqual(name, ctxt->name)) {
|
if (!xmlStrEqual(name, ctxt->name)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of tag %s: expecting %s\n", name, ctxt->name);
|
xmlGenericError(xmlGenericErrorContext,"End of tag %s: expecting %s\n", name, ctxt->name);
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->name != NULL) &&
|
if ((ctxt->name != NULL) &&
|
||||||
(!xmlStrEqual(ctxt->name, name))) {
|
(!xmlStrEqual(ctxt->name, name))) {
|
||||||
@ -3112,12 +3119,12 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) {
|
|||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of tag %s: popping out %s\n", name, oldname);
|
xmlGenericError(xmlGenericErrorContext,"End of tag %s: popping out %s\n", name, oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"End of tag %s: stack empty !!!\n", name);
|
xmlGenericError(xmlGenericErrorContext,"End of tag %s: stack empty !!!\n", name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3349,11 +3356,14 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
|||||||
name = ctxt->name;
|
name = ctxt->name;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (oldname == NULL)
|
if (oldname == NULL)
|
||||||
fprintf(stderr, "Start of element %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Start of element %s\n", name);
|
||||||
else if (name == NULL)
|
else if (name == NULL)
|
||||||
fprintf(stderr, "Start of element failed, was %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Start of element failed, was %s\n", oldname);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Start of element %s, was %s\n", name, oldname);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Start of element %s, was %s\n", name, oldname);
|
||||||
#endif
|
#endif
|
||||||
if (((depth == ctxt->nameNr) && (xmlStrEqual(oldname, ctxt->name))) ||
|
if (((depth == ctxt->nameNr) && (xmlStrEqual(oldname, ctxt->name))) ||
|
||||||
(name == NULL)) {
|
(name == NULL)) {
|
||||||
@ -3392,7 +3402,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
|||||||
ctxt->sax->endElement(ctxt->userData, name);
|
ctxt->sax->endElement(ctxt->userData, name);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of tag the XML way: popping out %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"End of tag the XML way: popping out %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
@ -3415,7 +3425,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
|||||||
nodePop(ctxt);
|
nodePop(ctxt);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of start tag problem: popping out %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"End of start tag problem: popping out %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
@ -3442,7 +3452,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
|||||||
ctxt->sax->endElement(ctxt->userData, name);
|
ctxt->sax->endElement(ctxt->userData, name);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of empty tag %s : popping out %s\n", name, oldname);
|
xmlGenericError(xmlGenericErrorContext,"End of empty tag %s : popping out %s\n", name, oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
@ -3473,7 +3483,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
|
|||||||
nodePop(ctxt);
|
nodePop(ctxt);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"Premature end of tag %s : popping out %s\n", name, oldname);
|
xmlGenericError(xmlGenericErrorContext,"Premature end of tag %s : popping out %s\n", name, oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
@ -3621,7 +3631,8 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
|
|||||||
|
|
||||||
sax = (htmlSAXHandler *) xmlMalloc(sizeof(htmlSAXHandler));
|
sax = (htmlSAXHandler *) xmlMalloc(sizeof(htmlSAXHandler));
|
||||||
if (sax == NULL) {
|
if (sax == NULL) {
|
||||||
fprintf(stderr, "htmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlInitParserCtxt: out of memory\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memset(sax, 0, sizeof(htmlSAXHandler));
|
memset(sax, 0, sizeof(htmlSAXHandler));
|
||||||
@ -3630,7 +3641,8 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
|
|||||||
ctxt->inputTab = (htmlParserInputPtr *)
|
ctxt->inputTab = (htmlParserInputPtr *)
|
||||||
xmlMalloc(5 * sizeof(htmlParserInputPtr));
|
xmlMalloc(5 * sizeof(htmlParserInputPtr));
|
||||||
if (ctxt->inputTab == NULL) {
|
if (ctxt->inputTab == NULL) {
|
||||||
fprintf(stderr, "htmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->inputNr = 0;
|
ctxt->inputNr = 0;
|
||||||
ctxt->inputMax = 0;
|
ctxt->inputMax = 0;
|
||||||
ctxt->input = NULL;
|
ctxt->input = NULL;
|
||||||
@ -3647,7 +3659,8 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
|
|||||||
/* Allocate the Node stack */
|
/* Allocate the Node stack */
|
||||||
ctxt->nodeTab = (htmlNodePtr *) xmlMalloc(10 * sizeof(htmlNodePtr));
|
ctxt->nodeTab = (htmlNodePtr *) xmlMalloc(10 * sizeof(htmlNodePtr));
|
||||||
if (ctxt->nodeTab == NULL) {
|
if (ctxt->nodeTab == NULL) {
|
||||||
fprintf(stderr, "htmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->nodeNr = 0;
|
ctxt->nodeNr = 0;
|
||||||
ctxt->nodeMax = 0;
|
ctxt->nodeMax = 0;
|
||||||
ctxt->node = NULL;
|
ctxt->node = NULL;
|
||||||
@ -3663,7 +3676,8 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
|
|||||||
/* Allocate the Name stack */
|
/* Allocate the Name stack */
|
||||||
ctxt->nameTab = (xmlChar **) xmlMalloc(10 * sizeof(xmlChar *));
|
ctxt->nameTab = (xmlChar **) xmlMalloc(10 * sizeof(xmlChar *));
|
||||||
if (ctxt->nameTab == NULL) {
|
if (ctxt->nameTab == NULL) {
|
||||||
fprintf(stderr, "htmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->nameNr = 0;
|
ctxt->nameNr = 0;
|
||||||
ctxt->nameMax = 10;
|
ctxt->nameMax = 10;
|
||||||
ctxt->name = NULL;
|
ctxt->name = NULL;
|
||||||
@ -3805,13 +3819,16 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
|||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
if (next == 0)
|
if (next == 0)
|
||||||
fprintf(stderr, "HPP: lookup '%c' found at %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: lookup '%c' found at %d\n",
|
||||||
first, base);
|
first, base);
|
||||||
else if (third == 0)
|
else if (third == 0)
|
||||||
fprintf(stderr, "HPP: lookup '%c%c' found at %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: lookup '%c%c' found at %d\n",
|
||||||
first, next, base);
|
first, next, base);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "HPP: lookup '%c%c%c' found at %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: lookup '%c%c%c' found at %d\n",
|
||||||
first, next, third, base);
|
first, next, third, base);
|
||||||
#endif
|
#endif
|
||||||
return(base - (in->cur - in->base));
|
return(base - (in->cur - in->base));
|
||||||
@ -3820,11 +3837,14 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
|||||||
ctxt->checkIndex = base;
|
ctxt->checkIndex = base;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
if (next == 0)
|
if (next == 0)
|
||||||
fprintf(stderr, "HPP: lookup '%c' failed\n", first);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: lookup '%c' failed\n", first);
|
||||||
else if (third == 0)
|
else if (third == 0)
|
||||||
fprintf(stderr, "HPP: lookup '%c%c' failed\n", first, next);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: lookup '%c%c' failed\n", first, next);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "HPP: lookup '%c%c%c' failed\n", first, next, third);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: lookup '%c%c%c' failed\n", first, next, third);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -3848,37 +3868,53 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
switch (ctxt->instate) {
|
switch (ctxt->instate) {
|
||||||
case XML_PARSER_EOF:
|
case XML_PARSER_EOF:
|
||||||
fprintf(stderr, "HPP: try EOF\n"); break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try EOF\n"); break;
|
||||||
case XML_PARSER_START:
|
case XML_PARSER_START:
|
||||||
fprintf(stderr, "HPP: try START\n"); break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try START\n"); break;
|
||||||
case XML_PARSER_MISC:
|
case XML_PARSER_MISC:
|
||||||
fprintf(stderr, "HPP: try MISC\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try MISC\n");break;
|
||||||
case XML_PARSER_COMMENT:
|
case XML_PARSER_COMMENT:
|
||||||
fprintf(stderr, "HPP: try COMMENT\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try COMMENT\n");break;
|
||||||
case XML_PARSER_PROLOG:
|
case XML_PARSER_PROLOG:
|
||||||
fprintf(stderr, "HPP: try PROLOG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try PROLOG\n");break;
|
||||||
case XML_PARSER_START_TAG:
|
case XML_PARSER_START_TAG:
|
||||||
fprintf(stderr, "HPP: try START_TAG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try START_TAG\n");break;
|
||||||
case XML_PARSER_CONTENT:
|
case XML_PARSER_CONTENT:
|
||||||
fprintf(stderr, "HPP: try CONTENT\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try CONTENT\n");break;
|
||||||
case XML_PARSER_CDATA_SECTION:
|
case XML_PARSER_CDATA_SECTION:
|
||||||
fprintf(stderr, "HPP: try CDATA_SECTION\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try CDATA_SECTION\n");break;
|
||||||
case XML_PARSER_END_TAG:
|
case XML_PARSER_END_TAG:
|
||||||
fprintf(stderr, "HPP: try END_TAG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try END_TAG\n");break;
|
||||||
case XML_PARSER_ENTITY_DECL:
|
case XML_PARSER_ENTITY_DECL:
|
||||||
fprintf(stderr, "HPP: try ENTITY_DECL\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try ENTITY_DECL\n");break;
|
||||||
case XML_PARSER_ENTITY_VALUE:
|
case XML_PARSER_ENTITY_VALUE:
|
||||||
fprintf(stderr, "HPP: try ENTITY_VALUE\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try ENTITY_VALUE\n");break;
|
||||||
case XML_PARSER_ATTRIBUTE_VALUE:
|
case XML_PARSER_ATTRIBUTE_VALUE:
|
||||||
fprintf(stderr, "HPP: try ATTRIBUTE_VALUE\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try ATTRIBUTE_VALUE\n");break;
|
||||||
case XML_PARSER_DTD:
|
case XML_PARSER_DTD:
|
||||||
fprintf(stderr, "HPP: try DTD\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try DTD\n");break;
|
||||||
case XML_PARSER_EPILOG:
|
case XML_PARSER_EPILOG:
|
||||||
fprintf(stderr, "HPP: try EPILOG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try EPILOG\n");break;
|
||||||
case XML_PARSER_PI:
|
case XML_PARSER_PI:
|
||||||
fprintf(stderr, "HPP: try PI\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try PI\n");break;
|
||||||
case XML_PARSER_SYSTEM_LITERAL:
|
case XML_PARSER_SYSTEM_LITERAL:
|
||||||
fprintf(stderr, "HPP: try SYSTEM_LITERAL\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: try SYSTEM_LITERAL\n");break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -3939,18 +3975,21 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing internal subset\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing internal subset\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseDocTypeDecl(ctxt);
|
htmlParseDocTypeDecl(ctxt);
|
||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering PROLOG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering PROLOG\n");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering MISC\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering MISC\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_MISC:
|
case XML_PARSER_MISC:
|
||||||
@ -3969,7 +4008,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseComment(ctxt);
|
htmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
@ -3982,12 +4022,14 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing internal subset\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing internal subset\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseDocTypeDecl(ctxt);
|
htmlParseDocTypeDecl(ctxt);
|
||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering PROLOG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering PROLOG\n");
|
||||||
#endif
|
#endif
|
||||||
} else if ((cur == '<') && (next == '!') &&
|
} else if ((cur == '<') && (next == '!') &&
|
||||||
(avail < 9)) {
|
(avail < 9)) {
|
||||||
@ -3995,7 +4037,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4015,7 +4058,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseComment(ctxt);
|
htmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
@ -4025,7 +4069,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4050,7 +4095,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseComment(ctxt);
|
htmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_EPILOG;
|
ctxt->instate = XML_PARSER_EPILOG;
|
||||||
@ -4065,7 +4111,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->wellFormed = 0;
|
ctxt->wellFormed = 0;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering EOF\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering EOF\n");
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
||||||
ctxt->sax->endDocument(ctxt->userData);
|
ctxt->sax->endDocument(ctxt->userData);
|
||||||
@ -4083,7 +4130,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if (cur != '<') {
|
if (cur != '<') {
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4096,12 +4144,15 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
name = ctxt->name;
|
name = ctxt->name;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (oldname == NULL)
|
if (oldname == NULL)
|
||||||
fprintf(stderr, "Start of element %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Start of element %s\n", name);
|
||||||
else if (name == NULL)
|
else if (name == NULL)
|
||||||
fprintf(stderr, "Start of element failed, was %s\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Start of element failed, was %s\n",
|
||||||
oldname);
|
oldname);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Start of element %s, was %s\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Start of element %s, was %s\n",
|
||||||
name, oldname);
|
name, oldname);
|
||||||
#endif
|
#endif
|
||||||
if (((depth == ctxt->nameNr) &&
|
if (((depth == ctxt->nameNr) &&
|
||||||
@ -4143,14 +4194,15 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->sax->endElement(ctxt->userData, name);
|
ctxt->sax->endElement(ctxt->userData, name);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of tag the XML way: popping out %s\n",
|
xmlGenericError(xmlGenericErrorContext,"End of tag the XML way: popping out %s\n",
|
||||||
oldname);
|
oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4171,7 +4223,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
nodePop(ctxt);
|
nodePop(ctxt);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"End of start tag problem: popping out %s\n", oldname);
|
"End of start tag problem: popping out %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
@ -4180,7 +4232,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
|
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4193,14 +4246,15 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->sax->endElement(ctxt->userData, name);
|
ctxt->sax->endElement(ctxt->userData, name);
|
||||||
oldname = htmlnamePop(ctxt);
|
oldname = htmlnamePop(ctxt);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr,"End of empty tag %s : popping out %s\n", name, oldname);
|
xmlGenericError(xmlGenericErrorContext,"End of empty tag %s : popping out %s\n", name, oldname);
|
||||||
#endif
|
#endif
|
||||||
if (oldname != NULL)
|
if (oldname != NULL)
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4258,7 +4312,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->instate = XML_PARSER_END_TAG;
|
ctxt->instate = XML_PARSER_END_TAG;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering END_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering END_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4285,7 +4340,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(htmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseComment(ctxt);
|
htmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
@ -4295,14 +4351,16 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->instate = XML_PARSER_END_TAG;
|
ctxt->instate = XML_PARSER_END_TAG;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering END_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering END_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (cur == '<') {
|
} else if (cur == '<') {
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (cur == '&') {
|
} else if (cur == '&') {
|
||||||
@ -4310,7 +4368,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(htmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
|
(htmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing Reference\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing Reference\n");
|
||||||
#endif
|
#endif
|
||||||
/* TODO: check generation of subtrees if noent !!! */
|
/* TODO: check generation of subtrees if noent !!! */
|
||||||
htmlParseReference(ctxt);
|
htmlParseReference(ctxt);
|
||||||
@ -4329,7 +4388,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
}
|
}
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: Parsing char data\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: Parsing char data\n");
|
||||||
#endif
|
#endif
|
||||||
htmlParseCharData(ctxt, 0);
|
htmlParseCharData(ctxt, 0);
|
||||||
}
|
}
|
||||||
@ -4361,71 +4421,88 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
}
|
}
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_CDATA_SECTION:
|
case XML_PARSER_CDATA_SECTION:
|
||||||
fprintf(stderr, "HPP: internal error, state == CDATA\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == CDATA\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_DTD:
|
case XML_PARSER_DTD:
|
||||||
fprintf(stderr, "HPP: internal error, state == DTD\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == DTD\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_COMMENT:
|
case XML_PARSER_COMMENT:
|
||||||
fprintf(stderr, "HPP: internal error, state == COMMENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == COMMENT\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_PI:
|
case XML_PARSER_PI:
|
||||||
fprintf(stderr, "HPP: internal error, state == PI\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == PI\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_ENTITY_DECL:
|
case XML_PARSER_ENTITY_DECL:
|
||||||
fprintf(stderr, "HPP: internal error, state == ENTITY_DECL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == ENTITY_DECL\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_ENTITY_VALUE:
|
case XML_PARSER_ENTITY_VALUE:
|
||||||
fprintf(stderr, "HPP: internal error, state == ENTITY_VALUE\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == ENTITY_VALUE\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering DTD\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering DTD\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_ATTRIBUTE_VALUE:
|
case XML_PARSER_ATTRIBUTE_VALUE:
|
||||||
fprintf(stderr, "HPP: internal error, state == ATTRIBUTE_VALUE\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == ATTRIBUTE_VALUE\n");
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_SYSTEM_LITERAL:
|
case XML_PARSER_SYSTEM_LITERAL:
|
||||||
fprintf(stderr, "HPP: internal error, state == XML_PARSER_SYSTEM_LITERAL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: internal error, state == XML_PARSER_SYSTEM_LITERAL\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"HPP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4454,7 +4531,7 @@ done:
|
|||||||
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
|
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: done %d\n", ret);
|
xmlGenericError(xmlGenericErrorContext, "HPP: done %d\n", ret);
|
||||||
#endif
|
#endif
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@ -4495,7 +4572,7 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
|
|||||||
ctxt->input->base = ctxt->input->buf->buffer->content + base;
|
ctxt->input->base = ctxt->input->buf->buffer->content + base;
|
||||||
ctxt->input->cur = ctxt->input->base + cur;
|
ctxt->input->cur = ctxt->input->base + cur;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: pushed %d\n", size);
|
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((terminate) || (ctxt->input->buf->buffer->use > 80))
|
if ((terminate) || (ctxt->input->buf->buffer->use > 80))
|
||||||
@ -4602,7 +4679,7 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
|
|||||||
(ctxt->input->buf != NULL)) {
|
(ctxt->input->buf != NULL)) {
|
||||||
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "HPP: pushed %d\n", size);
|
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
HTMLtree.c
37
HTMLtree.c
@ -31,6 +31,7 @@
|
|||||||
#include <libxml/HTMLtree.h>
|
#include <libxml/HTMLtree.h>
|
||||||
#include <libxml/entities.h>
|
#include <libxml/entities.h>
|
||||||
#include <libxml/valid.h>
|
#include <libxml/valid.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
@ -335,7 +336,8 @@ htmlDtdDump(xmlBufferPtr buf, xmlDocPtr doc) {
|
|||||||
xmlDtdPtr cur = doc->intSubset;
|
xmlDtdPtr cur = doc->intSubset;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlDtdDump : no internal subset\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlDtdDump : no internal subset\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlBufferWriteChar(buf, "<!DOCTYPE ");
|
xmlBufferWriteChar(buf, "<!DOCTYPE ");
|
||||||
@ -367,7 +369,8 @@ htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
|
|||||||
xmlChar *value;
|
xmlChar *value;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlAttrDump : property == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlAttrDump : property == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlBufferWriteChar(buf, " ");
|
xmlBufferWriteChar(buf, " ");
|
||||||
@ -395,7 +398,8 @@ htmlAttrDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
|
|||||||
static void
|
static void
|
||||||
htmlAttrListDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
|
htmlAttrListDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlAttrListDump : property == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlAttrListDump : property == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
@ -418,7 +422,8 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur);
|
|||||||
static void
|
static void
|
||||||
htmlNodeListDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
htmlNodeListDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlNodeListDump : node == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlNodeListDump : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
@ -440,7 +445,8 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
htmlElemDescPtr info;
|
htmlElemDescPtr info;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlNodeDump : node == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlNodeDump : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -624,7 +630,8 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
|
|||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
fprintf(stderr, "htmlxmlDocDumpMemory : document == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlxmlDocDumpMemory : document == NULL\n");
|
||||||
#endif
|
#endif
|
||||||
*mem = NULL;
|
*mem = NULL;
|
||||||
*size = 0;
|
*size = 0;
|
||||||
@ -665,7 +672,8 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, const char *encoding) {
|
|||||||
xmlDtdPtr cur = doc->intSubset;
|
xmlDtdPtr cur = doc->intSubset;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlDtdDump : no internal subset\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlDtdDump : no internal subset\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlOutputBufferWriteString(buf, "<!DOCTYPE ");
|
xmlOutputBufferWriteString(buf, "<!DOCTYPE ");
|
||||||
@ -697,7 +705,8 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const
|
|||||||
xmlChar *value;
|
xmlChar *value;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlAttrDump : property == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlAttrDump : property == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlOutputBufferWriteString(buf, " ");
|
xmlOutputBufferWriteString(buf, " ");
|
||||||
@ -725,7 +734,8 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const
|
|||||||
static void
|
static void
|
||||||
htmlAttrListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const char *encoding) {
|
htmlAttrListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const char *encoding) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlAttrListDump : property == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlAttrListDump : property == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
@ -749,7 +759,8 @@ void htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
|||||||
static void
|
static void
|
||||||
htmlNodeListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const char *encoding) {
|
htmlNodeListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const char *encoding) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlNodeListDump : node == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlNodeListDump : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
@ -771,7 +782,8 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const
|
|||||||
htmlElemDescPtr info;
|
htmlElemDescPtr info;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "htmlNodeDump : node == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlNodeDump : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -971,7 +983,8 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
|
|||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
fprintf(stderr, "htmlDocDump : document == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"htmlDocDump : document == NULL\n");
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
127
SAX.c
127
SAX.c
@ -161,7 +161,8 @@ internalSubset(void *ctx, const xmlChar *name,
|
|||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
xmlDtdPtr dtd;
|
xmlDtdPtr dtd;
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.internalSubset(%s, %s, %s)\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.internalSubset(%s, %s, %s)\n",
|
||||||
name, ExternalID, SystemID);
|
name, ExternalID, SystemID);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -194,7 +195,8 @@ externalSubset(void *ctx, const xmlChar *name,
|
|||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.externalSubset(%s, %s, %s)\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.externalSubset(%s, %s, %s)\n",
|
||||||
name, ExternalID, SystemID);
|
name, ExternalID, SystemID);
|
||||||
#endif
|
#endif
|
||||||
if (((ExternalID != NULL) || (SystemID != NULL)) &&
|
if (((ExternalID != NULL) || (SystemID != NULL)) &&
|
||||||
@ -323,7 +325,8 @@ resolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
|
|||||||
URI = xmlBuildURI(systemId, (const xmlChar *) base);
|
URI = xmlBuildURI(systemId, (const xmlChar *) base);
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.resolveEntity(%s, %s)\n", publicId, systemId);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.resolveEntity(%s, %s)\n", publicId, systemId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = xmlLoadExternalEntity((const char *) URI,
|
ret = xmlLoadExternalEntity((const char *) URI,
|
||||||
@ -349,7 +352,8 @@ getEntity(void *ctx, const xmlChar *name)
|
|||||||
xmlEntityPtr ret;
|
xmlEntityPtr ret;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.getEntity(%s)\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.getEntity(%s)\n", name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = xmlGetDocEntity(ctxt->myDoc, name);
|
ret = xmlGetDocEntity(ctxt->myDoc, name);
|
||||||
@ -385,7 +389,8 @@ getParameterEntity(void *ctx, const xmlChar *name)
|
|||||||
xmlEntityPtr ret;
|
xmlEntityPtr ret;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.getParameterEntity(%s)\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.getParameterEntity(%s)\n", name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = xmlGetParameterEntity(ctxt->myDoc, name);
|
ret = xmlGetParameterEntity(ctxt->myDoc, name);
|
||||||
@ -412,7 +417,8 @@ entityDecl(void *ctx, const xmlChar *name, int type,
|
|||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.entityDecl(%s, %d, %s, %s, %s)\n",
|
||||||
name, type, publicId, systemId, content);
|
name, type, publicId, systemId, content);
|
||||||
#endif
|
#endif
|
||||||
if (ctxt->inSubset == 1) {
|
if (ctxt->inSubset == 1) {
|
||||||
@ -482,7 +488,8 @@ attributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
|
|||||||
xmlChar *name = NULL, *prefix = NULL;
|
xmlChar *name = NULL, *prefix = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
|
||||||
elem, fullname, type, def, defaultValue);
|
elem, fullname, type, def, defaultValue);
|
||||||
#endif
|
#endif
|
||||||
name = xmlSplitQName(ctxt, fullname, &prefix);
|
name = xmlSplitQName(ctxt, fullname, &prefix);
|
||||||
@ -528,7 +535,8 @@ elementDecl(void *ctx, const xmlChar *name, int type,
|
|||||||
xmlElementPtr elem = NULL;
|
xmlElementPtr elem = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.elementDecl(%s, %d, ...)\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.elementDecl(%s, %d, ...)\n",
|
||||||
fullname, type);
|
fullname, type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -567,7 +575,8 @@ notationDecl(void *ctx, const xmlChar *name,
|
|||||||
xmlNotationPtr nota = NULL;
|
xmlNotationPtr nota = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ctxt->inSubset == 1)
|
if (ctxt->inSubset == 1)
|
||||||
@ -606,7 +615,8 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
|
|||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
|
||||||
name, publicId, systemId, notationName);
|
name, publicId, systemId, notationName);
|
||||||
#endif
|
#endif
|
||||||
if (ctxt->validate && ctxt->wellFormed &&
|
if (ctxt->validate && ctxt->wellFormed &&
|
||||||
@ -631,7 +641,8 @@ setDocumentLocator(void *ctx, xmlSAXLocatorPtr loc)
|
|||||||
{
|
{
|
||||||
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.setDocumentLocator()\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.setDocumentLocator()\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -648,14 +659,16 @@ startDocument(void *ctx)
|
|||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.startDocument()\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.startDocument()\n");
|
||||||
#endif
|
#endif
|
||||||
if (ctxt->html) {
|
if (ctxt->html) {
|
||||||
if (ctxt->myDoc == NULL)
|
if (ctxt->myDoc == NULL)
|
||||||
#ifdef LIBXML_HTML_ENABLED
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
|
ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, "libxml2 built without HTML support\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"libxml2 built without HTML support\n");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
|
doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
|
||||||
@ -684,7 +697,8 @@ endDocument(void *ctx)
|
|||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.endDocument()\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.endDocument()\n");
|
||||||
#endif
|
#endif
|
||||||
if (ctxt->validate && ctxt->wellFormed &&
|
if (ctxt->validate && ctxt->wellFormed &&
|
||||||
ctxt->myDoc && ctxt->myDoc->intSubset)
|
ctxt->myDoc && ctxt->myDoc->intSubset)
|
||||||
@ -731,7 +745,8 @@ attribute(void *ctx, const xmlChar *fullname, const xmlChar *value)
|
|||||||
|
|
||||||
/****************
|
/****************
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.attribute(%s, %s)\n", fullname, value);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.attribute(%s, %s)\n", fullname, value);
|
||||||
#endif
|
#endif
|
||||||
****************/
|
****************/
|
||||||
/*
|
/*
|
||||||
@ -897,7 +912,8 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.startElement(%s)\n", fullname);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.startElement(%s)\n", fullname);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -932,7 +948,7 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||||||
if (ret == NULL) return;
|
if (ret == NULL) return;
|
||||||
if (ctxt->myDoc->children == NULL) {
|
if (ctxt->myDoc->children == NULL) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "Setting %s as root\n", name);
|
xmlGenericError(xmlGenericErrorContext, "Setting %s as root\n", name);
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||||
} else if (parent == NULL) {
|
} else if (parent == NULL) {
|
||||||
@ -944,7 +960,7 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||||||
* We are parsing a new node.
|
* We are parsing a new node.
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "pushing(%s)\n", name);
|
xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
|
||||||
#endif
|
#endif
|
||||||
nodePush(ctxt, ret);
|
nodePush(ctxt, ret);
|
||||||
|
|
||||||
@ -954,12 +970,14 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
if (parent->type == XML_ELEMENT_NODE) {
|
if (parent->type == XML_ELEMENT_NODE) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "adding child %s to %s\n", name, parent->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"adding child %s to %s\n", name, parent->name);
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild(parent, ret);
|
xmlAddChild(parent, ret);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "adding sibling %s to ", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"adding sibling %s to ", name);
|
||||||
xmlDebugDumpOneNode(stderr, parent, 0);
|
xmlDebugDumpOneNode(stderr, parent, 0);
|
||||||
#endif
|
#endif
|
||||||
xmlAddSibling(parent, ret);
|
xmlAddSibling(parent, ret);
|
||||||
@ -1059,9 +1077,9 @@ endElement(void *ctx, const xmlChar *name)
|
|||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
fprintf(stderr, "SAX.endElement(NULL)\n");
|
xmlGenericError(xmlGenericErrorContext, "SAX.endElement(NULL)\n");
|
||||||
else
|
else
|
||||||
fprintf(stderr, "SAX.endElement(%s)\n", name);
|
xmlGenericError(xmlGenericErrorContext, "SAX.endElement(%s)\n", name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Capture end position and add node */
|
/* Capture end position and add node */
|
||||||
@ -1083,7 +1101,7 @@ endElement(void *ctx, const xmlChar *name)
|
|||||||
* end of parsing of this node.
|
* end of parsing of this node.
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "popping(%s)\n", cur->name);
|
xmlGenericError(xmlGenericErrorContext, "popping(%s)\n", cur->name);
|
||||||
#endif
|
#endif
|
||||||
nodePop(ctxt);
|
nodePop(ctxt);
|
||||||
}
|
}
|
||||||
@ -1102,14 +1120,16 @@ reference(void *ctx, const xmlChar *name)
|
|||||||
xmlNodePtr ret;
|
xmlNodePtr ret;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.reference(%s)\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.reference(%s)\n", name);
|
||||||
#endif
|
#endif
|
||||||
if (name[0] == '#')
|
if (name[0] == '#')
|
||||||
ret = xmlNewCharRef(ctxt->myDoc, name);
|
ret = xmlNewCharRef(ctxt->myDoc, name);
|
||||||
else
|
else
|
||||||
ret = xmlNewReference(ctxt->myDoc, name);
|
ret = xmlNewReference(ctxt->myDoc, name);
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "add reference %s to %s \n", name, ctxt->node->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"add reference %s to %s \n", name, ctxt->node->name);
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild(ctxt->node, ret);
|
xmlAddChild(ctxt->node, ret);
|
||||||
}
|
}
|
||||||
@ -1130,7 +1150,8 @@ characters(void *ctx, const xmlChar *ch, int len)
|
|||||||
xmlNodePtr lastChild;
|
xmlNodePtr lastChild;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.characters(%.30s, %d)\n", ch, len);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.characters(%.30s, %d)\n", ch, len);
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* Handle the data if any. If there is no child
|
* Handle the data if any. If there is no child
|
||||||
@ -1140,13 +1161,15 @@ characters(void *ctx, const xmlChar *ch, int len)
|
|||||||
|
|
||||||
if (ctxt->node == NULL) {
|
if (ctxt->node == NULL) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "add chars: ctxt->node == NULL !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"add chars: ctxt->node == NULL !\n");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastChild = xmlGetLastChild(ctxt->node);
|
lastChild = xmlGetLastChild(ctxt->node);
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "add chars to %s \n", ctxt->node->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"add chars to %s \n", ctxt->node->name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1222,7 +1245,8 @@ ignorableWhitespace(void *ctx, const xmlChar *ch, int len)
|
|||||||
{
|
{
|
||||||
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.ignorableWhitespace(%.30s, %d)\n", ch, len);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.ignorableWhitespace(%.30s, %d)\n", ch, len);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1243,7 +1267,8 @@ processingInstruction(void *ctx, const xmlChar *target,
|
|||||||
xmlNodePtr parent = ctxt->node;
|
xmlNodePtr parent = ctxt->node;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.processingInstruction(%s, %s)\n", target, data);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.processingInstruction(%s, %s)\n", target, data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret = xmlNewPI(target, data);
|
ret = xmlNewPI(target, data);
|
||||||
@ -1259,19 +1284,22 @@ processingInstruction(void *ctx, const xmlChar *target,
|
|||||||
}
|
}
|
||||||
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "Setting PI %s as root\n", target);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Setting PI %s as root\n", target);
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parent->type == XML_ELEMENT_NODE) {
|
if (parent->type == XML_ELEMENT_NODE) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "adding PI %s child to %s\n", target, parent->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"adding PI %s child to %s\n", target, parent->name);
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild(parent, ret);
|
xmlAddChild(parent, ret);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "adding PI %s sibling to ", target);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"adding PI %s sibling to ", target);
|
||||||
xmlDebugDumpOneNode(stderr, parent, 0);
|
xmlDebugDumpOneNode(stderr, parent, 0);
|
||||||
#endif
|
#endif
|
||||||
xmlAddSibling(parent, ret);
|
xmlAddSibling(parent, ret);
|
||||||
@ -1291,7 +1319,8 @@ globalNamespace(void *ctx, const xmlChar *href, const xmlChar *prefix)
|
|||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.globalNamespace(%s, %s)\n", href, prefix);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.globalNamespace(%s, %s)\n", href, prefix);
|
||||||
#endif
|
#endif
|
||||||
xmlNewGlobalNs(ctxt->myDoc, href, prefix);
|
xmlNewGlobalNs(ctxt->myDoc, href, prefix);
|
||||||
}
|
}
|
||||||
@ -1312,7 +1341,7 @@ setNamespace(void *ctx, const xmlChar *name)
|
|||||||
xmlNodePtr parent;
|
xmlNodePtr parent;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.setNamespace(%s)\n", name);
|
xmlGenericError(xmlGenericErrorContext, "SAX.setNamespace(%s)\n", name);
|
||||||
#endif
|
#endif
|
||||||
ns = xmlSearchNs(ctxt->myDoc, ctxt->node, name);
|
ns = xmlSearchNs(ctxt->myDoc, ctxt->node, name);
|
||||||
if (ns == NULL) { /* ctxt->node may not have a parent yet ! */
|
if (ns == NULL) { /* ctxt->node may not have a parent yet ! */
|
||||||
@ -1341,7 +1370,7 @@ getNamespace(void *ctx)
|
|||||||
xmlNsPtr ret;
|
xmlNsPtr ret;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.getNamespace()\n");
|
xmlGenericError(xmlGenericErrorContext, "SAX.getNamespace()\n");
|
||||||
#endif
|
#endif
|
||||||
ret = ctxt->node->ns;
|
ret = ctxt->node->ns;
|
||||||
return(ret);
|
return(ret);
|
||||||
@ -1365,7 +1394,8 @@ checkNamespace(void *ctx, xmlChar *namespace)
|
|||||||
xmlNodePtr cur = ctxt->node;
|
xmlNodePtr cur = ctxt->node;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.checkNamespace(%s)\n", namespace);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.checkNamespace(%s)\n", namespace);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1412,9 +1442,11 @@ namespaceDecl(void *ctx, const xmlChar *href, const xmlChar *prefix)
|
|||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
if (prefix == NULL)
|
if (prefix == NULL)
|
||||||
fprintf(stderr, "SAX.namespaceDecl(%s, NULL)\n", href);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.namespaceDecl(%s, NULL)\n", href);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "SAX.namespaceDecl(%s, %s)\n", href, prefix);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.namespaceDecl(%s, %s)\n", href, prefix);
|
||||||
#endif
|
#endif
|
||||||
xmlNewNs(ctxt->node, href, prefix);
|
xmlNewNs(ctxt->node, href, prefix);
|
||||||
}
|
}
|
||||||
@ -1434,7 +1466,7 @@ comment(void *ctx, const xmlChar *value)
|
|||||||
xmlNodePtr parent = ctxt->node;
|
xmlNodePtr parent = ctxt->node;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.comment(%s)\n", value);
|
xmlGenericError(xmlGenericErrorContext, "SAX.comment(%s)\n", value);
|
||||||
#endif
|
#endif
|
||||||
ret = xmlNewDocComment(ctxt->myDoc, value);
|
ret = xmlNewDocComment(ctxt->myDoc, value);
|
||||||
if (ret == NULL) return;
|
if (ret == NULL) return;
|
||||||
@ -1448,19 +1480,22 @@ comment(void *ctx, const xmlChar *value)
|
|||||||
}
|
}
|
||||||
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "Setting comment as root\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Setting comment as root\n");
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parent->type == XML_ELEMENT_NODE) {
|
if (parent->type == XML_ELEMENT_NODE) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "adding comment child to %s\n", parent->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"adding comment child to %s\n", parent->name);
|
||||||
#endif
|
#endif
|
||||||
xmlAddChild(parent, ret);
|
xmlAddChild(parent, ret);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "adding comment sibling to ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"adding comment sibling to ");
|
||||||
xmlDebugDumpOneNode(stderr, parent, 0);
|
xmlDebugDumpOneNode(stderr, parent, 0);
|
||||||
#endif
|
#endif
|
||||||
xmlAddSibling(parent, ret);
|
xmlAddSibling(parent, ret);
|
||||||
@ -1482,11 +1517,13 @@ cdataBlock(void *ctx, const xmlChar *value, int len)
|
|||||||
xmlNodePtr ret, lastChild;
|
xmlNodePtr ret, lastChild;
|
||||||
|
|
||||||
#ifdef DEBUG_SAX
|
#ifdef DEBUG_SAX
|
||||||
fprintf(stderr, "SAX.pcdata(%.10s, %d)\n", value, len);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"SAX.pcdata(%.10s, %d)\n", value, len);
|
||||||
#endif
|
#endif
|
||||||
lastChild = xmlGetLastChild(ctxt->node);
|
lastChild = xmlGetLastChild(ctxt->node);
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
fprintf(stderr, "add chars to %s \n", ctxt->node->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"add chars to %s \n", ctxt->node->name);
|
||||||
#endif
|
#endif
|
||||||
if ((lastChild != NULL) &&
|
if ((lastChild != NULL) &&
|
||||||
(lastChild->type == XML_CDATA_SECTION_NODE)) {
|
(lastChild->type == XML_CDATA_SECTION_NODE)) {
|
||||||
|
120
debugXML.c
120
debugXML.c
@ -31,6 +31,7 @@
|
|||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
#include <libxml/HTMLtree.h>
|
#include <libxml/HTMLtree.h>
|
||||||
#include <libxml/HTMLparser.h>
|
#include <libxml/HTMLparser.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#define IS_BLANK(c) \
|
#define IS_BLANK(c) \
|
||||||
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
|
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
|
||||||
@ -1203,31 +1204,36 @@ xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
|
|||||||
if (node == NULL)
|
if (node == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
if ((filename == NULL) || (filename[0] == 0)) {
|
if ((filename == NULL) || (filename[0] == 0)) {
|
||||||
fprintf(stderr, "Write command requires a filename argument\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Write command requires a filename argument\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#ifdef W_OK
|
#ifdef W_OK
|
||||||
if (access((char *) filename, W_OK)) {
|
if (access((char *) filename, W_OK)) {
|
||||||
fprintf(stderr, "Cannot write to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Cannot write to %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
switch(node->type) {
|
switch(node->type) {
|
||||||
case XML_DOCUMENT_NODE:
|
case XML_DOCUMENT_NODE:
|
||||||
if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
|
if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
|
||||||
fprintf(stderr, "Failed to write to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to write to %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_HTML_DOCUMENT_NODE:
|
case XML_HTML_DOCUMENT_NODE:
|
||||||
#ifdef LIBXML_HTML_ENABLED
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
||||||
fprintf(stderr, "Failed to write to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to write to %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
|
if (xmlSaveFile((char *) filename, ctxt->doc) < -1) {
|
||||||
fprintf(stderr, "Failed to write to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to write to %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_HTML_ENABLED */
|
#endif /* LIBXML_HTML_ENABLED */
|
||||||
@ -1237,7 +1243,8 @@ xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
|
|||||||
|
|
||||||
f = fopen((char *) filename, "w");
|
f = fopen((char *) filename, "w");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
fprintf(stderr, "Failed to write to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to write to %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
xmlElemDump(f, ctxt->doc, node);
|
xmlElemDump(f, ctxt->doc, node);
|
||||||
@ -1268,29 +1275,33 @@ xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
|
|||||||
filename = ctxt->filename;
|
filename = ctxt->filename;
|
||||||
#ifdef W_OK
|
#ifdef W_OK
|
||||||
if (access((char *) filename, W_OK)) {
|
if (access((char *) filename, W_OK)) {
|
||||||
fprintf(stderr, "Cannot save to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Cannot save to %s\n", filename);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
switch(ctxt->doc->type) {
|
switch(ctxt->doc->type) {
|
||||||
case XML_DOCUMENT_NODE:
|
case XML_DOCUMENT_NODE:
|
||||||
if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
||||||
fprintf(stderr, "Failed to save to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to save to %s\n", filename);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_HTML_DOCUMENT_NODE:
|
case XML_HTML_DOCUMENT_NODE:
|
||||||
#ifdef LIBXML_HTML_ENABLED
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
if (htmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
||||||
fprintf(stderr, "Failed to save to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to save to %s\n", filename);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
if (xmlSaveFile((char *) filename, ctxt->doc) < 0) {
|
||||||
fprintf(stderr, "Failed to save to %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to save to %s\n", filename);
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_HTML_ENABLED */
|
#endif /* LIBXML_HTML_ENABLED */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"To save to subparts of a document use the 'write' command\n");
|
"To save to subparts of a document use the 'write' command\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
@ -1653,7 +1664,8 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
if (list != NULL) {
|
if (list != NULL) {
|
||||||
switch (list->type) {
|
switch (list->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
fprintf(stderr, "%s: no such node\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET: {
|
case XPATH_NODESET: {
|
||||||
int i;
|
int i;
|
||||||
@ -1669,30 +1681,38 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XPATH_BOOLEAN:
|
case XPATH_BOOLEAN:
|
||||||
fprintf(stderr, "%s is a Boolean\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a Boolean\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_NUMBER:
|
case XPATH_NUMBER:
|
||||||
fprintf(stderr, "%s is a number\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a number\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_STRING:
|
case XPATH_STRING:
|
||||||
fprintf(stderr, "%s is a string\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a string\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_POINT:
|
case XPATH_POINT:
|
||||||
fprintf(stderr, "%s is a point\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a point\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_RANGE:
|
case XPATH_RANGE:
|
||||||
fprintf(stderr, "%s is a range\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_LOCATIONSET:
|
case XPATH_LOCATIONSET:
|
||||||
fprintf(stderr, "%s is a range\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_USERS:
|
case XPATH_USERS:
|
||||||
fprintf(stderr, "%s is user-defined\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is user-defined\n", arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xmlXPathFreeNodeSetList(list);
|
xmlXPathFreeNodeSetList(list);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: no such node\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
}
|
}
|
||||||
ctxt->pctxt->node = NULL;
|
ctxt->pctxt->node = NULL;
|
||||||
}
|
}
|
||||||
@ -1709,40 +1729,50 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
if (list != NULL) {
|
if (list != NULL) {
|
||||||
switch (list->type) {
|
switch (list->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
fprintf(stderr, "%s: no such node\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
if (list->nodesetval->nodeNr == 1) {
|
if (list->nodesetval->nodeNr == 1) {
|
||||||
ctxt->node = list->nodesetval->nodeTab[0];
|
ctxt->node = list->nodesetval->nodeTab[0];
|
||||||
} else
|
} else
|
||||||
fprintf(stderr, "%s is a %d Node Set\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a %d Node Set\n",
|
||||||
arg, list->nodesetval->nodeNr);
|
arg, list->nodesetval->nodeNr);
|
||||||
break;
|
break;
|
||||||
case XPATH_BOOLEAN:
|
case XPATH_BOOLEAN:
|
||||||
fprintf(stderr, "%s is a Boolean\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a Boolean\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_NUMBER:
|
case XPATH_NUMBER:
|
||||||
fprintf(stderr, "%s is a number\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a number\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_STRING:
|
case XPATH_STRING:
|
||||||
fprintf(stderr, "%s is a string\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a string\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_POINT:
|
case XPATH_POINT:
|
||||||
fprintf(stderr, "%s is a point\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a point\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_RANGE:
|
case XPATH_RANGE:
|
||||||
fprintf(stderr, "%s is a range\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_LOCATIONSET:
|
case XPATH_LOCATIONSET:
|
||||||
fprintf(stderr, "%s is a range\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_USERS:
|
case XPATH_USERS:
|
||||||
fprintf(stderr, "%s is user-defined\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is user-defined\n", arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xmlXPathFreeNodeSetList(list);
|
xmlXPathFreeNodeSetList(list);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: no such node\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
}
|
}
|
||||||
ctxt->pctxt->node = NULL;
|
ctxt->pctxt->node = NULL;
|
||||||
}
|
}
|
||||||
@ -1760,7 +1790,8 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
if (list != NULL) {
|
if (list != NULL) {
|
||||||
switch (list->type) {
|
switch (list->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
fprintf(stderr, "%s: no such node\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET: {
|
case XPATH_NODESET: {
|
||||||
int i;
|
int i;
|
||||||
@ -1773,35 +1804,44 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XPATH_BOOLEAN:
|
case XPATH_BOOLEAN:
|
||||||
fprintf(stderr, "%s is a Boolean\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a Boolean\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_NUMBER:
|
case XPATH_NUMBER:
|
||||||
fprintf(stderr, "%s is a number\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a number\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_STRING:
|
case XPATH_STRING:
|
||||||
fprintf(stderr, "%s is a string\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a string\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_POINT:
|
case XPATH_POINT:
|
||||||
fprintf(stderr, "%s is a point\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a point\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_RANGE:
|
case XPATH_RANGE:
|
||||||
fprintf(stderr, "%s is a range\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_LOCATIONSET:
|
case XPATH_LOCATIONSET:
|
||||||
fprintf(stderr, "%s is a range\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
break;
|
break;
|
||||||
case XPATH_USERS:
|
case XPATH_USERS:
|
||||||
fprintf(stderr, "%s is user-defined\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is user-defined\n", arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
xmlXPathFreeNodeSetList(list);
|
xmlXPathFreeNodeSetList(list);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: no such node\n", arg);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
}
|
}
|
||||||
ctxt->pctxt->node = NULL;
|
ctxt->pctxt->node = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Unknown command %s\n", command);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Unknown command %s\n", command);
|
||||||
}
|
}
|
||||||
free(cmdline); /* not xmlFree here ! */
|
free(cmdline); /* not xmlFree here ! */
|
||||||
}
|
}
|
||||||
|
107
encoding.c
107
encoding.c
@ -46,6 +46,7 @@
|
|||||||
#ifdef LIBXML_HTML_ENABLED
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
#include <libxml/HTMLparser.h>
|
#include <libxml/HTMLparser.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
|
xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
|
||||||
xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
|
xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
|
||||||
@ -585,7 +586,8 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
|
|||||||
*outlen = 2;
|
*outlen = 2;
|
||||||
*inlen = 0;
|
*inlen = 0;
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "Added FFFE Byte Order Mark\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Added FFFE Byte Order Mark\n");
|
||||||
#endif
|
#endif
|
||||||
return(2);
|
return(2);
|
||||||
}
|
}
|
||||||
@ -795,7 +797,8 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
|
|||||||
*outlen = 2;
|
*outlen = 2;
|
||||||
*inlen = 0;
|
*inlen = 0;
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "Added FEFF Byte Order Mark\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Added FEFF Byte Order Mark\n");
|
||||||
#endif
|
#endif
|
||||||
return(2);
|
return(2);
|
||||||
}
|
}
|
||||||
@ -1146,7 +1149,7 @@ xmlParseCharEncoding(const char* name)
|
|||||||
if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
|
if (!strcmp(upper, "EUC-JP")) return(XML_CHAR_ENCODING_EUC_JP);
|
||||||
|
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "Unknown encoding %s\n", name);
|
xmlGenericError(xmlGenericErrorContext, "Unknown encoding %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
return(XML_CHAR_ENCODING_ERROR);
|
return(XML_CHAR_ENCODING_ERROR);
|
||||||
}
|
}
|
||||||
@ -1265,7 +1268,8 @@ xmlNewCharEncodingHandler(const char *name,
|
|||||||
* Keep only the uppercase version of the encoding.
|
* Keep only the uppercase version of the encoding.
|
||||||
*/
|
*/
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
fprintf(stderr, "xmlNewCharEncodingHandler : no name !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewCharEncodingHandler : no name !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
for (i = 0;i < 499;i++) {
|
for (i = 0;i < 499;i++) {
|
||||||
@ -1275,7 +1279,8 @@ xmlNewCharEncodingHandler(const char *name,
|
|||||||
upper[i] = 0;
|
upper[i] = 0;
|
||||||
up = xmlMemStrdup(upper);
|
up = xmlMemStrdup(upper);
|
||||||
if (up == NULL) {
|
if (up == NULL) {
|
||||||
fprintf(stderr, "xmlNewCharEncodingHandler : out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewCharEncodingHandler : out of memory !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1285,7 +1290,8 @@ xmlNewCharEncodingHandler(const char *name,
|
|||||||
handler = (xmlCharEncodingHandlerPtr)
|
handler = (xmlCharEncodingHandlerPtr)
|
||||||
xmlMalloc(sizeof(xmlCharEncodingHandler));
|
xmlMalloc(sizeof(xmlCharEncodingHandler));
|
||||||
if (handler == NULL) {
|
if (handler == NULL) {
|
||||||
fprintf(stderr, "xmlNewCharEncodingHandler : out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewCharEncodingHandler : out of memory !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
handler->input = input;
|
handler->input = input;
|
||||||
@ -1302,7 +1308,8 @@ xmlNewCharEncodingHandler(const char *name,
|
|||||||
*/
|
*/
|
||||||
xmlRegisterCharEncodingHandler(handler);
|
xmlRegisterCharEncodingHandler(handler);
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "Registered encoding handler for %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Registered encoding handler for %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
return(handler);
|
return(handler);
|
||||||
}
|
}
|
||||||
@ -1327,10 +1334,12 @@ xmlInitCharEncodingHandlers(void) {
|
|||||||
|
|
||||||
if (*ptr == 0x12) xmlLittleEndian = 0;
|
if (*ptr == 0x12) xmlLittleEndian = 0;
|
||||||
else if (*ptr == 0x34) xmlLittleEndian = 1;
|
else if (*ptr == 0x34) xmlLittleEndian = 1;
|
||||||
else fprintf(stderr, "Odd problem at endianness detection\n");
|
else xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Odd problem at endianness detection\n");
|
||||||
|
|
||||||
if (handlers == NULL) {
|
if (handlers == NULL) {
|
||||||
fprintf(stderr, "xmlInitCharEncodingHandlers : out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitCharEncodingHandlers : out of memory !\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlNewCharEncodingHandler("UTF-8", NULL, NULL);
|
xmlNewCharEncodingHandler("UTF-8", NULL, NULL);
|
||||||
@ -1381,14 +1390,16 @@ void
|
|||||||
xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
|
xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
|
||||||
if (handlers == NULL) xmlInitCharEncodingHandlers();
|
if (handlers == NULL) xmlInitCharEncodingHandlers();
|
||||||
if (handler == NULL) {
|
if (handler == NULL) {
|
||||||
fprintf(stderr, "xmlRegisterCharEncodingHandler: NULL handler !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlRegisterCharEncodingHandler: NULL handler !\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
|
if (nbCharEncodingHandler >= MAX_ENCODING_HANDLERS) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlRegisterCharEncodingHandler: Too many handler registered\n");
|
"xmlRegisterCharEncodingHandler: Too many handler registered\n");
|
||||||
fprintf(stderr, "\tincrease MAX_ENCODING_HANDLERS : %s\n", __FILE__);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"\tincrease MAX_ENCODING_HANDLERS : %s\n", __FILE__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
handlers[nbCharEncodingHandler++] = handler;
|
handlers[nbCharEncodingHandler++] = handler;
|
||||||
@ -1518,7 +1529,8 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "No handler found for encoding %d\n", enc);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"No handler found for encoding %d\n", enc);
|
||||||
#endif
|
#endif
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -1567,7 +1579,8 @@ xmlFindCharEncodingHandler(const char *name) {
|
|||||||
for (i = 0;i < nbCharEncodingHandler; i++)
|
for (i = 0;i < nbCharEncodingHandler; i++)
|
||||||
if (!strcmp(upper, handlers[i]->name)) {
|
if (!strcmp(upper, handlers[i]->name)) {
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "Found registered handler for encoding %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Found registered handler for encoding %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
return(handlers[i]);
|
return(handlers[i]);
|
||||||
}
|
}
|
||||||
@ -1590,16 +1603,19 @@ xmlFindCharEncodingHandler(const char *name) {
|
|||||||
enc->iconv_in = icv_in;
|
enc->iconv_in = icv_in;
|
||||||
enc->iconv_out = icv_out;
|
enc->iconv_out = icv_out;
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "Found iconv handler for encoding %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Found iconv handler for encoding %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
return enc;
|
return enc;
|
||||||
} else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
|
} else if ((icv_in != (iconv_t) -1) || icv_out != (iconv_t) -1) {
|
||||||
fprintf(stderr, "iconv : problems with filters for '%s'\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"iconv : problems with filters for '%s'\n", name);
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_ICONV_ENABLED */
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
|
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "No handler found for encoding %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"No handler found for encoding %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1739,22 +1755,24 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
|||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case 0:
|
case 0:
|
||||||
fprintf(stderr, "converted %d bytes to %d bytes of input\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input\n",
|
||||||
toconv, written);
|
toconv, written);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
toconv, written, in->use);
|
toconv, written, in->use);
|
||||||
break;
|
break;
|
||||||
case -2:
|
case -2:
|
||||||
fprintf(stderr, "input conversion failed due to input error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"input conversion failed due to input error\n");
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
toconv, written, in->use);
|
toconv, written, in->use);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,"Unknown input conversion failed %d\n", ret);
|
xmlGenericError(xmlGenericErrorContext,"Unknown input conversion failed %d\n", ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
@ -1817,21 +1835,24 @@ xmlCharEncInFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
|||||||
switch (ret) {
|
switch (ret) {
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
case 0:
|
case 0:
|
||||||
fprintf(stderr, "converted %d bytes to %d bytes of input\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input\n",
|
||||||
toconv, written);
|
toconv, written);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
toconv, written, in->use);
|
toconv, written, in->use);
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
fprintf(stderr,"converted %d bytes to %d bytes of input, %d left\n",
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
toconv, written, in->use);
|
toconv, written, in->use);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case -2:
|
case -2:
|
||||||
fprintf(stderr, "input conversion failed due to input error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
fprintf(stderr, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
"input conversion failed due to input error\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||||
in->content[0], in->content[1],
|
in->content[0], in->content[1],
|
||||||
in->content[2], in->content[3]);
|
in->content[2], in->content[3]);
|
||||||
}
|
}
|
||||||
@ -1895,7 +1916,8 @@ retry:
|
|||||||
}
|
}
|
||||||
#endif /* LIBXML_ICONV_ENABLED */
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "initialized encoder\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"initialized encoder\n");
|
||||||
#endif
|
#endif
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -1928,7 +1950,8 @@ retry:
|
|||||||
}
|
}
|
||||||
#endif /* LIBXML_ICONV_ENABLED */
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "xmlCharEncOutFunc: no output function !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCharEncOutFunc: no output function !\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1940,14 +1963,16 @@ retry:
|
|||||||
switch (ret) {
|
switch (ret) {
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
case 0:
|
case 0:
|
||||||
fprintf(stderr, "converted %d bytes to %d bytes of output\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of output\n",
|
||||||
toconv, written);
|
toconv, written);
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
fprintf(stderr, "output conversion failed by lack of space\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"output conversion failed by lack of space\n");
|
||||||
break;
|
break;
|
||||||
case -3:
|
case -3:
|
||||||
fprintf(stderr,"converted %d bytes to %d bytes of output %d left\n",
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
|
||||||
toconv, written, in->use);
|
toconv, written, in->use);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -1961,8 +1986,10 @@ retry:
|
|||||||
xmlChar charref[20];
|
xmlChar charref[20];
|
||||||
|
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
fprintf(stderr, "handling output conversion error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
fprintf(stderr, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
"handling output conversion error\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||||
in->content[0], in->content[1],
|
in->content[0], in->content[1],
|
||||||
in->content[2], in->content[3]);
|
in->content[2], in->content[3]);
|
||||||
#endif
|
#endif
|
||||||
@ -1977,8 +2004,10 @@ retry:
|
|||||||
|
|
||||||
goto retry;
|
goto retry;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "output conversion failed due to conv error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
fprintf(stderr, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
"output conversion failed due to conv error\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||||
in->content[0], in->content[1],
|
in->content[0], in->content[1],
|
||||||
in->content[2], in->content[3]);
|
in->content[2], in->content[3]);
|
||||||
in->content[0] = ' ';
|
in->content[0] = ' ';
|
||||||
@ -2026,9 +2055,11 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
|
|||||||
#endif /* LIBXML_ICONV_ENABLED */
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
if (ret)
|
if (ret)
|
||||||
fprintf(stderr, "failed to close the encoding handler\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"failed to close the encoding handler\n");
|
||||||
else
|
else
|
||||||
fprintf(stderr, "closed the encoding handler\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"closed the encoding handler\n");
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return(ret);
|
return(ret);
|
||||||
|
33
entities.c
33
entities.c
@ -21,6 +21,7 @@
|
|||||||
#include <libxml/hash.h>
|
#include <libxml/hash.h>
|
||||||
#include <libxml/entities.h>
|
#include <libxml/entities.h>
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#define DEBUG_ENT_REF /* debugging of cross entities dependancies */
|
#define DEBUG_ENT_REF /* debugging of cross entities dependancies */
|
||||||
#define ENTITY_HASH_SIZE 256 /* modify xmlEntityComputeHash accordingly */
|
#define ENTITY_HASH_SIZE 256 /* modify xmlEntityComputeHash accordingly */
|
||||||
@ -122,7 +123,8 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAddEntity: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddEntity: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlEntity));
|
memset(ret, 0, sizeof(xmlEntity));
|
||||||
@ -236,12 +238,12 @@ xmlAddDtdEntity(xmlDocPtr doc, const xmlChar *name, int type,
|
|||||||
xmlDtdPtr dtd;
|
xmlDtdPtr dtd;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddDtdEntity: doc == NULL !\n");
|
"xmlAddDtdEntity: doc == NULL !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (doc->extSubset == NULL) {
|
if (doc->extSubset == NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddDtdEntity: document without external subset !\n");
|
"xmlAddDtdEntity: document without external subset !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -285,12 +287,12 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
|
|||||||
xmlDtdPtr dtd;
|
xmlDtdPtr dtd;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddDocEntity: document is NULL !\n");
|
"xmlAddDocEntity: document is NULL !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (doc->intSubset == NULL) {
|
if (doc->intSubset == NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddDtdEntity: document without internal subset !\n");
|
"xmlAddDtdEntity: document without internal subset !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -465,8 +467,10 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
|
|||||||
|
|
||||||
|
|
||||||
if (warning) {
|
if (warning) {
|
||||||
fprintf(stderr, "Deprecated API xmlEncodeEntities() used\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
fprintf(stderr, " change code to use xmlEncodeEntitiesReentrant()\n");
|
"Deprecated API xmlEncodeEntities() used\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" change code to use xmlEncodeEntitiesReentrant()\n");
|
||||||
warning = 0;
|
warning = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,7 +565,8 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
|
|||||||
* default case, this is not a valid char !
|
* default case, this is not a valid char !
|
||||||
* Skip it...
|
* Skip it...
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "xmlEncodeEntities: invalid char %d\n", (int) *cur);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlEncodeEntities: invalid char %d\n", (int) *cur);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cur++;
|
cur++;
|
||||||
@ -688,7 +693,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
|||||||
int val = 0, l = 1;
|
int val = 0, l = 1;
|
||||||
|
|
||||||
if (*cur < 0xC0) {
|
if (*cur < 0xC0) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlEncodeEntitiesReentrant : input not UTF-8\n");
|
"xmlEncodeEntitiesReentrant : input not UTF-8\n");
|
||||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
#ifdef HAVE_SNPRINTF
|
#ifdef HAVE_SNPRINTF
|
||||||
@ -723,7 +728,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
|||||||
l = 4;
|
l = 4;
|
||||||
}
|
}
|
||||||
if ((l == 1) || (!IS_CHAR(val))) {
|
if ((l == 1) || (!IS_CHAR(val))) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlEncodeEntitiesReentrant : char out of range\n");
|
"xmlEncodeEntitiesReentrant : char out of range\n");
|
||||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
#ifdef HAVE_SNPRINTF
|
#ifdef HAVE_SNPRINTF
|
||||||
@ -769,7 +774,8 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
|||||||
* default case, this is not a valid char !
|
* default case, this is not a valid char !
|
||||||
* Skip it...
|
* Skip it...
|
||||||
*/
|
*/
|
||||||
fprintf(stderr, "xmlEncodeEntities: invalid char %d\n", (int) *cur);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlEncodeEntities: invalid char %d\n", (int) *cur);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
cur++;
|
cur++;
|
||||||
@ -895,7 +901,8 @@ xmlCopyEntity(xmlEntityPtr ent) {
|
|||||||
|
|
||||||
cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
cur = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlCopyEntity: out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCopyEntity: out of memory !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlEntity));
|
memset(cur, 0, sizeof(xmlEntity));
|
||||||
@ -1008,7 +1015,7 @@ xmlDumpEntityDecl(xmlBufferPtr buf, xmlEntityPtr ent) {
|
|||||||
xmlBufferWriteChar(buf, ">\n");
|
xmlBufferWriteChar(buf, ">\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlDumpEntitiesTable: internal: unknown type %d\n",
|
"xmlDumpEntitiesTable: internal: unknown type %d\n",
|
||||||
ent->etype);
|
ent->etype);
|
||||||
}
|
}
|
||||||
|
101
error.c
101
error.c
@ -15,6 +15,64 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Handling of out of context errors *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlGenericErrorDefaultFunc:
|
||||||
|
* @ctx: an error context
|
||||||
|
* @msg: the message to display/transmit
|
||||||
|
* @...: extra parameters for the message display
|
||||||
|
*
|
||||||
|
* Default handler for out of context error messages.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (xmlGenericErrorContext == NULL)
|
||||||
|
xmlGenericErrorContext = (void *) stderr;
|
||||||
|
|
||||||
|
va_start(args, msg);
|
||||||
|
vfprintf((FILE *)xmlGenericErrorContext, msg, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlGenericErrorFunc xmlGenericError = xmlGenericErrorDefaultFunc;
|
||||||
|
void *xmlGenericErrorContext = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSetGenericErrorFunc:
|
||||||
|
* @ctx: the new error handling context
|
||||||
|
* @handler: the new handler function
|
||||||
|
*
|
||||||
|
* Function to reset the handler and the error context for out of
|
||||||
|
* context error messages.
|
||||||
|
* This simply means that @handler will be called for subsequent
|
||||||
|
* error messages while not parsing nor validating. And @ctx will
|
||||||
|
* be passed as first argument to @handler
|
||||||
|
* One can simply force messages to be emitted to another FILE * than
|
||||||
|
* stderr by setting @ctx to this file handle and @handler to NULL.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
|
||||||
|
if (ctx != NULL)
|
||||||
|
xmlGenericErrorContext = ctx;
|
||||||
|
if (handler != NULL)
|
||||||
|
xmlGenericError = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Handling of parsing errors *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlParserPrintFileInfo:
|
* xmlParserPrintFileInfo:
|
||||||
@ -27,10 +85,12 @@ void
|
|||||||
xmlParserPrintFileInfo(xmlParserInputPtr input) {
|
xmlParserPrintFileInfo(xmlParserInputPtr input) {
|
||||||
if (input != NULL) {
|
if (input != NULL) {
|
||||||
if (input->filename)
|
if (input->filename)
|
||||||
fprintf(stderr, "%s:%d: ", input->filename,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s:%d: ", input->filename,
|
||||||
input->line);
|
input->line);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Entity: line %d: ", input->line);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Entity: line %d: ", input->line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,19 +119,20 @@ xmlParserPrintFileContext(xmlParserInputPtr input) {
|
|||||||
base = cur;
|
base = cur;
|
||||||
n = 0;
|
n = 0;
|
||||||
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
|
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
|
||||||
fprintf(stderr, "%c", (unsigned char) *cur++);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%c", (unsigned char) *cur++);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
cur = input->cur;
|
cur = input->cur;
|
||||||
while ((*cur == '\n') || (*cur == '\r'))
|
while ((*cur == '\n') || (*cur == '\r'))
|
||||||
cur--;
|
cur--;
|
||||||
n = 0;
|
n = 0;
|
||||||
while ((cur != base) && (n++ < 80)) {
|
while ((cur != base) && (n++ < 80)) {
|
||||||
fprintf(stderr, " ");
|
xmlGenericError(xmlGenericErrorContext, " ");
|
||||||
base++;
|
base++;
|
||||||
}
|
}
|
||||||
fprintf(stderr,"^\n");
|
xmlGenericError(xmlGenericErrorContext,"^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,16 +162,16 @@ xmlParserError(void *ctx, const char *msg, ...)
|
|||||||
xmlParserPrintFileInfo(input);
|
xmlParserPrintFileInfo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "error: ");
|
xmlGenericError(xmlGenericErrorContext, "error: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(stderr, msg, args);
|
vfprintf(xmlGenericErrorContext, msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
xmlParserPrintFileContext(input);
|
xmlParserPrintFileContext(input);
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
xmlParserPrintFileInfo(cur);
|
xmlParserPrintFileInfo(cur);
|
||||||
fprintf(stderr, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
xmlParserPrintFileContext(cur);
|
xmlParserPrintFileContext(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,21 +204,28 @@ xmlParserWarning(void *ctx, const char *msg, ...)
|
|||||||
xmlParserPrintFileInfo(input);
|
xmlParserPrintFileInfo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "warning: ");
|
xmlGenericError(xmlGenericErrorContext, "warning: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(stderr, msg, args);
|
vfprintf(xmlGenericErrorContext, msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
xmlParserPrintFileContext(input);
|
xmlParserPrintFileContext(input);
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
xmlParserPrintFileInfo(cur);
|
xmlParserPrintFileInfo(cur);
|
||||||
fprintf(stderr, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
xmlParserPrintFileContext(cur);
|
xmlParserPrintFileContext(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Handling of validation errors *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlParserValidityError:
|
* xmlParserValidityError:
|
||||||
* @ctx: an XML parser context
|
* @ctx: an XML parser context
|
||||||
@ -182,9 +250,9 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
|||||||
xmlParserPrintFileInfo(input);
|
xmlParserPrintFileInfo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "validity error: ");
|
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(stderr, msg, args);
|
vfprintf(xmlGenericErrorContext, msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
@ -216,9 +284,9 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
|||||||
xmlParserPrintFileInfo(input);
|
xmlParserPrintFileInfo(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "validity warning: ");
|
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(stderr, msg, args);
|
vfprintf(xmlGenericErrorContext, msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
@ -226,3 +294,4 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,6 +135,30 @@ typedef enum {
|
|||||||
XML_ERR_URI_FRAGMENT /* 92 */
|
XML_ERR_URI_FRAGMENT /* 92 */
|
||||||
}xmlParserErrors;
|
}xmlParserErrors;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Signature of the function to use when there is an error and
|
||||||
|
* no parsing or validity context available
|
||||||
|
*/
|
||||||
|
typedef void (*xmlGenericErrorFunc) (void *ctx, const char *msg, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Those are the default error function and associated context to use
|
||||||
|
* when when there is an error and no parsing or validity context available
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern xmlGenericErrorFunc xmlGenericError;
|
||||||
|
extern void *xmlGenericErrorContext;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use the following function to reset the two previous global variables.
|
||||||
|
*/
|
||||||
|
void xmlSetGenericErrorFunc (void *ctx,
|
||||||
|
xmlGenericErrorFunc handler);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default message routines used by SAX and Valid context for error
|
||||||
|
* and warning reporting
|
||||||
|
*/
|
||||||
void xmlParserError (void *ctx,
|
void xmlParserError (void *ctx,
|
||||||
const char *msg,
|
const char *msg,
|
||||||
...);
|
...);
|
||||||
|
93
nanoftp.c
93
nanoftp.c
@ -63,6 +63,7 @@
|
|||||||
|
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/nanoftp.h>
|
#include <libxml/nanoftp.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
/* #define DEBUG_FTP 1 */
|
/* #define DEBUG_FTP 1 */
|
||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
@ -420,9 +421,9 @@ xmlNanoFTPScanProxy(const char *URL) {
|
|||||||
}
|
}
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
if (URL == NULL)
|
if (URL == NULL)
|
||||||
printf("Removing FTP proxy info\n");
|
xmlGenericError(xmlGenericErrorContext, "Removing FTP proxy info\n");
|
||||||
else
|
else
|
||||||
printf("Using FTP proxy %s\n", URL);
|
xmlGenericError(xmlGenericErrorContext, "Using FTP proxy %s\n", URL);
|
||||||
#endif
|
#endif
|
||||||
if (URL == NULL) return;
|
if (URL == NULL) return;
|
||||||
buf[index] = 0;
|
buf[index] = 0;
|
||||||
@ -567,7 +568,8 @@ xmlNanoFTPGetMore(void *ctx) {
|
|||||||
|
|
||||||
if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) {
|
if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) {
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("xmlNanoFTPGetMore : controlBufIndex = %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPGetMore : controlBufIndex = %d\n",
|
||||||
ctxt->controlBufIndex);
|
ctxt->controlBufIndex);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -575,14 +577,16 @@ xmlNanoFTPGetMore(void *ctx) {
|
|||||||
|
|
||||||
if ((ctxt->controlBufUsed < 0) || (ctxt->controlBufUsed > FTP_BUF_SIZE)) {
|
if ((ctxt->controlBufUsed < 0) || (ctxt->controlBufUsed > FTP_BUF_SIZE)) {
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("xmlNanoFTPGetMore : controlBufUsed = %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPGetMore : controlBufUsed = %d\n",
|
||||||
ctxt->controlBufUsed);
|
ctxt->controlBufUsed);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if (ctxt->controlBufIndex > ctxt->controlBufUsed) {
|
if (ctxt->controlBufIndex > ctxt->controlBufUsed) {
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("xmlNanoFTPGetMore : controlBufIndex > controlBufUsed %d > %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPGetMore : controlBufIndex > controlBufUsed %d > %d\n",
|
||||||
ctxt->controlBufIndex, ctxt->controlBufUsed);
|
ctxt->controlBufIndex, ctxt->controlBufUsed);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -600,7 +604,8 @@ xmlNanoFTPGetMore(void *ctx) {
|
|||||||
size = FTP_BUF_SIZE - ctxt->controlBufUsed;
|
size = FTP_BUF_SIZE - ctxt->controlBufUsed;
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("xmlNanoFTPGetMore : buffer full %d \n", ctxt->controlBufUsed);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPGetMore : buffer full %d \n", ctxt->controlBufUsed);
|
||||||
#endif
|
#endif
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -615,7 +620,8 @@ xmlNanoFTPGetMore(void *ctx) {
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("xmlNanoFTPGetMore : read %d [%d - %d]\n", len,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPGetMore : read %d [%d - %d]\n", len,
|
||||||
ctxt->controlBufUsed, ctxt->controlBufUsed + len);
|
ctxt->controlBufUsed, ctxt->controlBufUsed + len);
|
||||||
#endif
|
#endif
|
||||||
ctxt->controlBufUsed += len;
|
ctxt->controlBufUsed += len;
|
||||||
@ -651,7 +657,8 @@ get_more:
|
|||||||
end = &ctxt->controlBuf[ctxt->controlBufUsed];
|
end = &ctxt->controlBuf[ctxt->controlBufUsed];
|
||||||
|
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("\n<<<\n%s\n--\n", ptr);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"\n<<<\n%s\n--\n", ptr);
|
||||||
#endif
|
#endif
|
||||||
while (ptr < end) {
|
while (ptr < end) {
|
||||||
cur = xmlNanoFTPParseResponse(ctxt, ptr, end - ptr);
|
cur = xmlNanoFTPParseResponse(ctxt, ptr, end - ptr);
|
||||||
@ -681,11 +688,11 @@ get_more:
|
|||||||
ctxt->controlBufIndex = ptr - ctxt->controlBuf;
|
ctxt->controlBufIndex = ptr - ctxt->controlBuf;
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
ptr = &ctxt->controlBuf[ctxt->controlBufIndex];
|
ptr = &ctxt->controlBuf[ctxt->controlBufIndex];
|
||||||
printf("\n---\n%s\n--\n", ptr);
|
xmlGenericError(xmlGenericErrorContext, "\n---\n%s\n--\n", ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("Got %d\n", res);
|
xmlGenericError(xmlGenericErrorContext, "Got %d\n", res);
|
||||||
#endif
|
#endif
|
||||||
return(res / 100);
|
return(res / 100);
|
||||||
}
|
}
|
||||||
@ -761,7 +768,7 @@ xmlNanoFTPSendUser(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) return(res);
|
if (res < 0) return(res);
|
||||||
@ -794,7 +801,7 @@ xmlNanoFTPSendPasswd(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) return(res);
|
if (res < 0) return(res);
|
||||||
@ -821,7 +828,7 @@ xmlNanoFTPQuit(void *ctx) {
|
|||||||
sprintf(buf, "QUIT\r\n");
|
sprintf(buf, "QUIT\r\n");
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
return(0);
|
return(0);
|
||||||
@ -947,7 +954,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -977,7 +984,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1021,7 +1028,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1060,7 +1067,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1089,7 +1096,7 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1154,7 +1161,8 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fprintf(stderr, "FTP server asking for ACCNT on anonymous\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"FTP server asking for ACCNT on anonymous\n");
|
||||||
case 1:
|
case 1:
|
||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
@ -1230,7 +1238,7 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) return(res);
|
if (res < 0) return(res);
|
||||||
@ -1268,7 +1276,8 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
|
|
||||||
ctxt->dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
ctxt->dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (ctxt->dataFd < 0) {
|
if (ctxt->dataFd < 0) {
|
||||||
fprintf(stderr, "xmlNanoFTPGetConnection: failed to create socket\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPGetConnection: failed to create socket\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
dataAddrLen = sizeof(dataAddr);
|
dataAddrLen = sizeof(dataAddr);
|
||||||
@ -1279,7 +1288,7 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
sprintf(buf, "PASV\r\n");
|
sprintf(buf, "PASV\r\n");
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1303,7 +1312,8 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
while (((*cur < '0') || (*cur > '9')) && *cur != '\0') cur++;
|
while (((*cur < '0') || (*cur > '9')) && *cur != '\0') cur++;
|
||||||
if (sscanf(cur, "%d,%d,%d,%d,%d,%d", &temp[0], &temp[1], &temp[2],
|
if (sscanf(cur, "%d,%d,%d,%d,%d,%d", &temp[0], &temp[1], &temp[2],
|
||||||
&temp[3], &temp[4], &temp[5]) != 6) {
|
&temp[3], &temp[4], &temp[5]) != 6) {
|
||||||
fprintf(stderr, "Invalid answer to PASV\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Invalid answer to PASV\n");
|
||||||
if (ctxt->dataFd != -1) {
|
if (ctxt->dataFd != -1) {
|
||||||
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
||||||
}
|
}
|
||||||
@ -1313,7 +1323,8 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
memcpy(&dataAddr.sin_addr, &ad[0], 4);
|
memcpy(&dataAddr.sin_addr, &ad[0], 4);
|
||||||
memcpy(&dataAddr.sin_port, &ad[4], 2);
|
memcpy(&dataAddr.sin_port, &ad[4], 2);
|
||||||
if (connect(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) {
|
if (connect(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) {
|
||||||
fprintf(stderr, "Failed to create a data connection\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to create a data connection\n");
|
||||||
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
@ -1321,14 +1332,16 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen);
|
getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen);
|
||||||
dataAddr.sin_port = 0;
|
dataAddr.sin_port = 0;
|
||||||
if (bind(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) {
|
if (bind(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) {
|
||||||
fprintf(stderr, "Failed to bind a port\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to bind a port\n");
|
||||||
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen);
|
getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen);
|
||||||
|
|
||||||
if (listen(ctxt->dataFd, 1) < 0) {
|
if (listen(ctxt->dataFd, 1) < 0) {
|
||||||
fprintf(stderr, "Could not listen on port %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Could not listen on port %d\n",
|
||||||
ntohs(dataAddr.sin_port));
|
ntohs(dataAddr.sin_port));
|
||||||
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
closesocket(ctxt->dataFd); ctxt->dataFd = -1;
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -1347,7 +1360,7 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
@ -1398,7 +1411,8 @@ xmlNanoFTPCloseConnection(void *ctx) {
|
|||||||
}
|
}
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
fprintf(stderr, "xmlNanoFTPCloseConnection: timeout\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNanoFTPCloseConnection: timeout\n");
|
||||||
#endif
|
#endif
|
||||||
closesocket(ctxt->controlFd); ctxt->controlFd = -1;
|
closesocket(ctxt->controlFd); ctxt->controlFd = -1;
|
||||||
} else {
|
} else {
|
||||||
@ -1584,7 +1598,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1678,7 +1692,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
|||||||
sprintf(buf, "TYPE I\r\n");
|
sprintf(buf, "TYPE I\r\n");
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1705,7 +1719,7 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
|||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
xmlGenericError(xmlGenericErrorContext, buf);
|
||||||
#endif
|
#endif
|
||||||
res = send(ctxt->controlFd, buf, len, 0);
|
res = send(ctxt->controlFd, buf, len, 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
@ -1810,7 +1824,7 @@ xmlNanoFTPRead(void *ctx, void *dest, int len) {
|
|||||||
|
|
||||||
len = recv(ctxt->dataFd, dest, len, 0);
|
len = recv(ctxt->dataFd, dest, len, 0);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf("Recvd %d bytes\n", len);
|
xmlGenericError(xmlGenericErrorContext, "Recvd %d bytes\n", len);
|
||||||
#endif
|
#endif
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
xmlNanoFTPCloseConnection(ctxt);
|
xmlNanoFTPCloseConnection(ctxt);
|
||||||
@ -1888,7 +1902,8 @@ xmlNanoFTPClose(void *ctx) {
|
|||||||
void ftpList(void *userData, const char *filename, const char* attrib,
|
void ftpList(void *userData, const char *filename, const char* attrib,
|
||||||
const char *owner, const char *group, unsigned long size, int links,
|
const char *owner, const char *group, unsigned long size, int links,
|
||||||
int year, const char *month, int day, int hour, int minute) {
|
int year, const char *month, int day, int hour, int minute) {
|
||||||
printf("%s %s %s %ld %s\n", attrib, owner, group, size, filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s %s %s %ld %s\n", attrib, owner, group, size, filename);
|
||||||
}
|
}
|
||||||
void ftpData(void *userData, const char *data, int len) {
|
void ftpData(void *userData, const char *data, int len) {
|
||||||
if (userData == NULL) return;
|
if (userData == NULL) return;
|
||||||
@ -1908,7 +1923,8 @@ int main(int argc, char **argv) {
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
ctxt = xmlNanoFTPNewCtxt(argv[1]);
|
ctxt = xmlNanoFTPNewCtxt(argv[1]);
|
||||||
if (xmlNanoFTPConnect(ctxt) < 0) {
|
if (xmlNanoFTPConnect(ctxt) < 0) {
|
||||||
fprintf(stderr, "Couldn't connect to %s\n", argv[1]);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Couldn't connect to %s\n", argv[1]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
@ -1916,14 +1932,16 @@ int main(int argc, char **argv) {
|
|||||||
} else
|
} else
|
||||||
ctxt = xmlNanoFTPConnectTo("localhost", 0);
|
ctxt = xmlNanoFTPConnectTo("localhost", 0);
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
fprintf(stderr, "Couldn't connect to localhost\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Couldn't connect to localhost\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
xmlNanoFTPList(ctxt, ftpList, NULL, tstfile);
|
xmlNanoFTPList(ctxt, ftpList, NULL, tstfile);
|
||||||
output = fopen("/tmp/tstdata", "w");
|
output = fopen("/tmp/tstdata", "w");
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0)
|
if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0)
|
||||||
fprintf(stderr, "Failed to get file\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Failed to get file\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
xmlNanoFTPClose(ctxt);
|
xmlNanoFTPClose(ctxt);
|
||||||
@ -1935,7 +1953,8 @@ int main(int argc, char **argv) {
|
|||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
printf("%s : FTP support not compiled in\n", argv[0]);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s : FTP support not compiled in\n", argv[0]);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#endif /* STANDALONE */
|
#endif /* STANDALONE */
|
||||||
|
40
nanohttp.c
40
nanohttp.c
@ -302,9 +302,11 @@ xmlNanoHTTPScanProxy(const char *URL) {
|
|||||||
}
|
}
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
if (URL == NULL)
|
if (URL == NULL)
|
||||||
printf("Removing HTTP proxy info\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Removing HTTP proxy info\n");
|
||||||
else
|
else
|
||||||
printf("Using HTTP proxy %s\n", URL);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Using HTTP proxy %s\n", URL);
|
||||||
#endif
|
#endif
|
||||||
if (URL == NULL) return;
|
if (URL == NULL) return;
|
||||||
buf[index] = 0;
|
buf[index] = 0;
|
||||||
@ -749,7 +751,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
|||||||
if (h==NULL)
|
if (h==NULL)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
fprintf(stderr,"unable to resolve '%s'.\n", host);
|
xmlGenericError(xmlGenericErrorContext,"unable to resolve '%s'.\n", host);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -764,7 +766,8 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
fprintf(stderr, "unable to connect to '%s'.\n", host);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"unable to connect to '%s'.\n", host);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -935,9 +938,11 @@ retry:
|
|||||||
else
|
else
|
||||||
strcpy(p, "\r\n");
|
strcpy(p, "\r\n");
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
printf("-> %s%s", proxy? "(Proxy) " : "", bp);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"-> %s%s", proxy? "(Proxy) " : "", bp);
|
||||||
if ((blen -= strlen(bp)+1) < 0)
|
if ((blen -= strlen(bp)+1) < 0)
|
||||||
printf("ERROR: overflowed buffer by %d bytes\n", -blen);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"ERROR: overflowed buffer by %d bytes\n", -blen);
|
||||||
#endif
|
#endif
|
||||||
ctxt->outptr = ctxt->out = bp;
|
ctxt->outptr = ctxt->out = bp;
|
||||||
ctxt->state = XML_NANO_HTTP_WRITE;
|
ctxt->state = XML_NANO_HTTP_WRITE;
|
||||||
@ -955,7 +960,7 @@ retry:
|
|||||||
xmlNanoHTTPScanAnswer(ctxt, p);
|
xmlNanoHTTPScanAnswer(ctxt, p);
|
||||||
|
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
printf("<- %s\n", p);
|
xmlGenericError(xmlGenericErrorContext, "<- %s\n", p);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(p);
|
xmlFree(p);
|
||||||
}
|
}
|
||||||
@ -963,7 +968,8 @@ retry:
|
|||||||
if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) &&
|
if ((ctxt->location != NULL) && (ctxt->returnValue >= 300) &&
|
||||||
(ctxt->returnValue < 400)) {
|
(ctxt->returnValue < 400)) {
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
printf("\nRedirect to: %s\n", ctxt->location);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"\nRedirect to: %s\n", ctxt->location);
|
||||||
#endif
|
#endif
|
||||||
while (xmlNanoHTTPRecv(ctxt)) ;
|
while (xmlNanoHTTPRecv(ctxt)) ;
|
||||||
if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
|
if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
|
||||||
@ -974,7 +980,8 @@ retry:
|
|||||||
}
|
}
|
||||||
xmlNanoHTTPFreeCtxt(ctxt);
|
xmlNanoHTTPFreeCtxt(ctxt);
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
printf("Too many redirects, aborting ...\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Too many redirects, aborting ...\n");
|
||||||
#endif
|
#endif
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
@ -989,10 +996,12 @@ retry:
|
|||||||
|
|
||||||
#ifdef DEBUG_HTTP
|
#ifdef DEBUG_HTTP
|
||||||
if (ctxt->contentType != NULL)
|
if (ctxt->contentType != NULL)
|
||||||
printf("\nCode %d, content-type '%s'\n\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"\nCode %d, content-type '%s'\n\n",
|
||||||
ctxt->returnValue, ctxt->contentType);
|
ctxt->returnValue, ctxt->contentType);
|
||||||
else
|
else
|
||||||
printf("\nCode %d, no content-type\n\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"\nCode %d, no content-type\n\n",
|
||||||
ctxt->returnValue);
|
ctxt->returnValue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1107,8 +1116,10 @@ int main(int argc, char **argv) {
|
|||||||
xmlNanoHTTPFetch(argv[1], "-", &contentType);
|
xmlNanoHTTPFetch(argv[1], "-", &contentType);
|
||||||
if (contentType != NULL) xmlFree(contentType);
|
if (contentType != NULL) xmlFree(contentType);
|
||||||
} else {
|
} else {
|
||||||
printf("%s: minimal HTTP GET implementation\n", argv[0]);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
printf("\tusage %s [ URL [ filename ] ]\n", argv[0]);
|
"%s: minimal HTTP GET implementation\n", argv[0]);
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"\tusage %s [ URL [ filename ] ]\n", argv[0]);
|
||||||
}
|
}
|
||||||
xmlNanoHTTPCleanup();
|
xmlNanoHTTPCleanup();
|
||||||
xmlMemoryDump();
|
xmlMemoryDump();
|
||||||
@ -1119,7 +1130,8 @@ int main(int argc, char **argv) {
|
|||||||
#ifdef STANDALONE
|
#ifdef STANDALONE
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
printf("%s : HTTP support not compiled in\n", argv[0]);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s : HTTP support not compiled in\n", argv[0]);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
#endif /* STANDALONE */
|
#endif /* STANDALONE */
|
||||||
|
332
parser.c
332
parser.c
@ -120,7 +120,8 @@ scope int name##Push(xmlParserCtxtPtr ctxt, type value) { \
|
|||||||
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
||||||
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
||||||
if (ctxt->name##Tab == NULL) { \
|
if (ctxt->name##Tab == NULL) { \
|
||||||
fprintf(stderr, "realloc failed !\n"); \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"realloc failed !\n"); \
|
||||||
return(0); \
|
return(0); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -154,7 +155,8 @@ int spacePush(xmlParserCtxtPtr ctxt, int val) {
|
|||||||
ctxt->spaceTab = (int *) xmlRealloc(ctxt->spaceTab,
|
ctxt->spaceTab = (int *) xmlRealloc(ctxt->spaceTab,
|
||||||
ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
|
ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
|
||||||
if (ctxt->spaceTab == NULL) {
|
if (ctxt->spaceTab == NULL) {
|
||||||
fprintf(stderr, "realloc failed !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc failed !\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +318,8 @@ xmlChar
|
|||||||
xmlPopInput(xmlParserCtxtPtr ctxt) {
|
xmlPopInput(xmlParserCtxtPtr ctxt) {
|
||||||
if (ctxt->inputNr == 1) return(0); /* End of main Input */
|
if (ctxt->inputNr == 1) return(0); /* End of main Input */
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "Popping input %d\n", ctxt->inputNr);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Popping input %d\n", ctxt->inputNr);
|
||||||
xmlFreeInputStream(inputPop(ctxt));
|
xmlFreeInputStream(inputPop(ctxt));
|
||||||
if ((*ctxt->input->cur == 0) &&
|
if ((*ctxt->input->cur == 0) &&
|
||||||
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
|
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
|
||||||
@ -338,9 +341,11 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
|
|||||||
|
|
||||||
if (xmlParserDebugEntities) {
|
if (xmlParserDebugEntities) {
|
||||||
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
||||||
fprintf(stderr, "%s(%d): ", ctxt->input->filename,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s(%d): ", ctxt->input->filename,
|
||||||
ctxt->input->line);
|
ctxt->input->line);
|
||||||
fprintf(stderr, "Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
|
||||||
}
|
}
|
||||||
inputPush(ctxt, input);
|
inputPush(ctxt, input);
|
||||||
GROW;
|
GROW;
|
||||||
@ -661,7 +666,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
|
|||||||
NEXT;
|
NEXT;
|
||||||
name = xmlParseName(ctxt);
|
name = xmlParseName(ctxt);
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "PE Reference: %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PE Reference: %s\n", name);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
ctxt->errNo = XML_ERR_PEREF_NO_NAME;
|
ctxt->errNo = XML_ERR_PEREF_NO_NAME;
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
||||||
@ -829,7 +835,8 @@ xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what,
|
|||||||
}
|
}
|
||||||
} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
|
} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "String decoding Entity Reference: %.30s\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"String decoding Entity Reference: %.30s\n",
|
||||||
str);
|
str);
|
||||||
ent = xmlParseStringEntityRef(ctxt, &str);
|
ent = xmlParseStringEntityRef(ctxt, &str);
|
||||||
if ((ent != NULL) &&
|
if ((ent != NULL) &&
|
||||||
@ -873,7 +880,8 @@ xmlStringDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int what,
|
|||||||
}
|
}
|
||||||
} else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) {
|
} else if (c == '%' && (what & XML_SUBSTITUTE_PEREF)) {
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "String decoding PE Reference: %.30s\n", str);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"String decoding PE Reference: %.30s\n", str);
|
||||||
ent = xmlParseStringPEReference(ctxt, &str);
|
ent = xmlParseStringPEReference(ctxt, &str);
|
||||||
if (ent != NULL) {
|
if (ent != NULL) {
|
||||||
xmlChar *rep;
|
xmlChar *rep;
|
||||||
@ -930,7 +938,8 @@ xmlStrndup(const xmlChar *cur, int len) {
|
|||||||
if ((cur == NULL) || (len < 0)) return(NULL);
|
if ((cur == NULL) || (len < 0)) return(NULL);
|
||||||
ret = (xmlChar *) xmlMalloc((len + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlMalloc((len + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "malloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %ld byte failed\n",
|
||||||
(len + 1) * (long)sizeof(xmlChar));
|
(len + 1) * (long)sizeof(xmlChar));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -976,7 +985,7 @@ xmlCharStrndup(const char *cur, int len) {
|
|||||||
if ((cur == NULL) || (len < 0)) return(NULL);
|
if ((cur == NULL) || (len < 0)) return(NULL);
|
||||||
ret = (xmlChar *) xmlMalloc((len + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlMalloc((len + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "malloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext, "malloc of %ld byte failed\n",
|
||||||
(len + 1) * (long)sizeof(xmlChar));
|
(len + 1) * (long)sizeof(xmlChar));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -1309,7 +1318,8 @@ xmlStrncat(xmlChar *cur, const xmlChar *add, int len) {
|
|||||||
size = xmlStrlen(cur);
|
size = xmlStrlen(cur);
|
||||||
ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(cur, (size + len + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlStrncat: realloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlStrncat: realloc of %ld byte failed\n",
|
||||||
(size + len + 1) * (long)sizeof(xmlChar));
|
(size + len + 1) * (long)sizeof(xmlChar));
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
@ -1858,7 +1868,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
|
|||||||
}
|
}
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1886,7 +1897,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2213,7 +2225,8 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
|
|||||||
|
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ctxt->instate = XML_PARSER_SYSTEM_LITERAL;
|
ctxt->instate = XML_PARSER_SYSTEM_LITERAL;
|
||||||
@ -2223,7 +2236,8 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
ctxt->instate = (xmlParserInputState) state;
|
ctxt->instate = (xmlParserInputState) state;
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -2294,7 +2308,8 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
cur = CUR;
|
cur = CUR;
|
||||||
@ -2303,7 +2318,8 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2563,7 +2579,8 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
|
|||||||
SKIP(4);
|
SKIP(4);
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
ctxt->instate = state;
|
ctxt->instate = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2588,7 +2605,8 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
ctxt->instate = state;
|
ctxt->instate = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2752,7 +2770,8 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
ctxt->instate = state;
|
ctxt->instate = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2773,7 +2792,8 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
ctxt->instate = state;
|
ctxt->instate = state;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4430,9 +4450,11 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
if (xmlParserDebugEntities) {
|
if (xmlParserDebugEntities) {
|
||||||
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
||||||
fprintf(stderr, "%s(%d): ", ctxt->input->filename,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s(%d): ", ctxt->input->filename,
|
||||||
ctxt->input->line);
|
ctxt->input->line);
|
||||||
fprintf(stderr, "Entering INCLUDE Conditional Section\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Entering INCLUDE Conditional Section\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||
|
while ((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||
|
||||||
@ -4469,9 +4491,11 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
if (xmlParserDebugEntities) {
|
if (xmlParserDebugEntities) {
|
||||||
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
||||||
fprintf(stderr, "%s(%d): ", ctxt->input->filename,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s(%d): ", ctxt->input->filename,
|
||||||
ctxt->input->line);
|
ctxt->input->line);
|
||||||
fprintf(stderr, "Leaving INCLUDE Conditional Section\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Leaving INCLUDE Conditional Section\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((RAW == 'I') && (NXT(1) == 'G') && (NXT(2) == 'N') &&
|
} else if ((RAW == 'I') && (NXT(1) == 'G') && (NXT(2) == 'N') &&
|
||||||
@ -4492,9 +4516,11 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
if (xmlParserDebugEntities) {
|
if (xmlParserDebugEntities) {
|
||||||
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
||||||
fprintf(stderr, "%s(%d): ", ctxt->input->filename,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s(%d): ", ctxt->input->filename,
|
||||||
ctxt->input->line);
|
ctxt->input->line);
|
||||||
fprintf(stderr, "Entering IGNORE Conditional Section\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Entering IGNORE Conditional Section\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4538,9 +4564,11 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
|
|||||||
ctxt->disableSAX = state;
|
ctxt->disableSAX = state;
|
||||||
if (xmlParserDebugEntities) {
|
if (xmlParserDebugEntities) {
|
||||||
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
if ((ctxt->input != NULL) && (ctxt->input->filename))
|
||||||
fprintf(stderr, "%s(%d): ", ctxt->input->filename,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s(%d): ", ctxt->input->filename,
|
||||||
ctxt->input->line);
|
ctxt->input->line);
|
||||||
fprintf(stderr, "Leaving IGNORE Conditional Section\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Leaving IGNORE Conditional Section\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -5866,7 +5894,8 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
|
|||||||
maxatts = 10;
|
maxatts = 10;
|
||||||
atts = (const xmlChar **) xmlMalloc(maxatts * sizeof(xmlChar *));
|
atts = (const xmlChar **) xmlMalloc(maxatts * sizeof(xmlChar *));
|
||||||
if (atts == NULL) {
|
if (atts == NULL) {
|
||||||
fprintf(stderr, "malloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %ld byte failed\n",
|
||||||
maxatts * (long)sizeof(xmlChar *));
|
maxatts * (long)sizeof(xmlChar *));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -5875,7 +5904,8 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
|
|||||||
atts = (const xmlChar **) xmlRealloc((void *) atts,
|
atts = (const xmlChar **) xmlRealloc((void *) atts,
|
||||||
maxatts * sizeof(xmlChar *));
|
maxatts * sizeof(xmlChar *));
|
||||||
if (atts == NULL) {
|
if (atts == NULL) {
|
||||||
fprintf(stderr, "realloc of %ld byte failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %ld byte failed\n",
|
||||||
maxatts * (long)sizeof(xmlChar *));
|
maxatts * (long)sizeof(xmlChar *));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -6015,7 +6045,7 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG_STACK
|
#ifdef DEBUG_STACK
|
||||||
fprintf(stderr,"Close: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"Close: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -6083,7 +6113,8 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
|
|||||||
cur = CUR_CHAR(l);
|
cur = CUR_CHAR(l);
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (IS_CHAR(cur) &&
|
while (IS_CHAR(cur) &&
|
||||||
@ -6092,7 +6123,8 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6304,7 +6336,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG_STACK
|
#ifdef DEBUG_STACK
|
||||||
fprintf(stderr,"Close: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"Close: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -6336,7 +6368,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG_STACK
|
#ifdef DEBUG_STACK
|
||||||
fprintf(stderr,"Close: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"Close: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -6374,7 +6406,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG_STACK
|
#ifdef DEBUG_STACK
|
||||||
fprintf(stderr,"Close: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"Close: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -6417,7 +6449,8 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
|
|||||||
|
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
cur = CUR;
|
cur = CUR;
|
||||||
@ -6430,7 +6463,8 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6537,7 +6571,8 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
|
|||||||
((cur >= 'A') && (cur <= 'Z'))) {
|
((cur >= 'A') && (cur <= 'Z'))) {
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6553,7 +6588,8 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7251,13 +7287,16 @@ xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
|
|||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
if (next == 0)
|
if (next == 0)
|
||||||
fprintf(stderr, "PP: lookup '%c' found at %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup '%c' found at %d\n",
|
||||||
first, base);
|
first, base);
|
||||||
else if (third == 0)
|
else if (third == 0)
|
||||||
fprintf(stderr, "PP: lookup '%c%c' found at %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup '%c%c' found at %d\n",
|
||||||
first, next, base);
|
first, next, base);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "PP: lookup '%c%c%c' found at %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup '%c%c%c' found at %d\n",
|
||||||
first, next, third, base);
|
first, next, third, base);
|
||||||
#endif
|
#endif
|
||||||
return(base - (in->cur - in->base));
|
return(base - (in->cur - in->base));
|
||||||
@ -7266,11 +7305,14 @@ xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
|
|||||||
ctxt->checkIndex = base;
|
ctxt->checkIndex = base;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
if (next == 0)
|
if (next == 0)
|
||||||
fprintf(stderr, "PP: lookup '%c' failed\n", first);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup '%c' failed\n", first);
|
||||||
else if (third == 0)
|
else if (third == 0)
|
||||||
fprintf(stderr, "PP: lookup '%c%c' failed\n", first, next);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup '%c%c' failed\n", first, next);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "PP: lookup '%c%c%c' failed\n", first, next, third);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup '%c%c%c' failed\n", first, next, third);
|
||||||
#endif
|
#endif
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -7293,35 +7335,50 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
switch (ctxt->instate) {
|
switch (ctxt->instate) {
|
||||||
case XML_PARSER_EOF:
|
case XML_PARSER_EOF:
|
||||||
fprintf(stderr, "PP: try EOF\n"); break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try EOF\n"); break;
|
||||||
case XML_PARSER_START:
|
case XML_PARSER_START:
|
||||||
fprintf(stderr, "PP: try START\n"); break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try START\n"); break;
|
||||||
case XML_PARSER_MISC:
|
case XML_PARSER_MISC:
|
||||||
fprintf(stderr, "PP: try MISC\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try MISC\n");break;
|
||||||
case XML_PARSER_COMMENT:
|
case XML_PARSER_COMMENT:
|
||||||
fprintf(stderr, "PP: try COMMENT\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try COMMENT\n");break;
|
||||||
case XML_PARSER_PROLOG:
|
case XML_PARSER_PROLOG:
|
||||||
fprintf(stderr, "PP: try PROLOG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try PROLOG\n");break;
|
||||||
case XML_PARSER_START_TAG:
|
case XML_PARSER_START_TAG:
|
||||||
fprintf(stderr, "PP: try START_TAG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try START_TAG\n");break;
|
||||||
case XML_PARSER_CONTENT:
|
case XML_PARSER_CONTENT:
|
||||||
fprintf(stderr, "PP: try CONTENT\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try CONTENT\n");break;
|
||||||
case XML_PARSER_CDATA_SECTION:
|
case XML_PARSER_CDATA_SECTION:
|
||||||
fprintf(stderr, "PP: try CDATA_SECTION\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try CDATA_SECTION\n");break;
|
||||||
case XML_PARSER_END_TAG:
|
case XML_PARSER_END_TAG:
|
||||||
fprintf(stderr, "PP: try END_TAG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try END_TAG\n");break;
|
||||||
case XML_PARSER_ENTITY_DECL:
|
case XML_PARSER_ENTITY_DECL:
|
||||||
fprintf(stderr, "PP: try ENTITY_DECL\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try ENTITY_DECL\n");break;
|
||||||
case XML_PARSER_ENTITY_VALUE:
|
case XML_PARSER_ENTITY_VALUE:
|
||||||
fprintf(stderr, "PP: try ENTITY_VALUE\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try ENTITY_VALUE\n");break;
|
||||||
case XML_PARSER_ATTRIBUTE_VALUE:
|
case XML_PARSER_ATTRIBUTE_VALUE:
|
||||||
fprintf(stderr, "PP: try ATTRIBUTE_VALUE\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try ATTRIBUTE_VALUE\n");break;
|
||||||
case XML_PARSER_DTD:
|
case XML_PARSER_DTD:
|
||||||
fprintf(stderr, "PP: try DTD\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try DTD\n");break;
|
||||||
case XML_PARSER_EPILOG:
|
case XML_PARSER_EPILOG:
|
||||||
fprintf(stderr, "PP: try EPILOG\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try EPILOG\n");break;
|
||||||
case XML_PARSER_PI:
|
case XML_PARSER_PI:
|
||||||
fprintf(stderr, "PP: try PI\n");break;
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: try PI\n");break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -7383,7 +7440,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->disableSAX = 1;
|
ctxt->disableSAX = 1;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering EOF\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering EOF\n");
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
|
||||||
ctxt->sax->endDocument(ctxt->userData);
|
ctxt->sax->endDocument(ctxt->userData);
|
||||||
@ -7404,7 +7462,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(IS_BLANK(ctxt->input->cur[5]))) {
|
(IS_BLANK(ctxt->input->cur[5]))) {
|
||||||
ret += 5;
|
ret += 5;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing XML Decl\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing XML Decl\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseXMLDecl(ctxt);
|
xmlParseXMLDecl(ctxt);
|
||||||
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
|
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
|
||||||
@ -7424,7 +7483,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->sax->startDocument(ctxt->userData);
|
ctxt->sax->startDocument(ctxt->userData);
|
||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering MISC\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering MISC\n");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
|
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
|
||||||
@ -7433,7 +7493,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->sax->startDocument(ctxt->userData);
|
ctxt->sax->startDocument(ctxt->userData);
|
||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering MISC\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering MISC\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -7446,7 +7507,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->sax->startDocument(ctxt->userData);
|
ctxt->sax->startDocument(ctxt->userData);
|
||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering MISC\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering MISC\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7465,7 +7527,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing PI\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing PI\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParsePI(ctxt);
|
xmlParsePI(ctxt);
|
||||||
} else if ((cur == '<') && (next == '!') &&
|
} else if ((cur == '<') && (next == '!') &&
|
||||||
@ -7474,7 +7537,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseComment(ctxt);
|
xmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_MISC;
|
ctxt->instate = XML_PARSER_MISC;
|
||||||
@ -7487,14 +7551,16 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
|
(xmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing internal subset\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing internal subset\n");
|
||||||
#endif
|
#endif
|
||||||
ctxt->inSubset = 1;
|
ctxt->inSubset = 1;
|
||||||
xmlParseDocTypeDecl(ctxt);
|
xmlParseDocTypeDecl(ctxt);
|
||||||
if (RAW == '[') {
|
if (RAW == '[') {
|
||||||
ctxt->instate = XML_PARSER_DTD;
|
ctxt->instate = XML_PARSER_DTD;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering DTD\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering DTD\n");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -7509,7 +7575,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->inSubset = 0;
|
ctxt->inSubset = 0;
|
||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering PROLOG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering PROLOG\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if ((cur == '<') && (next == '!') &&
|
} else if ((cur == '<') && (next == '!') &&
|
||||||
@ -7518,7 +7585,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7537,7 +7605,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing PI\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing PI\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParsePI(ctxt);
|
xmlParsePI(ctxt);
|
||||||
} else if ((cur == '<') && (next == '!') &&
|
} else if ((cur == '<') && (next == '!') &&
|
||||||
@ -7546,7 +7615,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseComment(ctxt);
|
xmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
@ -7556,7 +7626,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7575,7 +7646,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing PI\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing PI\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParsePI(ctxt);
|
xmlParsePI(ctxt);
|
||||||
ctxt->instate = XML_PARSER_EPILOG;
|
ctxt->instate = XML_PARSER_EPILOG;
|
||||||
@ -7585,7 +7657,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseComment(ctxt);
|
xmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_EPILOG;
|
ctxt->instate = XML_PARSER_EPILOG;
|
||||||
@ -7601,7 +7674,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->disableSAX = 1;
|
ctxt->disableSAX = 1;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering EOF\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering EOF\n");
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL) &&
|
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL) &&
|
||||||
(!ctxt->disableSAX))
|
(!ctxt->disableSAX))
|
||||||
@ -7624,7 +7698,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->disableSAX = 1;
|
ctxt->disableSAX = 1;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering EOF\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering EOF\n");
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL) &&
|
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL) &&
|
||||||
(!ctxt->disableSAX))
|
(!ctxt->disableSAX))
|
||||||
@ -7643,7 +7718,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering EOF\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering EOF\n");
|
||||||
#endif
|
#endif
|
||||||
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL) &&
|
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL) &&
|
||||||
(!ctxt->disableSAX))
|
(!ctxt->disableSAX))
|
||||||
@ -7674,19 +7750,21 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG_STACK
|
#ifdef DEBUG_STACK
|
||||||
fprintf(stderr,"Close: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"Close: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
if (ctxt->name == NULL) {
|
if (ctxt->name == NULL) {
|
||||||
ctxt->instate = XML_PARSER_EPILOG;
|
ctxt->instate = XML_PARSER_EPILOG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering EPILOG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering EPILOG\n");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7710,7 +7788,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
spacePop(ctxt);
|
spacePop(ctxt);
|
||||||
if (oldname != NULL) {
|
if (oldname != NULL) {
|
||||||
#ifdef DEBUG_STACK
|
#ifdef DEBUG_STACK
|
||||||
fprintf(stderr,"Close: popped %s\n", oldname);
|
xmlGenericError(xmlGenericErrorContext,"Close: popped %s\n", oldname);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(oldname);
|
xmlFree(oldname);
|
||||||
}
|
}
|
||||||
@ -7718,7 +7796,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
xmlFree(name);
|
xmlFree(name);
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7752,7 +7831,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
(xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing PI\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing PI\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParsePI(ctxt);
|
xmlParsePI(ctxt);
|
||||||
} else if ((cur == '<') && (next == '!') &&
|
} else if ((cur == '<') && (next == '!') &&
|
||||||
@ -7761,7 +7841,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
(xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing Comment\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing Comment\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseComment(ctxt);
|
xmlParseComment(ctxt);
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
@ -7773,7 +7854,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
SKIP(9);
|
SKIP(9);
|
||||||
ctxt->instate = XML_PARSER_CDATA_SECTION;
|
ctxt->instate = XML_PARSER_CDATA_SECTION;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CDATA_SECTION\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CDATA_SECTION\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if ((cur == '<') && (next == '!') &&
|
} else if ((cur == '<') && (next == '!') &&
|
||||||
@ -7782,13 +7864,15 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
} else if ((cur == '<') && (next == '/')) {
|
} else if ((cur == '<') && (next == '/')) {
|
||||||
ctxt->instate = XML_PARSER_END_TAG;
|
ctxt->instate = XML_PARSER_END_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering END_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering END_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (cur == '<') {
|
} else if (cur == '<') {
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
} else if (cur == '&') {
|
} else if (cur == '&') {
|
||||||
@ -7796,7 +7880,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
(xmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
|
(xmlParseLookupSequence(ctxt, ';', 0, 0) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing Reference\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing Reference\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseReference(ctxt);
|
xmlParseReference(ctxt);
|
||||||
} else {
|
} else {
|
||||||
@ -7820,7 +7905,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
}
|
}
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: Parsing char data\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: Parsing char data\n");
|
||||||
#endif
|
#endif
|
||||||
xmlParseCharData(ctxt, 0);
|
xmlParseCharData(ctxt, 0);
|
||||||
}
|
}
|
||||||
@ -7872,7 +7958,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7887,12 +7974,14 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
if (ctxt->name == NULL) {
|
if (ctxt->name == NULL) {
|
||||||
ctxt->instate = XML_PARSER_EPILOG;
|
ctxt->instate = XML_PARSER_EPILOG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering EPILOG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering EPILOG\n");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7956,7 +8045,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
|
|||||||
ctxt->checkIndex = base;
|
ctxt->checkIndex = base;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
if (next == 0)
|
if (next == 0)
|
||||||
fprintf(stderr, "PP: lookup of int subset end filed\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: lookup of int subset end filed\n");
|
||||||
#endif
|
#endif
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
@ -7971,57 +8061,70 @@ found_end_int_subset:
|
|||||||
ctxt->instate = XML_PARSER_PROLOG;
|
ctxt->instate = XML_PARSER_PROLOG;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering PROLOG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering PROLOG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XML_PARSER_COMMENT:
|
case XML_PARSER_COMMENT:
|
||||||
fprintf(stderr, "PP: internal error, state == COMMENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: internal error, state == COMMENT\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_PI:
|
case XML_PARSER_PI:
|
||||||
fprintf(stderr, "PP: internal error, state == PI\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: internal error, state == PI\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering CONTENT\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering CONTENT\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_ENTITY_DECL:
|
case XML_PARSER_ENTITY_DECL:
|
||||||
fprintf(stderr, "PP: internal error, state == ENTITY_DECL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: internal error, state == ENTITY_DECL\n");
|
||||||
ctxt->instate = XML_PARSER_DTD;
|
ctxt->instate = XML_PARSER_DTD;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering DTD\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering DTD\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_ENTITY_VALUE:
|
case XML_PARSER_ENTITY_VALUE:
|
||||||
fprintf(stderr, "PP: internal error, state == ENTITY_VALUE\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: internal error, state == ENTITY_VALUE\n");
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering DTD\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering DTD\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_ATTRIBUTE_VALUE:
|
case XML_PARSER_ATTRIBUTE_VALUE:
|
||||||
fprintf(stderr, "PP: internal error, state == ATTRIBUTE_VALUE\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: internal error, state == ATTRIBUTE_VALUE\n");
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XML_PARSER_SYSTEM_LITERAL:
|
case XML_PARSER_SYSTEM_LITERAL:
|
||||||
fprintf(stderr, "PP: internal error, state == SYSTEM_LITERAL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: internal error, state == SYSTEM_LITERAL\n");
|
||||||
ctxt->instate = XML_PARSER_START_TAG;
|
ctxt->instate = XML_PARSER_START_TAG;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: entering START_TAG\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PP: entering START_TAG\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: done %d\n", ret);
|
xmlGenericError(xmlGenericErrorContext, "PP: done %d\n", ret);
|
||||||
#endif
|
#endif
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@ -8062,7 +8165,7 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
|
|||||||
ctxt->input->base = ctxt->input->buf->buffer->content + base;
|
ctxt->input->base = ctxt->input->buf->buffer->content + base;
|
||||||
ctxt->input->cur = ctxt->input->base + cur;
|
ctxt->input->cur = ctxt->input->base + cur;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: pushed %d\n", size);
|
xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((terminate) || (ctxt->input->buf->buffer->use > 80))
|
if ((terminate) || (ctxt->input->buf->buffer->use > 80))
|
||||||
@ -8190,7 +8293,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
|||||||
(ctxt->input->buf != NULL)) {
|
(ctxt->input->buf != NULL)) {
|
||||||
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
fprintf(stderr, "PP: pushed %d\n", size);
|
xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8532,7 +8635,8 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
|
|||||||
/* Allocate the Node stack */
|
/* Allocate the Node stack */
|
||||||
ctxt->vctxt.nodeTab = (xmlNodePtr *) xmlMalloc(4 * sizeof(xmlNodePtr));
|
ctxt->vctxt.nodeTab = (xmlNodePtr *) xmlMalloc(4 * sizeof(xmlNodePtr));
|
||||||
if (ctxt->vctxt.nodeTab == NULL) {
|
if (ctxt->vctxt.nodeTab == NULL) {
|
||||||
fprintf(stderr, "xmlParseCtxtExternalEntity: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParseCtxtExternalEntity: out of memory\n");
|
||||||
ctxt->validate = 0;
|
ctxt->validate = 0;
|
||||||
ctxt->vctxt.error = NULL;
|
ctxt->vctxt.error = NULL;
|
||||||
ctxt->vctxt.warning = NULL;
|
ctxt->vctxt.warning = NULL;
|
||||||
|
@ -68,13 +68,13 @@ xmlCheckVersion(int version) {
|
|||||||
int myversion = (int) LIBXML_VERSION;
|
int myversion = (int) LIBXML_VERSION;
|
||||||
|
|
||||||
if ((myversion / 10000) != (version / 10000)) {
|
if ((myversion / 10000) != (version / 10000)) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"Fatal: program compiled against libxml %d using libxml %d\n",
|
"Fatal: program compiled against libxml %d using libxml %d\n",
|
||||||
(version / 10000), (myversion / 10000));
|
(version / 10000), (myversion / 10000));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ((myversion / 100) < (version / 100)) {
|
if ((myversion / 100) < (version / 100)) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"Warning: program compiled against libxml %d using older %d\n",
|
"Warning: program compiled against libxml %d using older %d\n",
|
||||||
(version / 100), (myversion / 100));
|
(version / 100), (myversion / 100));
|
||||||
}
|
}
|
||||||
@ -877,15 +877,18 @@ xmlIsPubidChar(int c) {
|
|||||||
|
|
||||||
void check_buffer(xmlParserInputPtr in) {
|
void check_buffer(xmlParserInputPtr in) {
|
||||||
if (in->base != in->buf->buffer->content) {
|
if (in->base != in->buf->buffer->content) {
|
||||||
fprintf(stderr, "xmlParserInput: base mismatch problem\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInput: base mismatch problem\n");
|
||||||
}
|
}
|
||||||
if (in->cur < in->base) {
|
if (in->cur < in->base) {
|
||||||
fprintf(stderr, "xmlParserInput: cur < base problem\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInput: cur < base problem\n");
|
||||||
}
|
}
|
||||||
if (in->cur > in->base + in->buf->buffer->use) {
|
if (in->cur > in->base + in->buf->buffer->use) {
|
||||||
fprintf(stderr, "xmlParserInput: cur > base + use problem\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInput: cur > base + use problem\n");
|
||||||
}
|
}
|
||||||
fprintf(stderr,"buffer %x : content %x, cur %d, use %d, size %d\n",
|
xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d, size %d\n",
|
||||||
(int) in, (int) in->buf->buffer->content, in->cur - in->base,
|
(int) in, (int) in->buf->buffer->content, in->cur - in->base,
|
||||||
in->buf->buffer->use, in->buf->buffer->size);
|
in->buf->buffer->use, in->buf->buffer->size);
|
||||||
}
|
}
|
||||||
@ -913,7 +916,7 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
|
|||||||
int index;
|
int index;
|
||||||
|
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "Read\n");
|
xmlGenericError(xmlGenericErrorContext, "Read\n");
|
||||||
#endif
|
#endif
|
||||||
if (in->buf == NULL) return(-1);
|
if (in->buf == NULL) return(-1);
|
||||||
if (in->base == NULL) return(-1);
|
if (in->base == NULL) return(-1);
|
||||||
@ -961,7 +964,7 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
|||||||
int index;
|
int index;
|
||||||
|
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "Grow\n");
|
xmlGenericError(xmlGenericErrorContext, "Grow\n");
|
||||||
#endif
|
#endif
|
||||||
if (in->buf == NULL) return(-1);
|
if (in->buf == NULL) return(-1);
|
||||||
if (in->base == NULL) return(-1);
|
if (in->base == NULL) return(-1);
|
||||||
@ -1015,7 +1018,7 @@ xmlParserInputShrink(xmlParserInputPtr in) {
|
|||||||
int index;
|
int index;
|
||||||
|
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "Shrink\n");
|
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
|
||||||
#endif
|
#endif
|
||||||
if (in->buf == NULL) return;
|
if (in->buf == NULL) return;
|
||||||
if (in->base == NULL) return;
|
if (in->base == NULL) return;
|
||||||
@ -1479,7 +1482,8 @@ xmlCopyChar(int len, xmlChar *out, int val) {
|
|||||||
else if (val < 0x10000) len = 3;
|
else if (val < 0x10000) len = 3;
|
||||||
else if (val < 0x110000) len = 4;
|
else if (val < 0x110000) len = 4;
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
fprintf(stderr, "Internal error, xmlCopyChar 0x%X out of bound\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Internal error, xmlCopyChar 0x%X out of bound\n",
|
||||||
val);
|
val);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
@ -1736,7 +1740,8 @@ xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
|
|||||||
ctxt->input->buf->raw);
|
ctxt->input->buf->raw);
|
||||||
}
|
}
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
fprintf(stderr, "xmlSwitchToEncoding: encoder error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSwitchToEncoding: encoder error\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
ctxt->input->base =
|
ctxt->input->base =
|
||||||
@ -1776,7 +1781,8 @@ xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
|
|||||||
ctxt->input->buf->buffer,
|
ctxt->input->buf->buffer,
|
||||||
ctxt->input->buf->raw);
|
ctxt->input->buf->raw);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
fprintf(stderr, "xmlSwitchToEncoding: encoder error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSwitchToEncoding: encoder error\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1880,7 +1886,7 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
|
|||||||
xmlParserInputPtr inputStream;
|
xmlParserInputPtr inputStream;
|
||||||
|
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "new input from I/O\n");
|
xmlGenericError(xmlGenericErrorContext, "new input from I/O\n");
|
||||||
inputStream = xmlNewInputStream(ctxt);
|
inputStream = xmlNewInputStream(ctxt);
|
||||||
if (inputStream == NULL) {
|
if (inputStream == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -1918,7 +1924,8 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "new input from entity: %s\n", entity->name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"new input from entity: %s\n", entity->name);
|
||||||
if (entity->content == NULL) {
|
if (entity->content == NULL) {
|
||||||
switch (entity->etype) {
|
switch (entity->etype) {
|
||||||
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
||||||
@ -1982,7 +1989,8 @@ xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "new fixed input: %.30s\n", buffer);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"new fixed input: %.30s\n", buffer);
|
||||||
input = xmlNewInputStream(ctxt);
|
input = xmlNewInputStream(ctxt);
|
||||||
if (input == NULL) {
|
if (input == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -2010,7 +2018,8 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
|
|||||||
xmlChar *URI = NULL;
|
xmlChar *URI = NULL;
|
||||||
|
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "new input from file: %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"new input from file: %s\n", filename);
|
||||||
if (ctxt == NULL) return(NULL);
|
if (ctxt == NULL) return(NULL);
|
||||||
buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE);
|
buf = xmlParserInputBufferCreateFilename(filename, XML_CHAR_ENCODING_NONE);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
@ -2059,15 +2068,18 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
|||||||
|
|
||||||
sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
||||||
if (sax == NULL) {
|
if (sax == NULL) {
|
||||||
fprintf(stderr, "xmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitParserCtxt: out of memory\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memset(sax, 0, sizeof(xmlSAXHandler));
|
memset(sax, 0, sizeof(xmlSAXHandler));
|
||||||
|
|
||||||
/* Allocate the Input stack */
|
/* Allocate the Input stack */
|
||||||
ctxt->inputTab = (xmlParserInputPtr *) xmlMalloc(5 * sizeof(xmlParserInputPtr));
|
ctxt->inputTab = (xmlParserInputPtr *)
|
||||||
|
xmlMalloc(5 * sizeof(xmlParserInputPtr));
|
||||||
if (ctxt->inputTab == NULL) {
|
if (ctxt->inputTab == NULL) {
|
||||||
fprintf(stderr, "xmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->inputNr = 0;
|
ctxt->inputNr = 0;
|
||||||
ctxt->inputMax = 0;
|
ctxt->inputMax = 0;
|
||||||
ctxt->input = NULL;
|
ctxt->input = NULL;
|
||||||
@ -2091,7 +2103,8 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
|||||||
/* Allocate the Node stack */
|
/* Allocate the Node stack */
|
||||||
ctxt->nodeTab = (xmlNodePtr *) xmlMalloc(10 * sizeof(xmlNodePtr));
|
ctxt->nodeTab = (xmlNodePtr *) xmlMalloc(10 * sizeof(xmlNodePtr));
|
||||||
if (ctxt->nodeTab == NULL) {
|
if (ctxt->nodeTab == NULL) {
|
||||||
fprintf(stderr, "xmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->nodeNr = 0;
|
ctxt->nodeNr = 0;
|
||||||
ctxt->nodeMax = 0;
|
ctxt->nodeMax = 0;
|
||||||
ctxt->node = NULL;
|
ctxt->node = NULL;
|
||||||
@ -2107,7 +2120,8 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
|||||||
/* Allocate the Name stack */
|
/* Allocate the Name stack */
|
||||||
ctxt->nameTab = (xmlChar **) xmlMalloc(10 * sizeof(xmlChar *));
|
ctxt->nameTab = (xmlChar **) xmlMalloc(10 * sizeof(xmlChar *));
|
||||||
if (ctxt->nameTab == NULL) {
|
if (ctxt->nameTab == NULL) {
|
||||||
fprintf(stderr, "xmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->nodeNr = 0;
|
ctxt->nodeNr = 0;
|
||||||
ctxt->nodeMax = 0;
|
ctxt->nodeMax = 0;
|
||||||
ctxt->node = NULL;
|
ctxt->node = NULL;
|
||||||
@ -2126,7 +2140,8 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
|||||||
/* Allocate the space stack */
|
/* Allocate the space stack */
|
||||||
ctxt->spaceTab = (int *) xmlMalloc(10 * sizeof(int));
|
ctxt->spaceTab = (int *) xmlMalloc(10 * sizeof(int));
|
||||||
if (ctxt->spaceTab == NULL) {
|
if (ctxt->spaceTab == NULL) {
|
||||||
fprintf(stderr, "xmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->nodeNr = 0;
|
ctxt->nodeNr = 0;
|
||||||
ctxt->nodeMax = 0;
|
ctxt->nodeMax = 0;
|
||||||
ctxt->node = NULL;
|
ctxt->node = NULL;
|
||||||
@ -2169,7 +2184,8 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
|||||||
/* Allocate the Node stack */
|
/* Allocate the Node stack */
|
||||||
ctxt->vctxt.nodeTab = (xmlNodePtr *) xmlMalloc(4 * sizeof(xmlNodePtr));
|
ctxt->vctxt.nodeTab = (xmlNodePtr *) xmlMalloc(4 * sizeof(xmlNodePtr));
|
||||||
if (ctxt->vctxt.nodeTab == NULL) {
|
if (ctxt->vctxt.nodeTab == NULL) {
|
||||||
fprintf(stderr, "xmlInitParserCtxt: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitParserCtxt: out of memory\n");
|
||||||
ctxt->vctxt.nodeMax = 0;
|
ctxt->vctxt.nodeMax = 0;
|
||||||
ctxt->validate = 0;
|
ctxt->validate = 0;
|
||||||
ctxt->vctxt.error = NULL;
|
ctxt->vctxt.error = NULL;
|
||||||
@ -2247,7 +2263,8 @@ xmlNewParserCtxt()
|
|||||||
|
|
||||||
ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
|
ctxt = (xmlParserCtxtPtr) xmlMalloc(sizeof(xmlParserCtxt));
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
fprintf(stderr, "xmlNewParserCtxt : cannot allocate context\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewParserCtxt : cannot allocate context\n");
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -2540,7 +2557,8 @@ xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what,
|
|||||||
|
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlDecodeEntities() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlDecodeEntities() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2581,7 +2599,8 @@ xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what,
|
|||||||
} else if ((c == '&') && (ctxt->token != '&') &&
|
} else if ((c == '&') && (ctxt->token != '&') &&
|
||||||
(what & XML_SUBSTITUTE_REF)) {
|
(what & XML_SUBSTITUTE_REF)) {
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "decoding Entity Reference\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"decoding Entity Reference\n");
|
||||||
ent = xmlParseEntityRef(ctxt);
|
ent = xmlParseEntityRef(ctxt);
|
||||||
if ((ent != NULL) &&
|
if ((ent != NULL) &&
|
||||||
(ctxt->replaceEntities != 0)) {
|
(ctxt->replaceEntities != 0)) {
|
||||||
@ -2611,7 +2630,8 @@ xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what,
|
|||||||
* parsed if any. We will be called back later.
|
* parsed if any. We will be called back later.
|
||||||
*/
|
*/
|
||||||
if (xmlParserDebugEntities)
|
if (xmlParserDebugEntities)
|
||||||
fprintf(stderr, "decoding PE Reference\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"decoding PE Reference\n");
|
||||||
if (nbchars != 0) break;
|
if (nbchars != 0) break;
|
||||||
|
|
||||||
xmlParsePEReference(ctxt);
|
xmlParsePEReference(ctxt);
|
||||||
@ -2665,7 +2685,8 @@ xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt) {
|
|||||||
|
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlNamespaceParseNCName() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNamespaceParseNCName() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2674,7 +2695,8 @@ xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt) {
|
|||||||
GROW;
|
GROW;
|
||||||
if (!IS_LETTER(cur) && (cur != '_')) return(NULL);
|
if (!IS_LETTER(cur) && (cur != '_')) return(NULL);
|
||||||
|
|
||||||
fprintf(stderr, "xmlNamespaceParseNCName: reached loop 3\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNamespaceParseNCName: reached loop 3\n");
|
||||||
while ((IS_LETTER(cur)) || (IS_DIGIT(cur)) || /* NOT REACHED */
|
while ((IS_LETTER(cur)) || (IS_DIGIT(cur)) || /* NOT REACHED */
|
||||||
(cur == '.') || (cur == '-') ||
|
(cur == '.') || (cur == '-') ||
|
||||||
(cur == '_') ||
|
(cur == '_') ||
|
||||||
@ -2684,7 +2706,7 @@ fprintf(stderr, "xmlNamespaceParseNCName: reached loop 3\n");
|
|||||||
NEXTL(l);
|
NEXTL(l);
|
||||||
cur = CUR_CHAR(l);
|
cur = CUR_CHAR(l);
|
||||||
if (len >= XML_MAX_NAMELEN) {
|
if (len >= XML_MAX_NAMELEN) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlNamespaceParseNCName: reached XML_MAX_NAMELEN limit\n");
|
"xmlNamespaceParseNCName: reached XML_MAX_NAMELEN limit\n");
|
||||||
while ((IS_LETTER(cur)) || (IS_DIGIT(cur)) ||/* NOT REACHED */
|
while ((IS_LETTER(cur)) || (IS_DIGIT(cur)) ||/* NOT REACHED */
|
||||||
(cur == '.') || (cur == '-') ||
|
(cur == '.') || (cur == '-') ||
|
||||||
@ -2727,7 +2749,8 @@ xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, xmlChar **prefix) {
|
|||||||
|
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlNamespaceParseQName() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNamespaceParseQName() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2767,7 +2790,8 @@ xmlChar *
|
|||||||
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt) {
|
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt) {
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlNamespaceParseNSDef() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNamespaceParseNSDef() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -2801,7 +2825,8 @@ xmlChar *
|
|||||||
xmlParseQuotedString(xmlParserCtxtPtr ctxt) {
|
xmlParseQuotedString(xmlParserCtxtPtr ctxt) {
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlParseQuotedString() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParseQuotedString() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -2814,10 +2839,12 @@ xmlParseQuotedString(xmlParserCtxtPtr ctxt) {
|
|||||||
|
|
||||||
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"malloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "xmlParseQuotedString: reached loop 4\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParseQuotedString: reached loop 4\n");
|
||||||
if (RAW == '"') {
|
if (RAW == '"') {
|
||||||
NEXT;
|
NEXT;
|
||||||
c = CUR_CHAR(l);
|
c = CUR_CHAR(l);
|
||||||
@ -2826,7 +2853,8 @@ fprintf(stderr, "xmlParseQuotedString: reached loop 4\n");
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2852,7 +2880,8 @@ fprintf(stderr, "xmlParseQuotedString: reached loop 4\n");
|
|||||||
size *= 2;
|
size *= 2;
|
||||||
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "realloc of %d byte failed\n", size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"realloc of %d byte failed\n", size);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2894,7 +2923,8 @@ void
|
|||||||
xmlParseNamespace(xmlParserCtxtPtr ctxt) {
|
xmlParseNamespace(xmlParserCtxtPtr ctxt) {
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlParseNamespace() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParseNamespace() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2908,7 +2938,8 @@ xmlParseNamespace(xmlParserCtxtPtr ctxt) {
|
|||||||
*/
|
*/
|
||||||
SKIP_BLANKS;
|
SKIP_BLANKS;
|
||||||
|
|
||||||
fprintf(stderr, "xmlParseNamespace: reached loop 5\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParseNamespace: reached loop 5\n");
|
||||||
while (IS_CHAR(RAW) && (RAW != '>')) { /* NOT REACHED */
|
while (IS_CHAR(RAW) && (RAW != '>')) { /* NOT REACHED */
|
||||||
/*
|
/*
|
||||||
* We can have "ns" or "prefix" attributes
|
* We can have "ns" or "prefix" attributes
|
||||||
@ -3019,7 +3050,8 @@ xmlChar *
|
|||||||
xmlScanName(xmlParserCtxtPtr ctxt) {
|
xmlScanName(xmlParserCtxtPtr ctxt) {
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlScanName() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlScanName() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -3044,7 +3076,7 @@ xmlScanName(xmlParserCtxtPtr ctxt) {
|
|||||||
buf[len] = NXT(len);
|
buf[len] = NXT(len);
|
||||||
len++;
|
len++;
|
||||||
if (len >= XML_MAX_NAMELEN) {
|
if (len >= XML_MAX_NAMELEN) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlScanName: reached XML_MAX_NAMELEN limit\n");
|
"xmlScanName: reached XML_MAX_NAMELEN limit\n");
|
||||||
while ((IS_LETTER(NXT(len))) || /* NOT REACHED */
|
while ((IS_LETTER(NXT(len))) || /* NOT REACHED */
|
||||||
(IS_DIGIT(NXT(len))) ||
|
(IS_DIGIT(NXT(len))) ||
|
||||||
@ -3091,7 +3123,8 @@ void
|
|||||||
xmlParserHandleReference(xmlParserCtxtPtr ctxt) {
|
xmlParserHandleReference(xmlParserCtxtPtr ctxt) {
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlParserHandleReference() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserHandleReference() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3238,9 +3271,12 @@ xmlParserHandleReference(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: this seems not reached anymore .... Verify ... */
|
/* TODO: this seems not reached anymore .... Verify ... */
|
||||||
fprintf(stderr, "Reached deprecated section in xmlParserHandleReference()\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
fprintf(stderr, "Please forward the document to Daniel.Veillard@w3.org\n");
|
"Reached deprecated section in xmlParserHandleReference()\n");
|
||||||
fprintf(stderr, "indicating the version: %s, thanks !\n", xmlParserVersion);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Please forward the document to Daniel.Veillard@w3.org\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"indicating the version: %s, thanks !\n", xmlParserVersion);
|
||||||
NEXT;
|
NEXT;
|
||||||
name = xmlScanName(ctxt);
|
name = xmlScanName(ctxt);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
@ -3329,7 +3365,8 @@ void
|
|||||||
xmlHandleEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
xmlHandleEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||||
static int deprecated = 0;
|
static int deprecated = 0;
|
||||||
if (!deprecated) {
|
if (!deprecated) {
|
||||||
fprintf(stderr, "xmlHandleEntity() deprecated function reached\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlHandleEntity() deprecated function reached\n");
|
||||||
deprecated = 1;
|
deprecated = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <libxml/HTMLparser.h>
|
#include <libxml/HTMLparser.h>
|
||||||
#include <libxml/HTMLtree.h>
|
#include <libxml/HTMLtree.h>
|
||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
@ -719,7 +720,8 @@ void parseAndPrintFile(char *filename) {
|
|||||||
doc = htmlParseFile(filename, NULL);
|
doc = htmlParseFile(filename, NULL);
|
||||||
}
|
}
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "Could not parse %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Could not parse %s\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -617,7 +617,8 @@ void parseAndPrintFile(char *filename) {
|
|||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Cannot read file %s\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Cannot read file %s\n", filename);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Debug callback
|
* Debug callback
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
#if defined(LIBXML_XPTR_ENABLED)
|
#if defined(LIBXML_XPTR_ENABLED)
|
||||||
#include <libxml/xpointer.h>
|
#include <libxml/xpointer.h>
|
||||||
static int xptr = 0;
|
static int xptr = 0;
|
||||||
@ -115,7 +116,8 @@ void testXPathFile(const char *filename) {
|
|||||||
|
|
||||||
input = fopen(filename, "r");
|
input = fopen(filename, "r");
|
||||||
if (input == NULL) {
|
if (input == NULL) {
|
||||||
fprintf(stderr, "Cannot open %s for reading\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Cannot open %s for reading\n", filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (fgets(expr, 4500, input) != NULL) {
|
while (fgets(expr, 4500, input) != NULL) {
|
||||||
|
114
uri.c
114
uri.c
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* alpha = lowalpha | upalpha
|
* alpha = lowalpha | upalpha
|
||||||
@ -181,7 +182,8 @@ xmlCreateURI(void) {
|
|||||||
|
|
||||||
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI));
|
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlCreateURI: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCreateURI: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlURI));
|
memset(ret, 0, sizeof(xmlURI));
|
||||||
@ -209,7 +211,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max = 80;
|
max = 80;
|
||||||
ret = (xmlChar *) xmlMalloc((max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlMalloc((max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -221,7 +224,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,7 +235,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +249,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,7 +271,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,7 +283,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,15 +295,18 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((IS_UNRESERVED(*(p))) ||
|
if ((IS_UNRESERVED(*(p))) ||
|
||||||
((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '&')) ||
|
((*(p) == ';')) || ((*(p) == ':')) ||
|
||||||
((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||
|
((*(p) == '&')) || ((*(p) == '=')) ||
|
||||||
|
((*(p) == '+')) || ((*(p) == '$')) ||
|
||||||
((*(p) == ',')))
|
((*(p) == ',')))
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
else {
|
else {
|
||||||
@ -308,9 +319,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
}
|
}
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,9 +333,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len >= max) {
|
if (len >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,9 +346,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
if (uri->port > 0) {
|
if (uri->port > 0) {
|
||||||
if (len + 10 >= max) {
|
if (len + 10 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -342,9 +359,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
} else if (uri->authority != NULL) {
|
} else if (uri->authority != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,9 +373,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,9 +397,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
} else if (uri->scheme != NULL) {
|
} else if (uri->scheme != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,9 +413,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,9 +438,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
if (uri->query != NULL) {
|
if (uri->query != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,9 +451,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -444,9 +473,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
if (uri->fragment != NULL) {
|
if (uri->fragment != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -455,9 +486,11 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret,
|
||||||
|
(max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,7 +509,8 @@ xmlSaveUri(xmlURIPtr uri) {
|
|||||||
max *= 2;
|
max *= 2;
|
||||||
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlSaveUri: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlSaveUri: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -577,7 +611,8 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
|
|||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
ret = (char *) xmlMalloc(len + 1);
|
ret = (char *) xmlMalloc(len + 1);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlURIUnescapeString: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlURIUnescapeString: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@ -691,7 +726,8 @@ xmlParseURIScheme(xmlURIPtr uri, const char **str) {
|
|||||||
while (IS_SCHEME(*cur)) cur++;
|
while (IS_SCHEME(*cur)) cur++;
|
||||||
if (uri != NULL) {
|
if (uri != NULL) {
|
||||||
if (uri->scheme != NULL) xmlFree(uri->scheme);
|
if (uri->scheme != NULL) xmlFree(uri->scheme);
|
||||||
uri->scheme = xmlURIUnescapeString(*str, cur - *str, NULL); /* !!! strndup */
|
/* !!! strndup */
|
||||||
|
uri->scheme = xmlURIUnescapeString(*str, cur - *str, NULL);
|
||||||
}
|
}
|
||||||
*str = cur;
|
*str = cur;
|
||||||
return(0);
|
return(0);
|
||||||
@ -954,7 +990,8 @@ xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) {
|
|||||||
}
|
}
|
||||||
path = (char *) xmlMalloc(len + 1);
|
path = (char *) xmlMalloc(len + 1);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
fprintf(stderr, "xmlParseURIPathSegments: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParseURIPathSegments: out of memory\n");
|
||||||
*str = cur;
|
*str = cur;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -1557,7 +1594,8 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
|
|||||||
len += strlen(bas->path);
|
len += strlen(bas->path);
|
||||||
res->path = (char *) xmlMalloc(len);
|
res->path = (char *) xmlMalloc(len);
|
||||||
if (res->path == NULL) {
|
if (res->path == NULL) {
|
||||||
fprintf(stderr, "xmlBuildURI: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlBuildURI: out of memory\n");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
res->path[0] = 0;
|
res->path[0] = 0;
|
||||||
|
196
valid.c
196
valid.c
@ -25,6 +25,7 @@
|
|||||||
#include <libxml/valid.h>
|
#include <libxml/valid.h>
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic function for accessing stacks in the Validity Context
|
* Generic function for accessing stacks in the Validity Context
|
||||||
@ -37,7 +38,8 @@ scope int name##VPush(xmlValidCtxtPtr ctxt, type value) { \
|
|||||||
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
||||||
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
||||||
if (ctxt->name##Tab == NULL) { \
|
if (ctxt->name##Tab == NULL) { \
|
||||||
fprintf(stderr, "realloc failed !\n"); \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"realloc failed !\n"); \
|
||||||
return(0); \
|
return(0); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -65,59 +67,59 @@ PUSH_AND_POP(static, xmlNodePtr, node)
|
|||||||
#ifdef DEBUG_VALID_ALGO
|
#ifdef DEBUG_VALID_ALGO
|
||||||
void xmlValidPrintNodeList(xmlNodePtr cur) {
|
void xmlValidPrintNodeList(xmlNodePtr cur) {
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
fprintf(stderr, "null ");
|
xmlGenericError(xmlGenericErrorContext, "null ");
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
case XML_ELEMENT_NODE:
|
case XML_ELEMENT_NODE:
|
||||||
fprintf(stderr, "%s ", cur->name);
|
xmlGenericError(xmlGenericErrorContext, "%s ", cur->name);
|
||||||
break;
|
break;
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
fprintf(stderr, "text ");
|
xmlGenericError(xmlGenericErrorContext, "text ");
|
||||||
break;
|
break;
|
||||||
case XML_CDATA_SECTION_NODE:
|
case XML_CDATA_SECTION_NODE:
|
||||||
fprintf(stderr, "cdata ");
|
xmlGenericError(xmlGenericErrorContext, "cdata ");
|
||||||
break;
|
break;
|
||||||
case XML_ENTITY_REF_NODE:
|
case XML_ENTITY_REF_NODE:
|
||||||
fprintf(stderr, "&%s; ", cur->name);
|
xmlGenericError(xmlGenericErrorContext, "&%s; ", cur->name);
|
||||||
break;
|
break;
|
||||||
case XML_PI_NODE:
|
case XML_PI_NODE:
|
||||||
fprintf(stderr, "pi(%s) ", cur->name);
|
xmlGenericError(xmlGenericErrorContext, "pi(%s) ", cur->name);
|
||||||
break;
|
break;
|
||||||
case XML_COMMENT_NODE:
|
case XML_COMMENT_NODE:
|
||||||
fprintf(stderr, "comment ");
|
xmlGenericError(xmlGenericErrorContext, "comment ");
|
||||||
break;
|
break;
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
fprintf(stderr, "?attr? ");
|
xmlGenericError(xmlGenericErrorContext, "?attr? ");
|
||||||
break;
|
break;
|
||||||
case XML_ENTITY_NODE:
|
case XML_ENTITY_NODE:
|
||||||
fprintf(stderr, "?ent? ");
|
xmlGenericError(xmlGenericErrorContext, "?ent? ");
|
||||||
break;
|
break;
|
||||||
case XML_DOCUMENT_NODE:
|
case XML_DOCUMENT_NODE:
|
||||||
fprintf(stderr, "?doc? ");
|
xmlGenericError(xmlGenericErrorContext, "?doc? ");
|
||||||
break;
|
break;
|
||||||
case XML_DOCUMENT_TYPE_NODE:
|
case XML_DOCUMENT_TYPE_NODE:
|
||||||
fprintf(stderr, "?doctype? ");
|
xmlGenericError(xmlGenericErrorContext, "?doctype? ");
|
||||||
break;
|
break;
|
||||||
case XML_DOCUMENT_FRAG_NODE:
|
case XML_DOCUMENT_FRAG_NODE:
|
||||||
fprintf(stderr, "?frag? ");
|
xmlGenericError(xmlGenericErrorContext, "?frag? ");
|
||||||
break;
|
break;
|
||||||
case XML_NOTATION_NODE:
|
case XML_NOTATION_NODE:
|
||||||
fprintf(stderr, "?nota? ");
|
xmlGenericError(xmlGenericErrorContext, "?nota? ");
|
||||||
break;
|
break;
|
||||||
case XML_HTML_DOCUMENT_NODE:
|
case XML_HTML_DOCUMENT_NODE:
|
||||||
fprintf(stderr, "?html? ");
|
xmlGenericError(xmlGenericErrorContext, "?html? ");
|
||||||
break;
|
break;
|
||||||
case XML_DTD_NODE:
|
case XML_DTD_NODE:
|
||||||
fprintf(stderr, "?dtd? ");
|
xmlGenericError(xmlGenericErrorContext, "?dtd? ");
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_DECL:
|
case XML_ELEMENT_DECL:
|
||||||
fprintf(stderr, "?edecl? ");
|
xmlGenericError(xmlGenericErrorContext, "?edecl? ");
|
||||||
break;
|
break;
|
||||||
case XML_ATTRIBUTE_DECL:
|
case XML_ATTRIBUTE_DECL:
|
||||||
fprintf(stderr, "?adecl? ");
|
xmlGenericError(xmlGenericErrorContext, "?adecl? ");
|
||||||
break;
|
break;
|
||||||
case XML_ENTITY_DECL:
|
case XML_ENTITY_DECL:
|
||||||
fprintf(stderr, "?entdecl? ");
|
xmlGenericError(xmlGenericErrorContext, "?entdecl? ");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@ -128,11 +130,11 @@ void xmlValidDebug(xmlNodePtr cur, xmlElementContentPtr cont) {
|
|||||||
char expr[1000];
|
char expr[1000];
|
||||||
|
|
||||||
expr[0] = 0;
|
expr[0] = 0;
|
||||||
fprintf(stderr, "valid: ");
|
xmlGenericError(xmlGenericErrorContext, "valid: ");
|
||||||
xmlValidPrintNodeList(cur);
|
xmlValidPrintNodeList(cur);
|
||||||
fprintf(stderr, "against ");
|
xmlGenericError(xmlGenericErrorContext, "against ");
|
||||||
xmlSprintfElementContent(expr, cont, 0);
|
xmlSprintfElementContent(expr, cont, 0);
|
||||||
fprintf(stderr, "%s\n", expr);
|
xmlGenericError(xmlGenericErrorContext, "%s\n", expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c);
|
#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c);
|
||||||
@ -233,23 +235,27 @@ xmlNewElementContent(xmlChar *name, xmlElementContentType type) {
|
|||||||
switch(type) {
|
switch(type) {
|
||||||
case XML_ELEMENT_CONTENT_ELEMENT:
|
case XML_ELEMENT_CONTENT_ELEMENT:
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
fprintf(stderr, "xmlNewElementContent : name == NULL !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewElementContent : name == NULL !\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_CONTENT_PCDATA:
|
case XML_ELEMENT_CONTENT_PCDATA:
|
||||||
case XML_ELEMENT_CONTENT_SEQ:
|
case XML_ELEMENT_CONTENT_SEQ:
|
||||||
case XML_ELEMENT_CONTENT_OR:
|
case XML_ELEMENT_CONTENT_OR:
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
fprintf(stderr, "xmlNewElementContent : name != NULL !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewElementContent : name != NULL !\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "xmlNewElementContent: unknown type %d\n", type);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewElementContent: unknown type %d\n", type);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
|
ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlNewElementContent : out of memory!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlNewElementContent : out of memory!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->type = type;
|
ret->type = type;
|
||||||
@ -277,7 +283,8 @@ xmlCopyElementContent(xmlElementContentPtr cur) {
|
|||||||
if (cur == NULL) return(NULL);
|
if (cur == NULL) return(NULL);
|
||||||
ret = xmlNewElementContent((xmlChar *) cur->name, cur->type);
|
ret = xmlNewElementContent((xmlChar *) cur->name, cur->type);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlCopyElementContent : out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCopyElementContent : out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->ocur = cur->ocur;
|
ret->ocur = cur->ocur;
|
||||||
@ -302,7 +309,8 @@ xmlFreeElementContent(xmlElementContentPtr cur) {
|
|||||||
case XML_ELEMENT_CONTENT_OR:
|
case XML_ELEMENT_CONTENT_OR:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "xmlFreeElementContent : type %d\n", cur->type);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlFreeElementContent : type %d\n", cur->type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->c1 != NULL) xmlFreeElementContent(cur->c1);
|
if (cur->c1 != NULL) xmlFreeElementContent(cur->c1);
|
||||||
@ -357,7 +365,8 @@ xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob)
|
|||||||
xmlDumpElementContent(buf, content->c2, 0);
|
xmlDumpElementContent(buf, content->c2, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "xmlDumpElementContent: unknown type %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlDumpElementContent: unknown type %d\n",
|
||||||
content->type);
|
content->type);
|
||||||
}
|
}
|
||||||
if (glob)
|
if (glob)
|
||||||
@ -498,44 +507,47 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
|
|||||||
xmlChar *ns, *uqname;
|
xmlChar *ns, *uqname;
|
||||||
|
|
||||||
if (dtd == NULL) {
|
if (dtd == NULL) {
|
||||||
fprintf(stderr, "xmlAddElementDecl: dtd == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddElementDecl: dtd == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
fprintf(stderr, "xmlAddElementDecl: name == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddElementDecl: name == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case XML_ELEMENT_TYPE_EMPTY:
|
case XML_ELEMENT_TYPE_EMPTY:
|
||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddElementDecl: content != NULL for EMPTY\n");
|
"xmlAddElementDecl: content != NULL for EMPTY\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_TYPE_ANY:
|
case XML_ELEMENT_TYPE_ANY:
|
||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddElementDecl: content != NULL for ANY\n");
|
"xmlAddElementDecl: content != NULL for ANY\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_TYPE_MIXED:
|
case XML_ELEMENT_TYPE_MIXED:
|
||||||
if (content == NULL) {
|
if (content == NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddElementDecl: content == NULL for MIXED\n");
|
"xmlAddElementDecl: content == NULL for MIXED\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_TYPE_ELEMENT:
|
case XML_ELEMENT_TYPE_ELEMENT:
|
||||||
if (content == NULL) {
|
if (content == NULL) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddElementDecl: content == NULL for ELEMENT\n");
|
"xmlAddElementDecl: content == NULL for ELEMENT\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "xmlAddElementDecl: unknown type %d\n", type);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddElementDecl: unknown type %d\n", type);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,13 +567,15 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
|
|||||||
dtd->elements = (void *) table;
|
dtd->elements = (void *) table;
|
||||||
}
|
}
|
||||||
if (table == NULL) {
|
if (table == NULL) {
|
||||||
fprintf(stderr, "xmlAddElementDecl: Table creation failed!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddElementDecl: Table creation failed!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
|
ret = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAddElementDecl: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddElementDecl: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlElement));
|
memset(ret, 0, sizeof(xmlElement));
|
||||||
@ -633,7 +647,8 @@ xmlCopyElement(xmlElementPtr elem) {
|
|||||||
|
|
||||||
cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
|
cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlCopyElement: out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCopyElement: out of memory !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlElement));
|
memset(cur, 0, sizeof(xmlElement));
|
||||||
@ -703,7 +718,7 @@ xmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) {
|
|||||||
xmlBufferWriteChar(buf, ">\n");
|
xmlBufferWriteChar(buf, ">\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlDumpElementDecl: internal: unknown type %d\n",
|
"xmlDumpElementDecl: internal: unknown type %d\n",
|
||||||
elem->etype);
|
elem->etype);
|
||||||
}
|
}
|
||||||
@ -736,7 +751,8 @@ xmlCreateEnumeration(xmlChar *name) {
|
|||||||
|
|
||||||
ret = (xmlEnumerationPtr) xmlMalloc(sizeof(xmlEnumeration));
|
ret = (xmlEnumerationPtr) xmlMalloc(sizeof(xmlEnumeration));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlCreateEnumeration : xmlMalloc(%ld) failed\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCreateEnumeration : xmlMalloc(%ld) failed\n",
|
||||||
(long)sizeof(xmlEnumeration));
|
(long)sizeof(xmlEnumeration));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -851,11 +867,13 @@ xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
|
|||||||
xmlAttributeTablePtr table;
|
xmlAttributeTablePtr table;
|
||||||
|
|
||||||
if (dtd == NULL) {
|
if (dtd == NULL) {
|
||||||
fprintf(stderr, "xmlScanAttributeDecl: dtd == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlScanAttributeDecl: dtd == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (elem == NULL) {
|
if (elem == NULL) {
|
||||||
fprintf(stderr, "xmlScanAttributeDecl: elem == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlScanAttributeDecl: elem == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
table = (xmlAttributeTablePtr) dtd->attributes;
|
table = (xmlAttributeTablePtr) dtd->attributes;
|
||||||
@ -950,17 +968,20 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem,
|
|||||||
xmlElementPtr elemDef;
|
xmlElementPtr elemDef;
|
||||||
|
|
||||||
if (dtd == NULL) {
|
if (dtd == NULL) {
|
||||||
fprintf(stderr, "xmlAddAttributeDecl: dtd == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddAttributeDecl: dtd == NULL\n");
|
||||||
xmlFreeEnumeration(tree);
|
xmlFreeEnumeration(tree);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
fprintf(stderr, "xmlAddAttributeDecl: name == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddAttributeDecl: name == NULL\n");
|
||||||
xmlFreeEnumeration(tree);
|
xmlFreeEnumeration(tree);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (elem == NULL) {
|
if (elem == NULL) {
|
||||||
fprintf(stderr, "xmlAddAttributeDecl: elem == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddAttributeDecl: elem == NULL\n");
|
||||||
xmlFreeEnumeration(tree);
|
xmlFreeEnumeration(tree);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -989,7 +1010,8 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem,
|
|||||||
case XML_ATTRIBUTE_NOTATION:
|
case XML_ATTRIBUTE_NOTATION:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "xmlAddAttributeDecl: unknown type %d\n", type);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddAttributeDecl: unknown type %d\n", type);
|
||||||
xmlFreeEnumeration(tree);
|
xmlFreeEnumeration(tree);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -1009,14 +1031,16 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem,
|
|||||||
dtd->attributes = (void *) table;
|
dtd->attributes = (void *) table;
|
||||||
}
|
}
|
||||||
if (table == NULL) {
|
if (table == NULL) {
|
||||||
fprintf(stderr, "xmlAddAttributeDecl: Table creation failed!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddAttributeDecl: Table creation failed!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
|
ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAddAttributeDecl: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddAttributeDecl: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlAttribute));
|
memset(ret, 0, sizeof(xmlAttribute));
|
||||||
@ -1104,7 +1128,8 @@ xmlCopyAttribute(xmlAttributePtr attr) {
|
|||||||
|
|
||||||
cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
|
cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlCopyAttribute: out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCopyAttribute: out of memory !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlAttribute));
|
memset(cur, 0, sizeof(xmlAttribute));
|
||||||
@ -1186,7 +1211,7 @@ xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
|
|||||||
xmlDumpEnumeration(buf, attr->tree);
|
xmlDumpEnumeration(buf, attr->tree);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlDumpAttributeTable: internal: unknown type %d\n",
|
"xmlDumpAttributeTable: internal: unknown type %d\n",
|
||||||
attr->atype);
|
attr->atype);
|
||||||
}
|
}
|
||||||
@ -1203,7 +1228,7 @@ xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
|
|||||||
xmlBufferWriteChar(buf, " #FIXED");
|
xmlBufferWriteChar(buf, " #FIXED");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlDumpAttributeTable: internal: unknown default %d\n",
|
"xmlDumpAttributeTable: internal: unknown default %d\n",
|
||||||
attr->def);
|
attr->def);
|
||||||
}
|
}
|
||||||
@ -1283,15 +1308,18 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
|
|||||||
xmlNotationTablePtr table;
|
xmlNotationTablePtr table;
|
||||||
|
|
||||||
if (dtd == NULL) {
|
if (dtd == NULL) {
|
||||||
fprintf(stderr, "xmlAddNotationDecl: dtd == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddNotationDecl: dtd == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
fprintf(stderr, "xmlAddNotationDecl: name == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddNotationDecl: name == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if ((PublicID == NULL) && (SystemID == NULL)) {
|
if ((PublicID == NULL) && (SystemID == NULL)) {
|
||||||
fprintf(stderr, "xmlAddNotationDecl: no PUBLIC ID nor SYSTEM ID\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddNotationDecl: no PUBLIC ID nor SYSTEM ID\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1301,13 +1329,15 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
|
|||||||
if (table == NULL)
|
if (table == NULL)
|
||||||
dtd->notations = table = xmlCreateNotationTable();
|
dtd->notations = table = xmlCreateNotationTable();
|
||||||
if (table == NULL) {
|
if (table == NULL) {
|
||||||
fprintf(stderr, "xmlAddNotationDecl: Table creation failed!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddNotationDecl: Table creation failed!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
|
ret = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAddNotationDecl: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddNotationDecl: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlNotation));
|
memset(ret, 0, sizeof(xmlNotation));
|
||||||
@ -1326,7 +1356,7 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name,
|
|||||||
* Check the DTD for previous declarations of the ATTLIST
|
* Check the DTD for previous declarations of the ATTLIST
|
||||||
*/
|
*/
|
||||||
if (xmlHashAddEntry(table, name, ret)) {
|
if (xmlHashAddEntry(table, name, ret)) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddNotationDecl: %s already defined\n", name);
|
"xmlAddNotationDecl: %s already defined\n", name);
|
||||||
xmlFreeNotation(ret);
|
xmlFreeNotation(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -1359,7 +1389,8 @@ xmlCopyNotation(xmlNotationPtr nota) {
|
|||||||
|
|
||||||
cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
|
cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlCopyNotation: out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlCopyNotation: out of memory !\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (nota->name != NULL)
|
if (nota->name != NULL)
|
||||||
@ -1479,15 +1510,18 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
|||||||
xmlIDTablePtr table;
|
xmlIDTablePtr table;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "xmlAddIDDecl: doc == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddIDDecl: doc == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
fprintf(stderr, "xmlAddIDDecl: value == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddIDDecl: value == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
fprintf(stderr, "xmlAddIDDecl: attr == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddIDDecl: attr == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1498,13 +1532,15 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
|||||||
if (table == NULL)
|
if (table == NULL)
|
||||||
doc->ids = table = xmlCreateIDTable();
|
doc->ids = table = xmlCreateIDTable();
|
||||||
if (table == NULL) {
|
if (table == NULL) {
|
||||||
fprintf(stderr, "xmlAddID: Table creation failed!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddID: Table creation failed!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (xmlIDPtr) xmlMalloc(sizeof(xmlID));
|
ret = (xmlIDPtr) xmlMalloc(sizeof(xmlID));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAddID: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddID: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1625,12 +1661,12 @@ xmlGetID(xmlDocPtr doc, const xmlChar *ID) {
|
|||||||
xmlIDPtr id;
|
xmlIDPtr id;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "xmlGetID: doc == NULL\n");
|
xmlGenericError(xmlGenericErrorContext, "xmlGetID: doc == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ID == NULL) {
|
if (ID == NULL) {
|
||||||
fprintf(stderr, "xmlGetID: ID == NULL\n");
|
xmlGenericError(xmlGenericErrorContext, "xmlGetID: ID == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1695,15 +1731,18 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
|||||||
xmlRefTablePtr table;
|
xmlRefTablePtr table;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "xmlAddRefDecl: doc == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddRefDecl: doc == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
fprintf(stderr, "xmlAddRefDecl: value == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddRefDecl: value == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (attr == NULL) {
|
if (attr == NULL) {
|
||||||
fprintf(stderr, "xmlAddRefDecl: attr == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddRefDecl: attr == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1714,13 +1753,15 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
|||||||
if (table == NULL)
|
if (table == NULL)
|
||||||
doc->refs = table = xmlCreateRefTable();
|
doc->refs = table = xmlCreateRefTable();
|
||||||
if (table == NULL) {
|
if (table == NULL) {
|
||||||
fprintf(stderr, "xmlAddRef: Table creation failed!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddRef: Table creation failed!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = (xmlRefPtr) xmlMalloc(sizeof(xmlRef));
|
ret = (xmlRefPtr) xmlMalloc(sizeof(xmlRef));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAddRef: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAddRef: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1834,12 +1875,12 @@ xmlGetRef(xmlDocPtr doc, const xmlChar *Ref) {
|
|||||||
xmlRefTablePtr table;
|
xmlRefTablePtr table;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "xmlGetRef: doc == NULL\n");
|
xmlGenericError(xmlGenericErrorContext, "xmlGetRef: doc == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ref == NULL) {
|
if (Ref == NULL) {
|
||||||
fprintf(stderr, "xmlGetRef: Ref == NULL\n");
|
xmlGenericError(xmlGenericErrorContext, "xmlGetRef: Ref == NULL\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3350,7 +3391,8 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
|||||||
(cont->c1 == NULL) ||
|
(cont->c1 == NULL) ||
|
||||||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
|
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
|
||||||
/* Internal error !!! */
|
/* Internal error !!! */
|
||||||
fprintf(stderr, "Internal: MIXED struct bad\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Internal: MIXED struct bad\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cont = cont->c2;
|
cont = cont->c2;
|
||||||
@ -3370,7 +3412,8 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
|||||||
(cont->c1 == NULL) ||
|
(cont->c1 == NULL) ||
|
||||||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)) {
|
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)) {
|
||||||
/* Internal error !!! */
|
/* Internal error !!! */
|
||||||
fprintf(stderr, "Internal: MIXED struct bad\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Internal: MIXED struct bad\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cont = cont->c2;
|
cont = cont->c2;
|
||||||
@ -3648,7 +3691,8 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
|||||||
xmlRefTablePtr table;
|
xmlRefTablePtr table;
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
fprintf(stderr, "xmlValidateDocumentFinal: doc == NULL\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlValidateDocumentFinal: doc == NULL\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
60
xmlIO.c
60
xmlIO.c
@ -40,6 +40,7 @@
|
|||||||
#include <libxml/xmlIO.h>
|
#include <libxml/xmlIO.h>
|
||||||
#include <libxml/nanohttp.h>
|
#include <libxml/nanohttp.h>
|
||||||
#include <libxml/nanoftp.h>
|
#include <libxml/nanoftp.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
/* #define VERBOSE_FAILURE */
|
/* #define VERBOSE_FAILURE */
|
||||||
/* #define DEBUG_EXTERNAL_ENTITIES */
|
/* #define DEBUG_EXTERNAL_ENTITIES */
|
||||||
@ -728,7 +729,8 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
|
|||||||
|
|
||||||
ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer));
|
ret = (xmlParserInputBufferPtr) xmlMalloc(sizeof(xmlParserInputBuffer));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAllocParserInputBuffer : out of memory!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAllocParserInputBuffer : out of memory!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
|
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
|
||||||
@ -764,7 +766,8 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
|
|||||||
|
|
||||||
ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(stderr, "xmlAllocOutputBuffer : out of memory!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlAllocOutputBuffer : out of memory!\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
|
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
|
||||||
@ -1190,7 +1193,8 @@ xmlOutputBufferCreateIO(xmlOutputWriteCallback iowrite,
|
|||||||
* in case of error.
|
* in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf) {
|
xmlParserInputBufferPush(xmlParserInputBufferPtr in,
|
||||||
|
int len, const char *buf) {
|
||||||
int nbchars = 0;
|
int nbchars = 0;
|
||||||
|
|
||||||
if (len < 0) return(0);
|
if (len < 0) return(0);
|
||||||
@ -1208,7 +1212,8 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf) {
|
|||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
fprintf(stderr, "xmlParserInputBufferPush: encoder error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInputBufferPush: encoder error\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1216,7 +1221,8 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf) {
|
|||||||
xmlBufferAdd(in->buffer, (xmlChar *) buf, nbchars);
|
xmlBufferAdd(in->buffer, (xmlChar *) buf, nbchars);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "I/O: pushed %d chars, buffer %d/%d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"I/O: pushed %d chars, buffer %d/%d\n",
|
||||||
nbchars, in->buffer->use, in->buffer->size);
|
nbchars, in->buffer->use, in->buffer->size);
|
||||||
#endif
|
#endif
|
||||||
return(nbchars);
|
return(nbchars);
|
||||||
@ -1248,7 +1254,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
len = MINLEN;
|
len = MINLEN;
|
||||||
buffree = in->buffer->size - in->buffer->use;
|
buffree = in->buffer->size - in->buffer->use;
|
||||||
if (buffree <= 0) {
|
if (buffree <= 0) {
|
||||||
fprintf(stderr, "xmlParserInputBufferGrow : buffer full !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInputBufferGrow : buffer full !\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (len > buffree)
|
if (len > buffree)
|
||||||
@ -1256,7 +1263,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
|
|
||||||
buffer = (char *) xmlMalloc((len + 1) * sizeof(char));
|
buffer = (char *) xmlMalloc((len + 1) * sizeof(char));
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
fprintf(stderr, "xmlParserInputBufferGrow : out of memory !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInputBufferGrow : out of memory !\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1266,7 +1274,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
if (in->readcallback != NULL) {
|
if (in->readcallback != NULL) {
|
||||||
res = in->readcallback(in->context, &buffer[0], len);
|
res = in->readcallback(in->context, &buffer[0], len);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "xmlParserInputBufferGrow : no input !\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInputBufferGrow : no input !\n");
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -1290,7 +1299,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
fprintf(stderr, "xmlParserInputBufferGrow: encoder error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlParserInputBufferGrow: encoder error\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1299,7 +1309,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
xmlBufferAdd(in->buffer, (xmlChar *) buffer, nbchars);
|
xmlBufferAdd(in->buffer, (xmlChar *) buffer, nbchars);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "I/O: read %d chars, buffer %d/%d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"I/O: read %d chars, buffer %d/%d\n",
|
||||||
nbchars, in->buffer->use, in->buffer->size);
|
nbchars, in->buffer->use, in->buffer->size);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
@ -1367,7 +1378,8 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
|
|||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
nbchars = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
fprintf(stderr, "xmlOutputBufferWrite: encoder error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlOutputBufferWrite: encoder error\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
nbchars = out->conv->use;
|
nbchars = out->conv->use;
|
||||||
@ -1393,13 +1405,15 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
|
|||||||
xmlBufferShrink(out->buffer, nbchars);
|
xmlBufferShrink(out->buffer, nbchars);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "I/O: error %d writing %d bytes\n", ret, nbchars);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"I/O: error %d writing %d bytes\n", ret, nbchars);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
out->written += ret;
|
out->written += ret;
|
||||||
|
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "I/O: wrote %d chars\n", ret);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"I/O: wrote %d chars\n", ret);
|
||||||
#endif
|
#endif
|
||||||
return(nbchars);
|
return(nbchars);
|
||||||
}
|
}
|
||||||
@ -1451,7 +1465,8 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
|
|||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
nbchars = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
fprintf(stderr, "xmlOutputBufferWrite: encoder error\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlOutputBufferWrite: encoder error\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1471,13 +1486,15 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
|
|||||||
xmlBufferShrink(out->buffer, ret);
|
xmlBufferShrink(out->buffer, ret);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "I/O: error %d flushing %d bytes\n", ret, nbchars);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"I/O: error %d flushing %d bytes\n", ret, nbchars);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
out->written += ret;
|
out->written += ret;
|
||||||
|
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
fprintf(stderr, "I/O: flushed %d chars\n", ret);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"I/O: flushed %d chars\n", ret);
|
||||||
#endif
|
#endif
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@ -1548,19 +1565,20 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
|
|||||||
xmlParserInputPtr ret = NULL;
|
xmlParserInputPtr ret = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG_EXTERNAL_ENTITIES
|
#ifdef DEBUG_EXTERNAL_ENTITIES
|
||||||
fprintf(stderr, "xmlDefaultExternalEntityLoader(%s, xxx)\n", URL);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlDefaultExternalEntityLoader(%s, xxx)\n", URL);
|
||||||
#endif
|
#endif
|
||||||
if (URL == NULL) {
|
if (URL == NULL) {
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
||||||
ctxt->sax->warning(ctxt, "failed to load external entity \"%s\"\n",
|
ctxt->sax->warning(ctxt,
|
||||||
ID);
|
"failed to load external entity \"%s\"\n", ID);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret = xmlNewInputFromFile(ctxt, URL);
|
ret = xmlNewInputFromFile(ctxt, URL);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
|
||||||
ctxt->sax->warning(ctxt, "failed to load external entity \"%s\"\n",
|
ctxt->sax->warning(ctxt,
|
||||||
URL);
|
"failed to load external entity \"%s\"\n", URL);
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
24
xmlerror.h
24
xmlerror.h
@ -135,6 +135,30 @@ typedef enum {
|
|||||||
XML_ERR_URI_FRAGMENT /* 92 */
|
XML_ERR_URI_FRAGMENT /* 92 */
|
||||||
}xmlParserErrors;
|
}xmlParserErrors;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Signature of the function to use when there is an error and
|
||||||
|
* no parsing or validity context available
|
||||||
|
*/
|
||||||
|
typedef void (*xmlGenericErrorFunc) (void *ctx, const char *msg, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Those are the default error function and associated context to use
|
||||||
|
* when when there is an error and no parsing or validity context available
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern xmlGenericErrorFunc xmlGenericError;
|
||||||
|
extern void *xmlGenericErrorContext;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use the following function to reset the two previous global variables.
|
||||||
|
*/
|
||||||
|
void xmlSetGenericErrorFunc (void *ctx,
|
||||||
|
xmlGenericErrorFunc handler);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default message routines used by SAX and Valid context for error
|
||||||
|
* and warning reporting
|
||||||
|
*/
|
||||||
void xmlParserError (void *ctx,
|
void xmlParserError (void *ctx,
|
||||||
const char *msg,
|
const char *msg,
|
||||||
...);
|
...);
|
||||||
|
45
xmllint.c
45
xmllint.c
@ -54,6 +54,7 @@
|
|||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#include <libxml/xpath.h>
|
#include <libxml/xpath.h>
|
||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
@ -97,7 +98,7 @@ xmlHTMLEncodeSend(void) {
|
|||||||
|
|
||||||
result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
|
result = (char *) xmlEncodeEntitiesReentrant(NULL, BAD_CAST buffer);
|
||||||
if (result) {
|
if (result) {
|
||||||
fprintf(stderr, "%s", result);
|
xmlGenericError(xmlGenericErrorContext, "%s", result);
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
}
|
}
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
@ -112,7 +113,7 @@ xmlHTMLEncodeSend(void) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
|
xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
|
||||||
fprintf(stderr, "<p>");
|
xmlGenericError(xmlGenericErrorContext, "<p>");
|
||||||
if (input != NULL) {
|
if (input != NULL) {
|
||||||
if (input->filename) {
|
if (input->filename) {
|
||||||
sprintf(&buffer[strlen(buffer)], "%s:%d: ", input->filename,
|
sprintf(&buffer[strlen(buffer)], "%s:%d: ", input->filename,
|
||||||
@ -137,7 +138,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (input == NULL) return;
|
if (input == NULL) return;
|
||||||
fprintf(stderr, "<pre>\n");
|
xmlGenericError(xmlGenericErrorContext, "<pre>\n");
|
||||||
cur = input->cur;
|
cur = input->cur;
|
||||||
base = input->base;
|
base = input->base;
|
||||||
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
|
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
|
||||||
@ -164,7 +165,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
|
|||||||
}
|
}
|
||||||
sprintf(&buffer[strlen(buffer)],"^\n");
|
sprintf(&buffer[strlen(buffer)],"^\n");
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
fprintf(stderr, "</pre>");
|
xmlGenericError(xmlGenericErrorContext, "</pre>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,12 +194,12 @@ xmlHTMLError(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlHTMLPrintFileInfo(input);
|
xmlHTMLPrintFileInfo(input);
|
||||||
|
|
||||||
fprintf(stderr, "<b>error</b>: ");
|
xmlGenericError(xmlGenericErrorContext, "<b>error</b>: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vsprintf(&buffer[strlen(buffer)], msg, args);
|
vsprintf(&buffer[strlen(buffer)], msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
fprintf(stderr, "</p>\n");
|
xmlGenericError(xmlGenericErrorContext, "</p>\n");
|
||||||
|
|
||||||
xmlHTMLPrintFileContext(input);
|
xmlHTMLPrintFileContext(input);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
@ -231,12 +232,12 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlHTMLPrintFileInfo(input);
|
xmlHTMLPrintFileInfo(input);
|
||||||
|
|
||||||
fprintf(stderr, "<b>warning</b>: ");
|
xmlGenericError(xmlGenericErrorContext, "<b>warning</b>: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vsprintf(&buffer[strlen(buffer)], msg, args);
|
vsprintf(&buffer[strlen(buffer)], msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
fprintf(stderr, "</p>\n");
|
xmlGenericError(xmlGenericErrorContext, "</p>\n");
|
||||||
|
|
||||||
xmlHTMLPrintFileContext(input);
|
xmlHTMLPrintFileContext(input);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
@ -265,12 +266,12 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlHTMLPrintFileInfo(input);
|
xmlHTMLPrintFileInfo(input);
|
||||||
|
|
||||||
fprintf(stderr, "<b>validity error</b>: ");
|
xmlGenericError(xmlGenericErrorContext, "<b>validity error</b>: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vsprintf(&buffer[strlen(buffer)], msg, args);
|
vsprintf(&buffer[strlen(buffer)], msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
fprintf(stderr, "</p>\n");
|
xmlGenericError(xmlGenericErrorContext, "</p>\n");
|
||||||
|
|
||||||
xmlHTMLPrintFileContext(input);
|
xmlHTMLPrintFileContext(input);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
@ -299,12 +300,12 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlHTMLPrintFileInfo(input);
|
xmlHTMLPrintFileInfo(input);
|
||||||
|
|
||||||
fprintf(stderr, "<b>validity warning</b>: ");
|
xmlGenericError(xmlGenericErrorContext, "<b>validity warning</b>: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vsprintf(&buffer[strlen(buffer)], msg, args);
|
vsprintf(&buffer[strlen(buffer)], msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
fprintf(stderr, "</p>\n");
|
xmlGenericError(xmlGenericErrorContext, "</p>\n");
|
||||||
|
|
||||||
xmlHTMLPrintFileContext(input);
|
xmlHTMLPrintFileContext(input);
|
||||||
xmlHTMLEncodeSend();
|
xmlHTMLEncodeSend();
|
||||||
@ -568,12 +569,14 @@ void parseAndPrintFile(char *filename) {
|
|||||||
|
|
||||||
dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
|
dtd = xmlParseDTD(NULL, (const xmlChar *)dtdvalid);
|
||||||
if (dtd == NULL) {
|
if (dtd == NULL) {
|
||||||
fprintf(stderr, "Could not parse DTD %s\n", dtdvalid);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Could not parse DTD %s\n", dtdvalid);
|
||||||
} else {
|
} else {
|
||||||
xmlValidCtxt cvp;
|
xmlValidCtxt cvp;
|
||||||
cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
|
cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
|
||||||
if (!xmlValidateDtd(&cvp, doc, dtd)) {
|
if (!xmlValidateDtd(&cvp, doc, dtd)) {
|
||||||
fprintf(stderr, "Document %s does not validate against %s\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Document %s does not validate against %s\n",
|
||||||
filename, dtdvalid);
|
filename, dtdvalid);
|
||||||
}
|
}
|
||||||
xmlFreeDtd(dtd);
|
xmlFreeDtd(dtd);
|
||||||
@ -582,7 +585,8 @@ void parseAndPrintFile(char *filename) {
|
|||||||
xmlValidCtxt cvp;
|
xmlValidCtxt cvp;
|
||||||
cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
|
cvp.userData = (void *) stderr; cvp.error = (xmlValidityErrorFunc) fprintf; cvp.warning = (xmlValidityWarningFunc) fprintf;
|
||||||
if (!xmlValidateDocument(&cvp, doc)) {
|
if (!xmlValidateDocument(&cvp, doc)) {
|
||||||
fprintf(stderr, "Document %s does not validate\n", filename);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Document %s does not validate\n", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -703,13 +707,14 @@ int main(int argc, char **argv) {
|
|||||||
if (noent != 0) xmlSubstituteEntitiesDefault(1);
|
if (noent != 0) xmlSubstituteEntitiesDefault(1);
|
||||||
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
|
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
|
||||||
if ((htmlout) && (!nowrap)) {
|
if ((htmlout) && (!nowrap)) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
|
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n");
|
||||||
fprintf(stderr, "\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
fprintf(stderr,
|
"\t\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"<html><head><title>%s output</title></head>\n",
|
"<html><head><title>%s output</title></head>\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
|
"<body bgcolor=\"#ffffff\"><h1 align=\"center\">%s output</h1>\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
}
|
}
|
||||||
@ -734,7 +739,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((htmlout) && (!nowrap)) {
|
if ((htmlout) && (!nowrap)) {
|
||||||
fprintf(stderr, "</body></html>\n");
|
xmlGenericError(xmlGenericErrorContext, "</body></html>\n");
|
||||||
}
|
}
|
||||||
if (files == 0) {
|
if (files == 0) {
|
||||||
printf("Usage : %s [--debug] [--debugent] [--copy] [--recover] [--noent] [--noout] [--valid] [--repeat] XMLfiles ...\n",
|
printf("Usage : %s [--debug] [--debugent] [--copy] [--recover] [--noent] [--noout] [--valid] [--repeat] XMLfiles ...\n",
|
||||||
|
22
xmlmemory.c
22
xmlmemory.c
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#ifdef xmlMalloc
|
#ifdef xmlMalloc
|
||||||
#undef xmlMalloc
|
#undef xmlMalloc
|
||||||
@ -111,7 +112,8 @@ void debugmem_list_delete(MEMHDR *);
|
|||||||
|
|
||||||
void
|
void
|
||||||
xmlMallocBreakpoint(void) {
|
xmlMallocBreakpoint(void) {
|
||||||
fprintf(stderr, "xmlMallocBreakpoint reached on block %d\n", xmlMemStopAtBlock);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlMallocBreakpoint reached on block %d\n", xmlMemStopAtBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +134,8 @@ xmlMallocLoc(int size, const char * file, int line)
|
|||||||
|
|
||||||
if (!xmlMemInitialized) xmlInitMemory();
|
if (!xmlMemInitialized) xmlInitMemory();
|
||||||
#ifdef DEBUG_MEMORY
|
#ifdef DEBUG_MEMORY
|
||||||
fprintf(stderr, "Malloc(%d)\n",size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Malloc(%d)\n",size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST_POINT
|
TEST_POINT
|
||||||
@ -140,7 +143,8 @@ xmlMallocLoc(int size, const char * file, int line)
|
|||||||
p = (MEMHDR *) malloc(RESERVE_SIZE+size);
|
p = (MEMHDR *) malloc(RESERVE_SIZE+size);
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
fprintf(stderr, "xmlMalloc : Out of free space\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlMalloc : Out of free space\n");
|
||||||
xmlMemoryDump();
|
xmlMemoryDump();
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -157,7 +161,8 @@ xmlMallocLoc(int size, const char * file, int line)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_MEMORY
|
#ifdef DEBUG_MEMORY
|
||||||
fprintf(stderr, "Malloc(%d) Ok\n",size);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Malloc(%d) Ok\n",size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (xmlMemStopAtBlock == block) xmlMallocBreakpoint();
|
if (xmlMemStopAtBlock == block) xmlMallocBreakpoint();
|
||||||
@ -285,7 +290,8 @@ xmlMemFree(void *ptr)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
fprintf(stderr, "xmlFree(%X) error\n", (unsigned int) ptr);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlFree(%X) error\n", (unsigned int) ptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,7 +563,8 @@ void debugmem_list_delete(MEMHDR *p)
|
|||||||
|
|
||||||
void debugmem_tag_error(void *p)
|
void debugmem_tag_error(void *p)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Memory tag error occurs :%p \n\t bye\n", p);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Memory tag error occurs :%p \n\t bye\n", p);
|
||||||
#ifdef MEM_LIST
|
#ifdef MEM_LIST
|
||||||
if (stderr)
|
if (stderr)
|
||||||
xmlMemDisplay(stderr);
|
xmlMemDisplay(stderr);
|
||||||
@ -637,7 +644,8 @@ xmlInitMemory(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_MEMORY
|
#ifdef DEBUG_MEMORY
|
||||||
fprintf(stderr, "xmlInitMemory() Ok\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlInitMemory() Ok\n");
|
||||||
#endif
|
#endif
|
||||||
ret = 0;
|
ret = 0;
|
||||||
return(ret);
|
return(ret);
|
||||||
|
242
xpath.c
242
xpath.c
@ -57,6 +57,7 @@
|
|||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
/* #define DEBUG */
|
/* #define DEBUG */
|
||||||
/* #define DEBUG_STEP */
|
/* #define DEBUG_STEP */
|
||||||
@ -173,21 +174,17 @@ xmlXPathInit(void) {
|
|||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
FILE *xmlXPathDebug = NULL;
|
|
||||||
|
|
||||||
#define TODO \
|
#define TODO \
|
||||||
fprintf(xmlXPathDebug, "Unimplemented block at %s:%d\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"Unimplemented block at %s:%d\n", \
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
#define STRANGE \
|
#define STRANGE \
|
||||||
fprintf(xmlXPathDebug, "Internal error at %s:%d\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"Internal error at %s:%d\n", \
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
double xmlXPathStringEvalNumber(const xmlChar *str);
|
|
||||||
void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
|
||||||
void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt);
|
|
||||||
|
|
||||||
void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
|
void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
|
||||||
int i;
|
int i;
|
||||||
char shift[100];
|
char shift[100];
|
||||||
@ -360,7 +357,8 @@ extern int name##Push(xmlXPathParserContextPtr ctxt, type value) { \
|
|||||||
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
ctxt->name##Tab = (type *) xmlRealloc(ctxt->name##Tab, \
|
||||||
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
ctxt->name##Max * sizeof(ctxt->name##Tab[0])); \
|
||||||
if (ctxt->name##Tab == NULL) { \
|
if (ctxt->name##Tab == NULL) { \
|
||||||
fprintf(xmlXPathDebug, "realloc failed !\n"); \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"realloc failed !\n"); \
|
||||||
return(0); \
|
return(0); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@ -464,7 +462,8 @@ xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file,
|
|||||||
const xmlChar *cur;
|
const xmlChar *cur;
|
||||||
const xmlChar *base;
|
const xmlChar *base;
|
||||||
|
|
||||||
fprintf(xmlXPathDebug, "Error %s:%d: %s\n", file, line,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Error %s:%d: %s\n", file, line,
|
||||||
xmlXPathErrorMessages[no]);
|
xmlXPathErrorMessages[no]);
|
||||||
|
|
||||||
cur = ctxt->cur;
|
cur = ctxt->cur;
|
||||||
@ -479,19 +478,19 @@ xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file,
|
|||||||
base = cur;
|
base = cur;
|
||||||
n = 0;
|
n = 0;
|
||||||
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
|
while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < 79)) {
|
||||||
fprintf(xmlXPathDebug, "%c", (unsigned char) *cur++);
|
xmlGenericError(xmlGenericErrorContext, "%c", (unsigned char) *cur++);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
fprintf(xmlXPathDebug, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
cur = ctxt->cur;
|
cur = ctxt->cur;
|
||||||
while ((*cur == '\n') || (*cur == '\r'))
|
while ((*cur == '\n') || (*cur == '\r'))
|
||||||
cur--;
|
cur--;
|
||||||
n = 0;
|
n = 0;
|
||||||
while ((cur != base) && (n++ < 80)) {
|
while ((cur != base) && (n++ < 80)) {
|
||||||
fprintf(xmlXPathDebug, " ");
|
xmlGenericError(xmlGenericErrorContext, " ");
|
||||||
base++;
|
base++;
|
||||||
}
|
}
|
||||||
fprintf(xmlXPathDebug,"^\n");
|
xmlGenericError(xmlGenericErrorContext,"^\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -516,7 +515,8 @@ xmlXPathNodeSetCreate(xmlNodePtr val) {
|
|||||||
|
|
||||||
ret = (xmlNodeSetPtr) xmlMalloc(sizeof(xmlNodeSet));
|
ret = (xmlNodeSetPtr) xmlMalloc(sizeof(xmlNodeSet));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewNodeSet: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewNodeSet: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlNodeSet));
|
memset(ret, 0 , (size_t) sizeof(xmlNodeSet));
|
||||||
@ -524,7 +524,8 @@ xmlXPathNodeSetCreate(xmlNodePtr val) {
|
|||||||
ret->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
|
ret->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
|
||||||
sizeof(xmlNodePtr));
|
sizeof(xmlNodePtr));
|
||||||
if (ret->nodeTab == NULL) {
|
if (ret->nodeTab == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewNodeSet: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewNodeSet: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret->nodeTab, 0 ,
|
memset(ret->nodeTab, 0 ,
|
||||||
@ -561,7 +562,8 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
|
|||||||
cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
|
cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
|
||||||
sizeof(xmlNodePtr));
|
sizeof(xmlNodePtr));
|
||||||
if (cur->nodeTab == NULL) {
|
if (cur->nodeTab == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNodeSetAdd: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNodeSetAdd: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(cur->nodeTab, 0 ,
|
memset(cur->nodeTab, 0 ,
|
||||||
@ -574,7 +576,8 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
|
|||||||
temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
|
temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
|
||||||
sizeof(xmlNodePtr));
|
sizeof(xmlNodePtr));
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNodeSetAdd: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNodeSetAdd: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur->nodeTab = temp;
|
cur->nodeTab = temp;
|
||||||
@ -634,7 +637,7 @@ xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val) {
|
|||||||
|
|
||||||
if (i >= cur->nodeNr) {
|
if (i >= cur->nodeNr) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(xmlXPathDebug,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlXPathNodeSetDel: Node %s wasn't found in NodeList\n",
|
"xmlXPathNodeSetDel: Node %s wasn't found in NodeList\n",
|
||||||
val->name);
|
val->name);
|
||||||
#endif
|
#endif
|
||||||
@ -686,17 +689,17 @@ xmlXPathFreeNodeSet(xmlNodeSetPtr obj) {
|
|||||||
|
|
||||||
#if defined(DEBUG) || defined(DEBUG_STEP)
|
#if defined(DEBUG) || defined(DEBUG_STEP)
|
||||||
/**
|
/**
|
||||||
* xmlXPathDebugNodeSet:
|
* xmlGenericErrorContextNodeSet:
|
||||||
* @output: a FILE * for the output
|
* @output: a FILE * for the output
|
||||||
* @obj: the xmlNodeSetPtr to free
|
* @obj: the xmlNodeSetPtr to free
|
||||||
*
|
*
|
||||||
* Quick display of a NodeSet
|
* Quick display of a NodeSet
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlXPathDebugNodeSet(FILE *output, xmlNodeSetPtr obj) {
|
xmlGenericErrorContextNodeSet(FILE *output, xmlNodeSetPtr obj) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (output == NULL) output = xmlXPathDebug;
|
if (output == NULL) output = xmlGenericErrorContext;
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
fprintf(output, "NodeSet == NULL !\n");
|
fprintf(output, "NodeSet == NULL !\n");
|
||||||
return;
|
return;
|
||||||
@ -740,7 +743,8 @@ xmlXPathNewNodeSet(xmlNodePtr val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewNodeSet: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewNodeSet: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -791,7 +795,8 @@ xmlXPathWrapNodeSet(xmlNodeSetPtr val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathWrapNodeSet: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathWrapNodeSet: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -976,7 +981,8 @@ xmlXPathNewFloat(double val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewFloat: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewFloat: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -999,7 +1005,8 @@ xmlXPathNewBoolean(int val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewBoolean: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewBoolean: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -1022,7 +1029,8 @@ xmlXPathNewString(const xmlChar *val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewString: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewString: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -1045,7 +1053,8 @@ xmlXPathNewCString(const char *val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewCString: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewCString: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -1071,7 +1080,8 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathObjectCopy: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathObjectCopy: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memcpy(ret, val , (size_t) sizeof(xmlXPathObject));
|
memcpy(ret, val , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -1095,7 +1105,8 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
|
|||||||
#endif
|
#endif
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
case XPATH_USERS:
|
case XPATH_USERS:
|
||||||
fprintf(xmlXPathDebug, "xmlXPathObjectCopy: unsupported type %d\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathObjectCopy: unsupported type %d\n",
|
||||||
val->type);
|
val->type);
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
@ -1149,7 +1160,8 @@ xmlXPathNewContext(xmlDocPtr doc) {
|
|||||||
|
|
||||||
ret = (xmlXPathContextPtr) xmlMalloc(sizeof(xmlXPathContext));
|
ret = (xmlXPathContextPtr) xmlMalloc(sizeof(xmlXPathContext));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewContext: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewContext: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathContext));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathContext));
|
||||||
@ -1207,22 +1219,25 @@ xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
|
|||||||
|
|
||||||
#define CHECK_CTXT(ctxt) \
|
#define CHECK_CTXT(ctxt) \
|
||||||
if (ctxt == NULL) { \
|
if (ctxt == NULL) { \
|
||||||
fprintf(xmlXPathDebug, "%s:%d Internal error: ctxt == NULL\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"%s:%d Internal error: ctxt == NULL\n", \
|
||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
|
|
||||||
#define CHECK_CONTEXT(ctxt) \
|
#define CHECK_CONTEXT(ctxt) \
|
||||||
if (ctxt == NULL) { \
|
if (ctxt == NULL) { \
|
||||||
fprintf(xmlXPathDebug, "%s:%d Internal error: no context\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"%s:%d Internal error: no context\n", \
|
||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
} \
|
} \
|
||||||
else if (ctxt->doc == NULL) { \
|
else if (ctxt->doc == NULL) { \
|
||||||
fprintf(xmlXPathDebug, "%s:%d Internal error: no document\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"%s:%d Internal error: no document\n", \
|
||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
} \
|
} \
|
||||||
else if (ctxt->doc->children == NULL) { \
|
else if (ctxt->doc->children == NULL) { \
|
||||||
fprintf(xmlXPathDebug, \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
"%s:%d Internal error: document without root\n", \
|
"%s:%d Internal error: document without root\n", \
|
||||||
__FILE__, __LINE__); \
|
__FILE__, __LINE__); \
|
||||||
} \
|
} \
|
||||||
@ -1243,7 +1258,8 @@ xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
|
|||||||
|
|
||||||
ret = (xmlXPathParserContextPtr) xmlMalloc(sizeof(xmlXPathParserContext));
|
ret = (xmlXPathParserContextPtr) xmlMalloc(sizeof(xmlXPathParserContext));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathNewParserContext: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathNewParserContext: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext));
|
||||||
@ -1432,7 +1448,8 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
|
|||||||
|
|
||||||
if (arg1 == arg2) {
|
if (arg1 == arg2) {
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: by pointer\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: by pointer\n");
|
||||||
#endif
|
#endif
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@ -1440,14 +1457,16 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
|
|||||||
switch (arg1->type) {
|
switch (arg1->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: undefined\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
switch (arg2->type) {
|
switch (arg2->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: undefined\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
@ -1478,7 +1497,8 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
|
|||||||
switch (arg2->type) {
|
switch (arg2->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: undefined\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
@ -1489,7 +1509,8 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
|
|||||||
break;
|
break;
|
||||||
case XPATH_BOOLEAN:
|
case XPATH_BOOLEAN:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: %d boolean %d \n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: %d boolean %d \n",
|
||||||
arg1->boolval, arg2->boolval);
|
arg1->boolval, arg2->boolval);
|
||||||
#endif
|
#endif
|
||||||
ret = (arg1->boolval == arg2->boolval);
|
ret = (arg1->boolval == arg2->boolval);
|
||||||
@ -1518,7 +1539,8 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
|
|||||||
switch (arg2->type) {
|
switch (arg2->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: undefined\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
@ -1549,7 +1571,8 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
|
|||||||
switch (arg2->type) {
|
switch (arg2->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Equal: undefined\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Equal: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case XPATH_NODESET:
|
case XPATH_NODESET:
|
||||||
@ -2346,74 +2369,88 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
|
|||||||
obj = valuePop(ctxt);
|
obj = valuePop(ctxt);
|
||||||
|
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "new step : ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"new step : ");
|
||||||
#endif
|
#endif
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case AXIS_ANCESTOR:
|
case AXIS_ANCESTOR:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'ancestors' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'ancestors' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextAncestor; break;
|
next = xmlXPathNextAncestor; break;
|
||||||
case AXIS_ANCESTOR_OR_SELF:
|
case AXIS_ANCESTOR_OR_SELF:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'ancestors-or-self' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'ancestors-or-self' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextAncestorOrSelf; break;
|
next = xmlXPathNextAncestorOrSelf; break;
|
||||||
case AXIS_ATTRIBUTE:
|
case AXIS_ATTRIBUTE:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'attributes' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'attributes' ");
|
||||||
#endif
|
#endif
|
||||||
next = (xmlXPathTraversalFunction) xmlXPathNextAttribute; break;
|
next = (xmlXPathTraversalFunction) xmlXPathNextAttribute; break;
|
||||||
break;
|
break;
|
||||||
case AXIS_CHILD:
|
case AXIS_CHILD:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'child' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'child' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextChild; break;
|
next = xmlXPathNextChild; break;
|
||||||
case AXIS_DESCENDANT:
|
case AXIS_DESCENDANT:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'descendant' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'descendant' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextDescendant; break;
|
next = xmlXPathNextDescendant; break;
|
||||||
case AXIS_DESCENDANT_OR_SELF:
|
case AXIS_DESCENDANT_OR_SELF:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'descendant-or-self' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'descendant-or-self' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextDescendantOrSelf; break;
|
next = xmlXPathNextDescendantOrSelf; break;
|
||||||
case AXIS_FOLLOWING:
|
case AXIS_FOLLOWING:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'following' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'following' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextFollowing; break;
|
next = xmlXPathNextFollowing; break;
|
||||||
case AXIS_FOLLOWING_SIBLING:
|
case AXIS_FOLLOWING_SIBLING:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'following-siblings' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'following-siblings' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextFollowingSibling; break;
|
next = xmlXPathNextFollowingSibling; break;
|
||||||
case AXIS_NAMESPACE:
|
case AXIS_NAMESPACE:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'namespace' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'namespace' ");
|
||||||
#endif
|
#endif
|
||||||
next = (xmlXPathTraversalFunction) xmlXPathNextNamespace; break;
|
next = (xmlXPathTraversalFunction) xmlXPathNextNamespace; break;
|
||||||
break;
|
break;
|
||||||
case AXIS_PARENT:
|
case AXIS_PARENT:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'parent' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'parent' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextParent; break;
|
next = xmlXPathNextParent; break;
|
||||||
case AXIS_PRECEDING:
|
case AXIS_PRECEDING:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'preceding' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'preceding' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextPreceding; break;
|
next = xmlXPathNextPreceding; break;
|
||||||
case AXIS_PRECEDING_SIBLING:
|
case AXIS_PRECEDING_SIBLING:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'preceding-sibling' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'preceding-sibling' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextPrecedingSibling; break;
|
next = xmlXPathNextPrecedingSibling; break;
|
||||||
case AXIS_SELF:
|
case AXIS_SELF:
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "axis 'self' ");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"axis 'self' ");
|
||||||
#endif
|
#endif
|
||||||
next = xmlXPathNextSelf; break;
|
next = xmlXPathNextSelf; break;
|
||||||
}
|
}
|
||||||
@ -2423,33 +2460,41 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
|
|||||||
nodelist = obj->nodesetval;
|
nodelist = obj->nodesetval;
|
||||||
ret = xmlXPathNodeSetCreate(NULL);
|
ret = xmlXPathNodeSetCreate(NULL);
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, " context contains %d nodes\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" context contains %d nodes\n",
|
||||||
nodelist->nodeNr);
|
nodelist->nodeNr);
|
||||||
switch (test) {
|
switch (test) {
|
||||||
case NODE_TEST_NONE:
|
case NODE_TEST_NONE:
|
||||||
fprintf(xmlXPathDebug, " searching for none !!!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" searching for none !!!\n");
|
||||||
break;
|
break;
|
||||||
case NODE_TEST_TYPE:
|
case NODE_TEST_TYPE:
|
||||||
fprintf(xmlXPathDebug, " searching for type %d\n", type);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" searching for type %d\n", type);
|
||||||
break;
|
break;
|
||||||
case NODE_TEST_PI:
|
case NODE_TEST_PI:
|
||||||
fprintf(xmlXPathDebug, " searching for PI !!!\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" searching for PI !!!\n");
|
||||||
break;
|
break;
|
||||||
case NODE_TEST_ALL:
|
case NODE_TEST_ALL:
|
||||||
fprintf(xmlXPathDebug, " searching for *\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" searching for *\n");
|
||||||
break;
|
break;
|
||||||
case NODE_TEST_NS:
|
case NODE_TEST_NS:
|
||||||
fprintf(xmlXPathDebug, " searching for namespace %s\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" searching for namespace %s\n",
|
||||||
prefix);
|
prefix);
|
||||||
break;
|
break;
|
||||||
case NODE_TEST_NAME:
|
case NODE_TEST_NAME:
|
||||||
fprintf(xmlXPathDebug, " searching for name %s\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" searching for name %s\n", name);
|
||||||
if (prefix != NULL)
|
if (prefix != NULL)
|
||||||
fprintf(xmlXPathDebug, " with namespace %s\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
" with namespace %s\n",
|
||||||
prefix);
|
prefix);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(xmlXPathDebug, "Testing : ");
|
xmlGenericError(xmlGenericErrorContext, "Testing : ");
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* 2.3 Node Tests
|
* 2.3 Node Tests
|
||||||
@ -2470,7 +2515,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
|
|||||||
if (cur == NULL) break;
|
if (cur == NULL) break;
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
t++;
|
t++;
|
||||||
fprintf(xmlXPathDebug, " %s", cur->name);
|
xmlGenericError(xmlGenericErrorContext, " %s", cur->name);
|
||||||
#endif
|
#endif
|
||||||
switch (test) {
|
switch (test) {
|
||||||
case NODE_TEST_NONE:
|
case NODE_TEST_NONE:
|
||||||
@ -2543,7 +2588,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
|
|||||||
} while (cur != NULL);
|
} while (cur != NULL);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"\nExamined %d nodes, found %d nodes at that step\n", t, n);
|
"\nExamined %d nodes, found %d nodes at that step\n", t, n);
|
||||||
#endif
|
#endif
|
||||||
xmlXPathFreeObject(obj);
|
xmlXPathFreeObject(obj);
|
||||||
@ -2597,7 +2642,8 @@ xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
if (ctxt->context->contextSize > 0) {
|
if (ctxt->context->contextSize > 0) {
|
||||||
valuePush(ctxt, xmlXPathNewFloat((double) ctxt->context->contextSize));
|
valuePush(ctxt, xmlXPathNewFloat((double) ctxt->context->contextSize));
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "last() : %d\n", ctxt->context->contextSize);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"last() : %d\n", ctxt->context->contextSize);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
XP_ERROR(XPATH_INVALID_CTXT_SIZE);
|
XP_ERROR(XPATH_INVALID_CTXT_SIZE);
|
||||||
@ -2620,7 +2666,7 @@ xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
valuePush(ctxt,
|
valuePush(ctxt,
|
||||||
xmlXPathNewFloat((double) ctxt->context->proximityPosition));
|
xmlXPathNewFloat((double) ctxt->context->proximityPosition));
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "position() : %d\n",
|
xmlGenericError(xmlGenericErrorContext, "position() : %d\n",
|
||||||
ctxt->context->proximityPosition);
|
ctxt->context->proximityPosition);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@ -2885,7 +2931,7 @@ xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "String: undefined\n");
|
xmlGenericError(xmlGenericErrorContext, "String: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
valuePush(ctxt, xmlXPathNewCString(""));
|
valuePush(ctxt, xmlXPathNewCString(""));
|
||||||
break;
|
break;
|
||||||
@ -3495,7 +3541,7 @@ xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
case XPATH_UNDEFINED:
|
case XPATH_UNDEFINED:
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "NUMBER: undefined\n");
|
xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n");
|
||||||
#endif
|
#endif
|
||||||
valuePush(ctxt, xmlXPathNewFloat(0.0));
|
valuePush(ctxt, xmlXPathNewFloat(0.0));
|
||||||
break;
|
break;
|
||||||
@ -3967,7 +4013,7 @@ xmlXPathEvalFunctionCall(xmlXPathParserContextPtr ctxt) {
|
|||||||
XP_ERROR(XPATH_UNKNOWN_FUNC_ERROR);
|
XP_ERROR(XPATH_UNKNOWN_FUNC_ERROR);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_EXPR
|
#ifdef DEBUG_EXPR
|
||||||
fprintf(xmlXPathDebug, "Calling function %s\n", name);
|
xmlGenericError(xmlGenericErrorContext, "Calling function %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (CUR != '(') {
|
if (CUR != '(') {
|
||||||
@ -4098,7 +4144,7 @@ xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
|
|||||||
buf[len] = NXT(len);
|
buf[len] = NXT(len);
|
||||||
len++;
|
len++;
|
||||||
if (len >= XML_MAX_NAMELEN) {
|
if (len >= XML_MAX_NAMELEN) {
|
||||||
fprintf(stderr,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlScanName: reached XML_MAX_NAMELEN limit\n");
|
"xmlScanName: reached XML_MAX_NAMELEN limit\n");
|
||||||
while ((IS_LETTER(NXT(len))) || (IS_DIGIT(NXT(len))) ||
|
while ((IS_LETTER(NXT(len))) || (IS_DIGIT(NXT(len))) ||
|
||||||
(NXT(len) == '.') || (NXT(len) == '-') ||
|
(NXT(len) == '.') || (NXT(len) == '-') ||
|
||||||
@ -4170,7 +4216,8 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) {
|
|||||||
if (NXT(len) == '/') {
|
if (NXT(len) == '/') {
|
||||||
/* element name */
|
/* element name */
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "PathExpr: AbbrRelLocation\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PathExpr: AbbrRelLocation\n");
|
||||||
#endif
|
#endif
|
||||||
lc = 1;
|
lc = 1;
|
||||||
break;
|
break;
|
||||||
@ -4179,7 +4226,8 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) {
|
|||||||
blank = 1;
|
blank = 1;
|
||||||
} else if (NXT(len) == ':') {
|
} else if (NXT(len) == ':') {
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "PathExpr: AbbrRelLocation\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PathExpr: AbbrRelLocation\n");
|
||||||
#endif
|
#endif
|
||||||
lc = 1;
|
lc = 1;
|
||||||
break;
|
break;
|
||||||
@ -4187,12 +4235,14 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) {
|
|||||||
/* Note Type or Function */
|
/* Note Type or Function */
|
||||||
if (xmlXPathIsNodeType(name)) {
|
if (xmlXPathIsNodeType(name)) {
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "PathExpr: Type search\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PathExpr: Type search\n");
|
||||||
#endif
|
#endif
|
||||||
lc = 1;
|
lc = 1;
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "PathExpr: function call\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PathExpr: function call\n");
|
||||||
#endif
|
#endif
|
||||||
lc = 0;
|
lc = 0;
|
||||||
}
|
}
|
||||||
@ -4200,7 +4250,8 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) {
|
|||||||
} else if ((NXT(len) == '[')) {
|
} else if ((NXT(len) == '[')) {
|
||||||
/* element name */
|
/* element name */
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "PathExpr: AbbrRelLocation\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PathExpr: AbbrRelLocation\n");
|
||||||
#endif
|
#endif
|
||||||
lc = 1;
|
lc = 1;
|
||||||
break;
|
break;
|
||||||
@ -4211,7 +4262,8 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) {
|
|||||||
}
|
}
|
||||||
if (NXT(len) == 0) {
|
if (NXT(len) == 0) {
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "PathExpr: AbbrRelLocation\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"PathExpr: AbbrRelLocation\n");
|
||||||
#endif
|
#endif
|
||||||
/* element name */
|
/* element name */
|
||||||
lc = 1;
|
lc = 1;
|
||||||
@ -4685,8 +4737,9 @@ xmlXPathEvalPredicate(xmlXPathParserContextPtr ctxt) {
|
|||||||
NEXT;
|
NEXT;
|
||||||
SKIP_BLANKS;
|
SKIP_BLANKS;
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "After predicate : ");
|
xmlGenericError(xmlGenericErrorContext, "After predicate : ");
|
||||||
xmlXPathDebugNodeSet(xmlXPathDebug, ctxt->value->nodesetval);
|
xmlGenericErrorContextNodeSet(xmlGenericErrorContext,
|
||||||
|
ctxt->value->nodesetval);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5017,12 +5070,13 @@ xmlXPathEvalStep(xmlXPathParserContextPtr ctxt) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "Basis : computing new set\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Basis : computing new set\n");
|
||||||
#endif
|
#endif
|
||||||
xmlXPathNodeCollectAndTest(ctxt, axis, test, type, prefix, name);
|
xmlXPathNodeCollectAndTest(ctxt, axis, test, type, prefix, name);
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "Basis : ");
|
xmlGenericError(xmlGenericErrorContext, "Basis : ");
|
||||||
xmlXPathDebugNodeSet(stdout, ctxt->value->nodesetval);
|
xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
|
||||||
#endif
|
#endif
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
xmlFree(name);
|
xmlFree(name);
|
||||||
@ -5036,8 +5090,9 @@ eval_predicates:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_STEP
|
#ifdef DEBUG_STEP
|
||||||
fprintf(xmlXPathDebug, "Step : ");
|
xmlGenericError(xmlGenericErrorContext, "Step : ");
|
||||||
xmlXPathDebugNodeSet(xmlXPathDebug, ctxt->value->nodesetval);
|
xmlGenericErrorContextNodeSet(xmlGenericErrorContext,
|
||||||
|
ctxt->value->nodesetval);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5144,9 +5199,6 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
|
|
||||||
xmlXPathInit();
|
xmlXPathInit();
|
||||||
|
|
||||||
if (xmlXPathDebug == NULL)
|
|
||||||
xmlXPathDebug = stderr;
|
|
||||||
|
|
||||||
CHECK_CONTEXT(ctx)
|
CHECK_CONTEXT(ctx)
|
||||||
|
|
||||||
ctxt = xmlXPathNewParserContext(str, ctx);
|
ctxt = xmlXPathNewParserContext(str, ctx);
|
||||||
@ -5159,7 +5211,7 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
xmlXPathEvalExpr(ctxt);
|
xmlXPathEvalExpr(ctxt);
|
||||||
|
|
||||||
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
|
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
|
||||||
fprintf(xmlXPathDebug,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlXPathEval: evaluation failed to return a node set\n");
|
"xmlXPathEval: evaluation failed to return a node set\n");
|
||||||
} else {
|
} else {
|
||||||
res = valuePop(ctxt);
|
res = valuePop(ctxt);
|
||||||
@ -5174,7 +5226,8 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
}
|
}
|
||||||
} while (tmp != NULL);
|
} while (tmp != NULL);
|
||||||
if (stack != 0) {
|
if (stack != 0) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathEval: %d object left on the stack\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathEval: %d object left on the stack\n",
|
||||||
stack);
|
stack);
|
||||||
}
|
}
|
||||||
if (ctxt->error != XPATH_EXPRESSION_OK) {
|
if (ctxt->error != XPATH_EXPRESSION_OK) {
|
||||||
@ -5206,8 +5259,6 @@ xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
|
|||||||
|
|
||||||
CHECK_CONTEXT(ctxt)
|
CHECK_CONTEXT(ctxt)
|
||||||
|
|
||||||
if (xmlXPathDebug == NULL)
|
|
||||||
xmlXPathDebug = stderr;
|
|
||||||
pctxt = xmlXPathNewParserContext(str, ctxt);
|
pctxt = xmlXPathNewParserContext(str, ctxt);
|
||||||
xmlXPathEvalExpr(pctxt);
|
xmlXPathEvalExpr(pctxt);
|
||||||
|
|
||||||
@ -5220,7 +5271,8 @@ xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
|
|||||||
}
|
}
|
||||||
} while (tmp != NULL);
|
} while (tmp != NULL);
|
||||||
if (stack != 0) {
|
if (stack != 0) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPathEvalExpression: %d object left on the stack\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPathEvalExpression: %d object left on the stack\n",
|
||||||
stack);
|
stack);
|
||||||
}
|
}
|
||||||
xmlXPathFreeParserContext(pctxt);
|
xmlXPathFreeParserContext(pctxt);
|
||||||
|
103
xpointer.c
103
xpointer.c
@ -33,20 +33,20 @@
|
|||||||
#ifdef LIBXML_DEBUG_ENABLED
|
#ifdef LIBXML_DEBUG_ENABLED
|
||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
#ifdef LIBXML_XPTR_ENABLED
|
#ifdef LIBXML_XPTR_ENABLED
|
||||||
|
|
||||||
/* #define DEBUG_RANGES */
|
/* #define DEBUG_RANGES */
|
||||||
|
|
||||||
|
|
||||||
extern FILE *xmlXPathDebug;
|
|
||||||
|
|
||||||
#define TODO \
|
#define TODO \
|
||||||
fprintf(xmlXPathDebug, "Unimplemented block at %s:%d\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"Unimplemented block at %s:%d\n", \
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
#define STRANGE \
|
#define STRANGE \
|
||||||
fprintf(xmlXPathDebug, "Internal error at %s:%d\n", \
|
xmlGenericError(xmlGenericErrorContext, \
|
||||||
|
"Internal error at %s:%d\n", \
|
||||||
__FILE__, __LINE__);
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -235,7 +235,8 @@ xmlXPtrNewPoint(xmlNodePtr node, int index) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewPoint: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewPoint: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -300,7 +301,8 @@ xmlXPtrNewRange(xmlNodePtr start, int startindex,
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangePoints: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangePoints: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -337,7 +339,8 @@ xmlXPtrNewRangePoints(xmlXPathObjectPtr start, xmlXPathObjectPtr end) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangePoints: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangePoints: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -372,7 +375,8 @@ xmlXPtrNewRangePointNode(xmlXPathObjectPtr start, xmlNodePtr end) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangePointNode: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangePointNode: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -409,7 +413,8 @@ xmlXPtrNewRangeNodePoint(xmlNodePtr start, xmlXPathObjectPtr end) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangeNodePoint: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangeNodePoint: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -442,7 +447,8 @@ xmlXPtrNewRangeNodes(xmlNodePtr start, xmlNodePtr end) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangeNodes: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangeNodes: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -472,7 +478,8 @@ xmlXPtrNewCollapsedRange(xmlNodePtr start) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangeNodes: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangeNodes: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -518,7 +525,8 @@ xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr end) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewRangeNodeObject: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewRangeNodeObject: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -558,7 +566,8 @@ xmlXPtrLocationSetCreate(xmlXPathObjectPtr val) {
|
|||||||
|
|
||||||
ret = (xmlLocationSetPtr) xmlMalloc(sizeof(xmlLocationSet));
|
ret = (xmlLocationSetPtr) xmlMalloc(sizeof(xmlLocationSet));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrLocationSetCreate: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrLocationSetCreate: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlLocationSet));
|
memset(ret, 0 , (size_t) sizeof(xmlLocationSet));
|
||||||
@ -566,7 +575,8 @@ xmlXPtrLocationSetCreate(xmlXPathObjectPtr val) {
|
|||||||
ret->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
|
ret->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
|
||||||
sizeof(xmlXPathObjectPtr));
|
sizeof(xmlXPathObjectPtr));
|
||||||
if (ret->locTab == NULL) {
|
if (ret->locTab == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrLocationSetCreate: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrLocationSetCreate: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret->locTab, 0 ,
|
memset(ret->locTab, 0 ,
|
||||||
@ -603,7 +613,8 @@ xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
|
|||||||
cur->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
|
cur->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
|
||||||
sizeof(xmlXPathObjectPtr));
|
sizeof(xmlXPathObjectPtr));
|
||||||
if (cur->locTab == NULL) {
|
if (cur->locTab == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrLocationSetAdd: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrLocationSetAdd: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(cur->locTab, 0 ,
|
memset(cur->locTab, 0 ,
|
||||||
@ -616,7 +627,8 @@ xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
|
|||||||
temp = (xmlXPathObjectPtr *) xmlRealloc(cur->locTab, cur->locMax *
|
temp = (xmlXPathObjectPtr *) xmlRealloc(cur->locTab, cur->locMax *
|
||||||
sizeof(xmlXPathObjectPtr));
|
sizeof(xmlXPathObjectPtr));
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrLocationSetAdd: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrLocationSetAdd: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cur->locTab = temp;
|
cur->locTab = temp;
|
||||||
@ -673,7 +685,7 @@ xmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
|
|||||||
|
|
||||||
if (i >= cur->locNr) {
|
if (i >= cur->locNr) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(xmlXPathDebug,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlXPtrLocationSetDel: Range %s wasn't found in RangeList\n",
|
"xmlXPtrLocationSetDel: Range %s wasn't found in RangeList\n",
|
||||||
val->name);
|
val->name);
|
||||||
#endif
|
#endif
|
||||||
@ -745,7 +757,8 @@ xmlXPtrNewLocationSetNodes(xmlNodePtr start, xmlNodePtr end) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewLocationSetNodes: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewLocationSetNodes: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -772,7 +785,8 @@ xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrNewLocationSetNodes: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrNewLocationSetNodes: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -808,7 +822,8 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
|
|||||||
|
|
||||||
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrWrapLocationSet: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrWrapLocationSet: out of memory\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
|
||||||
@ -943,7 +958,8 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
|
|||||||
len++;
|
len++;
|
||||||
buffer = (xmlChar *) xmlMalloc(len * sizeof (xmlChar));
|
buffer = (xmlChar *) xmlMalloc(len * sizeof (xmlChar));
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrEvalXPtrPart: out of memory\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrEvalXPtrPart: out of memory\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,7 +1003,8 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
|
|||||||
xmlXPathEvalExpr(ctxt);
|
xmlXPathEvalExpr(ctxt);
|
||||||
CUR_PTR=left;
|
CUR_PTR=left;
|
||||||
} else {
|
} else {
|
||||||
fprintf(xmlXPathDebug, "unsupported scheme '%s'\n", name);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"unsupported scheme '%s'\n", name);
|
||||||
}
|
}
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
xmlFree(name);
|
xmlFree(name);
|
||||||
@ -1095,7 +1112,8 @@ xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
|
|||||||
* this might prove useful in some cases, warn about it.
|
* this might prove useful in some cases, warn about it.
|
||||||
*/
|
*/
|
||||||
if ((name == NULL) && (CUR == '/') && (NXT(1) != '1')) {
|
if ((name == NULL) && (CUR == '/') && (NXT(1) != '1')) {
|
||||||
fprintf(xmlXPathDebug, "warning: ChildSeq not starting by /1\n");
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"warning: ChildSeq not starting by /1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
@ -1234,8 +1252,6 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
if ((ctx == NULL) || (str == NULL))
|
if ((ctx == NULL) || (str == NULL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (xmlXPathDebug == NULL)
|
|
||||||
xmlXPathDebug = stderr;
|
|
||||||
ctxt = xmlXPathNewParserContext(str, ctx);
|
ctxt = xmlXPathNewParserContext(str, ctx);
|
||||||
if (ctx->node != NULL) {
|
if (ctx->node != NULL) {
|
||||||
init = xmlXPathNewNodeSet(ctx->node);
|
init = xmlXPathNewNodeSet(ctx->node);
|
||||||
@ -1246,7 +1262,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
if ((ctxt->value != NULL) &&
|
if ((ctxt->value != NULL) &&
|
||||||
(ctxt->value->type != XPATH_NODESET) &&
|
(ctxt->value->type != XPATH_NODESET) &&
|
||||||
(ctxt->value->type != XPATH_LOCATIONSET)) {
|
(ctxt->value->type != XPATH_LOCATIONSET)) {
|
||||||
fprintf(xmlXPathDebug,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlXPtrEval: evaluation failed to return a node set\n");
|
"xmlXPtrEval: evaluation failed to return a node set\n");
|
||||||
} else {
|
} else {
|
||||||
res = valuePop(ctxt);
|
res = valuePop(ctxt);
|
||||||
@ -1272,7 +1288,8 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
}
|
}
|
||||||
} while (tmp != NULL);
|
} while (tmp != NULL);
|
||||||
if (stack != 0) {
|
if (stack != 0) {
|
||||||
fprintf(xmlXPathDebug, "xmlXPtrEval: %d object left on the stack\n",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"xmlXPtrEval: %d object left on the stack\n",
|
||||||
stack);
|
stack);
|
||||||
}
|
}
|
||||||
if (ctxt->error != XPATH_EXPRESSION_OK) {
|
if (ctxt->error != XPATH_EXPRESSION_OK) {
|
||||||
@ -2054,10 +2071,11 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
|
|||||||
match = (!xmlStrncmp(&cur->content[pos], string, stringlen));
|
match = (!xmlStrncmp(&cur->content[pos], string, stringlen));
|
||||||
if (match) {
|
if (match) {
|
||||||
#ifdef DEBUG_RANGES
|
#ifdef DEBUG_RANGES
|
||||||
fprintf(stdout, "found range %d bytes at index %d of ->",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"found range %d bytes at index %d of ->",
|
||||||
stringlen, pos + 1);
|
stringlen, pos + 1);
|
||||||
xmlDebugDumpString(stdout, cur->content);
|
xmlDebugDumpString(stdout, cur->content);
|
||||||
fprintf(stdout, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
#endif
|
#endif
|
||||||
*end = cur;
|
*end = cur;
|
||||||
*endindex = pos + stringlen;
|
*endindex = pos + stringlen;
|
||||||
@ -2070,10 +2088,11 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
|
|||||||
match = (!xmlStrncmp(&cur->content[pos], string, sub));
|
match = (!xmlStrncmp(&cur->content[pos], string, sub));
|
||||||
if (match) {
|
if (match) {
|
||||||
#ifdef DEBUG_RANGES
|
#ifdef DEBUG_RANGES
|
||||||
fprintf(stdout, "found subrange %d bytes at index %d of ->",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"found subrange %d bytes at index %d of ->",
|
||||||
sub, pos + 1);
|
sub, pos + 1);
|
||||||
xmlDebugDumpString(stdout, cur->content);
|
xmlDebugDumpString(stdout, cur->content);
|
||||||
fprintf(stdout, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
#endif
|
#endif
|
||||||
string = &string[sub];
|
string = &string[sub];
|
||||||
stringlen -= sub;
|
stringlen -= sub;
|
||||||
@ -2138,10 +2157,11 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
|
|||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
pos = (str - cur->content);
|
pos = (str - cur->content);
|
||||||
#ifdef DEBUG_RANGES
|
#ifdef DEBUG_RANGES
|
||||||
fprintf(stdout, "found '%c' at index %d of ->",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"found '%c' at index %d of ->",
|
||||||
first, pos + 1);
|
first, pos + 1);
|
||||||
xmlDebugDumpString(stdout, cur->content);
|
xmlDebugDumpString(stdout, cur->content);
|
||||||
fprintf(stdout, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
#endif
|
#endif
|
||||||
if (xmlXPtrMatchString(string, cur, pos + 1,
|
if (xmlXPtrMatchString(string, cur, pos + 1,
|
||||||
end, endindex)) {
|
end, endindex)) {
|
||||||
@ -2160,10 +2180,11 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
|
|||||||
* character.
|
* character.
|
||||||
*/
|
*/
|
||||||
#ifdef DEBUG_RANGES
|
#ifdef DEBUG_RANGES
|
||||||
fprintf(stdout, "found '' at index %d of ->",
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"found '' at index %d of ->",
|
||||||
pos + 1);
|
pos + 1);
|
||||||
xmlDebugDumpString(stdout, cur->content);
|
xmlDebugDumpString(stdout, cur->content);
|
||||||
fprintf(stdout, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
#endif
|
#endif
|
||||||
*start = cur;
|
*start = cur;
|
||||||
*startindex = pos + 1;
|
*startindex = pos + 1;
|
||||||
@ -2397,12 +2418,14 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
xmlXPtrGetLastChar(&end, &endindex);
|
xmlXPtrGetLastChar(&end, &endindex);
|
||||||
|
|
||||||
#ifdef DEBUG_RANGES
|
#ifdef DEBUG_RANGES
|
||||||
fprintf(stdout, "from index %d of ->", startindex);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"from index %d of ->", startindex);
|
||||||
xmlDebugDumpString(stdout, start->content);
|
xmlDebugDumpString(stdout, start->content);
|
||||||
fprintf(stdout, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
fprintf(stdout, "to index %d of ->", endindex);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"to index %d of ->", endindex);
|
||||||
xmlDebugDumpString(stdout, end->content);
|
xmlDebugDumpString(stdout, end->content);
|
||||||
fprintf(stdout, "\n");
|
xmlGenericError(xmlGenericErrorContext, "\n");
|
||||||
#endif
|
#endif
|
||||||
do {
|
do {
|
||||||
fend = end;
|
fend = end;
|
||||||
|
Reference in New Issue
Block a user