1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

Huge cleanup, I switched to compile with

-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit
-Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat
-Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow
-Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline
- HTMLparser.[ch] HTMLtree.c SAX.c debugXML.c encoding.[ch]
  encoding.h entities.c error.c list.[ch] nanoftp.c
  nanohttp.c parser.[ch] parserInternals.[ch] testHTML.c
  testSAX.c testURI.c testXPath.c tree.[ch] uri.c
  valid.[ch] xinclude.c xmlIO.[ch] xmllint.c xmlmemory.c
  xpath.c xpathInternals.h xpointer.[ch] example/gjobread.c:
  Cleanup, staticfied a number of non-exported functions,
  detected and cleaned up a dozen of problem found this way,
  avoided a lot of public function name/typedef/system names clashes
- doc/xml.html: updated
- configure.in: switched private flags to the really pedantic ones.
Daniel
This commit is contained in:
Daniel Veillard
2001-03-24 17:00:36 +00:00
parent c7ad7ce598
commit 56a4cb8c4d
49 changed files with 1261 additions and 1186 deletions

View File

@ -1,3 +1,22 @@
Sat Mar 24 17:45:36 CET 2001
Huge cleanup, I switched to compile with
-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit
-Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat
-Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow
-Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline
* HTMLparser.[ch] HTMLtree.c SAX.c debugXML.c encoding.[ch]
encoding.h entities.c error.c list.[ch] nanoftp.c
nanohttp.c parser.[ch] parserInternals.[ch] testHTML.c
testSAX.c testURI.c testXPath.c tree.[ch] uri.c
valid.[ch] xinclude.c xmlIO.[ch] xmllint.c xmlmemory.c
xpath.c xpathInternals.h xpointer.[ch] example/gjobread.c:
Cleanup, staticfied a number of non-exported functions,
detected and cleaned up a dozen of problem found this way,
avoided a lot of public function name/typedef/system names clashes
* doc/xml.html: updated
* configure.in: switched private flags to the really pedantic ones.
Thu Mar 22 22:44:15 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Thu Mar 22 22:44:15 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* configure.in: 2.3.5 * configure.in: 2.3.5

View File

@ -41,6 +41,7 @@
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/HTMLparser.h> #include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include <libxml/entities.h> #include <libxml/entities.h>
#include <libxml/encoding.h> #include <libxml/encoding.h>
#include <libxml/valid.h> #include <libxml/valid.h>
@ -55,6 +56,21 @@
int htmlOmittedDefaultValue = 1; int htmlOmittedDefaultValue = 1;
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
xmlChar end, xmlChar end2, xmlChar end3);
/************************************************************************ /************************************************************************
* * * *
* Parser stacks related functions and macros * * Parser stacks related functions and macros *
@ -95,8 +111,8 @@ scope type html##name##Pop(htmlParserCtxtPtr ctxt) { \
return(ret); \ return(ret); \
} \ } \
PUSH_AND_POP(extern, xmlNodePtr, node) /* PUSH_AND_POP(static, xmlNodePtr, node) */
PUSH_AND_POP(extern, xmlChar*, name) PUSH_AND_POP(static, xmlChar*, name)
/* /*
* Macros for accessing the content. Those should be used only by the parser, * Macros for accessing the content. Those should be used only by the parser,
@ -189,7 +205,7 @@ PUSH_AND_POP(extern, xmlChar*, name)
* Returns the current char value and its lenght * Returns the current char value and its lenght
*/ */
int static int
htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
if (ctxt->instate == XML_PARSER_EOF) if (ctxt->instate == XML_PARSER_EOF)
return(0); return(0);
@ -305,31 +321,6 @@ encoding_error:
return((int) *ctxt->input->cur); return((int) *ctxt->input->cur);
} }
/**
* htmlNextChar:
* @ctxt: the HTML parser context
*
* Skip to the next char input char.
*/
void
htmlNextChar(htmlParserCtxtPtr ctxt) {
if (ctxt->instate == XML_PARSER_EOF)
return;
if ((*ctxt->input->cur == 0) &&
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
xmlPopInput(ctxt);
} else {
if (*(ctxt->input->cur) == '\n') {
ctxt->input->line++; ctxt->input->col = 1;
} else ctxt->input->col++;
ctxt->input->cur++;
ctxt->nbChars++;
if (*ctxt->input->cur == 0)
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
}
}
/** /**
* htmlSkipBlankChars: * htmlSkipBlankChars:
* @ctxt: the HTML parser context * @ctxt: the HTML parser context
@ -339,7 +330,7 @@ htmlNextChar(htmlParserCtxtPtr ctxt) {
* Returns the number of space chars skipped * Returns the number of space chars skipped
*/ */
int static int
htmlSkipBlankChars(xmlParserCtxtPtr ctxt) { htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
int res = 0; int res = 0;
@ -478,7 +469,7 @@ htmlElemDesc html40ElementTable[] = {
* any tag of each line implies the end of the current element if the type of * any tag of each line implies the end of the current element if the type of
* that element is in the same line * that element is in the same line
*/ */
char *htmlEquEnd[] = { const char *htmlEquEnd[] = {
"dt", "dd", "li", "option", NULL, "dt", "dd", "li", "option", NULL,
"h1", "h2", "h3", "h4", "h5", "h6", NULL, "h1", "h2", "h3", "h4", "h5", "h6", NULL,
"ol", "menu", "dir", "address", "pre", "listing", "xmp", NULL, "ol", "menu", "dir", "address", "pre", "listing", "xmp", NULL,
@ -493,7 +484,7 @@ NULL
/* /*
* start tags that imply the end of current element * start tags that imply the end of current element
*/ */
char *htmlStartClose[] = { const char *htmlStartClose[] = {
"form", "form", "p", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "form", "form", "p", "hr", "h1", "h2", "h3", "h4", "h5", "h6",
"dl", "ul", "ol", "menu", "dir", "address", "pre", "dl", "ul", "ol", "menu", "dir", "address", "pre",
"listing", "xmp", "head", NULL, "listing", "xmp", "head", NULL,
@ -557,7 +548,7 @@ NULL
* TODO: extend that list by reading the HTML SGML DtD on * TODO: extend that list by reading the HTML SGML DtD on
* implied paragraph * implied paragraph
*/ */
static char *htmlNoContentElements[] = { static const char *htmlNoContentElements[] = {
"html", "html",
"head", "head",
"body", "body",
@ -569,7 +560,7 @@ static char *htmlNoContentElements[] = {
* NOTE: when adding ones, check htmlIsScriptAttribute() since * NOTE: when adding ones, check htmlIsScriptAttribute() since
* it assumes the name starts with 'on' * it assumes the name starts with 'on'
*/ */
static char *htmlScriptAttributes[] = { static const char *htmlScriptAttributes[] = {
"onclick", "onclick",
"ondblclick", "ondblclick",
"onmousedown", "onmousedown",
@ -591,7 +582,7 @@ static char *htmlScriptAttributes[] = {
}; };
static char** htmlStartCloseIndex[100]; static const char** htmlStartCloseIndex[100];
static int htmlStartCloseIndexinitialized = 0; static int htmlStartCloseIndexinitialized = 0;
/************************************************************************ /************************************************************************
@ -609,14 +600,14 @@ static int htmlStartCloseIndexinitialized = 0;
*/ */
void void
htmlInitAutoClose(void) { htmlInitAutoClose(void) {
int index, i = 0; int indx, i = 0;
if (htmlStartCloseIndexinitialized) return; if (htmlStartCloseIndexinitialized) return;
for (index = 0;index < 100;index ++) htmlStartCloseIndex[index] = NULL; for (indx = 0;indx < 100;indx ++) htmlStartCloseIndex[indx] = NULL;
index = 0; indx = 0;
while ((htmlStartClose[i] != NULL) && (index < 100 - 1)) { while ((htmlStartClose[i] != NULL) && (indx < 100 - 1)) {
htmlStartCloseIndex[index++] = &htmlStartClose[i]; htmlStartCloseIndex[indx++] = &htmlStartClose[i];
while (htmlStartClose[i] != NULL) i++; while (htmlStartClose[i] != NULL) i++;
i++; i++;
} }
@ -633,7 +624,7 @@ htmlInitAutoClose(void) {
*/ */
htmlElemDescPtr htmlElemDescPtr
htmlTagLookup(const xmlChar *tag) { htmlTagLookup(const xmlChar *tag) {
int i; unsigned int i;
for (i = 0; i < (sizeof(html40ElementTable) / for (i = 0; i < (sizeof(html40ElementTable) /
sizeof(html40ElementTable[0]));i++) { sizeof(html40ElementTable[0]));i++) {
@ -653,21 +644,21 @@ htmlTagLookup(const xmlChar *tag) {
* *
* Returns 0 if no, 1 if yes. * Returns 0 if no, 1 if yes.
*/ */
int static int
htmlCheckAutoClose(const xmlChar *newtag, const xmlChar *oldtag) { htmlCheckAutoClose(const xmlChar *newtag, const xmlChar *oldtag) {
int i, index; int i, indx;
char **close = NULL; const char **closed = NULL;
if (htmlStartCloseIndexinitialized == 0) htmlInitAutoClose(); if (htmlStartCloseIndexinitialized == 0) htmlInitAutoClose();
/* inefficient, but not a big deal */ /* inefficient, but not a big deal */
for (index = 0; index < 100;index++) { for (indx = 0; indx < 100;indx++) {
close = htmlStartCloseIndex[index]; closed = htmlStartCloseIndex[indx];
if (close == NULL) return(0); if (closed == NULL) return(0);
if (xmlStrEqual(BAD_CAST *close, newtag)) break; if (xmlStrEqual(BAD_CAST *closed, newtag)) break;
} }
i = close - htmlStartClose; i = closed - htmlStartClose;
i++; i++;
while (htmlStartClose[i] != NULL) { while (htmlStartClose[i] != NULL) {
if (xmlStrEqual(BAD_CAST htmlStartClose[i], oldtag)) { if (xmlStrEqual(BAD_CAST htmlStartClose[i], oldtag)) {
@ -685,7 +676,7 @@ htmlCheckAutoClose(const xmlChar *newtag, const xmlChar *oldtag) {
* *
* The HTmL DtD allows an ending tag to implicitely close other tags. * The HTmL DtD allows an ending tag to implicitely close other tags.
*/ */
void static void
htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
htmlElemDescPtr info; htmlElemDescPtr info;
xmlChar *oldname; xmlChar *oldname;
@ -739,7 +730,7 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
* If newtag is NULL this mean we are at the end of the resource * If newtag is NULL this mean we are at the end of the resource
* and we should check * and we should check
*/ */
void static void
htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
xmlChar *oldname; xmlChar *oldname;
while ((newtag != NULL) && (ctxt->name != NULL) && while ((newtag != NULL) && (ctxt->name != NULL) &&
@ -843,7 +834,7 @@ htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem) {
* called when a new tag has been detected and generates the * called when a new tag has been detected and generates the
* appropriates implicit tags if missing * appropriates implicit tags if missing
*/ */
void static void
htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
if (!htmlOmittedDefaultValue) if (!htmlOmittedDefaultValue)
return; return;
@ -909,7 +900,7 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
* in case of error. * in case of error.
*/ */
int static int
htmlCheckParagraph(htmlParserCtxtPtr ctxt) { htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
const xmlChar *tag; const xmlChar *tag;
int i; int i;
@ -953,7 +944,7 @@ htmlCheckParagraph(htmlParserCtxtPtr ctxt) {
*/ */
int int
htmlIsScriptAttribute(const xmlChar *name) { htmlIsScriptAttribute(const xmlChar *name) {
int i; unsigned int i;
if (name == NULL) if (name == NULL)
return(0); return(0);
@ -1113,7 +1104,7 @@ htmlEntityDesc html40EntitiesTable[] = {
{ 920, "Theta","greek capital letter theta, U+0398 ISOgrk3" }, { 920, "Theta","greek capital letter theta, U+0398 ISOgrk3" },
{ 921, "Iota", "greek capital letter iota, U+0399" }, { 921, "Iota", "greek capital letter iota, U+0399" },
{ 922, "Kappa","greek capital letter kappa, U+039A" }, { 922, "Kappa","greek capital letter kappa, U+039A" },
{ 923, "Lambda""greek capital letter lambda, U+039B ISOgrk3" }, { 923, "Lambda", "greek capital letter lambda, U+039B ISOgrk3" },
{ 924, "Mu", "greek capital letter mu, U+039C" }, { 924, "Mu", "greek capital letter mu, U+039C" },
{ 925, "Nu", "greek capital letter nu, U+039D" }, { 925, "Nu", "greek capital letter nu, U+039D" },
{ 926, "Xi", "greek capital letter xi, U+039E ISOgrk3" }, { 926, "Xi", "greek capital letter xi, U+039E ISOgrk3" },
@ -1291,7 +1282,7 @@ htmlEntityDesc html40EntitiesTable[] = {
*/ */
htmlEntityDescPtr htmlEntityDescPtr
htmlEntityLookup(const xmlChar *name) { htmlEntityLookup(const xmlChar *name) {
int i; unsigned int i;
for (i = 0;i < (sizeof(html40EntitiesTable)/ for (i = 0;i < (sizeof(html40EntitiesTable)/
sizeof(html40EntitiesTable[0]));i++) { sizeof(html40EntitiesTable[0]));i++) {
@ -1316,16 +1307,16 @@ htmlEntityLookup(const xmlChar *name) {
* Returns the associated htmlEntityDescPtr if found, NULL otherwise. * Returns the associated htmlEntityDescPtr if found, NULL otherwise.
*/ */
htmlEntityDescPtr htmlEntityDescPtr
htmlEntityValueLookup(int value) { htmlEntityValueLookup(unsigned int value) {
int i; unsigned int i;
#ifdef DEBUG #ifdef DEBUG
int lv = 0; int lv = 0;
#endif #endif
for (i = 0;i < (sizeof(html40EntitiesTable)/ for (i = 0;i < (sizeof(html40EntitiesTable)/
sizeof(html40EntitiesTable[0]));i++) { sizeof(html40EntitiesTable[0]));i++) {
if ((unsigned int) html40EntitiesTable[i].value >= value) { if (html40EntitiesTable[i].value >= value) {
if ((unsigned int) html40EntitiesTable[i].value > value) if (html40EntitiesTable[i].value > value)
break; break;
#ifdef DEBUG #ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name); xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name);
@ -1503,7 +1494,8 @@ htmlEncodeEntities(unsigned char* out, int *outlen,
} }
/* assertion: c is a single UTF-4 value */ /* assertion: c is a single UTF-4 value */
if (c < 0x80 && c != quoteChar && c != '&' && c != '<' && c != '>') { if ((c < 0x80) && (c != (unsigned int) quoteChar) &&
(c != '&') && (c != '<') && (c != '>')) {
if (out >= outend) if (out >= outend)
break; break;
*out++ = c; *out++ = c;
@ -1554,8 +1546,16 @@ htmlEncodeEntities(unsigned char* out, int *outlen,
* must deallocate it ! * must deallocate it !
*/ */
xmlChar * xmlChar *
htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len, htmlDecodeEntities(htmlParserCtxtPtr ctxt UNUSED, int len UNUSED,
xmlChar end, xmlChar end2, xmlChar end3) { xmlChar end UNUSED, xmlChar end2 UNUSED, xmlChar end3 UNUSED) {
static int deprecated = 0;
if (!deprecated) {
xmlGenericError(xmlGenericErrorContext,
"htmlDecodeEntities() deprecated function reached\n");
deprecated = 1;
}
return(NULL);
#if 0
xmlChar *name = NULL; xmlChar *name = NULL;
xmlChar *buffer = NULL; xmlChar *buffer = NULL;
unsigned int buffer_size = 0; unsigned int buffer_size = 0;
@ -1627,6 +1627,7 @@ htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
} }
buffer[nbchars++] = 0; buffer[nbchars++] = 0;
return(buffer); return(buffer);
#endif
} }
/************************************************************************ /************************************************************************
@ -1635,26 +1636,6 @@ htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len,
* * * *
************************************************************************/ ************************************************************************/
/**
* htmlFreeInputStream:
* @input: an htmlParserInputPtr
*
* Free up an input stream.
*/
void
htmlFreeInputStream(htmlParserInputPtr input) {
if (input == NULL) return;
if (input->filename != NULL) xmlFree((char *) input->filename);
if (input->directory != NULL) xmlFree((char *) input->directory);
if ((input->free != NULL) && (input->base != NULL))
input->free((xmlChar *) input->base);
if (input->buf != NULL)
xmlFreeParserInputBuffer(input->buf);
MEM_CLEANUP(input, sizeof(htmlParserInput));
xmlFree(input);
}
/** /**
* htmlNewInputStream: * htmlNewInputStream:
* @ctxt: an HTML parser context * @ctxt: an HTML parser context
@ -1662,7 +1643,7 @@ htmlFreeInputStream(htmlParserInputPtr input) {
* Create a new input stream structure * Create a new input stream structure
* Returns the new input stream or NULL * Returns the new input stream or NULL
*/ */
htmlParserInputPtr static htmlParserInputPtr
htmlNewInputStream(htmlParserCtxtPtr ctxt) { htmlNewInputStream(htmlParserCtxtPtr ctxt) {
htmlParserInputPtr input; htmlParserInputPtr input;
@ -1741,37 +1722,6 @@ static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
return(1); return(1);
} }
/**
* htmlHandleEntity:
* @ctxt: an HTML parser context
* @entity: an XML entity pointer.
*
* Default handling of an HTML entity, call the parser with the
* substitution string
*/
void
htmlHandleEntity(htmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
int len;
if (entity->content == NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData, "htmlHandleEntity %s: content == NULL\n",
entity->name);
ctxt->wellFormed = 0;
return;
}
len = xmlStrlen(entity->content);
/*
* Just handle the content as a set of chars.
*/
htmlCheckParagraph(ctxt);
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, entity->content, len);
}
/** /**
* htmlNewDocNoDtD: * htmlNewDocNoDtD:
* @URI: URI for the dtd, or NULL * @URI: URI for the dtd, or NULL
@ -1857,7 +1807,7 @@ htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) {
* Returns the Tag Name parsed or NULL * Returns the Tag Name parsed or NULL
*/ */
xmlChar * static xmlChar *
htmlParseHTMLName(htmlParserCtxtPtr ctxt) { htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
xmlChar *ret = NULL; xmlChar *ret = NULL;
int i = 0; int i = 0;
@ -1890,7 +1840,7 @@ htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
* Returns the Name parsed or NULL * Returns the Name parsed or NULL
*/ */
xmlChar * static xmlChar *
htmlParseName(htmlParserCtxtPtr ctxt) { htmlParseName(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_MAX_NAMELEN]; xmlChar buf[HTML_MAX_NAMELEN];
int len = 0; int len = 0;
@ -1933,7 +1883,7 @@ htmlParseName(htmlParserCtxtPtr ctxt) {
* Returns the attribute parsed or NULL * Returns the attribute parsed or NULL
*/ */
xmlChar * static xmlChar *
htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) { htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
xmlChar *buffer = NULL; xmlChar *buffer = NULL;
int buffer_size = 0; int buffer_size = 0;
@ -1982,20 +1932,20 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
if (name == NULL) { if (name == NULL) {
*out++ = '&'; *out++ = '&';
if (out - buffer > buffer_size - 100) { if (out - buffer > buffer_size - 100) {
int index = out - buffer; int indx = out - buffer;
growBuffer(buffer); growBuffer(buffer);
out = &buffer[index]; out = &buffer[indx];
} }
} else if (ent == NULL) { } else if (ent == NULL) {
*out++ = '&'; *out++ = '&';
cur = name; cur = name;
while (*cur != 0) { while (*cur != 0) {
if (out - buffer > buffer_size - 100) { if (out - buffer > buffer_size - 100) {
int index = out - buffer; int indx = out - buffer;
growBuffer(buffer); growBuffer(buffer);
out = &buffer[index]; out = &buffer[indx];
} }
*out++ = *cur++; *out++ = *cur++;
} }
@ -2005,10 +1955,10 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
int bits; int bits;
if (out - buffer > buffer_size - 100) { if (out - buffer > buffer_size - 100) {
int index = out - buffer; int indx = out - buffer;
growBuffer(buffer); growBuffer(buffer);
out = &buffer[index]; out = &buffer[indx];
} }
c = (xmlChar)ent->value; c = (xmlChar)ent->value;
if (c < 0x80) if (c < 0x80)
@ -2031,10 +1981,10 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
int bits, l; int bits, l;
if (out - buffer > buffer_size - 100) { if (out - buffer > buffer_size - 100) {
int index = out - buffer; int indx = out - buffer;
growBuffer(buffer); growBuffer(buffer);
out = &buffer[index]; out = &buffer[indx];
} }
c = CUR_CHAR(l); c = CUR_CHAR(l);
if (c < 0x80) if (c < 0x80)
@ -2056,43 +2006,6 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
return(buffer); return(buffer);
} }
/**
* htmlParseNmtoken:
* @ctxt: an HTML parser context
*
* parse an HTML Nmtoken.
*
* Returns the Nmtoken parsed or NULL
*/
xmlChar *
htmlParseNmtoken(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_MAX_NAMELEN];
int len = 0;
GROW;
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
(CUR == '.') || (CUR == '-') ||
(CUR == '_') || (CUR == ':') ||
(IS_COMBINING(CUR)) ||
(IS_EXTENDER(CUR))) {
buf[len++] = CUR;
NEXT;
if (len >= HTML_MAX_NAMELEN) {
xmlGenericError(xmlGenericErrorContext,
"htmlParseNmtoken: reached HTML_MAX_NAMELEN limit\n");
while ((IS_LETTER(CUR)) || (IS_DIGIT(CUR)) ||
(CUR == '.') || (CUR == '-') ||
(CUR == '_') || (CUR == ':') ||
(IS_COMBINING(CUR)) ||
(IS_EXTENDER(CUR)))
NEXT;
break;
}
}
return(xmlStrndup(buf, len));
}
/** /**
* htmlParseEntityRef: * htmlParseEntityRef:
* @ctxt: an HTML parser context * @ctxt: an HTML parser context
@ -2152,7 +2065,7 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, xmlChar **str) {
* Returns the AttValue parsed or NULL. * Returns the AttValue parsed or NULL.
*/ */
xmlChar * static xmlChar *
htmlParseAttValue(htmlParserCtxtPtr ctxt) { htmlParseAttValue(htmlParserCtxtPtr ctxt) {
xmlChar *ret = NULL; xmlChar *ret = NULL;
@ -2199,7 +2112,7 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) {
* Returns the SystemLiteral parsed or NULL * Returns the SystemLiteral parsed or NULL
*/ */
xmlChar * static xmlChar *
htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
const xmlChar *q; const xmlChar *q;
xmlChar *ret = NULL; xmlChar *ret = NULL;
@ -2251,7 +2164,7 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
* Returns the PubidLiteral parsed or NULL. * Returns the PubidLiteral parsed or NULL.
*/ */
xmlChar * static xmlChar *
htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) { htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
const xmlChar *q; const xmlChar *q;
xmlChar *ret = NULL; xmlChar *ret = NULL;
@ -2313,7 +2226,7 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
* as CDATA but SGML allows entities references in attributes so their * as CDATA but SGML allows entities references in attributes so their
* processing is identical as other attributes * processing is identical as other attributes
*/ */
void static void
htmlParseScript(htmlParserCtxtPtr ctxt) { htmlParseScript(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 1]; xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 1];
int nbchar = 0; int nbchar = 0;
@ -2368,7 +2281,6 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
/** /**
* htmlParseCharData: * htmlParseCharData:
* @ctxt: an HTML parser context * @ctxt: an HTML parser context
* @cdata: int indicating whether we are within a CDATA section
* *
* parse a CharData section. * parse a CharData section.
* if we are within a CDATA section ']]>' marks an end of section. * if we are within a CDATA section ']]>' marks an end of section.
@ -2376,8 +2288,8 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
* [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) * [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
*/ */
void static void
htmlParseCharData(htmlParserCtxtPtr ctxt, int cdata) { htmlParseCharData(htmlParserCtxtPtr ctxt) {
xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5]; xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5];
int nbchar = 0; int nbchar = 0;
int cur, l; int cur, l;
@ -2429,14 +2341,9 @@ htmlParseCharData(htmlParserCtxtPtr ctxt, int cdata) {
* htmlParseExternalID: * htmlParseExternalID:
* @ctxt: an HTML parser context * @ctxt: an HTML parser context
* @publicID: a xmlChar** receiving PubidLiteral * @publicID: a xmlChar** receiving PubidLiteral
* @strict: indicate whether we should restrict parsing to only
* production [75], see NOTE below
* *
* Parse an External ID or a Public ID * Parse an External ID or a Public ID
* *
* NOTE: Productions [75] and [83] interract badly since [75] can generate
* 'PUBLIC' S PubidLiteral S SystemLiteral
*
* [75] ExternalID ::= 'SYSTEM' S SystemLiteral * [75] ExternalID ::= 'SYSTEM' S SystemLiteral
* | 'PUBLIC' S PubidLiteral S SystemLiteral * | 'PUBLIC' S PubidLiteral S SystemLiteral
* *
@ -2447,8 +2354,8 @@ htmlParseCharData(htmlParserCtxtPtr ctxt, int cdata) {
* it is possible to return NULL and have publicID set. * it is possible to return NULL and have publicID set.
*/ */
xmlChar * static xmlChar *
htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) { htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID) {
xmlChar *URI = NULL; xmlChar *URI = NULL;
if ((UPPER == 'S') && (UPP(1) == 'Y') && if ((UPPER == 'S') && (UPP(1) == 'Y') &&
@ -2503,7 +2410,7 @@ htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
* *
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->' * [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
*/ */
void static void
htmlParseComment(htmlParserCtxtPtr ctxt) { htmlParseComment(htmlParserCtxtPtr ctxt) {
xmlChar *buf = NULL; xmlChar *buf = NULL;
int len; int len;
@ -2662,7 +2569,7 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
* ('[' (markupdecl | PEReference | S)* ']' S?)? '>' * ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*/ */
void static void
htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) { htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
xmlChar *name; xmlChar *name;
xmlChar *ExternalID = NULL; xmlChar *ExternalID = NULL;
@ -2693,7 +2600,7 @@ htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
/* /*
* Check for SystemID and ExternalID * Check for SystemID and ExternalID
*/ */
URI = htmlParseExternalID(ctxt, &ExternalID, 0); URI = htmlParseExternalID(ctxt, &ExternalID);
SKIP_BLANKS; SKIP_BLANKS;
/* /*
@ -2743,7 +2650,7 @@ htmlParseDocTypeDecl(htmlParserCtxtPtr ctxt) {
* Returns the attribute name, and the value in *value. * Returns the attribute name, and the value in *value.
*/ */
xmlChar * static xmlChar *
htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) { htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
xmlChar *name, *val = NULL; xmlChar *name, *val = NULL;
@ -2786,7 +2693,7 @@ htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
* If a new encoding is detected the parser is switched to decode * If a new encoding is detected the parser is switched to decode
* it and pass UTF8 * it and pass UTF8
*/ */
void static void
htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) { htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
const xmlChar *encoding; const xmlChar *encoding;
@ -2869,7 +2776,7 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
* *
* Checks an attributes from a Meta tag * Checks an attributes from a Meta tag
*/ */
void static void
htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) { htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
int i; int i;
const xmlChar *att, *value; const xmlChar *att, *value;
@ -2914,7 +2821,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
* *
*/ */
void static void
htmlParseStartTag(htmlParserCtxtPtr ctxt) { htmlParseStartTag(htmlParserCtxtPtr ctxt) {
xmlChar *name; xmlChar *name;
xmlChar *attname; xmlChar *attname;
@ -2975,9 +2882,9 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
return; return;
} }
if (xmlStrEqual(name, BAD_CAST"body")) { if (xmlStrEqual(name, BAD_CAST"body")) {
int i; int indx;
for (i = 0;i < ctxt->nameNr;i++) { for (indx = 0;indx < ctxt->nameNr;indx++) {
if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) { if (xmlStrEqual(ctxt->nameTab[indx], BAD_CAST"body")) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData, ctxt->sax->error(ctxt->userData,
"htmlParseStartTag: misplaced <body> tag\n"); "htmlParseStartTag: misplaced <body> tag\n");
@ -3108,7 +3015,7 @@ failed:
* [NS 9] ETag ::= '</' QName S? '>' * [NS 9] ETag ::= '</' QName S? '>'
*/ */
void static void
htmlParseEndTag(htmlParserCtxtPtr ctxt) { htmlParseEndTag(htmlParserCtxtPtr ctxt) {
xmlChar *name; xmlChar *name;
xmlChar *oldname; xmlChar *oldname;
@ -3213,7 +3120,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt) {
* this will end-up in a call to character() since this is either a * this will end-up in a call to character() since this is either a
* CharRef, or a predefined entity. * CharRef, or a predefined entity.
*/ */
void static void
htmlParseReference(htmlParserCtxtPtr ctxt) { htmlParseReference(htmlParserCtxtPtr ctxt) {
htmlEntityDescPtr ent; htmlEntityDescPtr ent;
xmlChar out[6]; xmlChar out[6];
@ -3292,7 +3199,7 @@ htmlParseReference(htmlParserCtxtPtr ctxt) {
* *
*/ */
void static void
htmlParseContent(htmlParserCtxtPtr ctxt) { htmlParseContent(htmlParserCtxtPtr ctxt) {
xmlChar *currentNode; xmlChar *currentNode;
int depth; int depth;
@ -3381,7 +3288,7 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
* Last case, text. Note that References are handled directly. * Last case, text. Note that References are handled directly.
*/ */
else { else {
htmlParseCharData(ctxt, 0); htmlParseCharData(ctxt);
} }
if (cons == ctxt->nbChars) { if (cons == ctxt->nbChars) {
@ -3592,7 +3499,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
* as a result of the parsing. * as a result of the parsing.
*/ */
int static int
htmlParseDocument(htmlParserCtxtPtr ctxt) { htmlParseDocument(htmlParserCtxtPtr ctxt) {
xmlDtdPtr dtd; xmlDtdPtr dtd;
@ -3696,7 +3603,7 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
* Initialize a parser context * Initialize a parser context
*/ */
void static void
htmlInitParserCtxt(htmlParserCtxtPtr ctxt) htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
{ {
htmlSAXHandler *sax; htmlSAXHandler *sax;
@ -3806,10 +3713,12 @@ htmlFreeParserCtxt(htmlParserCtxtPtr ctxt)
* *
* Create a parser context for an HTML document. * Create a parser context for an HTML document.
* *
* TODO: check the need to add encoding handling there
*
* Returns the new parser context or NULL * Returns the new parser context or NULL
*/ */
htmlParserCtxtPtr static htmlParserCtxtPtr
htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding) { htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding UNUSED) {
htmlParserCtxtPtr ctxt; htmlParserCtxtPtr ctxt;
htmlParserInputPtr input; htmlParserInputPtr input;
/* htmlCharEncoding enc; */ /* htmlCharEncoding enc; */
@ -3860,7 +3769,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding) {
* Returns the index to the current parsing point if the full sequence * Returns the index to the current parsing point if the full sequence
* is available, -1 otherwise. * is available, -1 otherwise.
*/ */
int static int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first, htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third) { xmlChar next, xmlChar third) {
int base, len; int base, len;
@ -3933,7 +3842,7 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
* *
* Returns zero if no parsing was possible * Returns zero if no parsing was possible
*/ */
int static int
htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
int ret = 0; int ret = 0;
htmlParserInputPtr in; htmlParserInputPtr in;
@ -4158,7 +4067,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
goto done; goto done;
cur = in->cur[0]; cur = in->cur[0];
if (IS_BLANK(cur)) { if (IS_BLANK(cur)) {
htmlParseCharData(ctxt, 0); htmlParseCharData(ctxt);
goto done; goto done;
} }
if (avail < 2) if (avail < 2)
@ -4466,7 +4375,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"HPP: Parsing char data\n"); "HPP: Parsing char data\n");
#endif #endif
htmlParseCharData(ctxt, 0); htmlParseCharData(ctxt);
} }
} }
if (cons == ctxt->nbChars) { if (cons == ctxt->nbChars) {
@ -4621,19 +4530,6 @@ done:
return(ret); return(ret);
} }
/**
* htmlParseTry:
* @ctxt: an HTML parser context
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
int
htmlParseTry(htmlParserCtxtPtr ctxt) {
return(htmlParseTryOrFinish(ctxt, 0));
}
/** /**
* htmlParseChunk: * htmlParseChunk:
* @ctxt: an XML parser context * @ctxt: an XML parser context

View File

@ -49,7 +49,7 @@ struct _htmlElemDesc {
typedef struct _htmlEntityDesc htmlEntityDesc; typedef struct _htmlEntityDesc htmlEntityDesc;
typedef htmlEntityDesc *htmlEntityDescPtr; typedef htmlEntityDesc *htmlEntityDescPtr;
struct _htmlEntityDesc { struct _htmlEntityDesc {
int value; /* the UNICODE value for the character */ unsigned int value; /* the UNICODE value for the character */
const char *name; /* The entity name */ const char *name; /* The entity name */
const char *desc; /* the description */ const char *desc; /* the description */
}; };
@ -59,7 +59,7 @@ struct _htmlEntityDesc {
*/ */
htmlElemDescPtr htmlTagLookup (const xmlChar *tag); htmlElemDescPtr htmlTagLookup (const xmlChar *tag);
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name); htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
htmlEntityDescPtr htmlEntityValueLookup(int value); htmlEntityDescPtr htmlEntityValueLookup(unsigned int value);
int htmlIsAutoClosed(htmlDocPtr doc, int htmlIsAutoClosed(htmlDocPtr doc,
htmlNodePtr elem); htmlNodePtr elem);

View File

@ -34,6 +34,18 @@
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/parserInternals.h> #include <libxml/parserInternals.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/************************************************************************ /************************************************************************
* * * *
* Getting/Setting encoding meta tags * * Getting/Setting encoding meta tags *
@ -680,10 +692,13 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
* @doc: the document * @doc: the document
* @encoding: the encoding string * @encoding: the encoding string
* *
* TODO: check whether encoding is needed
*
* Dump the HTML document DTD, if any. * Dump the HTML document DTD, if any.
*/ */
static void static void
htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, const char *encoding) { htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
const char *encoding UNUSED) {
xmlDtdPtr cur = doc->intSubset; xmlDtdPtr cur = doc->intSubset;
if (cur == NULL) { if (cur == NULL) {
@ -717,7 +732,8 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, const char *encoding) {
* Dump an HTML attribute * Dump an HTML attribute
*/ */
static void static void
htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, const char *encoding) { htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
const char *encoding UNUSED) {
xmlChar *value; xmlChar *value;
if (cur == NULL) { if (cur == NULL) {

22
SAX.c
View File

@ -31,6 +31,16 @@
/* #define DEBUG_SAX */ /* #define DEBUG_SAX */
/* #define DEBUG_SAX_TREE */ /* #define DEBUG_SAX_TREE */
#ifdef __GNUC__
#ifndef DEBUG_SAX
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
#else
#define UNUSED
#endif
/** /**
* getPublicId: * getPublicId:
* @ctx: the user data (XML parser context) * @ctx: the user data (XML parser context)
@ -40,7 +50,7 @@
* Returns a xmlChar * * Returns a xmlChar *
*/ */
const xmlChar * const xmlChar *
getPublicId(void *ctx) getPublicId(void *ctx UNUSED)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
return(NULL); return(NULL);
@ -59,7 +69,7 @@ const xmlChar *
getSystemId(void *ctx) getSystemId(void *ctx)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
return(BAD_CAST ctxt->input->filename); return((const xmlChar *) ctxt->input->filename);
} }
/** /**
@ -648,7 +658,7 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
* Everything is available on the context, so this is useless in our case. * Everything is available on the context, so this is useless in our case.
*/ */
void void
setDocumentLocator(void *ctx, xmlSAXLocatorPtr loc) setDocumentLocator(void *ctx UNUSED, xmlSAXLocatorPtr loc UNUSED)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX
@ -693,7 +703,7 @@ startDocument(void *ctx)
} }
if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) && if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
(ctxt->input != NULL) && (ctxt->input->filename != NULL)) { (ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
ctxt->myDoc->URL = xmlStrdup((xmlChar *) ctxt->input->filename); ctxt->myDoc->URL = xmlStrdup((const xmlChar *) ctxt->input->filename);
} }
} }
@ -1082,7 +1092,7 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
* called when the end of an element has been detected. * called when the end of an element has been detected.
*/ */
void void
endElement(void *ctx, const xmlChar *name) endElement(void *ctx, const xmlChar *name UNUSED)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserNodeInfo node_info; xmlParserNodeInfo node_info;
@ -1261,7 +1271,7 @@ characters(void *ctx, const xmlChar *ch, int len)
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void void
ignorableWhitespace(void *ctx, const xmlChar *ch, int len) ignorableWhitespace(void *ctx UNUSED, const xmlChar *ch UNUSED, int len UNUSED)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
#ifdef DEBUG_SAX #ifdef DEBUG_SAX

View File

@ -237,7 +237,8 @@ dnl fi
if test "${with_xptr}" = "" ; then if test "${with_xptr}" = "" ; then
with_xptr="yes" with_xptr="yes"
fi fi
CFLAGS="-Wall -g -pedantic" CFLAGS="-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline "
dnl -Wcast-qual
fi fi
dnl dnl
dnl Aloow to disable various pieces dnl Aloow to disable various pieces

View File

@ -33,6 +33,18 @@
#include <libxml/HTMLparser.h> #include <libxml/HTMLparser.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
#define IS_BLANK(c) \ #define IS_BLANK(c) \
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' ')) (((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
@ -51,7 +63,8 @@ void xmlDebugDumpString(FILE *output, const xmlChar *str) {
fprintf(output, "..."); fprintf(output, "...");
} }
void xmlDebugDumpDtd(FILE *output, xmlDtdPtr dtd, int depth) { static void
xmlDebugDumpDtdNode(FILE *output, xmlDtdPtr dtd, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -99,7 +112,8 @@ void xmlDebugDumpDtd(FILE *output, xmlDtdPtr dtd, int depth) {
} }
} }
void xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) { static void
xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -154,11 +168,11 @@ void xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
break; break;
} }
if (attr->tree != NULL) { if (attr->tree != NULL) {
int i; int indx;
xmlEnumerationPtr cur = attr->tree; xmlEnumerationPtr cur = attr->tree;
for (i = 0;i < 5; i++) { for (indx = 0;indx < 5; indx++) {
if (i != 0) if (indx != 0)
fprintf(output, "|%s", cur->name); fprintf(output, "|%s", cur->name);
else else
fprintf(output, " (%s", cur->name); fprintf(output, " (%s", cur->name);
@ -215,7 +229,8 @@ void xmlDebugDumpAttrDecl(FILE *output, xmlAttributePtr attr, int depth) {
} }
} }
void xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) { static void
xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -284,7 +299,8 @@ void xmlDebugDumpElemDecl(FILE *output, xmlElementPtr elem, int depth) {
} }
} }
void xmlDebugDumpEntityDecl(FILE *output, xmlEntityPtr ent, int depth) { static void
xmlDebugDumpEntityDecl(FILE *output, xmlEntityPtr ent, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -368,7 +384,8 @@ void xmlDebugDumpEntityDecl(FILE *output, xmlEntityPtr ent, int depth) {
} }
} }
void xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) { static void
xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -397,14 +414,16 @@ void xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
} }
} }
void xmlDebugDumpNamespaceList(FILE *output, xmlNsPtr ns, int depth) { static void
xmlDebugDumpNamespaceList(FILE *output, xmlNsPtr ns, int depth) {
while (ns != NULL) { while (ns != NULL) {
xmlDebugDumpNamespace(output, ns, depth); xmlDebugDumpNamespace(output, ns, depth);
ns = ns->next; ns = ns->next;
} }
} }
void xmlDebugDumpEntity(FILE *output, xmlEntityPtr ent, int depth) { static void
xmlDebugDumpEntity(FILE *output, xmlEntityPtr ent, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -563,7 +582,7 @@ void xmlDebugDumpOneNode(FILE *output, xmlNodePtr node, int depth) {
fprintf(output, "NOTATION\n"); fprintf(output, "NOTATION\n");
break; break;
case XML_DTD_NODE: case XML_DTD_NODE:
xmlDebugDumpDtd(output, (xmlDtdPtr) node, depth); xmlDebugDumpDtdNode(output, (xmlDtdPtr) node, depth);
return; return;
case XML_ELEMENT_DECL: case XML_ELEMENT_DECL:
xmlDebugDumpElemDecl(output, (xmlElementPtr) node, depth); xmlDebugDumpElemDecl(output, (xmlElementPtr) node, depth);
@ -786,8 +805,8 @@ void xmlDebugDumpDTD(FILE *output, xmlDtdPtr dtd) {
xmlDebugDumpNodeList(output, dtd->children, 1); xmlDebugDumpNodeList(output, dtd->children, 1);
} }
void xmlDebugDumpEntityCallback(xmlEntityPtr cur, FILE *output, static void
const xmlChar *name) { xmlDebugDumpEntityCallback(xmlEntityPtr cur, FILE *output) {
fprintf(output, "%s : ", cur->name); fprintf(output, "%s : ", cur->name);
switch (cur->etype) { switch (cur->etype) {
case XML_INTERNAL_GENERAL_ENTITY: case XML_INTERNAL_GENERAL_ENTITY:
@ -1067,9 +1086,9 @@ void xmlLsOneNode(FILE *output, xmlNodePtr node) {
* *
* Returns 0 * Returns 0
*/ */
int static int
xmlShellList(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlShellList(xmlShellCtxtPtr ctxt UNUSED , char *arg UNUSED, xmlNodePtr node,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
xmlNodePtr cur; xmlNodePtr cur;
if ((node->type == XML_DOCUMENT_NODE) || if ((node->type == XML_DOCUMENT_NODE) ||
@ -1100,9 +1119,9 @@ xmlShellList(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
* *
* Returns 0 * Returns 0
*/ */
int static int
xmlShellDir(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlShellDir(xmlShellCtxtPtr ctxt UNUSED, char *arg UNUSED, xmlNodePtr node,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
if ((node->type == XML_DOCUMENT_NODE) || if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE)) { (node->type == XML_HTML_DOCUMENT_NODE)) {
xmlDebugDumpDocumentHead(stdout, (xmlDocPtr) node); xmlDebugDumpDocumentHead(stdout, (xmlDocPtr) node);
@ -1126,9 +1145,9 @@ xmlShellDir(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
* *
* Returns 0 * Returns 0
*/ */
int static int
xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlShellCat(xmlShellCtxtPtr ctxt, char *arg UNUSED, xmlNodePtr node,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) { if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
if (node->type == XML_HTML_DOCUMENT_NODE) if (node->type == XML_HTML_DOCUMENT_NODE)
@ -1163,9 +1182,9 @@ xmlShellCat(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node,
* *
* Returns 0 or -1 if loading failed * Returns 0 or -1 if loading failed
*/ */
int static int
xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node, xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node UNUSED,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
xmlDocPtr doc; xmlDocPtr doc;
int html = 0; int html = 0;
@ -1215,9 +1234,9 @@ xmlShellLoad(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
* *
* Returns 0 or -1 in case of error * Returns 0 or -1 in case of error
*/ */
int static int
xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node, xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
if (node == NULL) if (node == NULL)
return(-1); return(-1);
if ((filename == NULL) || (filename[0] == 0)) { if ((filename == NULL) || (filename[0] == 0)) {
@ -1283,9 +1302,9 @@ xmlShellWrite(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
* *
* Returns 0 or -1 in case of error * Returns 0 or -1 in case of error
*/ */
int static int
xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node, xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node UNUSED,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
if (ctxt->doc == NULL) if (ctxt->doc == NULL)
return(-1); return(-1);
if ((filename == NULL) || (filename[0] == 0)) if ((filename == NULL) || (filename[0] == 0))
@ -1339,9 +1358,9 @@ xmlShellSave(xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node,
* *
* Returns 0 or -1 in case of error * Returns 0 or -1 in case of error
*/ */
int static int
xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node, xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node UNUSED,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
xmlValidCtxt vctxt; xmlValidCtxt vctxt;
int res = -1; int res = -1;
@ -1377,9 +1396,9 @@ xmlShellValidate(xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node,
* *
* Returns 0 or -1 in case of error * Returns 0 or -1 in case of error
*/ */
int static int
xmlShellDu(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr tree, xmlShellDu(xmlShellCtxtPtr ctxt UNUSED, char *arg UNUSED, xmlNodePtr tree,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
xmlNodePtr node; xmlNodePtr node;
int indent = 0,i; int indent = 0,i;
@ -1453,9 +1472,9 @@ xmlShellDu(xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr tree,
* *
* Returns 0 or -1 in case of error * Returns 0 or -1 in case of error
*/ */
int static int
xmlShellPwd(xmlShellCtxtPtr ctxt, char *buffer, xmlNodePtr node, xmlShellPwd(xmlShellCtxtPtr ctxt UNUSED, char *buffer, xmlNodePtr node,
xmlNodePtr node2) { xmlNodePtr node2 UNUSED) {
xmlNodePtr cur, tmp, next; xmlNodePtr cur, tmp, next;
char buf[500]; char buf[500];
char sep; char sep;
@ -1605,6 +1624,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
* Parse the command itself * Parse the command itself
*/ */
cur = cmdline; cur = cmdline;
nbargs = 0;
while ((*cur == ' ') || (*cur == '\t')) cur++; while ((*cur == ' ') || (*cur == '\t')) cur++;
i = 0; i = 0;
while ((*cur != ' ') && (*cur != '\t') && while ((*cur != ' ') && (*cur != '\t') &&
@ -1685,15 +1705,16 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
"%s: no such node\n", arg); "%s: no such node\n", arg);
break; break;
case XPATH_NODESET: { case XPATH_NODESET: {
int i; int indx;
for (i = 0;i < list->nodesetval->nodeNr;i++) { for (indx = 0;indx < list->nodesetval->nodeNr;
indx++) {
if (dir) if (dir)
xmlShellDir(ctxt, NULL, xmlShellDir(ctxt, NULL,
list->nodesetval->nodeTab[i], NULL); list->nodesetval->nodeTab[indx], NULL);
else else
xmlShellList(ctxt, NULL, xmlShellList(ctxt, NULL,
list->nodesetval->nodeTab[i], NULL); list->nodesetval->nodeTab[indx], NULL);
} }
break; break;
} }
@ -1819,12 +1840,13 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
"%s: no such node\n", arg); "%s: no such node\n", arg);
break; break;
case XPATH_NODESET: { case XPATH_NODESET: {
int i; int indx;
for (i = 0;i < list->nodesetval->nodeNr;i++) { for (indx = 0;indx < list->nodesetval->nodeNr;
indx++) {
if (i > 0) printf(" -------\n"); if (i > 0) printf(" -------\n");
xmlShellCat(ctxt, NULL, xmlShellCat(ctxt, NULL,
list->nodesetval->nodeTab[i], NULL); list->nodesetval->nodeTab[indx], NULL);
} }
break; break;
} }

View File

@ -1,5 +1,3 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<title>The XML C library for Gnome</title> <title>The XML C library for Gnome</title>
@ -246,6 +244,15 @@ you want to test those</p>
docs</li> docs</li>
</ul> </ul>
<h3>2.3.5: Mar 23 2001</h3>
<ul>
<li>Biggest change is separate parsing and evaluation of XPath expressions,
there is some new APIs for this too</li>
<li>included a number of bug fixes(XML push parser, 51876, notations,
52299)</li>
<li>Fixed some portability issues</li>
</ul>
<h3>2.3.4: Mar 10 2001</h3> <h3>2.3.4: Mar 10 2001</h3>
<ul> <ul>
<li>Fixed bugs #51860 and #51861</li> <li>Fixed bugs #51860 and #51861</li>
@ -1481,6 +1488,6 @@ Gnome CVS base under gnome-xml/example</p>
<p><a href="mailto:Daniel.Veillard@imag.fr">Daniel Veillard</a></p> <p><a href="mailto:Daniel.Veillard@imag.fr">Daniel Veillard</a></p>
<p>$Id: xml.html,v 1.74 2001/03/10 12:32:02 veillard Exp $</p> <p>$Id: xml.html,v 1.75 2001/03/21 10:28:36 veillard Exp $</p>
</body> </body>
</html> </html>

View File

@ -91,7 +91,7 @@ static int xmlLittleEndian = 1;
* Returns the char value or -1 in case of error and update @len with the * Returns the char value or -1 in case of error and update @len with the
* number of bytes used * number of bytes used
*/ */
int static int
xmlGetUTF8Char(const unsigned char *utf, int *len) { xmlGetUTF8Char(const unsigned char *utf, int *len) {
unsigned int c; unsigned int c;
@ -206,7 +206,7 @@ xmlCheckUTF8(const unsigned char *utf)
* as the return value is positive, else unpredictiable. * as the return value is positive, else unpredictiable.
* The value of @outlen after return is the number of ocetes consumed. * The value of @outlen after return is the number of ocetes consumed.
*/ */
int static int
asciiToUTF8(unsigned char* out, int *outlen, asciiToUTF8(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen) { const unsigned char* in, int *inlen) {
unsigned char* outstart = out; unsigned char* outstart = out;
@ -258,7 +258,7 @@ asciiToUTF8(unsigned char* out, int *outlen,
* as the return value is positive, else unpredictiable. * as the return value is positive, else unpredictiable.
* The value of @outlen after return is the number of ocetes consumed. * The value of @outlen after return is the number of ocetes consumed.
*/ */
int static int
UTF8Toascii(unsigned char* out, int *outlen, UTF8Toascii(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen) { const unsigned char* in, int *inlen) {
const unsigned char* processed = in; const unsigned char* processed = in;
@ -478,7 +478,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
* The value of *inlen after return is the number of octets consumed * The value of *inlen after return is the number of octets consumed
* as the return value is positive, else unpredictiable. * as the return value is positive, else unpredictiable.
*/ */
int static int
UTF16LEToUTF8(unsigned char* out, int *outlen, UTF16LEToUTF8(unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb) const unsigned char* inb, int *inlenb)
{ {
@ -562,7 +562,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
* Returns the number of byte written, or -1 by lack of space, or -2 * Returns the number of byte written, or -1 by lack of space, or -2
* if the transcoding failed. * if the transcoding failed.
*/ */
int static int
UTF8ToUTF16LE(unsigned char* outb, int *outlen, UTF8ToUTF16LE(unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen) const unsigned char* in, int *inlen)
{ {
@ -685,7 +685,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
* The value of *inlen after return is the number of octets consumed * The value of *inlen after return is the number of octets consumed
* as the return value is positive, else unpredictiable. * as the return value is positive, else unpredictiable.
*/ */
int static int
UTF16BEToUTF8(unsigned char* out, int *outlen, UTF16BEToUTF8(unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb) const unsigned char* inb, int *inlenb)
{ {
@ -773,7 +773,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
* Returns the number of byte written, or -1 by lack of space, or -2 * Returns the number of byte written, or -1 by lack of space, or -2
* if the transcoding failed. * if the transcoding failed.
*/ */
int static int
UTF8ToUTF16BE(unsigned char* outb, int *outlen, UTF8ToUTF16BE(unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen) const unsigned char* in, int *inlen)
{ {
@ -1247,7 +1247,7 @@ static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL;
* Create and registers an xmlCharEncodingHandler. * Create and registers an xmlCharEncodingHandler.
* Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error). * Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error).
*/ */
xmlCharEncodingHandlerPtr static xmlCharEncodingHandlerPtr
xmlNewCharEncodingHandler(const char *name, xmlNewCharEncodingHandler(const char *name,
xmlCharEncodingInputFunc input, xmlCharEncodingInputFunc input,
xmlCharEncodingOutputFunc output) { xmlCharEncodingOutputFunc output) {
@ -1662,9 +1662,7 @@ xmlIconvWrapper(iconv_t cd,
char *icv_out = (char *) out; char *icv_out = (char *) out;
int ret; int ret;
ret = iconv(cd, ret = iconv(cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
&icv_in, &icv_inlen,
&icv_out, &icv_outlen);
if (in != NULL) { if (in != NULL) {
*inlen -= icv_inlen; *inlen -= icv_inlen;
*outlen -= icv_outlen; *outlen -= icv_outlen;
@ -1672,7 +1670,7 @@ xmlIconvWrapper(iconv_t cd,
*inlen = 0; *inlen = 0;
*outlen = 0; *outlen = 0;
} }
if (icv_inlen != 0 || ret == (size_t) -1) { if ((icv_inlen != 0) || (ret == -1)) {
#ifdef EILSEQ #ifdef EILSEQ
if (errno == EILSEQ) { if (errno == EILSEQ) {
return -2; return -2;

View File

@ -180,6 +180,17 @@ int xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
xmlBufferPtr in); xmlBufferPtr in);
int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
/*
* Export a few useful functions
*/
int UTF8Toisolat1 (unsigned char* out,
int *outlen,
const unsigned char* in,
int *inlen);
int isolat1ToUTF8 (unsigned char* out,
int *outlen,
const unsigned char* in,
int *inlen);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -24,23 +24,6 @@
#include <libxml/xmlerror.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 */
/*
* xmlEntityComputeHash:
*
* Computes the hash value for this given entity
*/
int
xmlEntityComputeHash(const xmlChar *name) {
register const unsigned char *cur = (const unsigned char *) name;
register unsigned char val = 0;
if (name == NULL)
return(val);
while (*cur) val += *cur++;
return(val);
}
/* /*
* The XML predefined entities. * The XML predefined entities.
@ -67,7 +50,7 @@ xmlHashTablePtr xmlPredefinedEntities = NULL;
/* /*
* xmlFreeEntity : clean-up an entity record. * xmlFreeEntity : clean-up an entity record.
*/ */
void xmlFreeEntity(xmlEntityPtr entity) { static void xmlFreeEntity(xmlEntityPtr entity) {
if (entity == NULL) return; if (entity == NULL) return;
if (entity->children) if (entity->children)
@ -166,7 +149,7 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
* Set up the predefined entities. * Set up the predefined entities.
*/ */
void xmlInitializePredefinedEntities(void) { void xmlInitializePredefinedEntities(void) {
int i; unsigned int i;
xmlChar name[50]; xmlChar name[50];
xmlChar value[50]; xmlChar value[50];
const char *in; const char *in;
@ -326,7 +309,7 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
* *
* Returns A pointer to the entity structure or NULL if not found. * Returns A pointer to the entity structure or NULL if not found.
*/ */
xmlEntityPtr static xmlEntityPtr
xmlGetEntityFromTable(xmlEntitiesTablePtr table, const xmlChar *name) { xmlGetEntityFromTable(xmlEntitiesTablePtr table, const xmlChar *name) {
return((xmlEntityPtr) xmlHashLookup(table, name)); return((xmlEntityPtr) xmlHashLookup(table, name));
} }
@ -428,13 +411,13 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
/* /*
* A buffer used for converting entities to their equivalent and back. * A buffer used for converting entities to their equivalent and back.
*/ */
static int buffer_size = 0; static int static_buffer_size = 0;
static xmlChar *buffer = NULL; static xmlChar *static_buffer = NULL;
int growBuffer(void) { static int growBuffer(void) {
buffer_size *= 2; static_buffer_size *= 2;
buffer = (xmlChar *) xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); static_buffer = (xmlChar *) xmlRealloc(static_buffer, static_buffer_size * sizeof(xmlChar));
if (buffer == NULL) { if (static_buffer == NULL) {
perror("realloc failed"); perror("realloc failed");
return(-1); return(-1);
} }
@ -461,7 +444,7 @@ int growBuffer(void) {
const xmlChar * const xmlChar *
xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) { xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
const xmlChar *cur = input; const xmlChar *cur = input;
xmlChar *out = buffer; xmlChar *out = static_buffer;
static int warning = 1; static int warning = 1;
int html = 0; int html = 0;
@ -478,21 +461,21 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
if (doc != NULL) if (doc != NULL)
html = (doc->type == XML_HTML_DOCUMENT_NODE); html = (doc->type == XML_HTML_DOCUMENT_NODE);
if (buffer == NULL) { if (static_buffer == NULL) {
buffer_size = 1000; static_buffer_size = 1000;
buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar)); static_buffer = (xmlChar *) xmlMalloc(static_buffer_size * sizeof(xmlChar));
if (buffer == NULL) { if (static_buffer == NULL) {
perror("malloc failed"); perror("malloc failed");
return(NULL); return(NULL);
} }
out = buffer; out = static_buffer;
} }
while (*cur != '\0') { while (*cur != '\0') {
if (out - buffer > buffer_size - 100) { if (out - static_buffer > static_buffer_size - 100) {
int index = out - buffer; int indx = out - static_buffer;
growBuffer(); growBuffer();
out = &buffer[index]; out = &static_buffer[indx];
} }
/* /*
@ -572,7 +555,7 @@ xmlEncodeEntities(xmlDocPtr doc, const xmlChar *input) {
cur++; cur++;
} }
*out++ = 0; *out++ = 0;
return(buffer); return(static_buffer);
} }
/* /*
@ -626,10 +609,10 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
while (*cur != '\0') { while (*cur != '\0') {
if (out - buffer > buffer_size - 100) { if (out - buffer > buffer_size - 100) {
int index = out - buffer; int indx = out - buffer;
growBufferReentrant(); growBufferReentrant();
out = &buffer[index]; out = &buffer[indx];
} }
/* /*
@ -819,10 +802,10 @@ xmlEncodeSpecialChars(xmlDocPtr doc, const xmlChar *input) {
while (*cur != '\0') { while (*cur != '\0') {
if (out - buffer > buffer_size - 10) { if (out - buffer > buffer_size - 10) {
int index = out - buffer; int indx = out - buffer;
growBufferReentrant(); growBufferReentrant();
out = &buffer[index]; out = &buffer[indx];
} }
/* /*
@ -895,7 +878,7 @@ xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
* *
* Returns the new xmlEntitiesPtr or NULL in case of error. * Returns the new xmlEntitiesPtr or NULL in case of error.
*/ */
xmlEntityPtr static xmlEntityPtr
xmlCopyEntity(xmlEntityPtr ent) { xmlCopyEntity(xmlEntityPtr ent) {
xmlEntityPtr cur; xmlEntityPtr cur;

11
error.c
View File

@ -18,6 +18,11 @@
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/************************************************************************ /************************************************************************
* * * *
* Handling of out of context errors * * Handling of out of context errors *
@ -32,8 +37,8 @@
* *
* Default handler for out of context error messages. * Default handler for out of context error messages.
*/ */
void static void
xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...) { xmlGenericErrorDefaultFunc(void *ctx UNUSED, const char *msg, ...) {
va_list args; va_list args;
if (xmlGenericErrorContext == NULL) if (xmlGenericErrorContext == NULL)
@ -146,7 +151,7 @@ xmlParserPrintFileContext(xmlParserInputPtr input) {
* Get an arbitrary-sized string for an error argument * Get an arbitrary-sized string for an error argument
* The caller must free() the returned string * The caller must free() the returned string
*/ */
char * static char *
xmlGetVarStr(const char * msg, va_list args) { xmlGetVarStr(const char * msg, va_list args) {
int size; int size;
int length; int length;

View File

@ -42,7 +42,8 @@ typedef struct person {
/* /*
* And the code needed to parse it * And the code needed to parse it
*/ */
personPtr parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) { static personPtr
parsePerson(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
personPtr ret = NULL; personPtr ret = NULL;
DEBUG("parsePerson\n"); DEBUG("parsePerson\n");
@ -75,7 +76,8 @@ DEBUG("parsePerson\n");
/* /*
* and to print it * and to print it
*/ */
void printPerson(personPtr cur) { static void
printPerson(personPtr cur) {
if (cur == NULL) return; if (cur == NULL) return;
printf("------ Person\n"); printf("------ Person\n");
if (cur->name) printf(" name: %s\n", cur->name); if (cur->name) printf(" name: %s\n", cur->name);
@ -103,7 +105,8 @@ typedef struct job {
/* /*
* And the code needed to parse it * And the code needed to parse it
*/ */
jobPtr parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) { static jobPtr
parseJob(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) {
jobPtr ret = NULL; jobPtr ret = NULL;
DEBUG("parseJob\n"); DEBUG("parseJob\n");
@ -148,7 +151,8 @@ DEBUG("parseJob\n");
/* /*
* and to print it * and to print it
*/ */
void printJob(jobPtr cur) { static void
printJob(jobPtr cur) {
int i; int i;
if (cur == NULL) return; if (cur == NULL) return;
@ -172,10 +176,11 @@ typedef struct gjob {
} gJob, *gJobPtr; } gJob, *gJobPtr;
gJobPtr parseGjobFile(char *filename) { static gJobPtr
parseGjobFile(char *filename) {
xmlDocPtr doc; xmlDocPtr doc;
gJobPtr ret; gJobPtr ret;
jobPtr job; jobPtr curjob;
xmlNsPtr ns; xmlNsPtr ns;
xmlNodePtr cur; xmlNodePtr cur;
@ -247,9 +252,9 @@ gJobPtr parseGjobFile(char *filename) {
while (cur != NULL) { while (cur != NULL) {
if ((!xmlStrcmp(cur->name, (const xmlChar *) "Job")) && if ((!xmlStrcmp(cur->name, (const xmlChar *) "Job")) &&
(cur->ns == ns)) { (cur->ns == ns)) {
job = parseJob(doc, ns, cur); curjob = parseJob(doc, ns, cur);
if (job != NULL) if (curjob != NULL)
ret->jobs[ret->nbJobs++] = job; ret->jobs[ret->nbJobs++] = curjob;
if (ret->nbJobs >= 500) break; if (ret->nbJobs >= 500) break;
} }
cur = cur->next; cur = cur->next;
@ -258,7 +263,8 @@ gJobPtr parseGjobFile(char *filename) {
return(ret); return(ret);
} }
void handleGjob(gJobPtr cur) { static void
handleGjob(gJobPtr cur) {
int i; int i;
/* /*

View File

@ -49,7 +49,7 @@ struct _htmlElemDesc {
typedef struct _htmlEntityDesc htmlEntityDesc; typedef struct _htmlEntityDesc htmlEntityDesc;
typedef htmlEntityDesc *htmlEntityDescPtr; typedef htmlEntityDesc *htmlEntityDescPtr;
struct _htmlEntityDesc { struct _htmlEntityDesc {
int value; /* the UNICODE value for the character */ unsigned int value; /* the UNICODE value for the character */
const char *name; /* The entity name */ const char *name; /* The entity name */
const char *desc; /* the description */ const char *desc; /* the description */
}; };
@ -59,7 +59,7 @@ struct _htmlEntityDesc {
*/ */
htmlElemDescPtr htmlTagLookup (const xmlChar *tag); htmlElemDescPtr htmlTagLookup (const xmlChar *tag);
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name); htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
htmlEntityDescPtr htmlEntityValueLookup(int value); htmlEntityDescPtr htmlEntityValueLookup(unsigned int value);
int htmlIsAutoClosed(htmlDocPtr doc, int htmlIsAutoClosed(htmlDocPtr doc,
htmlNodePtr elem); htmlNodePtr elem);

View File

@ -180,6 +180,17 @@ int xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
xmlBufferPtr in); xmlBufferPtr in);
int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
/*
* Export a few useful functions
*/
int UTF8Toisolat1 (unsigned char* out,
int *outlen,
const unsigned char* in,
int *inlen);
int isolat1ToUTF8 (unsigned char* out,
int *outlen,
const unsigned char* in,
int *inlen);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -15,6 +15,13 @@
* Author: Gary.Pennington@uk.sun.com * Author: Gary.Pennington@uk.sun.com
*/ */
#ifndef __XML_LINK_INCLUDE__
#define __XML_LINK_INCLUDE__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _xmlLink xmlLink; typedef struct _xmlLink xmlLink;
typedef xmlLink *xmlLinkPtr; typedef xmlLink *xmlLinkPtr;
@ -78,4 +85,8 @@ void * xmlLinkGetData (xmlLinkPtr lk);
/* xmlListUnique() */ /* xmlListUnique() */
/* xmlListSwap */ /* xmlListSwap */
#ifdef __cplusplus
}
#endif
#endif /* __XML_LINK_INCLUDE__ */

View File

@ -338,6 +338,9 @@ int xmlParserInputGrow (xmlParserInputPtr in,
xmlChar * xmlStrdup (const xmlChar *cur); xmlChar * xmlStrdup (const xmlChar *cur);
xmlChar * xmlStrndup (const xmlChar *cur, xmlChar * xmlStrndup (const xmlChar *cur,
int len); int len);
xmlChar * xmlCharStrndup (const char *cur,
int len);
xmlChar * xmlCharStrdup (const char *cur);
xmlChar * xmlStrsub (const xmlChar *str, xmlChar * xmlStrsub (const xmlChar *str,
int start, int start,
int len); int len);

View File

@ -14,6 +14,7 @@
#define __XML_PARSER_INTERNALS_H__ #define __XML_PARSER_INTERNALS_H__
#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -157,6 +158,8 @@ void xmlHandleEntity (xmlParserCtxtPtr ctxt,
/** /**
* Input Streams * Input Streams
*/ */
xmlParserInputPtr xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
const xmlChar *buffer);
xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
xmlEntityPtr entity); xmlEntityPtr entity);
void xmlPushInput (xmlParserCtxtPtr ctxt, void xmlPushInput (xmlParserCtxtPtr ctxt,
@ -278,6 +281,9 @@ xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
int inputPush (xmlParserCtxtPtr ctxt, int inputPush (xmlParserCtxtPtr ctxt,
xmlParserInputPtr value); xmlParserInputPtr value);
xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt); xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
xmlChar *namePop (xmlParserCtxtPtr ctxt);
int namePush (xmlParserCtxtPtr ctxt,
xmlChar *value);
/* /*
* other comodities shared between parser.c and parserInternals * other comodities shared between parser.c and parserInternals
@ -288,7 +294,6 @@ int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
int *len); int *len);
void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
void xmlParserHandleReference(xmlParserCtxtPtr ctxt); void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
xmlChar *namePop (xmlParserCtxtPtr ctxt);
int xmlCheckLanguageID (const xmlChar *lang); int xmlCheckLanguageID (const xmlChar *lang);
/* /*
@ -296,6 +301,8 @@ int xmlCheckLanguageID (const xmlChar *lang);
*/ */
int xmlCurrentChar (xmlParserCtxtPtr ctxt, int xmlCurrentChar (xmlParserCtxtPtr ctxt,
int *len); int *len);
int xmlCopyCharMultiByte (xmlChar *out,
int val);
int xmlCopyChar (int len, int xmlCopyChar (int len,
xmlChar *out, xmlChar *out,
int val); int val);
@ -307,6 +314,8 @@ void xmlParserInputShrink (xmlParserInputPtr in);
* Actually comes from the HTML parser but launched from the init stuff * Actually comes from the HTML parser but launched from the init stuff
*/ */
void htmlInitAutoClose (void); void htmlInitAutoClose (void);
htmlParserCtxtPtr htmlCreateFileParserCtxt(const char *filename,
const char *encoding);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -394,8 +394,13 @@ LIBXML_DLL_IMPORT extern int xmlDefaultBufferSize; /* default buffer size */
* Handling Buffers. * Handling Buffers.
*/ */
void xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
xmlBufferAllocationScheme xmlGetBufferAllocationScheme(void);
xmlBufferPtr xmlBufferCreate (void); xmlBufferPtr xmlBufferCreate (void);
xmlBufferPtr xmlBufferCreateSize (size_t size); xmlBufferPtr xmlBufferCreateSize (size_t size);
int xmlBufferResize (xmlBufferPtr buf,
unsigned int size);
void xmlBufferFree (xmlBufferPtr buf); void xmlBufferFree (xmlBufferPtr buf);
int xmlBufferDump (FILE *file, int xmlBufferDump (FILE *file,
xmlBufferPtr buf); xmlBufferPtr buf);
@ -440,6 +445,7 @@ xmlNsPtr xmlNewNs (xmlNodePtr node,
const xmlChar *href, const xmlChar *href,
const xmlChar *prefix); const xmlChar *prefix);
void xmlFreeNs (xmlNsPtr cur); void xmlFreeNs (xmlNsPtr cur);
void xmlFreeNsList (xmlNsPtr cur);
xmlDocPtr xmlNewDoc (const xmlChar *version); xmlDocPtr xmlNewDoc (const xmlChar *version);
void xmlFreeDoc (xmlDocPtr cur); void xmlFreeDoc (xmlDocPtr cur);
xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,

View File

@ -11,6 +11,7 @@
#define __XML_VALID_H__ #define __XML_VALID_H__
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/list.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -167,6 +168,8 @@ int xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem, xmlNodePtr elem,
xmlAttrPtr attr); xmlAttrPtr attr);
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr); int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
xmlListPtr xmlGetRefs (xmlDocPtr doc,
const xmlChar *ID);
/** /**
* The public function calls related to validity checking * The public function calls related to validity checking

View File

@ -112,10 +112,10 @@ int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
char * xmlParserGetDirectory (const char *filename); char * xmlParserGetDirectory (const char *filename);
int xmlRegisterInputCallbacks (xmlInputMatchCallback match, int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
xmlInputOpenCallback open, xmlInputOpenCallback openFunc,
xmlInputReadCallback read, xmlInputReadCallback readFunc,
xmlInputCloseCallback close); xmlInputCloseCallback closeFunc);
/* /*
* Interfaces for output * Interfaces for output
*/ */
@ -151,10 +151,10 @@ int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
int xmlOutputBufferFlush (xmlOutputBufferPtr out); int xmlOutputBufferFlush (xmlOutputBufferPtr out);
int xmlOutputBufferClose (xmlOutputBufferPtr out); int xmlOutputBufferClose (xmlOutputBufferPtr out);
int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match, int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
xmlOutputOpenCallback open, xmlOutputOpenCallback openFunc,
xmlOutputWriteCallback write, xmlOutputWriteCallback writeFunc,
xmlOutputCloseCallback close); xmlOutputCloseCallback closeFunc);
/* /*
* This save function are part of tree.h and HTMLtree.h actually * This save function are part of tree.h and HTMLtree.h actually

View File

@ -79,7 +79,9 @@ void xmlXPatherror (xmlXPathParserContextPtr ctxt,
void xmlXPathDebugDumpObject (FILE *output, void xmlXPathDebugDumpObject (FILE *output,
xmlXPathObjectPtr cur, xmlXPathObjectPtr cur,
int depth); int depth);
void xmlXPathDebugDumpCompExpr(FILE *output,
xmlXPathCompExprPtr comp,
int depth);
/** /**
* Extending a context * Extending a context
*/ */
@ -139,7 +141,9 @@ xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val); xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur, void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
xmlNodePtr val); xmlNodePtr val);
void xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
xmlNodePtr val);
void xmlXPathNodeSetSort (xmlNodeSetPtr set);
void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt, void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt,
int nargs); int nargs);
@ -193,13 +197,37 @@ void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
void xmlXPathDivValues(xmlXPathParserContextPtr ctxt); void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
void xmlXPathModValues(xmlXPathParserContextPtr ctxt); void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
int xmlXPathIsNodeType(const xmlChar *name);
/* /*
* Some of the axis navigation routines * Some of the axis navigation routines
*/ */
xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); xmlNodePtr cur);
xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
/* /*
* The official core of XPath functions * The official core of XPath functions
*/ */

View File

@ -38,11 +38,31 @@ xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2); xmlLocationSetPtr val2);
xmlXPathObjectPtr xmlXPtrNewRange (xmlNodePtr start,
int startindex,
xmlNodePtr end,
int endindex);
xmlXPathObjectPtr xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end);
xmlXPathObjectPtr xmlXPtrNewRangeNodePoint(xmlNodePtr start,
xmlXPathObjectPtr end);
xmlXPathObjectPtr xmlXPtrNewRangePointNode(xmlXPathObjectPtr start,
xmlNodePtr end);
xmlXPathObjectPtr xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end);
xmlXPathObjectPtr xmlXPtrNewLocationSetNodes(xmlNodePtr start,
xmlNodePtr end);
xmlXPathObjectPtr xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
xmlXPathObjectPtr end); xmlXPathObjectPtr end);
xmlXPathObjectPtr xmlXPtrNewCollapsedRange(xmlNodePtr start);
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val); xmlXPathObjectPtr val);
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val); xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
void xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
void xmlXPtrLocationSetRemove(xmlLocationSetPtr cur,
int val);
/* /*
* Functions * Functions

2
list.c
View File

@ -155,7 +155,7 @@ xmlListLinkSearch(xmlListPtr l, void *data)
* *
* Returns the link containing the data or NULL * Returns the link containing the data or NULL
*/ */
xmlLinkPtr static xmlLinkPtr
xmlListLinkReverseSearch(xmlListPtr l, void *data) xmlListLinkReverseSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;

11
list.h
View File

@ -15,6 +15,13 @@
* Author: Gary.Pennington@uk.sun.com * Author: Gary.Pennington@uk.sun.com
*/ */
#ifndef __XML_LINK_INCLUDE__
#define __XML_LINK_INCLUDE__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _xmlLink xmlLink; typedef struct _xmlLink xmlLink;
typedef xmlLink *xmlLinkPtr; typedef xmlLink *xmlLinkPtr;
@ -78,4 +85,8 @@ void * xmlLinkGetData (xmlLinkPtr lk);
/* xmlListUnique() */ /* xmlListUnique() */
/* xmlListSwap */ /* xmlListSwap */
#ifdef __cplusplus
}
#endif
#endif /* __XML_LINK_INCLUDE__ */

101
nanoftp.c
View File

@ -237,7 +237,7 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) {
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
const char *cur = URL; const char *cur = URL;
char buf[4096]; char buf[4096];
int index = 0; int indx = 0;
int port = 0; int port = 0;
if (ctxt->protocol != NULL) { if (ctxt->protocol != NULL) {
@ -253,25 +253,25 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) {
ctxt->path = NULL; ctxt->path = NULL;
} }
if (URL == NULL) return; if (URL == NULL) return;
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) { while (*cur != 0) {
if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
buf[index] = 0; buf[indx] = 0;
ctxt->protocol = xmlMemStrdup(buf); ctxt->protocol = xmlMemStrdup(buf);
index = 0; indx = 0;
cur += 3; cur += 3;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) return; if (*cur == 0) return;
buf[index] = 0; buf[indx] = 0;
while (1) { while (1) {
if (cur[0] == ':') { if (cur[0] == ':') {
buf[index] = 0; buf[indx] = 0;
ctxt->hostname = xmlMemStrdup(buf); ctxt->hostname = xmlMemStrdup(buf);
index = 0; indx = 0;
cur += 1; cur += 1;
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
port *= 10; port *= 10;
@ -284,21 +284,21 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) {
break; break;
} }
if ((*cur == '/') || (*cur == 0)) { if ((*cur == '/') || (*cur == 0)) {
buf[index] = 0; buf[indx] = 0;
ctxt->hostname = xmlMemStrdup(buf); ctxt->hostname = xmlMemStrdup(buf);
index = 0; indx = 0;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) if (*cur == 0)
ctxt->path = xmlMemStrdup("/"); ctxt->path = xmlMemStrdup("/");
else { else {
index = 0; indx = 0;
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) while (*cur != 0)
buf[index++] = *cur++; buf[indx++] = *cur++;
buf[index] = 0; buf[indx] = 0;
ctxt->path = xmlMemStrdup(buf); ctxt->path = xmlMemStrdup(buf);
} }
} }
@ -322,7 +322,7 @@ xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
const char *cur = URL; const char *cur = URL;
char buf[4096]; char buf[4096];
int index = 0; int indx = 0;
int port = 0; int port = 0;
if (URL == NULL) if (URL == NULL)
@ -333,28 +333,28 @@ xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
return(-1); return(-1);
if (ctxt->hostname == NULL) if (ctxt->hostname == NULL)
return(-1); return(-1);
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) { while (*cur != 0) {
if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
buf[index] = 0; buf[indx] = 0;
if (strcmp(ctxt->protocol, buf)) if (strcmp(ctxt->protocol, buf))
return(-1); return(-1);
index = 0; indx = 0;
cur += 3; cur += 3;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) if (*cur == 0)
return(-1); return(-1);
buf[index] = 0; buf[indx] = 0;
while (1) { while (1) {
if (cur[0] == ':') { if (cur[0] == ':') {
buf[index] = 0; buf[indx] = 0;
if (strcmp(ctxt->hostname, buf)) if (strcmp(ctxt->hostname, buf))
return(-1); return(-1);
index = 0; indx = 0;
cur += 1; cur += 1;
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
port *= 10; port *= 10;
@ -368,13 +368,13 @@ xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
break; break;
} }
if ((*cur == '/') || (*cur == 0)) { if ((*cur == '/') || (*cur == 0)) {
buf[index] = 0; buf[indx] = 0;
if (strcmp(ctxt->hostname, buf)) if (strcmp(ctxt->hostname, buf))
return(-1); return(-1);
index = 0; indx = 0;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (ctxt->path != NULL) { if (ctxt->path != NULL) {
xmlFree(ctxt->path); xmlFree(ctxt->path);
@ -384,11 +384,11 @@ xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
if (*cur == 0) if (*cur == 0)
ctxt->path = xmlMemStrdup("/"); ctxt->path = xmlMemStrdup("/");
else { else {
index = 0; indx = 0;
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) while (*cur != 0)
buf[index++] = *cur++; buf[indx++] = *cur++;
buf[index] = 0; buf[indx] = 0;
ctxt->path = xmlMemStrdup(buf); ctxt->path = xmlMemStrdup(buf);
} }
return(0); return(0);
@ -408,7 +408,7 @@ void
xmlNanoFTPScanProxy(const char *URL) { xmlNanoFTPScanProxy(const char *URL) {
const char *cur = URL; const char *cur = URL;
char buf[4096]; char buf[4096];
int index = 0; int indx = 0;
int port = 0; int port = 0;
if (proxy != NULL) { if (proxy != NULL) {
@ -425,24 +425,24 @@ xmlNanoFTPScanProxy(const char *URL) {
xmlGenericError(xmlGenericErrorContext, "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[indx] = 0;
while (*cur != 0) { while (*cur != 0) {
if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
buf[index] = 0; buf[indx] = 0;
index = 0; indx = 0;
cur += 3; cur += 3;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) return; if (*cur == 0) return;
buf[index] = 0; buf[indx] = 0;
while (1) { while (1) {
if (cur[0] == ':') { if (cur[0] == ':') {
buf[index] = 0; buf[indx] = 0;
proxy = xmlMemStrdup(buf); proxy = xmlMemStrdup(buf);
index = 0; indx = 0;
cur += 1; cur += 1;
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
port *= 10; port *= 10;
@ -455,12 +455,12 @@ xmlNanoFTPScanProxy(const char *URL) {
break; break;
} }
if ((*cur == '/') || (*cur == 0)) { if ((*cur == '/') || (*cur == 0)) {
buf[index] = 0; buf[indx] = 0;
proxy = xmlMemStrdup(buf); proxy = xmlMemStrdup(buf);
index = 0; indx = 0;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
} }
@ -517,7 +517,6 @@ xmlNanoFTPFreeCtxt(void * ctx) {
/** /**
* xmlNanoFTPParseResponse: * xmlNanoFTPParseResponse:
* @ctx: the FTP connection context
* @buf: the buffer containing the response * @buf: the buffer containing the response
* @len: the buffer length * @len: the buffer length
* *
@ -528,7 +527,7 @@ xmlNanoFTPFreeCtxt(void * ctx) {
* -XXX for response to be continued * -XXX for response to be continued
*/ */
static int static int
xmlNanoFTPParseResponse(void *ctx, char *buf, int len) { xmlNanoFTPParseResponse(char *buf, int len) {
int val = 0; int val = 0;
if (len < 3) return(-1); if (len < 3) return(-1);
@ -663,7 +662,7 @@ get_more:
"\n<<<\n%s\n--\n", ptr); "\n<<<\n%s\n--\n", ptr);
#endif #endif
while (ptr < end) { while (ptr < end) {
cur = xmlNanoFTPParseResponse(ctxt, ptr, end - ptr); cur = xmlNanoFTPParseResponse(ptr, end - ptr);
if (cur > 0) { if (cur > 0) {
/* /*
* Successfully scanned the control code, scratch * Successfully scanned the control code, scratch
@ -1572,7 +1571,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
char buf[4096 + 1]; char buf[4096 + 1];
int len, res; int len, res;
int index = 0, base; int indx = 0, base;
fd_set rfd, efd; fd_set rfd, efd;
struct timeval tv; struct timeval tv;
@ -1643,7 +1642,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
continue; continue;
} }
if ((len = recv(ctxt->dataFd, &buf[index], sizeof(buf) - (index + 1), 0)) < 0) { if ((len = recv(ctxt->dataFd, &buf[indx], sizeof(buf) - (indx + 1), 0)) < 0) {
#ifdef DEBUG_FTP #ifdef DEBUG_FTP
perror("recv"); perror("recv");
#endif #endif
@ -1652,18 +1651,18 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
return(-1); return(-1);
} }
#ifdef DEBUG_FTP #ifdef DEBUG_FTP
write(1, &buf[index], len); write(1, &buf[indx], len);
#endif #endif
index += len; indx += len;
buf[index] = 0; buf[indx] = 0;
base = 0; base = 0;
do { do {
res = xmlNanoFTPParseList(&buf[base], callback, userData); res = xmlNanoFTPParseList(&buf[base], callback, userData);
base += res; base += res;
} while (res > 0); } while (res > 0);
memmove(&buf[0], &buf[base], index - base); memmove(&buf[0], &buf[base], indx - base);
index -= base; indx -= base;
} while (len != 0); } while (len != 0);
xmlNanoFTPCloseConnection(ctxt); xmlNanoFTPCloseConnection(ctxt);
return(0); return(0);

View File

@ -126,7 +126,7 @@ static unsigned int timeout = 60;/* the select() timeout in seconds */
/** /**
* A portability function * A portability function
*/ */
int socket_errno(void) { static int socket_errno(void) {
#ifdef _WINSOCKAPI_ #ifdef _WINSOCKAPI_
return(WSAGetLastError()); return(WSAGetLastError());
#else #else
@ -194,19 +194,6 @@ xmlNanoHTTPCleanup(void) {
return; return;
} }
/**
* xmlNanoHTTPTimeout:
* @delay: the delay in seconds
*
* Set the HTTP timeout, (default is 60secs). 0 means immediate
* return, while -1 infinite.
*/
void
xmlNanoHTTPTimeout(int delay) {
timeout = (unsigned int) delay;
}
/** /**
* xmlNanoHTTPScanURL: * xmlNanoHTTPScanURL:
* @ctxt: an HTTP context * @ctxt: an HTTP context
@ -220,7 +207,7 @@ static void
xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) { xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
const char *cur = URL; const char *cur = URL;
char buf[4096]; char buf[4096];
int index = 0; int indx = 0;
int port = 0; int port = 0;
if (ctxt->protocol != NULL) { if (ctxt->protocol != NULL) {
@ -236,25 +223,25 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
ctxt->path = NULL; ctxt->path = NULL;
} }
if (URL == NULL) return; if (URL == NULL) return;
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) { while (*cur != 0) {
if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
buf[index] = 0; buf[indx] = 0;
ctxt->protocol = xmlMemStrdup(buf); ctxt->protocol = xmlMemStrdup(buf);
index = 0; indx = 0;
cur += 3; cur += 3;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) return; if (*cur == 0) return;
buf[index] = 0; buf[indx] = 0;
while (1) { while (1) {
if (cur[0] == ':') { if (cur[0] == ':') {
buf[index] = 0; buf[indx] = 0;
ctxt->hostname = xmlMemStrdup(buf); ctxt->hostname = xmlMemStrdup(buf);
index = 0; indx = 0;
cur += 1; cur += 1;
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
port *= 10; port *= 10;
@ -267,21 +254,21 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
break; break;
} }
if ((*cur == '/') || (*cur == 0)) { if ((*cur == '/') || (*cur == 0)) {
buf[index] = 0; buf[indx] = 0;
ctxt->hostname = xmlMemStrdup(buf); ctxt->hostname = xmlMemStrdup(buf);
index = 0; indx = 0;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) if (*cur == 0)
ctxt->path = xmlMemStrdup("/"); ctxt->path = xmlMemStrdup("/");
else { else {
index = 0; indx = 0;
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) while (*cur != 0)
buf[index++] = *cur++; buf[indx++] = *cur++;
buf[index] = 0; buf[indx] = 0;
ctxt->path = xmlMemStrdup(buf); ctxt->path = xmlMemStrdup(buf);
} }
} }
@ -300,7 +287,7 @@ void
xmlNanoHTTPScanProxy(const char *URL) { xmlNanoHTTPScanProxy(const char *URL) {
const char *cur = URL; const char *cur = URL;
char buf[4096]; char buf[4096];
int index = 0; int indx = 0;
int port = 0; int port = 0;
if (proxy != NULL) { if (proxy != NULL) {
@ -319,24 +306,24 @@ xmlNanoHTTPScanProxy(const char *URL) {
"Using HTTP proxy %s\n", URL); "Using HTTP proxy %s\n", URL);
#endif #endif
if (URL == NULL) return; if (URL == NULL) return;
buf[index] = 0; buf[indx] = 0;
while (*cur != 0) { while (*cur != 0) {
if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) { if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
buf[index] = 0; buf[indx] = 0;
index = 0; indx = 0;
cur += 3; cur += 3;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
if (*cur == 0) return; if (*cur == 0) return;
buf[index] = 0; buf[indx] = 0;
while (1) { while (1) {
if (cur[0] == ':') { if (cur[0] == ':') {
buf[index] = 0; buf[indx] = 0;
proxy = xmlMemStrdup(buf); proxy = xmlMemStrdup(buf);
index = 0; indx = 0;
cur += 1; cur += 1;
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
port *= 10; port *= 10;
@ -349,12 +336,12 @@ xmlNanoHTTPScanProxy(const char *URL) {
break; break;
} }
if ((*cur == '/') || (*cur == 0)) { if ((*cur == '/') || (*cur == 0)) {
buf[index] = 0; buf[indx] = 0;
proxy = xmlMemStrdup(buf); proxy = xmlMemStrdup(buf);
index = 0; indx = 0;
break; break;
} }
buf[index++] = *cur++; buf[indx++] = *cur++;
} }
} }
@ -418,14 +405,13 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
static void static void
xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt) { xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt) {
if (ctxt->state & XML_NANO_HTTP_WRITE) { if (ctxt->state & XML_NANO_HTTP_WRITE) {
int total_sent = 0; unsigned int total_sent = 0;
while (total_sent <strlen(ctxt->outptr)) { while (total_sent <strlen(ctxt->outptr)) {
int nsent = send(ctxt->fd, ctxt->outptr+total_sent, unsigned int nsent = send(ctxt->fd, ctxt->outptr+total_sent,
strlen(ctxt->outptr)-total_sent, 0); strlen(ctxt->outptr)-total_sent, 0);
if (nsent>0) if (nsent>0)
total_sent += nsent; total_sent += nsent;
} }
ctxt->last = total_sent; ctxt->last = total_sent;
} }
} }
@ -636,8 +622,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
/** /**
* xmlNanoHTTPConnectAttempt: * xmlNanoHTTPConnectAttempt:
* @ia: an internet adress structure * @addr: a socket adress structure
* @port: the port number
* *
* Attempt a connection to the given IP:port endpoint. It forces * Attempt a connection to the given IP:port endpoint. It forces
* non-blocking semantic on the socket, and allow 60 seconds for * non-blocking semantic on the socket, and allow 60 seconds for
@ -647,7 +632,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
*/ */
static int static int
xmlNanoHTTPConnectAttempt(struct sockaddr *addr, int port) xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
{ {
SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
fd_set wfd; fd_set wfd;
@ -765,10 +750,10 @@ xmlNanoHTTPConnectHost(const char *host, int port)
struct hostent *h; struct hostent *h;
struct sockaddr *addr; struct sockaddr *addr;
struct in_addr ia; struct in_addr ia;
struct sockaddr_in sin; struct sockaddr_in sockin;
#ifdef SUPPORT_IP6 #ifdef SUPPORT_IP6
struct in6_addr ia6; struct in6_addr ia6;
struct sockaddr_in6 sin6; struct sockaddr_in6 sockin6;
#endif #endif
int i; int i;
int s; int s;
@ -792,23 +777,23 @@ xmlNanoHTTPConnectHost(const char *host, int port)
if (h->h_addrtype == AF_INET) { if (h->h_addrtype == AF_INET) {
/* A records (IPv4) */ /* A records (IPv4) */
memcpy(&ia, h->h_addr_list[i], h->h_length); memcpy(&ia, h->h_addr_list[i], h->h_length);
sin.sin_family = h->h_addrtype; sockin.sin_family = h->h_addrtype;
sin.sin_addr = ia; sockin.sin_addr = ia;
sin.sin_port = htons(port); sockin.sin_port = htons(port);
addr = (struct sockaddr *)&sin; addr = (struct sockaddr *)&sockin;
#ifdef SUPPORT_IP6 #ifdef SUPPORT_IP6
} else if (h->h_addrtype == AF_INET6) { } else if (h->h_addrtype == AF_INET6) {
/* AAAA records (IPv6) */ /* AAAA records (IPv6) */
memcpy(&ia6, h->h_addr_list[i], h->h_length); memcpy(&ia6, h->h_addr_list[i], h->h_length);
sin6.sin_family = h->h_addrtype; sockin6.sin_family = h->h_addrtype;
sin6.sin_addr = ia6; sockin6.sin_addr = ia6;
sin6.sin_port = htons(port); sockin6.sin_port = htons(port);
addr = (struct sockaddr *)&sin6; addr = (struct sockaddr *)&sockin6;
#endif #endif
} else } else
break; /* for */ break; /* for */
s = xmlNanoHTTPConnectAttempt(addr, port); s = xmlNanoHTTPConnectAttempt(addr);
if (s != -1) if (s != -1)
return(s); return(s);
} }

123
parser.c
View File

@ -160,7 +160,7 @@ PUSH_AND_POP(extern, xmlParserInputPtr, input)
PUSH_AND_POP(extern, xmlNodePtr, node) PUSH_AND_POP(extern, xmlNodePtr, node)
PUSH_AND_POP(extern, xmlChar*, name) PUSH_AND_POP(extern, xmlChar*, name)
int spacePush(xmlParserCtxtPtr ctxt, int val) { static int spacePush(xmlParserCtxtPtr ctxt, int val) {
if (ctxt->spaceNr >= ctxt->spaceMax) { if (ctxt->spaceNr >= ctxt->spaceMax) {
ctxt->spaceMax *= 2; ctxt->spaceMax *= 2;
ctxt->spaceTab = (int *) xmlRealloc(ctxt->spaceTab, ctxt->spaceTab = (int *) xmlRealloc(ctxt->spaceTab,
@ -176,7 +176,7 @@ int spacePush(xmlParserCtxtPtr ctxt, int val) {
return(ctxt->spaceNr++); return(ctxt->spaceNr++);
} }
int spacePop(xmlParserCtxtPtr ctxt) { static int spacePop(xmlParserCtxtPtr ctxt) {
int ret; int ret;
if (ctxt->spaceNr <= 0) return(0); if (ctxt->spaceNr <= 0) return(0);
ctxt->spaceNr--; ctxt->spaceNr--;
@ -274,7 +274,7 @@ int spacePop(xmlParserCtxtPtr ctxt) {
#define COPY_BUF(l,b,i,v) \ #define COPY_BUF(l,b,i,v) \
if (l == 1) b[i++] = (xmlChar) v; \ if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyChar(l,&b[i],v) else i += xmlCopyCharMultiByte(&b[i],v)
/** /**
* xmlSkipBlankChars: * xmlSkipBlankChars:
@ -493,7 +493,7 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
* Returns the value parsed (as an int), 0 in case of error, str will be * Returns the value parsed (as an int), 0 in case of error, str will be
* updated to the current value of the index * updated to the current value of the index
*/ */
int static int
xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) { xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
const xmlChar *ptr; const xmlChar *ptr;
xmlChar cur; xmlChar cur;
@ -1741,7 +1741,7 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
* is updated to the current location in the string. * is updated to the current location in the string.
*/ */
xmlChar * static xmlChar *
xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) { xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
xmlChar buf[XML_MAX_NAMELEN + 5]; xmlChar buf[XML_MAX_NAMELEN + 5];
const xmlChar *cur = *str; const xmlChar *cur = *str;
@ -4253,7 +4253,7 @@ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, xmlChar *name,
ctxt->errNo = XML_ERR_ELEMCONTENT_NOT_STARTED; ctxt->errNo = XML_ERR_ELEMCONTENT_NOT_STARTED;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData, ctxt->sax->error(ctxt->userData,
"xmlParseElementContentDecl : '(' expected\n"); "xmlParseElementContentDecl : %s '(' expected\n", name);
ctxt->wellFormed = 0; ctxt->wellFormed = 0;
ctxt->disableSAX = 1; ctxt->disableSAX = 1;
return(-1); return(-1);
@ -4566,7 +4566,7 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
* [65] Ignore ::= Char* - (Char* ('<![' | ']]>') Char*) * [65] Ignore ::= Char* - (Char* ('<![' | ']]>') Char*)
*/ */
void static void
xmlParseConditionalSections(xmlParserCtxtPtr ctxt) { xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
SKIP(3); SKIP(3);
SKIP_BLANKS; SKIP_BLANKS;
@ -4824,7 +4824,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
int i = 0; int i = 0;
xmlChar out[10]; xmlChar out[10];
int hex = NXT(2); int hex = NXT(2);
int val = xmlParseCharRef(ctxt); int value = xmlParseCharRef(ctxt);
if (ctxt->charset != XML_CHAR_ENCODING_UTF8) { if (ctxt->charset != XML_CHAR_ENCODING_UTF8) {
/* /*
@ -4832,17 +4832,17 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
* Check that the char fit on 8bits, if not * Check that the char fit on 8bits, if not
* generate a CharRef. * generate a CharRef.
*/ */
if (val <= 0xFF) { if (value <= 0xFF) {
out[0] = val; out[0] = value;
out[1] = 0; out[1] = 0;
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) && if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->characters(ctxt->userData, out, 1); ctxt->sax->characters(ctxt->userData, out, 1);
} else { } else {
if ((hex == 'x') || (hex == 'X')) if ((hex == 'x') || (hex == 'X'))
sprintf((char *)out, "#x%X", val); sprintf((char *)out, "#x%X", value);
else else
sprintf((char *)out, "#%d", val); sprintf((char *)out, "#%d", value);
if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) && if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->reference(ctxt->userData, out); ctxt->sax->reference(ctxt->userData, out);
@ -4851,7 +4851,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
/* /*
* Just encode the value in UTF-8 * Just encode the value in UTF-8
*/ */
COPY_BUF(0 ,out, i, val); COPY_BUF(0 ,out, i, value);
out[i] = 0; out[i] = 0;
if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) && if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
@ -5765,7 +5765,7 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) {
* [28 end] ('[' (markupdecl | PEReference | S)* ']' S?)? '>' * [28 end] ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*/ */
void static void
xmlParseInternalSubset(xmlParserCtxtPtr ctxt) { xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
/* /*
* Is there any DTD definition ? * Is there any DTD definition ?
@ -7381,7 +7381,7 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
* Returns the index to the current parsing point if the full sequence * Returns the index to the current parsing point if the full sequence
* is available, -1 otherwise. * is available, -1 otherwise.
*/ */
int static int
xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first, xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third) { xmlChar next, xmlChar third) {
int base, len; int base, len;
@ -7454,7 +7454,7 @@ xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
* *
* Returns zero if no parsing was possible * Returns zero if no parsing was possible
*/ */
int static int
xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
int ret = 0; int ret = 0;
int avail; int avail;
@ -7932,12 +7932,12 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
* Handle preparsed entities and charRef * Handle preparsed entities and charRef
*/ */
if (ctxt->token != 0) { if (ctxt->token != 0) {
xmlChar cur[2] = { 0 , 0 } ; xmlChar current[2] = { 0 , 0 } ;
cur[0] = (xmlChar) ctxt->token; current[0] = (xmlChar) ctxt->token;
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) && if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->characters != NULL)) (ctxt->sax->characters != NULL))
ctxt->sax->characters(ctxt->userData, cur, 1); ctxt->sax->characters(ctxt->userData, current, 1);
ctxt->token = 0; ctxt->token = 0;
} }
if ((avail < 2) && (ctxt->inputNr == 1)) if ((avail < 2) && (ctxt->inputNr == 1))
@ -8251,19 +8251,6 @@ done:
return(ret); return(ret);
} }
/**
* xmlParseTry:
* @ctxt: an XML parser context
*
* Try to progress on parsing
*
* Returns zero if no parsing was possible
*/
int
xmlParseTry(xmlParserCtxtPtr ctxt) {
return(xmlParseTryOrFinish(ctxt, 0));
}
/** /**
* xmlParseChunk: * xmlParseChunk:
* @ctxt: an XML parser context * @ctxt: an XML parser context
@ -8695,78 +8682,6 @@ xmlParseDTD(const xmlChar *ExternalID, const xmlChar *SystemID) {
* * * *
************************************************************************/ ************************************************************************/
/**
* xmlSAXParseBalancedChunk:
* @ctx: an XML parser context (possibly NULL)
* @sax: the SAX handler bloc (possibly NULL)
* @user_data: The user data returned on SAX callbacks (possibly NULL)
* @input: a parser input stream
* @enc: the encoding
*
* Parse a well-balanced chunk of an XML document
* The user has to provide SAX callback block whose routines will be
* called by the parser
* The allowed sequence for the Well Balanced Chunk is the one defined by
* the content production in the XML grammar:
*
* [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
*
* Returns 0 if the chunk is well balanced, -1 in case of args problem and
* the error code otherwise
*/
int
xmlSAXParseBalancedChunk(xmlParserCtxtPtr ctx, xmlSAXHandlerPtr sax,
void *user_data, xmlParserInputPtr input,
xmlCharEncoding enc) {
xmlParserCtxtPtr ctxt;
int ret;
if (input == NULL) return(-1);
if (ctx != NULL)
ctxt = ctx;
else {
ctxt = xmlNewParserCtxt();
if (ctxt == NULL)
return(-1);
if (sax == NULL)
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
}
/*
* Set-up the SAX context
*/
if (sax != NULL) {
if (ctxt->sax != NULL)
xmlFree(ctxt->sax);
ctxt->sax = sax;
ctxt->userData = user_data;
}
/*
* plug some encoding conversion routines here.
*/
xmlPushInput(ctxt, input);
if (enc != XML_CHAR_ENCODING_NONE)
xmlSwitchEncoding(ctxt, enc);
/*
* let's parse that entity knowing it's an external subset.
*/
xmlParseContent(ctxt);
ret = ctxt->errNo;
if (ctx == NULL) {
if (sax != NULL)
ctxt->sax = NULL;
else
xmlFreeDoc(ctxt->myDoc);
xmlFreeParserCtxt(ctxt);
}
return(ret);
}
/** /**
* xmlParseCtxtExternalEntity: * xmlParseCtxtExternalEntity:
* @ctx: the existing parsing context * @ctx: the existing parsing context

View File

@ -338,6 +338,9 @@ int xmlParserInputGrow (xmlParserInputPtr in,
xmlChar * xmlStrdup (const xmlChar *cur); xmlChar * xmlStrdup (const xmlChar *cur);
xmlChar * xmlStrndup (const xmlChar *cur, xmlChar * xmlStrndup (const xmlChar *cur,
int len); int len);
xmlChar * xmlCharStrndup (const char *cur,
int len);
xmlChar * xmlCharStrdup (const char *cur);
xmlChar * xmlStrsub (const xmlChar *str, xmlChar * xmlStrsub (const xmlChar *str,
int start, int start,
int len); int len);

View File

@ -48,6 +48,19 @@
#include <libxml/xmlIO.h> #include <libxml/xmlIO.h>
#include <libxml/uri.h> #include <libxml/uri.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
void xmlUpgradeOldNs(xmlDocPtr doc);
/************************************************************************ /************************************************************************
* * * *
@ -932,7 +945,7 @@ int
xmlParserInputRead(xmlParserInputPtr in, int len) { xmlParserInputRead(xmlParserInputPtr in, int len) {
int ret; int ret;
int used; int used;
int index; int indx;
#ifdef DEBUG_INPUT #ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext, "Read\n"); xmlGenericError(xmlGenericErrorContext, "Read\n");
@ -956,9 +969,9 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
/* /*
* the buffer has been realloced * the buffer has been realloced
*/ */
index = in->cur - in->base; indx = in->cur - in->base;
in->base = in->buf->buffer->content; in->base = in->buf->buffer->content;
in->cur = &in->buf->buffer->content[index]; in->cur = &in->buf->buffer->content[indx];
} }
in->end = &in->buf->buffer->content[in->buf->buffer->use]; in->end = &in->buf->buffer->content[in->buf->buffer->use];
@ -981,7 +994,7 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
int int
xmlParserInputGrow(xmlParserInputPtr in, int len) { xmlParserInputGrow(xmlParserInputPtr in, int len) {
int ret; int ret;
int index; int indx;
#ifdef DEBUG_INPUT #ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext, "Grow\n"); xmlGenericError(xmlGenericErrorContext, "Grow\n");
@ -993,8 +1006,8 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
CHECK_BUFFER(in); CHECK_BUFFER(in);
index = in->cur - in->base; indx = in->cur - in->base;
if (in->buf->buffer->use > (unsigned int) index + INPUT_CHUNK) { if (in->buf->buffer->use > (unsigned int) indx + INPUT_CHUNK) {
CHECK_BUFFER(in); CHECK_BUFFER(in);
@ -1015,9 +1028,9 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
/* /*
* the buffer has been realloced * the buffer has been realloced
*/ */
index = in->cur - in->base; indx = in->cur - in->base;
in->base = in->buf->buffer->content; in->base = in->buf->buffer->content;
in->cur = &in->buf->buffer->content[index]; in->cur = &in->buf->buffer->content[indx];
} }
in->end = &in->buf->buffer->content[in->buf->buffer->use]; in->end = &in->buf->buffer->content[in->buf->buffer->use];
@ -1036,7 +1049,7 @@ void
xmlParserInputShrink(xmlParserInputPtr in) { xmlParserInputShrink(xmlParserInputPtr in) {
int used; int used;
int ret; int ret;
int index; int indx;
#ifdef DEBUG_INPUT #ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext, "Shrink\n"); xmlGenericError(xmlGenericErrorContext, "Shrink\n");
@ -1053,7 +1066,7 @@ xmlParserInputShrink(xmlParserInputPtr in) {
* Do not shrink on large buffers whose only a tiny fraction * Do not shrink on large buffers whose only a tiny fraction
* was consumned * was consumned
*/ */
if (in->buf->buffer->use > used + 2 * INPUT_CHUNK) if ((int) in->buf->buffer->use > used + 2 * INPUT_CHUNK)
return; return;
if (used > INPUT_CHUNK) { if (used > INPUT_CHUNK) {
ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN); ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN);
@ -1074,9 +1087,9 @@ xmlParserInputShrink(xmlParserInputPtr in) {
/* /*
* the buffer has been realloced * the buffer has been realloced
*/ */
index = in->cur - in->base; indx = in->cur - in->base;
in->base = in->buf->buffer->content; in->base = in->buf->buffer->content;
in->cur = &in->buf->buffer->content[index]; in->cur = &in->buf->buffer->content[indx];
} }
in->end = &in->buf->buffer->content[in->buf->buffer->use]; in->end = &in->buf->buffer->content[in->buf->buffer->use];
@ -1481,18 +1494,16 @@ encoding_error:
} }
/** /**
* xmlCopyChar: * xmlCopyCharMultiByte:
* @len: pointer to the length of the char read (or zero) * @out: pointer to an arry of xmlChar
* @array: pointer to an arry of xmlChar
* @val: the char value * @val: the char value
* *
* append the char value in the array * append the char value in the array
* *
* Returns the number of xmlChar written * Returns the number of xmlChar written
*/ */
int int
xmlCopyChar(int len, xmlChar *out, int val) { xmlCopyCharMultiByte(xmlChar *out, int val) {
/* /*
* We are supposed to handle UTF8, check it's valid * We are supposed to handle UTF8, check it's valid
* From rfc2044: encoding of the Unicode values on UTF-8: * From rfc2044: encoding of the Unicode values on UTF-8:
@ -1502,34 +1513,45 @@ xmlCopyChar(int len, xmlChar *out, int val) {
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
* 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*/ */
if (len == 0) { if (val >= 0x80) {
if (val < 0) len = 0; xmlChar *savedout = out;
else if (val < 0x80) len = 1; int bits;
else if (val < 0x800) len = 2; if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
else if (val < 0x10000) len = 3; else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
else if (val < 0x110000) len = 4; else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
if (len == 0) { else {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"Internal error, xmlCopyChar 0x%X out of bound\n", "Internal error, xmlCopyChar 0x%X out of bound\n",
val); val);
return(0); return(0);
} }
} for ( ; bits >= 0; bits-= 6)
if (len > 1) { *out++= ((val >> bits) & 0x3F) | 0x80 ;
int bits; return (out - savedout);
if (val < 0x80) { *out++= val; bits= -6; }
else if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6; }
else { *out++= (val >> 18) | 0xF0; bits= 12; }
for ( ; bits >= 0; bits-= 6)
*out++= ((val >> bits) & 0x3F) | 0x80 ;
return(len);
} }
*out = (xmlChar) val; *out = (xmlChar) val;
return(1); return 1;
}
/**
* xmlCopyChar:
* @len: Ignored, compatibility
* @out: pointer to an arry of xmlChar
* @val: the char value
*
* append the char value in the array
*
* Returns the number of xmlChar written
*/
int
xmlCopyChar(int len UNUSED, xmlChar *out, int val) {
/* the len parameter is ignored */
if (val >= 0x80) {
return(xmlCopyCharMultiByte (out, val));
}
*out = (xmlChar) val;
return 1;
} }
/************************************************************************ /************************************************************************
@ -2575,8 +2597,8 @@ xmlCheckLanguageID(const xmlChar *lang) {
* must deallocate it ! * must deallocate it !
*/ */
xmlChar * xmlChar *
xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what, xmlDecodeEntities(xmlParserCtxtPtr ctxt UNUSED, int len UNUSED, int what UNUSED,
xmlChar end, xmlChar end2, xmlChar end3) { xmlChar end UNUSED, xmlChar end2 UNUSED, xmlChar end3 UNUSED) {
#if 0 #if 0
xmlChar *buffer = NULL; xmlChar *buffer = NULL;
unsigned int buffer_size = 0; unsigned int buffer_size = 0;
@ -2709,7 +2731,7 @@ xmlDecodeEntities(xmlParserCtxtPtr ctxt, int len, int what,
*/ */
xmlChar * xmlChar *
xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt) { xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt UNUSED) {
#if 0 #if 0
xmlChar buf[XML_MAX_NAMELEN + 5]; xmlChar buf[XML_MAX_NAMELEN + 5];
int len = 0, l; int len = 0, l;
@ -2778,7 +2800,7 @@ xmlGenericError(xmlGenericErrorContext,
*/ */
xmlChar * xmlChar *
xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, xmlChar **prefix) { xmlNamespaceParseQName(xmlParserCtxtPtr ctxt UNUSED, xmlChar **prefix UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
@ -2820,7 +2842,7 @@ xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, xmlChar **prefix) {
*/ */
xmlChar * xmlChar *
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt) { xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -2855,7 +2877,7 @@ xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt) {
* Returns the string parser or NULL. * Returns the string parser or NULL.
*/ */
xmlChar * xmlChar *
xmlParseQuotedString(xmlParserCtxtPtr ctxt) { xmlParseQuotedString(xmlParserCtxtPtr ctxt UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -2953,7 +2975,7 @@ xmlGenericError(xmlGenericErrorContext,
*/ */
void void
xmlParseNamespace(xmlParserCtxtPtr ctxt) { xmlParseNamespace(xmlParserCtxtPtr ctxt UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -3080,7 +3102,7 @@ xmlGenericError(xmlGenericErrorContext,
*/ */
xmlChar * xmlChar *
xmlScanName(xmlParserCtxtPtr ctxt) { xmlScanName(xmlParserCtxtPtr ctxt UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -3153,7 +3175,7 @@ xmlScanName(xmlParserCtxtPtr ctxt) {
* http://www.w3.org/TR/REC-xml#entproc * http://www.w3.org/TR/REC-xml#entproc
*/ */
void void
xmlParserHandleReference(xmlParserCtxtPtr ctxt) { xmlParserHandleReference(xmlParserCtxtPtr ctxt UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -3399,7 +3421,7 @@ xmlGenericError(xmlGenericErrorContext,
*/ */
void void
xmlHandleEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) { xmlHandleEntity(xmlParserCtxtPtr ctxt UNUSED, xmlEntityPtr entity UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -3452,7 +3474,8 @@ handle_as_char:
* Returns NULL this functionnality had been removed * Returns NULL this functionnality had been removed
*/ */
xmlNsPtr xmlNsPtr
xmlNewGlobalNs(xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix) { xmlNewGlobalNs(xmlDocPtr doc UNUSED, const xmlChar *href UNUSED,
const xmlChar *prefix UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -3513,7 +3536,7 @@ xmlNewGlobalNs(xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix) {
* DEPRECATED * DEPRECATED
*/ */
void void
xmlUpgradeOldNs(xmlDocPtr doc) { xmlUpgradeOldNs(xmlDocPtr doc UNUSED) {
static int deprecated = 0; static int deprecated = 0;
if (!deprecated) { if (!deprecated) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,

View File

@ -14,6 +14,7 @@
#define __XML_PARSER_INTERNALS_H__ #define __XML_PARSER_INTERNALS_H__
#include <libxml/parser.h> #include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -157,6 +158,8 @@ void xmlHandleEntity (xmlParserCtxtPtr ctxt,
/** /**
* Input Streams * Input Streams
*/ */
xmlParserInputPtr xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
const xmlChar *buffer);
xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlParserInputPtr xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
xmlEntityPtr entity); xmlEntityPtr entity);
void xmlPushInput (xmlParserCtxtPtr ctxt, void xmlPushInput (xmlParserCtxtPtr ctxt,
@ -278,6 +281,9 @@ xmlNodePtr nodePop (xmlParserCtxtPtr ctxt);
int inputPush (xmlParserCtxtPtr ctxt, int inputPush (xmlParserCtxtPtr ctxt,
xmlParserInputPtr value); xmlParserInputPtr value);
xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt); xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
xmlChar *namePop (xmlParserCtxtPtr ctxt);
int namePush (xmlParserCtxtPtr ctxt,
xmlChar *value);
/* /*
* other comodities shared between parser.c and parserInternals * other comodities shared between parser.c and parserInternals
@ -288,7 +294,6 @@ int xmlStringCurrentChar (xmlParserCtxtPtr ctxt,
int *len); int *len);
void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); void xmlParserHandlePEReference(xmlParserCtxtPtr ctxt);
void xmlParserHandleReference(xmlParserCtxtPtr ctxt); void xmlParserHandleReference(xmlParserCtxtPtr ctxt);
xmlChar *namePop (xmlParserCtxtPtr ctxt);
int xmlCheckLanguageID (const xmlChar *lang); int xmlCheckLanguageID (const xmlChar *lang);
/* /*
@ -296,6 +301,8 @@ int xmlCheckLanguageID (const xmlChar *lang);
*/ */
int xmlCurrentChar (xmlParserCtxtPtr ctxt, int xmlCurrentChar (xmlParserCtxtPtr ctxt,
int *len); int *len);
int xmlCopyCharMultiByte (xmlChar *out,
int val);
int xmlCopyChar (int len, int xmlCopyChar (int len,
xmlChar *out, xmlChar *out,
int val); int val);
@ -307,6 +314,8 @@ void xmlParserInputShrink (xmlParserInputPtr in);
* Actually comes from the HTML parser but launched from the init stuff * Actually comes from the HTML parser but launched from the init stuff
*/ */
void htmlInitAutoClose (void); void htmlInitAutoClose (void);
htmlParserCtxtPtr htmlCreateFileParserCtxt(const char *filename,
const char *encoding);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -43,6 +43,18 @@
#include <libxml/debugXML.h> #include <libxml/debugXML.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
#ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_DEBUG_ENABLED
static int debug = 0; static int debug = 0;
#endif #endif
@ -79,6 +91,8 @@ xmlSAXHandler emptySAXHandlerStruct = {
NULL, /* xmlParserError */ NULL, /* xmlParserError */
NULL, /* xmlParserError */ NULL, /* xmlParserError */
NULL, /* getParameterEntity */ NULL, /* getParameterEntity */
NULL, /* cdataBlock */
NULL /* externalSubset */
}; };
xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
@ -98,8 +112,8 @@ extern xmlSAXHandlerPtr debugSAXHandler;
* *
* Returns 1 if true * Returns 1 if true
*/ */
int static int
isStandaloneDebug(void *ctx) isStandaloneDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.isStandalone()\n"); fprintf(stdout, "SAX.isStandalone()\n");
return(0); return(0);
@ -113,8 +127,8 @@ isStandaloneDebug(void *ctx)
* *
* Returns 1 if true * Returns 1 if true
*/ */
int static int
hasInternalSubsetDebug(void *ctx) hasInternalSubsetDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.hasInternalSubset()\n"); fprintf(stdout, "SAX.hasInternalSubset()\n");
return(0); return(0);
@ -128,8 +142,8 @@ hasInternalSubsetDebug(void *ctx)
* *
* Returns 1 if true * Returns 1 if true
*/ */
int static int
hasExternalSubsetDebug(void *ctx) hasExternalSubsetDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.hasExternalSubset()\n"); fprintf(stdout, "SAX.hasExternalSubset()\n");
return(0); return(0);
@ -141,8 +155,8 @@ hasExternalSubsetDebug(void *ctx)
* *
* Does this document has an internal subset * Does this document has an internal subset
*/ */
void static void
internalSubsetDebug(void *ctx, const xmlChar *name, internalSubsetDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID) const xmlChar *ExternalID, const xmlChar *SystemID)
{ {
fprintf(stdout, "SAX.internalSubset(%s,", name); fprintf(stdout, "SAX.internalSubset(%s,", name);
@ -170,8 +184,8 @@ internalSubsetDebug(void *ctx, const xmlChar *name,
* *
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/ */
xmlParserInputPtr static xmlParserInputPtr
resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId) resolveEntityDebug(void *ctx UNUSED, const xmlChar *publicId, const xmlChar *systemId)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
@ -202,8 +216,8 @@ resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
* *
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/ */
xmlEntityPtr static xmlEntityPtr
getEntityDebug(void *ctx, const xmlChar *name) getEntityDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.getEntity(%s)\n", name); fprintf(stdout, "SAX.getEntity(%s)\n", name);
return(NULL); return(NULL);
@ -218,8 +232,8 @@ getEntityDebug(void *ctx, const xmlChar *name)
* *
* Returns the xmlParserInputPtr * Returns the xmlParserInputPtr
*/ */
xmlEntityPtr static xmlEntityPtr
getParameterEntityDebug(void *ctx, const xmlChar *name) getParameterEntityDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
return(NULL); return(NULL);
@ -237,8 +251,8 @@ getParameterEntityDebug(void *ctx, const xmlChar *name)
* *
* An entity definition has been parsed * An entity definition has been parsed
*/ */
void static void
entityDeclDebug(void *ctx, const xmlChar *name, int type, entityDeclDebug(void *ctx UNUSED, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
{ {
fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
@ -253,10 +267,10 @@ entityDeclDebug(void *ctx, const xmlChar *name, int type,
* *
* An attribute definition has been parsed * An attribute definition has been parsed
*/ */
void static void
attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name, attributeDeclDebug(void *ctx UNUSED, const xmlChar *elem, const xmlChar *name,
int type, int def, const xmlChar *defaultValue, int type, int def, const xmlChar *defaultValue,
xmlEnumerationPtr tree) xmlEnumerationPtr tree UNUSED)
{ {
fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n", fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
elem, name, type, def, defaultValue); elem, name, type, def, defaultValue);
@ -271,9 +285,9 @@ attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name,
* *
* An element definition has been parsed * An element definition has been parsed
*/ */
void static void
elementDeclDebug(void *ctx, const xmlChar *name, int type, elementDeclDebug(void *ctx UNUSED, const xmlChar *name, int type,
xmlElementContentPtr content) xmlElementContentPtr content UNUSED)
{ {
fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
name, type); name, type);
@ -288,8 +302,8 @@ elementDeclDebug(void *ctx, const xmlChar *name, int type,
* *
* What to do when a notation declaration has been parsed. * What to do when a notation declaration has been parsed.
*/ */
void static void
notationDeclDebug(void *ctx, const xmlChar *name, notationDeclDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId) const xmlChar *publicId, const xmlChar *systemId)
{ {
fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
@ -306,8 +320,8 @@ notationDeclDebug(void *ctx, const xmlChar *name,
* *
* What to do when an unparsed entity declaration is parsed * What to do when an unparsed entity declaration is parsed
*/ */
void static void
unparsedEntityDeclDebug(void *ctx, const xmlChar *name, unparsedEntityDeclDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *notationName) const xmlChar *notationName)
{ {
@ -324,8 +338,8 @@ unparsedEntityDeclDebug(void *ctx, const xmlChar *name,
* Receive the document locator at startup, actually xmlDefaultSAXLocator * Receive the document locator at startup, actually xmlDefaultSAXLocator
* Everything is available on the context, so this is useless in our case. * Everything is available on the context, so this is useless in our case.
*/ */
void static void
setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc) setDocumentLocatorDebug(void *ctx UNUSED, xmlSAXLocatorPtr loc UNUSED)
{ {
fprintf(stdout, "SAX.setDocumentLocator()\n"); fprintf(stdout, "SAX.setDocumentLocator()\n");
} }
@ -336,8 +350,8 @@ setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc)
* *
* called when the document start being processed. * called when the document start being processed.
*/ */
void static void
startDocumentDebug(void *ctx) startDocumentDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.startDocument()\n"); fprintf(stdout, "SAX.startDocument()\n");
} }
@ -348,8 +362,8 @@ startDocumentDebug(void *ctx)
* *
* called when the document end has been detected. * called when the document end has been detected.
*/ */
void static void
endDocumentDebug(void *ctx) endDocumentDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.endDocument()\n"); fprintf(stdout, "SAX.endDocument()\n");
} }
@ -361,8 +375,8 @@ endDocumentDebug(void *ctx)
* *
* called when an opening tag has been processed. * called when an opening tag has been processed.
*/ */
void static void
startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts) startElementDebug(void *ctx UNUSED, const xmlChar *name, const xmlChar **atts)
{ {
int i; int i;
@ -395,8 +409,8 @@ startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts)
* *
* called when the end of an element has been detected. * called when the end of an element has been detected.
*/ */
void static void
endElementDebug(void *ctx, const xmlChar *name) endElementDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
} }
@ -410,8 +424,8 @@ endElementDebug(void *ctx, const xmlChar *name)
* receiving some chars from the parser. * receiving some chars from the parser.
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void static void
charactersDebug(void *ctx, const xmlChar *ch, int len) charactersDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{ {
unsigned char output[40]; unsigned char output[40];
int inlen = len, outlen = 30; int inlen = len, outlen = 30;
@ -431,8 +445,8 @@ charactersDebug(void *ctx, const xmlChar *ch, int len)
* receiving some cdata chars from the parser. * receiving some cdata chars from the parser.
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void static void
cdataDebug(void *ctx, const xmlChar *ch, int len) cdataDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{ {
unsigned char output[40]; unsigned char output[40];
int inlen = len, outlen = 30; int inlen = len, outlen = 30;
@ -450,8 +464,8 @@ cdataDebug(void *ctx, const xmlChar *ch, int len)
* *
* called when an entity reference is detected. * called when an entity reference is detected.
*/ */
void static void
referenceDebug(void *ctx, const xmlChar *name) referenceDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.reference(%s)\n", name); fprintf(stdout, "SAX.reference(%s)\n", name);
} }
@ -466,8 +480,8 @@ referenceDebug(void *ctx, const xmlChar *name)
* receiving some ignorable whitespaces from the parser. * receiving some ignorable whitespaces from the parser.
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void static void
ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len) ignorableWhitespaceDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{ {
char output[40]; char output[40];
int i; int i;
@ -488,8 +502,8 @@ ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len)
* *
* A processing instruction has been parsed. * A processing instruction has been parsed.
*/ */
void static void
processingInstructionDebug(void *ctx, const xmlChar *target, processingInstructionDebug(void *ctx UNUSED, const xmlChar *target,
const xmlChar *data) const xmlChar *data)
{ {
fprintf(stdout, "SAX.processingInstruction(%s, %s)\n", fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
@ -503,8 +517,8 @@ processingInstructionDebug(void *ctx, const xmlChar *target,
* *
* A comment has been parsed. * A comment has been parsed.
*/ */
void static void
commentDebug(void *ctx, const xmlChar *value) commentDebug(void *ctx UNUSED, const xmlChar *value)
{ {
fprintf(stdout, "SAX.comment(%s)\n", value); fprintf(stdout, "SAX.comment(%s)\n", value);
} }
@ -518,8 +532,8 @@ commentDebug(void *ctx, const xmlChar *value)
* Display and format a warning messages, gives file, line, position and * Display and format a warning messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
warningDebug(void *ctx, const char *msg, ...) warningDebug(void *ctx UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -538,8 +552,8 @@ warningDebug(void *ctx, const char *msg, ...)
* Display and format a error messages, gives file, line, position and * Display and format a error messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
errorDebug(void *ctx, const char *msg, ...) errorDebug(void *ctx UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -558,8 +572,8 @@ errorDebug(void *ctx, const char *msg, ...)
* Display and format a fatalError messages, gives file, line, position and * Display and format a fatalError messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
fatalErrorDebug(void *ctx, const char *msg, ...) fatalErrorDebug(void *ctx UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -606,7 +620,8 @@ xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
* * * *
************************************************************************/ ************************************************************************/
void parseSAXFile(char *filename) { static void
parseSAXFile(char *filename) {
htmlDocPtr doc = NULL; htmlDocPtr doc = NULL;
/* /*
@ -687,7 +702,8 @@ void parseSAXFile(char *filename) {
} }
} }
void parseAndPrintFile(char *filename) { static void
parseAndPrintFile(char *filename) {
htmlDocPtr doc = NULL, tmp; htmlDocPtr doc = NULL, tmp;
/* /*

178
testSAX.c
View File

@ -44,6 +44,18 @@
#include <libxml/debugXML.h> #include <libxml/debugXML.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
static int debug = 0; static int debug = 0;
static int copy = 0; static int copy = 0;
static int recovery = 0; static int recovery = 0;
@ -77,6 +89,7 @@ xmlSAXHandler emptySAXHandlerStruct = {
NULL, /* xmlParserError */ NULL, /* xmlParserError */
NULL, /* getParameterEntity */ NULL, /* getParameterEntity */
NULL, /* cdataBlock; */ NULL, /* cdataBlock; */
NULL /* externalSubset; */
}; };
xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct; xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
@ -96,8 +109,8 @@ extern xmlSAXHandlerPtr debugSAXHandler;
* *
* Returns 1 if true * Returns 1 if true
*/ */
int static int
isStandaloneDebug(void *ctx) isStandaloneDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.isStandalone()\n"); fprintf(stdout, "SAX.isStandalone()\n");
return(0); return(0);
@ -111,8 +124,8 @@ isStandaloneDebug(void *ctx)
* *
* Returns 1 if true * Returns 1 if true
*/ */
int static int
hasInternalSubsetDebug(void *ctx) hasInternalSubsetDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.hasInternalSubset()\n"); fprintf(stdout, "SAX.hasInternalSubset()\n");
return(0); return(0);
@ -126,8 +139,8 @@ hasInternalSubsetDebug(void *ctx)
* *
* Returns 1 if true * Returns 1 if true
*/ */
int static int
hasExternalSubsetDebug(void *ctx) hasExternalSubsetDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.hasExternalSubset()\n"); fprintf(stdout, "SAX.hasExternalSubset()\n");
return(0); return(0);
@ -139,8 +152,8 @@ hasExternalSubsetDebug(void *ctx)
* *
* Does this document has an internal subset * Does this document has an internal subset
*/ */
void static void
internalSubsetDebug(void *ctx, const xmlChar *name, internalSubsetDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID) const xmlChar *ExternalID, const xmlChar *SystemID)
{ {
fprintf(stdout, "SAX.internalSubset(%s,", name); fprintf(stdout, "SAX.internalSubset(%s,", name);
@ -154,6 +167,27 @@ internalSubsetDebug(void *ctx, const xmlChar *name,
fprintf(stdout, " %s)\n", SystemID); fprintf(stdout, " %s)\n", SystemID);
} }
/**
* externalSubsetDebug:
* @ctxt: An XML parser context
*
* Does this document has an external subset
*/
static void
externalSubsetDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
fprintf(stdout, "SAX.externalSubset(%s,", name);
if (ExternalID == NULL)
fprintf(stdout, " ,");
else
fprintf(stdout, " %s,", ExternalID);
if (SystemID == NULL)
fprintf(stdout, " )\n");
else
fprintf(stdout, " %s)\n", SystemID);
}
/** /**
* resolveEntityDebug: * resolveEntityDebug:
* @ctxt: An XML parser context * @ctxt: An XML parser context
@ -168,8 +202,8 @@ internalSubsetDebug(void *ctx, const xmlChar *name,
* *
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/ */
xmlParserInputPtr static xmlParserInputPtr
resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId) resolveEntityDebug(void *ctx UNUSED, const xmlChar *publicId, const xmlChar *systemId)
{ {
/* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */ /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
@ -200,8 +234,8 @@ resolveEntityDebug(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
* *
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
*/ */
xmlEntityPtr static xmlEntityPtr
getEntityDebug(void *ctx, const xmlChar *name) getEntityDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.getEntity(%s)\n", name); fprintf(stdout, "SAX.getEntity(%s)\n", name);
return(NULL); return(NULL);
@ -216,8 +250,8 @@ getEntityDebug(void *ctx, const xmlChar *name)
* *
* Returns the xmlParserInputPtr * Returns the xmlParserInputPtr
*/ */
xmlEntityPtr static xmlEntityPtr
getParameterEntityDebug(void *ctx, const xmlChar *name) getParameterEntityDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.getParameterEntity(%s)\n", name); fprintf(stdout, "SAX.getParameterEntity(%s)\n", name);
return(NULL); return(NULL);
@ -235,8 +269,8 @@ getParameterEntityDebug(void *ctx, const xmlChar *name)
* *
* An entity definition has been parsed * An entity definition has been parsed
*/ */
void static void
entityDeclDebug(void *ctx, const xmlChar *name, int type, entityDeclDebug(void *ctx UNUSED, const xmlChar *name, int type,
const xmlChar *publicId, const xmlChar *systemId, xmlChar *content) const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
{ {
fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n", fprintf(stdout, "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
@ -251,10 +285,10 @@ entityDeclDebug(void *ctx, const xmlChar *name, int type,
* *
* An attribute definition has been parsed * An attribute definition has been parsed
*/ */
void static void
attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name, attributeDeclDebug(void *ctx UNUSED, const xmlChar *elem, const xmlChar *name,
int type, int def, const xmlChar *defaultValue, int type, int def, const xmlChar *defaultValue,
xmlEnumerationPtr tree) xmlEnumerationPtr tree UNUSED)
{ {
if (defaultValue == NULL) if (defaultValue == NULL)
fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n", fprintf(stdout, "SAX.attributeDecl(%s, %s, %d, %d, NULL, ...)\n",
@ -273,9 +307,9 @@ attributeDeclDebug(void *ctx, const xmlChar *elem, const xmlChar *name,
* *
* An element definition has been parsed * An element definition has been parsed
*/ */
void static void
elementDeclDebug(void *ctx, const xmlChar *name, int type, elementDeclDebug(void *ctx UNUSED, const xmlChar *name, int type,
xmlElementContentPtr content) xmlElementContentPtr content UNUSED)
{ {
fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n", fprintf(stdout, "SAX.elementDecl(%s, %d, ...)\n",
name, type); name, type);
@ -290,8 +324,8 @@ elementDeclDebug(void *ctx, const xmlChar *name, int type,
* *
* What to do when a notation declaration has been parsed. * What to do when a notation declaration has been parsed.
*/ */
void static void
notationDeclDebug(void *ctx, const xmlChar *name, notationDeclDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId) const xmlChar *publicId, const xmlChar *systemId)
{ {
fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n", fprintf(stdout, "SAX.notationDecl(%s, %s, %s)\n",
@ -308,8 +342,8 @@ notationDeclDebug(void *ctx, const xmlChar *name,
* *
* What to do when an unparsed entity declaration is parsed * What to do when an unparsed entity declaration is parsed
*/ */
void static void
unparsedEntityDeclDebug(void *ctx, const xmlChar *name, unparsedEntityDeclDebug(void *ctx UNUSED, const xmlChar *name,
const xmlChar *publicId, const xmlChar *systemId, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *notationName) const xmlChar *notationName)
{ {
@ -326,8 +360,8 @@ unparsedEntityDeclDebug(void *ctx, const xmlChar *name,
* Receive the document locator at startup, actually xmlDefaultSAXLocator * Receive the document locator at startup, actually xmlDefaultSAXLocator
* Everything is available on the context, so this is useless in our case. * Everything is available on the context, so this is useless in our case.
*/ */
void static void
setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc) setDocumentLocatorDebug(void *ctx UNUSED, xmlSAXLocatorPtr loc UNUSED)
{ {
fprintf(stdout, "SAX.setDocumentLocator()\n"); fprintf(stdout, "SAX.setDocumentLocator()\n");
} }
@ -338,8 +372,8 @@ setDocumentLocatorDebug(void *ctx, xmlSAXLocatorPtr loc)
* *
* called when the document start being processed. * called when the document start being processed.
*/ */
void static void
startDocumentDebug(void *ctx) startDocumentDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.startDocument()\n"); fprintf(stdout, "SAX.startDocument()\n");
} }
@ -350,8 +384,8 @@ startDocumentDebug(void *ctx)
* *
* called when the document end has been detected. * called when the document end has been detected.
*/ */
void static void
endDocumentDebug(void *ctx) endDocumentDebug(void *ctx UNUSED)
{ {
fprintf(stdout, "SAX.endDocument()\n"); fprintf(stdout, "SAX.endDocument()\n");
} }
@ -363,8 +397,8 @@ endDocumentDebug(void *ctx)
* *
* called when an opening tag has been processed. * called when an opening tag has been processed.
*/ */
void static void
startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts) startElementDebug(void *ctx UNUSED, const xmlChar *name, const xmlChar **atts)
{ {
int i; int i;
@ -386,8 +420,8 @@ startElementDebug(void *ctx, const xmlChar *name, const xmlChar **atts)
* *
* called when the end of an element has been detected. * called when the end of an element has been detected.
*/ */
void static void
endElementDebug(void *ctx, const xmlChar *name) endElementDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.endElement(%s)\n", (char *) name); fprintf(stdout, "SAX.endElement(%s)\n", (char *) name);
} }
@ -401,8 +435,8 @@ endElementDebug(void *ctx, const xmlChar *name)
* receiving some chars from the parser. * receiving some chars from the parser.
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void static void
charactersDebug(void *ctx, const xmlChar *ch, int len) charactersDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{ {
char output[40]; char output[40];
int i; int i;
@ -421,8 +455,8 @@ charactersDebug(void *ctx, const xmlChar *ch, int len)
* *
* called when an entity reference is detected. * called when an entity reference is detected.
*/ */
void static void
referenceDebug(void *ctx, const xmlChar *name) referenceDebug(void *ctx UNUSED, const xmlChar *name)
{ {
fprintf(stdout, "SAX.reference(%s)\n", name); fprintf(stdout, "SAX.reference(%s)\n", name);
} }
@ -437,8 +471,8 @@ referenceDebug(void *ctx, const xmlChar *name)
* receiving some ignorable whitespaces from the parser. * receiving some ignorable whitespaces from the parser.
* Question: how much at a time ??? * Question: how much at a time ???
*/ */
void static void
ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len) ignorableWhitespaceDebug(void *ctx UNUSED, const xmlChar *ch, int len)
{ {
char output[40]; char output[40];
int i; int i;
@ -458,8 +492,8 @@ ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len)
* *
* A processing instruction has been parsed. * A processing instruction has been parsed.
*/ */
void static void
processingInstructionDebug(void *ctx, const xmlChar *target, processingInstructionDebug(void *ctx UNUSED, const xmlChar *target,
const xmlChar *data) const xmlChar *data)
{ {
fprintf(stdout, "SAX.processingInstruction(%s, %s)\n", fprintf(stdout, "SAX.processingInstruction(%s, %s)\n",
@ -474,8 +508,8 @@ processingInstructionDebug(void *ctx, const xmlChar *target,
* *
* called when a pcdata block has been parsed * called when a pcdata block has been parsed
*/ */
void static void
cdataBlockDebug(void *ctx, const xmlChar *value, int len) cdataBlockDebug(void *ctx UNUSED, const xmlChar *value, int len)
{ {
fprintf(stdout, "SAX.pcdata(%.20s, %d)\n", fprintf(stdout, "SAX.pcdata(%.20s, %d)\n",
(char *) value, len); (char *) value, len);
@ -488,8 +522,8 @@ cdataBlockDebug(void *ctx, const xmlChar *value, int len)
* *
* A comment has been parsed. * A comment has been parsed.
*/ */
void static void
commentDebug(void *ctx, const xmlChar *value) commentDebug(void *ctx UNUSED, const xmlChar *value)
{ {
fprintf(stdout, "SAX.comment(%s)\n", value); fprintf(stdout, "SAX.comment(%s)\n", value);
} }
@ -503,8 +537,8 @@ commentDebug(void *ctx, const xmlChar *value)
* Display and format a warning messages, gives file, line, position and * Display and format a warning messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
warningDebug(void *ctx, const char *msg, ...) warningDebug(void *ctx UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -523,8 +557,8 @@ warningDebug(void *ctx, const char *msg, ...)
* Display and format a error messages, gives file, line, position and * Display and format a error messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
errorDebug(void *ctx, const char *msg, ...) errorDebug(void *ctx UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -543,8 +577,8 @@ errorDebug(void *ctx, const char *msg, ...)
* Display and format a fatalError messages, gives file, line, position and * Display and format a fatalError messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
fatalErrorDebug(void *ctx, const char *msg, ...) fatalErrorDebug(void *ctx UNUSED, const char *msg, ...)
{ {
va_list args; va_list args;
@ -580,7 +614,8 @@ xmlSAXHandler debugSAXHandlerStruct = {
errorDebug, errorDebug,
fatalErrorDebug, fatalErrorDebug,
getParameterEntityDebug, getParameterEntityDebug,
cdataBlockDebug cdataBlockDebug,
externalSubsetDebug
}; };
xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct; xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
@ -591,7 +626,8 @@ xmlSAXHandlerPtr debugSAXHandler = &debugSAXHandlerStruct;
* * * *
************************************************************************/ ************************************************************************/
void parseAndPrintFile(char *filename) { static void
parseAndPrintFile(char *filename) {
int res; int res;
if (push) { if (push) {
@ -602,16 +638,16 @@ void parseAndPrintFile(char *filename) {
*/ */
f = fopen(filename, "r"); f = fopen(filename, "r");
if (f != NULL) { if (f != NULL) {
int res; int ret;
char chars[10]; char chars[10];
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
res = fread(chars, 1, 4, f); ret = fread(chars, 1, 4, f);
if (res > 0) { if (ret > 0) {
ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL, ctxt = xmlCreatePushParserCtxt(emptySAXHandler, NULL,
chars, res, filename); chars, ret, filename);
while ((res = fread(chars, 1, 3, f)) > 0) { while ((ret = fread(chars, 1, 3, f)) > 0) {
xmlParseChunk(ctxt, chars, res, 0); xmlParseChunk(ctxt, chars, ret, 0);
} }
xmlParseChunk(ctxt, chars, 0, 1); xmlParseChunk(ctxt, chars, 0, 1);
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
@ -626,22 +662,22 @@ void parseAndPrintFile(char *filename) {
*/ */
f = fopen(filename, "r"); f = fopen(filename, "r");
if (f != NULL) { if (f != NULL) {
int res; int ret;
char chars[10]; char chars[10];
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
res = fread(chars, 1, 4, f); ret = fread(chars, 1, 4, f);
if (res > 0) { if (ret > 0) {
ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL, ctxt = xmlCreatePushParserCtxt(debugSAXHandler, NULL,
chars, res, filename); chars, ret, filename);
while ((res = fread(chars, 1, 3, f)) > 0) { while ((ret = fread(chars, 1, 3, f)) > 0) {
xmlParseChunk(ctxt, chars, res, 0); xmlParseChunk(ctxt, chars, ret, 0);
} }
res = xmlParseChunk(ctxt, chars, 0, 1); ret = xmlParseChunk(ctxt, chars, 0, 1);
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
if (res != 0) { if (ret != 0) {
fprintf(stdout, fprintf(stdout,
"xmlSAXUserParseFile returned error %d\n", res); "xmlSAXUserParseFile returned error %d\n", ret);
} }
} }
fclose(f); fclose(f);

View File

@ -27,7 +27,7 @@ int main(int argc, char **argv) {
const char *base = NULL; const char *base = NULL;
xmlChar *composite; xmlChar *composite;
if ((argv[arg] != NULL) && if ((argc > 1) && (argv[arg] != NULL) &&
((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) { ((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
arg++; arg++;
base = argv[arg]; base = argv[arg];

View File

@ -87,7 +87,8 @@ static xmlChar buffer[] =
"; ";
void testXPath(const char *str) { static void
testXPath(const char *str) {
xmlXPathObjectPtr res; xmlXPathObjectPtr res;
xmlXPathContextPtr ctxt; xmlXPathContextPtr ctxt;
@ -111,9 +112,10 @@ void testXPath(const char *str) {
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
} }
void testXPathFile(const char *filename) { static void
testXPathFile(const char *filename) {
FILE *input; FILE *input;
char expr[5000]; char expression[5000];
int len; int len;
input = fopen(filename, "r"); input = fopen(filename, "r");
@ -122,16 +124,16 @@ void testXPathFile(const char *filename) {
"Cannot open %s for reading\n", filename); "Cannot open %s for reading\n", filename);
return; return;
} }
while (fgets(expr, 4500, input) != NULL) { while (fgets(expression, 4500, input) != NULL) {
len = strlen(expr); len = strlen(expression);
len--; len--;
while ((len >= 0) && while ((len >= 0) &&
((expr[len] == '\n') || (expr[len] == '\t') || ((expression[len] == '\n') || (expression[len] == '\t') ||
(expr[len] == '\r') || (expr[len] == ' '))) len--; (expression[len] == '\r') || (expression[len] == ' '))) len--;
expr[len + 1] = 0; expression[len + 1] = 0;
if (len >= 0) { if (len >= 0) {
printf("\n========================\nExpression: %s\n", expr) ; printf("\n========================\nExpression: %s\n", expression) ;
testXPath(expr); testXPath(expression);
} }
} }

58
tree.c
View File

@ -37,6 +37,26 @@
#include <libxml/valid.h> #include <libxml/valid.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
/************************************************************************
* *
* A few static variables and macros *
* *
************************************************************************/
xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 };
xmlChar xmlStringTextNoenc[] = xmlChar xmlStringTextNoenc[] =
{ 't', 'e', 'x', 't', 'n', 'o', 'e', 'n', 'c', 0 }; { 't', 'e', 'x', 't', 'n', 'o', 'e', 'n', 'c', 0 };
@ -99,7 +119,7 @@ xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
* Returns the current allocation scheme * Returns the current allocation scheme
*/ */
xmlBufferAllocationScheme xmlBufferAllocationScheme
xmlGetBufferAllocationScheme() { xmlGetBufferAllocationScheme(void) {
return xmlBufferAllocScheme; return xmlBufferAllocScheme;
} }
@ -1686,6 +1706,7 @@ xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len) {
} }
memset(cur, 0, sizeof(xmlNode)); memset(cur, 0, sizeof(xmlNode));
cur->type = XML_CDATA_SECTION_NODE; cur->type = XML_CDATA_SECTION_NODE;
cur->doc = doc;
if (content != NULL) { if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT #ifndef XML_USE_BUFFER_CONTENT
@ -3079,34 +3100,6 @@ xmlNodeSetBase(xmlNodePtr cur, xmlChar* uri) {
xmlSetProp(cur, BAD_CAST "xml:base", uri); xmlSetProp(cur, BAD_CAST "xml:base", uri);
} }
/**
* xmlDocumentGetBase:
* @doc: the document
*
* Searches for the Document BASE URL. The code should work on both XML
* and HTML document.
* It returns the base as defined in RFC 2396 section
* 5.1.3. Base URI from the Retrieval URI
* However it does not return the computed base (5.1.1 and 5.1.2), use
* xmlNodeGetBase() for this
*
* Returns a pointer to the base URL, or NULL if not found
* It's up to the caller to free the memory.
*/
xmlChar *
xmlDocumentGetBase(xmlDocPtr doc) {
if (doc == NULL)
return(NULL);
if (doc->type == XML_HTML_DOCUMENT_NODE) {
if (doc->URL != NULL)
return(xmlStrdup(doc->URL));
return(NULL);
}
if (doc->URL != NULL)
return(xmlStrdup(doc->URL));
return(NULL);
}
/** /**
* xmlNodeGetBase: * xmlNodeGetBase:
* @doc: the document the node pertains to * @doc: the document the node pertains to
@ -3627,7 +3620,7 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
* namespace if defined * namespace if defined
*/ */
xmlNsPtr * xmlNsPtr *
xmlGetNsList(xmlDocPtr doc, xmlNodePtr node) { xmlGetNsList(xmlDocPtr doc UNUSED, xmlNodePtr node) {
xmlNsPtr cur; xmlNsPtr cur;
xmlNsPtr *ret = NULL; xmlNsPtr *ret = NULL;
int nbns = 0; int nbns = 0;
@ -5448,7 +5441,7 @@ xmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDtdPtr dtd, const char *encoding) {
*/ */
static void static void
xmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, xmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
const char *encoding) { const char *encoding UNUSED) {
xmlChar *value; xmlChar *value;
if (cur == NULL) { if (cur == NULL) {
@ -5804,7 +5797,8 @@ xmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
void void
xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr, xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
int * doc_txt_len, const char * txt_encoding, int format) { int * doc_txt_len, const char * txt_encoding,
int format UNUSED) {
int dummy = 0; int dummy = 0;
xmlCharEncoding doc_charset; xmlCharEncoding doc_charset;

6
tree.h
View File

@ -394,8 +394,13 @@ LIBXML_DLL_IMPORT extern int xmlDefaultBufferSize; /* default buffer size */
* Handling Buffers. * Handling Buffers.
*/ */
void xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
xmlBufferAllocationScheme xmlGetBufferAllocationScheme(void);
xmlBufferPtr xmlBufferCreate (void); xmlBufferPtr xmlBufferCreate (void);
xmlBufferPtr xmlBufferCreateSize (size_t size); xmlBufferPtr xmlBufferCreateSize (size_t size);
int xmlBufferResize (xmlBufferPtr buf,
unsigned int size);
void xmlBufferFree (xmlBufferPtr buf); void xmlBufferFree (xmlBufferPtr buf);
int xmlBufferDump (FILE *file, int xmlBufferDump (FILE *file,
xmlBufferPtr buf); xmlBufferPtr buf);
@ -440,6 +445,7 @@ xmlNsPtr xmlNewNs (xmlNodePtr node,
const xmlChar *href, const xmlChar *href,
const xmlChar *prefix); const xmlChar *prefix);
void xmlFreeNs (xmlNsPtr cur); void xmlFreeNs (xmlNsPtr cur);
void xmlFreeNsList (xmlNsPtr cur);
xmlDocPtr xmlNewDoc (const xmlChar *version); xmlDocPtr xmlNewDoc (const xmlChar *version);
void xmlFreeDoc (xmlDocPtr cur); void xmlFreeDoc (xmlDocPtr cur);
xmlAttrPtr xmlNewDocProp (xmlDocPtr doc, xmlAttrPtr xmlNewDocProp (xmlDocPtr doc,

32
uri.c
View File

@ -556,7 +556,7 @@ xmlPrintURI(FILE *stream, xmlURIPtr uri) {
* *
* Make sure the xmlURI struct is free of content * Make sure the xmlURI struct is free of content
*/ */
void static void
xmlCleanURI(xmlURIPtr uri) { xmlCleanURI(xmlURIPtr uri) {
if (uri == NULL) return; if (uri == NULL) return;
@ -1064,7 +1064,7 @@ xmlURIEscape(const xmlChar *str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIFragment(xmlURIPtr uri, const char **str) { xmlParseURIFragment(xmlURIPtr uri, const char **str) {
const char *cur = *str; const char *cur = *str;
@ -1090,7 +1090,7 @@ xmlParseURIFragment(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIQuery(xmlURIPtr uri, const char **str) { xmlParseURIQuery(xmlURIPtr uri, const char **str) {
const char *cur = *str; const char *cur = *str;
@ -1116,7 +1116,7 @@ xmlParseURIQuery(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIScheme(xmlURIPtr uri, const char **str) { xmlParseURIScheme(xmlURIPtr uri, const char **str) {
const char *cur; const char *cur;
@ -1148,7 +1148,7 @@ xmlParseURIScheme(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIOpaquePart(xmlURIPtr uri, const char **str) { xmlParseURIOpaquePart(xmlURIPtr uri, const char **str) {
const char *cur; const char *cur;
@ -1190,7 +1190,7 @@ xmlParseURIOpaquePart(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIServer(xmlURIPtr uri, const char **str) { xmlParseURIServer(xmlURIPtr uri, const char **str) {
const char *cur; const char *cur;
const char *host, *tmp; const char *host, *tmp;
@ -1324,7 +1324,7 @@ host_done:
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIRelSegment(xmlURIPtr uri, const char **str) { xmlParseURIRelSegment(xmlURIPtr uri, const char **str) {
const char *cur; const char *cur;
@ -1359,7 +1359,7 @@ xmlParseURIRelSegment(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) { xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) {
const char *cur; const char *cur;
@ -1439,7 +1439,7 @@ xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIAuthority(xmlURIPtr uri, const char **str) { xmlParseURIAuthority(xmlURIPtr uri, const char **str) {
const char *cur; const char *cur;
int ret; int ret;
@ -1489,7 +1489,7 @@ xmlParseURIAuthority(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseURIHierPart(xmlURIPtr uri, const char **str) { xmlParseURIHierPart(xmlURIPtr uri, const char **str) {
int ret; int ret;
const char *cur; const char *cur;
@ -1538,7 +1538,7 @@ xmlParseURIHierPart(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseAbsoluteURI(xmlURIPtr uri, const char **str) { xmlParseAbsoluteURI(xmlURIPtr uri, const char **str) {
int ret; int ret;
@ -1570,7 +1570,7 @@ xmlParseAbsoluteURI(xmlURIPtr uri, const char **str) {
* *
* Returns 0 or the error code * Returns 0 or the error code
*/ */
int static int
xmlParseRelativeURI(xmlURIPtr uri, const char **str) { xmlParseRelativeURI(xmlURIPtr uri, const char **str) {
int ret = 0; int ret = 0;
const char *cur; const char *cur;
@ -1712,7 +1712,7 @@ xmlParseURI(const char *str) {
xmlChar * xmlChar *
xmlBuildURI(const xmlChar *URI, const xmlChar *base) { xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
xmlChar *val = NULL; xmlChar *val = NULL;
int ret, len, index, cur, out; int ret, len, indx, cur, out;
xmlURIPtr ref = NULL; xmlURIPtr ref = NULL;
xmlURIPtr bas = NULL; xmlURIPtr bas = NULL;
xmlURIPtr res = NULL; xmlURIPtr res = NULL;
@ -1908,14 +1908,14 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
* string. * string.
*/ */
if (ref->path != NULL && ref->path[0] != 0) { if (ref->path != NULL && ref->path[0] != 0) {
index = 0; indx = 0;
/* /*
* Ensure the path includes a '/' * Ensure the path includes a '/'
*/ */
if ((out == 0) && (bas->server != NULL)) if ((out == 0) && (bas->server != NULL))
res->path[out++] = '/'; res->path[out++] = '/';
while (ref->path[index] != 0) { while (ref->path[indx] != 0) {
res->path[out++] = ref->path[index++]; res->path[out++] = ref->path[indx++];
} }
} }
res->path[out] = 0; res->path[out] = 0;

83
valid.c
View File

@ -28,6 +28,18 @@
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
#include <libxml/list.h> #include <libxml/list.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/* /*
* Generic function for accessing stacks in the Validity Context * Generic function for accessing stacks in the Validity Context
*/ */
@ -333,7 +345,7 @@ xmlFreeElementContent(xmlElementContentPtr cur) {
* *
* This will dump the content of the element table as an XML DTD definition * This will dump the content of the element table as an XML DTD definition
*/ */
void static void
xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob) { xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob) {
if (content == NULL) return; if (content == NULL) return;
@ -466,7 +478,7 @@ xmlSprintfElementContent(char *buf, xmlElementContentPtr content, int glob) {
* *
* Returns the xmlElementTablePtr just created or NULL in case of error. * Returns the xmlElementTablePtr just created or NULL in case of error.
*/ */
xmlElementTablePtr static xmlElementTablePtr
xmlCreateElementTable(void) { xmlCreateElementTable(void) {
return(xmlHashCreate(0)); return(xmlHashCreate(0));
} }
@ -477,7 +489,7 @@ xmlCreateElementTable(void) {
* *
* Deallocate the memory used by an element definition * Deallocate the memory used by an element definition
*/ */
void static void
xmlFreeElement(xmlElementPtr elem) { xmlFreeElement(xmlElementPtr elem) {
if (elem == NULL) return; if (elem == NULL) return;
xmlUnlinkNode((xmlNodePtr) elem); xmlUnlinkNode((xmlNodePtr) elem);
@ -646,7 +658,7 @@ xmlFreeElementTable(xmlElementTablePtr table) {
* *
* Returns the new xmlElementPtr or NULL in case of error. * Returns the new xmlElementPtr or NULL in case of error.
*/ */
xmlElementPtr static xmlElementPtr
xmlCopyElement(xmlElementPtr elem) { xmlCopyElement(xmlElementPtr elem) {
xmlElementPtr cur; xmlElementPtr cur;
@ -814,7 +826,7 @@ xmlCopyEnumeration(xmlEnumerationPtr cur) {
* *
* This will dump the content of the enumeration * This will dump the content of the enumeration
*/ */
void static void
xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) { xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
if (cur == NULL) return; if (cur == NULL) return;
@ -835,7 +847,7 @@ xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
* Returns the xmlAttributeTablePtr just created or NULL in case * Returns the xmlAttributeTablePtr just created or NULL in case
* of error. * of error.
*/ */
xmlAttributeTablePtr static xmlAttributeTablePtr
xmlCreateAttributeTable(void) { xmlCreateAttributeTable(void) {
return(xmlHashCreate(0)); return(xmlHashCreate(0));
} }
@ -848,9 +860,9 @@ xmlCreateAttributeTable(void) {
* Callback called by xmlScanAttributeDecl when a new attribute * Callback called by xmlScanAttributeDecl when a new attribute
* has to be entered in the list. * has to be entered in the list.
*/ */
void static void
xmlScanAttributeDeclCallback(xmlAttributePtr attr, xmlAttributePtr *list, xmlScanAttributeDeclCallback(xmlAttributePtr attr, xmlAttributePtr *list,
const xmlChar* name) { const xmlChar* name UNUSED) {
attr->nexth = *list; attr->nexth = *list;
*list = attr; *list = attr;
} }
@ -901,7 +913,7 @@ xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
* *
* Returns the number of ID attributes found. * Returns the number of ID attributes found.
*/ */
int static int
xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem) { xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
xmlAttributePtr cur; xmlAttributePtr cur;
int ret = 0; int ret = 0;
@ -927,7 +939,7 @@ xmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
* *
* Deallocate the memory used by an attribute definition * Deallocate the memory used by an attribute definition
*/ */
void static void
xmlFreeAttribute(xmlAttributePtr attr) { xmlFreeAttribute(xmlAttributePtr attr) {
if (attr == NULL) return; if (attr == NULL) return;
xmlUnlinkNode((xmlNodePtr) attr); xmlUnlinkNode((xmlNodePtr) attr);
@ -1127,7 +1139,7 @@ xmlFreeAttributeTable(xmlAttributeTablePtr table) {
* *
* Returns the new xmlAttributePtr or NULL in case of error. * Returns the new xmlAttributePtr or NULL in case of error.
*/ */
xmlAttributePtr static xmlAttributePtr
xmlCopyAttribute(xmlAttributePtr attr) { xmlCopyAttribute(xmlAttributePtr attr) {
xmlAttributePtr cur; xmlAttributePtr cur;
@ -1269,7 +1281,7 @@ xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table) {
* Returns the xmlNotationTablePtr just created or NULL in case * Returns the xmlNotationTablePtr just created or NULL in case
* of error. * of error.
*/ */
xmlNotationTablePtr static xmlNotationTablePtr
xmlCreateNotationTable(void) { xmlCreateNotationTable(void) {
return(xmlHashCreate(0)); return(xmlHashCreate(0));
} }
@ -1280,7 +1292,7 @@ xmlCreateNotationTable(void) {
* *
* Deallocate the memory used by an notation definition * Deallocate the memory used by an notation definition
*/ */
void static void
xmlFreeNotation(xmlNotationPtr nota) { xmlFreeNotation(xmlNotationPtr nota) {
if (nota == NULL) return; if (nota == NULL) return;
if (nota->name != NULL) if (nota->name != NULL)
@ -1307,7 +1319,8 @@ xmlFreeNotation(xmlNotationPtr nota) {
* Returns NULL if not, othervise the entity * Returns NULL if not, othervise the entity
*/ */
xmlNotationPtr xmlNotationPtr
xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlAddNotationDecl(xmlValidCtxtPtr ctxt UNUSED, xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *PublicID, const xmlChar *SystemID) { const xmlChar *PublicID, const xmlChar *SystemID) {
xmlNotationPtr ret; xmlNotationPtr ret;
xmlNotationTablePtr table; xmlNotationTablePtr table;
@ -1388,7 +1401,7 @@ xmlFreeNotationTable(xmlNotationTablePtr table) {
* *
* Returns the new xmlNotationPtr or NULL in case of error. * Returns the new xmlNotationPtr or NULL in case of error.
*/ */
xmlNotationPtr static xmlNotationPtr
xmlCopyNotation(xmlNotationPtr nota) { xmlCopyNotation(xmlNotationPtr nota) {
xmlNotationPtr cur; xmlNotationPtr cur;
@ -1477,7 +1490,7 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
* Returns the xmlIDTablePtr just created or NULL in case * Returns the xmlIDTablePtr just created or NULL in case
* of error. * of error.
*/ */
xmlIDTablePtr static xmlIDTablePtr
xmlCreateIDTable(void) { xmlCreateIDTable(void) {
return(xmlHashCreate(0)); return(xmlHashCreate(0));
} }
@ -1488,7 +1501,7 @@ xmlCreateIDTable(void) {
* *
* Deallocate the memory used by an id definition * Deallocate the memory used by an id definition
*/ */
void static void
xmlFreeID(xmlIDPtr id) { xmlFreeID(xmlIDPtr id) {
if (id == NULL) return; if (id == NULL) return;
if (id->value != NULL) if (id->value != NULL)
@ -1714,7 +1727,7 @@ typedef xmlValidateMemo *xmlValidateMemoPtr;
* Returns the xmlRefTablePtr just created or NULL in case * Returns the xmlRefTablePtr just created or NULL in case
* of error. * of error.
*/ */
xmlRefTablePtr static xmlRefTablePtr
xmlCreateRefTable(void) { xmlCreateRefTable(void) {
return(xmlHashCreate(0)); return(xmlHashCreate(0));
} }
@ -1780,7 +1793,7 @@ xmlWalkRemoveRef(const void *data, const void *user)
* Returns NULL if not, othervise the new xmlRefPtr * Returns NULL if not, othervise the new xmlRefPtr
*/ */
xmlRefPtr xmlRefPtr
xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAddRef(xmlValidCtxtPtr ctxt UNUSED, xmlDocPtr doc, const xmlChar *value,
xmlAttrPtr attr) { xmlAttrPtr attr) {
xmlRefPtr ret; xmlRefPtr ret;
xmlRefTablePtr table; xmlRefTablePtr table;
@ -2029,7 +2042,7 @@ xmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name) {
* returns the xmlElementPtr if found or NULL * returns the xmlElementPtr if found or NULL
*/ */
xmlElementPtr static xmlElementPtr
xmlGetDtdQElementDesc(xmlDtdPtr dtd, const xmlChar *name, xmlGetDtdQElementDesc(xmlDtdPtr dtd, const xmlChar *name,
const xmlChar *prefix) { const xmlChar *prefix) {
xmlElementTablePtr table; xmlElementTablePtr table;
@ -2090,7 +2103,7 @@ xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name) {
* returns the xmlAttributePtr if found or NULL * returns the xmlAttributePtr if found or NULL
*/ */
xmlAttributePtr static xmlAttributePtr
xmlGetDtdQAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, xmlGetDtdQAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name,
const xmlChar *prefix) { const xmlChar *prefix) {
xmlAttributeTablePtr table; xmlAttributeTablePtr table;
@ -2198,7 +2211,7 @@ xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) {
* returns 1 if valid or 0 otherwise * returns 1 if valid or 0 otherwise
*/ */
int static int
xmlValidateNameValue(const xmlChar *value) { xmlValidateNameValue(const xmlChar *value) {
const xmlChar *cur; const xmlChar *cur;
@ -2231,7 +2244,7 @@ xmlValidateNameValue(const xmlChar *value) {
* returns 1 if valid or 0 otherwise * returns 1 if valid or 0 otherwise
*/ */
int static int
xmlValidateNamesValue(const xmlChar *value) { xmlValidateNamesValue(const xmlChar *value) {
const xmlChar *cur; const xmlChar *cur;
@ -2282,7 +2295,7 @@ xmlValidateNamesValue(const xmlChar *value) {
* returns 1 if valid or 0 otherwise * returns 1 if valid or 0 otherwise
*/ */
int static int
xmlValidateNmtokenValue(const xmlChar *value) { xmlValidateNmtokenValue(const xmlChar *value) {
const xmlChar *cur; const xmlChar *cur;
@ -2319,7 +2332,7 @@ xmlValidateNmtokenValue(const xmlChar *value) {
* returns 1 if valid or 0 otherwise * returns 1 if valid or 0 otherwise
*/ */
int static int
xmlValidateNmtokensValue(const xmlChar *value) { xmlValidateNmtokensValue(const xmlChar *value) {
const xmlChar *cur; const xmlChar *cur;
@ -2381,8 +2394,8 @@ xmlValidateNmtokensValue(const xmlChar *value) {
*/ */
int int
xmlValidateNotationDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlValidateNotationDecl(xmlValidCtxtPtr ctxt UNUSED, xmlDocPtr doc UNUSED,
xmlNotationPtr nota) { xmlNotationPtr nota UNUSED) {
int ret = 1; int ret = 1;
return(ret); return(ret);
@ -2464,7 +2477,7 @@ xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) {
* returns 1 if valid or 0 otherwise * returns 1 if valid or 0 otherwise
*/ */
int static int
xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
const xmlChar *name, xmlAttributeType type, const xmlChar *value) { const xmlChar *name, xmlAttributeType type, const xmlChar *value) {
int ret = 1; int ret = 1;
@ -2618,9 +2631,9 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
return(ret); return(ret);
} }
void static void
xmlValidateAttributeIdCallback(xmlAttributePtr attr, int *count, xmlValidateAttributeIdCallback(xmlAttributePtr attr, int *count,
const xmlChar* name) { const xmlChar* name UNUSED) {
if (attr->atype == XML_ATTRIBUTE_ID) (*count)++; if (attr->atype == XML_ATTRIBUTE_ID) (*count)++;
} }
@ -3066,7 +3079,7 @@ int xmlValidateElementTypeElement(xmlValidCtxtPtr ctxt, xmlNodePtr *child,
* also update child value in-situ. * also update child value in-situ.
*/ */
int static int
xmlValidateElementTypeExpr(xmlValidCtxtPtr ctxt, xmlNodePtr *child, xmlValidateElementTypeExpr(xmlValidCtxtPtr ctxt, xmlNodePtr *child,
xmlElementContentPtr cont) { xmlElementContentPtr cont) {
xmlNodePtr cur; xmlNodePtr cur;
@ -3262,7 +3275,7 @@ xmlValidateElementTypeElement(xmlValidCtxtPtr ctxt, xmlNodePtr *child,
* This will dump the list of childs to the buffer * This will dump the list of childs to the buffer
* Intended just for the debug routine * Intended just for the debug routine
*/ */
void static void
xmlSprintfElementChilds(char *buf, xmlNodePtr node, int glob) { xmlSprintfElementChilds(char *buf, xmlNodePtr node, int glob) {
xmlNodePtr cur; xmlNodePtr cur;
@ -3728,7 +3741,7 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
* @name: Name of ID we are searching for * @name: Name of ID we are searching for
* *
*/ */
void static void
xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt, xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
const xmlChar *name) { const xmlChar *name) {
xmlAttrPtr id; xmlAttrPtr id;
@ -3896,9 +3909,9 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
return(ret); return(ret);
} }
void static void
xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt, xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
const xmlChar *name) { const xmlChar *name UNUSED) {
if (cur == NULL) if (cur == NULL)
return; return;
switch (cur->atype) { switch (cur->atype) {

View File

@ -11,6 +11,7 @@
#define __XML_VALID_H__ #define __XML_VALID_H__
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/list.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -167,6 +168,8 @@ int xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem, xmlNodePtr elem,
xmlAttrPtr attr); xmlAttrPtr attr);
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr); int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
xmlListPtr xmlGetRefs (xmlDocPtr doc,
const xmlChar *ID);
/** /**
* The public function calls related to validity checking * The public function calls related to validity checking

View File

@ -79,7 +79,7 @@ struct _xmlXIncludeCtxt {
* *
* Add a new node to process to an XInclude context * Add a new node to process to an XInclude context
*/ */
void static void
xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
if (ctxt->incMax == 0) { if (ctxt->incMax == 0) {
ctxt->incMax = 4; ctxt->incMax = 4;
@ -128,7 +128,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
* *
* Add a new document to the list * Add a new document to the list
*/ */
void static void
xmlXIncludeAddDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const xmlURL url) { xmlXIncludeAddDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const xmlURL url) {
if (ctxt->docMax == 0) { if (ctxt->docMax == 0) {
ctxt->docMax = 4; ctxt->docMax = 4;
@ -177,7 +177,7 @@ xmlXIncludeAddDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, const xmlURL url) {
* *
* Add a new txtument to the list * Add a new txtument to the list
*/ */
void static void
xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) { xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
if (ctxt->txtMax == 0) { if (ctxt->txtMax == 0) {
ctxt->txtMax = 4; ctxt->txtMax = 4;
@ -226,7 +226,7 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
* *
* Returns the new set * Returns the new set
*/ */
xmlXIncludeCtxtPtr static xmlXIncludeCtxtPtr
xmlXIncludeNewContext(xmlDocPtr doc) { xmlXIncludeNewContext(xmlDocPtr doc) {
xmlXIncludeCtxtPtr ret; xmlXIncludeCtxtPtr ret;
@ -254,7 +254,7 @@ xmlXIncludeNewContext(xmlDocPtr doc) {
* *
* Free an XInclude context * Free an XInclude context
*/ */
void static void
xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) { xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
int i; int i;
@ -299,7 +299,7 @@ xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
* *
* Load the document, and store the result in the XInclude context * Load the document, and store the result in the XInclude context
*/ */
void static void
xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlDocPtr doc; xmlDocPtr doc;
xmlURIPtr uri; xmlURIPtr uri;
@ -417,7 +417,7 @@ loaded:
* *
* Load the content, and store the result in the XInclude context * Load the content, and store the result in the XInclude context
*/ */
void static void
xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlParserInputBufferPtr buf; xmlParserInputBufferPtr buf;
xmlNodePtr node; xmlNodePtr node;
@ -529,7 +529,7 @@ loaded:
* *
* Returns the result list or NULL in case of error * Returns the result list or NULL in case of error
*/ */
xmlNodePtr static xmlNodePtr
xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) { xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
xmlXIncludeAddNode(ctxt, node); xmlXIncludeAddNode(ctxt, node);
return(0); return(0);
@ -544,7 +544,7 @@ xmlXIncludePreProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
* *
* Returns 0 if substition succeeded, -1 if some processing failed * Returns 0 if substition succeeded, -1 if some processing failed
*/ */
int static int
xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) { xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlNodePtr cur; xmlNodePtr cur;
xmlChar *href; xmlChar *href;
@ -668,7 +668,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
* *
* Returns 0 if substition succeeded, -1 if some processing failed * Returns 0 if substition succeeded, -1 if some processing failed
*/ */
int static int
xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) { xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlNodePtr cur, end, list; xmlNodePtr cur, end, list;
@ -710,15 +710,14 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
/** /**
* xmlXIncludeTestNode: * xmlXIncludeTestNode:
* @doc: an XML document
* @node: an XInclude node * @node: an XInclude node
* *
* test if the node is an XInclude node * test if the node is an XInclude node
* *
* Returns 1 true, 0 otherwise * Returns 1 true, 0 otherwise
*/ */
int static int
xmlXIncludeTestNode(xmlDocPtr doc, xmlNodePtr node) { xmlXIncludeTestNode(xmlNodePtr node) {
if (node == NULL) if (node == NULL)
return(0); return(0);
if (node->ns == NULL) if (node->ns == NULL)
@ -754,18 +753,18 @@ xmlXIncludeProcess(xmlDocPtr doc) {
* First phase: lookup the elements in the document * First phase: lookup the elements in the document
*/ */
cur = xmlDocGetRootElement(doc); cur = xmlDocGetRootElement(doc);
if (xmlXIncludeTestNode(doc, cur)) if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur); xmlXIncludePreProcessNode(ctxt, cur);
while (cur != NULL) { while (cur != NULL) {
/* TODO: need to work on entities -> stack */ /* TODO: need to work on entities -> stack */
if ((cur->children != NULL) && if ((cur->children != NULL) &&
(cur->children->type != XML_ENTITY_DECL)) { (cur->children->type != XML_ENTITY_DECL)) {
cur = cur->children; cur = cur->children;
if (xmlXIncludeTestNode(doc, cur)) if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur); xmlXIncludePreProcessNode(ctxt, cur);
} else if (cur->next != NULL) { } else if (cur->next != NULL) {
cur = cur->next; cur = cur->next;
if (xmlXIncludeTestNode(doc, cur)) if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur); xmlXIncludePreProcessNode(ctxt, cur);
} else { } else {
do { do {
@ -773,7 +772,7 @@ xmlXIncludeProcess(xmlDocPtr doc) {
if (cur == NULL) break; /* do */ if (cur == NULL) break; /* do */
if (cur->next != NULL) { if (cur->next != NULL) {
cur = cur->next; cur = cur->next;
if (xmlXIncludeTestNode(doc, cur)) if (xmlXIncludeTestNode(cur))
xmlXIncludePreProcessNode(ctxt, cur); xmlXIncludePreProcessNode(ctxt, cur);
break; /* do */ break; /* do */
} }

193
xmlIO.c
View File

@ -118,6 +118,18 @@ xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
int xmlOutputCallbackNr = 0; int xmlOutputCallbackNr = 0;
int xmlOutputCallbackInitialized = 0; int xmlOutputCallbackInitialized = 0;
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/************************************************************************ /************************************************************************
* * * *
* Standard I/O for file accesses * * Standard I/O for file accesses *
@ -159,94 +171,11 @@ xmlCheckFilename (const char *path)
return 1; return 1;
} }
int static int
xmlNop(void) { xmlNop(void) {
return(0); return(0);
} }
/**
* xmlFdMatch:
* @filename: the URI for matching
*
* input from file descriptor
*
* Returns 1 if matches, 0 otherwise
*/
int
xmlFdMatch (const char *filename) {
return(1);
}
/**
* xmlFdOpen:
* @filename: the URI for matching
*
* input from file descriptor, supports compressed input
* if @filename is "-" then the standard input is used
*
* Returns an I/O context or NULL in case of error
*/
void *
xmlFdOpen (const char *filename) {
const char *path = NULL;
int fd;
if (!strcmp(filename, "-")) {
fd = 0;
return((void *) fd);
}
if (!strncmp(filename, "file://localhost", 16))
path = &filename[16];
else if (!strncmp(filename, "file:///", 8))
path = &filename[8];
else if (filename[0] == '/')
path = filename;
if (path == NULL)
return(NULL);
#ifdef WIN32
fd = _open (path, O_RDONLY | _O_BINARY);
#else
fd = open (path, O_RDONLY);
#endif
return((void *) fd);
}
/**
* xmlFdOpenW:
* @filename: the URI for matching
*
* input from file descriptor,
* if @filename is "-" then the standard output is used
*
* Returns an I/O context or NULL in case of error
*/
void *
xmlFdOpenW (const char *filename) {
const char *path = NULL;
int fd;
if (!strcmp(filename, "-")) {
fd = 1;
return((void *) fd);
}
if (!strncmp(filename, "file://localhost", 16))
path = &filename[16];
else if (!strncmp(filename, "file:///", 8))
path = &filename[8];
else if (filename[0] == '/')
path = filename;
if (path == NULL)
return(NULL);
fd = open (path, O_WRONLY);
return((void *) fd);
}
/** /**
* xmlFdRead: * xmlFdRead:
* @context: the I/O context * @context: the I/O context
@ -257,7 +186,7 @@ xmlFdOpenW (const char *filename) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlFdRead (void * context, char * buffer, int len) { xmlFdRead (void * context, char * buffer, int len) {
return(read((int) context, &buffer[0], len)); return(read((int) context, &buffer[0], len));
} }
@ -272,7 +201,7 @@ xmlFdRead (void * context, char * buffer, int len) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlFdWrite (void * context, const char * buffer, int len) { xmlFdWrite (void * context, const char * buffer, int len) {
return(write((int) context, &buffer[0], len)); return(write((int) context, &buffer[0], len));
} }
@ -283,7 +212,7 @@ xmlFdWrite (void * context, const char * buffer, int len) {
* *
* Close an I/O channel * Close an I/O channel
*/ */
void static void
xmlFdClose (void * context) { xmlFdClose (void * context) {
close((int) context); close((int) context);
} }
@ -296,8 +225,8 @@ xmlFdClose (void * context) {
* *
* Returns 1 if matches, 0 otherwise * Returns 1 if matches, 0 otherwise
*/ */
int static int
xmlFileMatch (const char *filename) { xmlFileMatch (const char *filename UNUSED) {
return(1); return(1);
} }
@ -310,7 +239,7 @@ xmlFileMatch (const char *filename) {
* *
* Returns an I/O context or NULL in case of error * Returns an I/O context or NULL in case of error
*/ */
void * static void *
xmlFileOpen (const char *filename) { xmlFileOpen (const char *filename) {
const char *path = NULL; const char *path = NULL;
FILE *fd; FILE *fd;
@ -349,7 +278,7 @@ xmlFileOpen (const char *filename) {
* *
* Returns an I/O context or NULL in case of error * Returns an I/O context or NULL in case of error
*/ */
void * static void *
xmlFileOpenW (const char *filename) { xmlFileOpenW (const char *filename) {
const char *path = NULL; const char *path = NULL;
FILE *fd; FILE *fd;
@ -383,7 +312,7 @@ xmlFileOpenW (const char *filename) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlFileRead (void * context, char * buffer, int len) { xmlFileRead (void * context, char * buffer, int len) {
return(fread(&buffer[0], 1, len, (FILE *) context)); return(fread(&buffer[0], 1, len, (FILE *) context));
} }
@ -398,7 +327,7 @@ xmlFileRead (void * context, char * buffer, int len) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlFileWrite (void * context, const char * buffer, int len) { xmlFileWrite (void * context, const char * buffer, int len) {
return(fwrite(&buffer[0], 1, len, (FILE *) context)); return(fwrite(&buffer[0], 1, len, (FILE *) context));
} }
@ -409,7 +338,7 @@ xmlFileWrite (void * context, const char * buffer, int len) {
* *
* Close an I/O channel * Close an I/O channel
*/ */
void static void
xmlFileClose (void * context) { xmlFileClose (void * context) {
fclose((FILE *) context); fclose((FILE *) context);
} }
@ -420,7 +349,7 @@ xmlFileClose (void * context) {
* *
* Flush an I/O channel * Flush an I/O channel
*/ */
void static void
xmlFileFlush (void * context) { xmlFileFlush (void * context) {
fflush((FILE *) context); fflush((FILE *) context);
} }
@ -439,8 +368,8 @@ xmlFileFlush (void * context) {
* *
* Returns 1 if matches, 0 otherwise * Returns 1 if matches, 0 otherwise
*/ */
int static int
xmlGzfileMatch (const char *filename) { xmlGzfileMatch (const char *filename UNUSED) {
return(1); return(1);
} }
@ -453,7 +382,7 @@ xmlGzfileMatch (const char *filename) {
* *
* Returns an I/O context or NULL in case of error * Returns an I/O context or NULL in case of error
*/ */
void * static void *
xmlGzfileOpen (const char *filename) { xmlGzfileOpen (const char *filename) {
const char *path = NULL; const char *path = NULL;
gzFile fd; gzFile fd;
@ -489,7 +418,7 @@ xmlGzfileOpen (const char *filename) {
* *
* Returns an I/O context or NULL in case of error * Returns an I/O context or NULL in case of error
*/ */
void * static void *
xmlGzfileOpenW (const char *filename, int compression) { xmlGzfileOpenW (const char *filename, int compression) {
const char *path = NULL; const char *path = NULL;
char mode[15]; char mode[15];
@ -525,7 +454,7 @@ xmlGzfileOpenW (const char *filename, int compression) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlGzfileRead (void * context, char * buffer, int len) { xmlGzfileRead (void * context, char * buffer, int len) {
return(gzread((gzFile) context, &buffer[0], len)); return(gzread((gzFile) context, &buffer[0], len));
} }
@ -540,7 +469,7 @@ xmlGzfileRead (void * context, char * buffer, int len) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlGzfileWrite (void * context, const char * buffer, int len) { xmlGzfileWrite (void * context, const char * buffer, int len) {
return(gzwrite((gzFile) context, (char *) &buffer[0], len)); return(gzwrite((gzFile) context, (char *) &buffer[0], len));
} }
@ -551,7 +480,7 @@ xmlGzfileWrite (void * context, const char * buffer, int len) {
* *
* Close a compressed I/O channel * Close a compressed I/O channel
*/ */
void static void
xmlGzfileClose (void * context) { xmlGzfileClose (void * context) {
gzclose((gzFile) context); gzclose((gzFile) context);
} }
@ -571,7 +500,7 @@ xmlGzfileClose (void * context) {
* *
* Returns 1 if matches, 0 otherwise * Returns 1 if matches, 0 otherwise
*/ */
int static int
xmlIOHTTPMatch (const char *filename) { xmlIOHTTPMatch (const char *filename) {
if (!strncmp(filename, "http://", 7)) if (!strncmp(filename, "http://", 7))
return(1); return(1);
@ -586,7 +515,7 @@ xmlIOHTTPMatch (const char *filename) {
* *
* Returns an I/O context or NULL in case of error * Returns an I/O context or NULL in case of error
*/ */
void * static void *
xmlIOHTTPOpen (const char *filename) { xmlIOHTTPOpen (const char *filename) {
return(xmlNanoHTTPOpen(filename, NULL)); return(xmlNanoHTTPOpen(filename, NULL));
} }
@ -601,7 +530,7 @@ xmlIOHTTPOpen (const char *filename) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlIOHTTPRead(void * context, char * buffer, int len) { xmlIOHTTPRead(void * context, char * buffer, int len) {
return(xmlNanoHTTPRead(context, &buffer[0], len)); return(xmlNanoHTTPRead(context, &buffer[0], len));
} }
@ -612,7 +541,7 @@ xmlIOHTTPRead(void * context, char * buffer, int len) {
* *
* Close an HTTP I/O channel * Close an HTTP I/O channel
*/ */
void static void
xmlIOHTTPClose (void * context) { xmlIOHTTPClose (void * context) {
xmlNanoHTTPClose(context); xmlNanoHTTPClose(context);
} }
@ -632,7 +561,7 @@ xmlIOHTTPClose (void * context) {
* *
* Returns 1 if matches, 0 otherwise * Returns 1 if matches, 0 otherwise
*/ */
int static int
xmlIOFTPMatch (const char *filename) { xmlIOFTPMatch (const char *filename) {
if (!strncmp(filename, "ftp://", 6)) if (!strncmp(filename, "ftp://", 6))
return(1); return(1);
@ -647,7 +576,7 @@ xmlIOFTPMatch (const char *filename) {
* *
* Returns an I/O context or NULL in case of error * Returns an I/O context or NULL in case of error
*/ */
void * static void *
xmlIOFTPOpen (const char *filename) { xmlIOFTPOpen (const char *filename) {
return(xmlNanoFTPOpen(filename)); return(xmlNanoFTPOpen(filename));
} }
@ -662,7 +591,7 @@ xmlIOFTPOpen (const char *filename) {
* *
* Returns the number of bytes written * Returns the number of bytes written
*/ */
int static int
xmlIOFTPRead(void * context, char * buffer, int len) { xmlIOFTPRead(void * context, char * buffer, int len) {
return(xmlNanoFTPRead(context, &buffer[0], len)); return(xmlNanoFTPRead(context, &buffer[0], len));
} }
@ -673,7 +602,7 @@ xmlIOFTPRead(void * context, char * buffer, int len) {
* *
* Close an FTP I/O channel * Close an FTP I/O channel
*/ */
void static void
xmlIOFTPClose (void * context) { xmlIOFTPClose (void * context) {
xmlNanoFTPClose(context); xmlNanoFTPClose(context);
} }
@ -682,51 +611,51 @@ xmlIOFTPClose (void * context) {
/** /**
* xmlRegisterInputCallbacks: * xmlRegisterInputCallbacks:
* @match: the xmlInputMatchCallback * @matchFunc: the xmlInputMatchCallback
* @open: the xmlInputOpenCallback * @openFunc: the xmlInputOpenCallback
* @read: the xmlInputReadCallback * @readFunc: the xmlInputReadCallback
* @close: the xmlInputCloseCallback * @closeFunc: the xmlInputCloseCallback
* *
* Register a new set of I/O callback for handling parser input. * Register a new set of I/O callback for handling parser input.
* *
* Returns the registered handler number or -1 in case of error * Returns the registered handler number or -1 in case of error
*/ */
int int
xmlRegisterInputCallbacks(xmlInputMatchCallback match, xmlRegisterInputCallbacks(xmlInputMatchCallback matchFunc,
xmlInputOpenCallback open, xmlInputReadCallback read, xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc,
xmlInputCloseCallback close) { xmlInputCloseCallback closeFunc) {
if (xmlInputCallbackNr >= MAX_INPUT_CALLBACK) { if (xmlInputCallbackNr >= MAX_INPUT_CALLBACK) {
return(-1); return(-1);
} }
xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = match; xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = matchFunc;
xmlInputCallbackTable[xmlInputCallbackNr].opencallback = open; xmlInputCallbackTable[xmlInputCallbackNr].opencallback = openFunc;
xmlInputCallbackTable[xmlInputCallbackNr].readcallback = read; xmlInputCallbackTable[xmlInputCallbackNr].readcallback = readFunc;
xmlInputCallbackTable[xmlInputCallbackNr].closecallback = close; xmlInputCallbackTable[xmlInputCallbackNr].closecallback = closeFunc;
return(xmlInputCallbackNr++); return(xmlInputCallbackNr++);
} }
/** /**
* xmlRegisterOutputCallbacks: * xmlRegisterOutputCallbacks:
* @match: the xmlOutputMatchCallback * @matchFunc: the xmlOutputMatchCallback
* @open: the xmlOutputOpenCallback * @openFunc: the xmlOutputOpenCallback
* @write: the xmlOutputWriteCallback * @writeFunc: the xmlOutputWriteCallback
* @close: the xmlOutputCloseCallback * @closeFunc: the xmlOutputCloseCallback
* *
* Register a new set of I/O callback for handling output. * Register a new set of I/O callback for handling output.
* *
* Returns the registered handler number or -1 in case of error * Returns the registered handler number or -1 in case of error
*/ */
int int
xmlRegisterOutputCallbacks(xmlOutputMatchCallback match, xmlRegisterOutputCallbacks(xmlOutputMatchCallback matchFunc,
xmlOutputOpenCallback open, xmlOutputWriteCallback write, xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc,
xmlOutputCloseCallback close) { xmlOutputCloseCallback closeFunc) {
if (xmlOutputCallbackNr >= MAX_INPUT_CALLBACK) { if (xmlOutputCallbackNr >= MAX_INPUT_CALLBACK) {
return(-1); return(-1);
} }
xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = match; xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = matchFunc;
xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = open; xmlOutputCallbackTable[xmlOutputCallbackNr].opencallback = openFunc;
xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = write; xmlOutputCallbackTable[xmlOutputCallbackNr].writecallback = writeFunc;
xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = close; xmlOutputCallbackTable[xmlOutputCallbackNr].closecallback = closeFunc;
return(xmlOutputCallbackNr++); return(xmlOutputCallbackNr++);
} }

16
xmlIO.h
View File

@ -112,10 +112,10 @@ int xmlParserInputBufferPush (xmlParserInputBufferPtr in,
void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); void xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
char * xmlParserGetDirectory (const char *filename); char * xmlParserGetDirectory (const char *filename);
int xmlRegisterInputCallbacks (xmlInputMatchCallback match, int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
xmlInputOpenCallback open, xmlInputOpenCallback openFunc,
xmlInputReadCallback read, xmlInputReadCallback readFunc,
xmlInputCloseCallback close); xmlInputCloseCallback closeFunc);
/* /*
* Interfaces for output * Interfaces for output
*/ */
@ -151,10 +151,10 @@ int xmlOutputBufferWriteString (xmlOutputBufferPtr out,
int xmlOutputBufferFlush (xmlOutputBufferPtr out); int xmlOutputBufferFlush (xmlOutputBufferPtr out);
int xmlOutputBufferClose (xmlOutputBufferPtr out); int xmlOutputBufferClose (xmlOutputBufferPtr out);
int xmlRegisterOutputCallbacks (xmlOutputMatchCallback match, int xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
xmlOutputOpenCallback open, xmlOutputOpenCallback openFunc,
xmlOutputWriteCallback write, xmlOutputWriteCallback writeFunc,
xmlOutputCloseCallback close); xmlOutputCloseCallback closeFunc);
/* /*
* This save function are part of tree.h and HTMLtree.h actually * This save function are part of tree.h and HTMLtree.h actually

View File

@ -109,7 +109,7 @@ extern int xmlGetWarningsDefaultValue;
************************************************************************/ ************************************************************************/
char buffer[50000]; char buffer[50000];
void static void
xmlHTMLEncodeSend(void) { xmlHTMLEncodeSend(void) {
char *result; char *result;
@ -128,7 +128,7 @@ xmlHTMLEncodeSend(void) {
* Displays the associated file and line informations for the current input * Displays the associated file and line informations for the current input
*/ */
void static void
xmlHTMLPrintFileInfo(xmlParserInputPtr input) { xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
xmlGenericError(xmlGenericErrorContext, "<p>"); xmlGenericError(xmlGenericErrorContext, "<p>");
if (input != NULL) { if (input != NULL) {
@ -149,7 +149,7 @@ xmlHTMLPrintFileInfo(xmlParserInputPtr input) {
* Displays current context within the input content for error tracking * Displays current context within the input content for error tracking
*/ */
void static void
xmlHTMLPrintFileContext(xmlParserInputPtr input) { xmlHTMLPrintFileContext(xmlParserInputPtr input) {
const xmlChar *cur, *base; const xmlChar *cur, *base;
int n; int n;
@ -194,7 +194,7 @@ xmlHTMLPrintFileContext(xmlParserInputPtr input) {
* Display and format an error messages, gives file, line, position and * Display and format an error messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
xmlHTMLError(void *ctx, const char *msg, ...) xmlHTMLError(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -231,7 +231,7 @@ xmlHTMLError(void *ctx, const char *msg, ...)
* Display and format a warning messages, gives file, line, position and * Display and format a warning messages, gives file, line, position and
* extra parameters. * extra parameters.
*/ */
void static void
xmlHTMLWarning(void *ctx, const char *msg, ...) xmlHTMLWarning(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -269,7 +269,7 @@ xmlHTMLWarning(void *ctx, const char *msg, ...)
* Display and format an validity error messages, gives file, * Display and format an validity error messages, gives file,
* line, position and extra parameters. * line, position and extra parameters.
*/ */
void static void
xmlHTMLValidityError(void *ctx, const char *msg, ...) xmlHTMLValidityError(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -303,7 +303,7 @@ xmlHTMLValidityError(void *ctx, const char *msg, ...)
* Display and format a validity warning messages, gives file, line, * Display and format a validity warning messages, gives file, line,
* position and extra parameters. * position and extra parameters.
*/ */
void static void
xmlHTMLValidityWarning(void *ctx, const char *msg, ...) xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
@ -342,7 +342,7 @@ xmlHTMLValidityWarning(void *ctx, const char *msg, ...)
* Returns a pointer to it or NULL on EOF the caller is expected to * Returns a pointer to it or NULL on EOF the caller is expected to
* free the returned string. * free the returned string.
*/ */
char * static char *
xmlShellReadline(char *prompt) { xmlShellReadline(char *prompt) {
#ifdef HAVE_LIBREADLINE #ifdef HAVE_LIBREADLINE
char *line_read; char *line_read;
@ -373,10 +373,10 @@ xmlShellReadline(char *prompt) {
* * * *
************************************************************************/ ************************************************************************/
int myRead(FILE *f, char * buffer, int len) { static int myRead(FILE *f, char * buf, int len) {
return(fread(buffer, 1, len, f)); return(fread(buf, 1, len, f));
} }
void myClose(FILE *f) { static void myClose(FILE *f) {
if (f != stdin) { if (f != stdin) {
fclose(f); fclose(f);
} }
@ -387,7 +387,7 @@ void myClose(FILE *f) {
* Test processing * * Test processing *
* * * *
************************************************************************/ ************************************************************************/
void parseAndPrintFile(char *filename) { static void parseAndPrintFile(char *filename) {
xmlDocPtr doc = NULL, tmp; xmlDocPtr doc = NULL, tmp;
if ((timing) && (!repeat)) if ((timing) && (!repeat))

View File

@ -33,6 +33,32 @@
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
void xmlMallocBreakpoint(void);
void * xmlMemMalloc(int size);
void * xmlMallocLoc(int size, const char * file, int line);
void * xmlMemRealloc(void *ptr,int size);
void xmlMemFree(void *ptr);
char * xmlMemoryStrdup(const char *str);
/************************************************************************
* *
* Macros, variables and associated types *
* *
************************************************************************/
#ifdef xmlMalloc #ifdef xmlMalloc
#undef xmlMalloc #undef xmlMalloc
#endif #endif
@ -384,7 +410,7 @@ xmlMemUsed(void) {
* tries to show some content from the memory block * tries to show some content from the memory block
*/ */
void static void
xmlMemContentShow(FILE *fp, MEMHDR *p) xmlMemContentShow(FILE *fp, MEMHDR *p)
{ {
int i,j,len = p->mh_size; int i,j,len = p->mh_size;
@ -498,7 +524,7 @@ xmlMemDisplay(FILE *fp)
currentTime = time(NULL); currentTime = time(NULL);
tstruct = localtime(&currentTime); tstruct = localtime(&currentTime);
strftime(buf, sizeof(buf) - 1, "%c", tstruct); strftime(buf, sizeof(buf) - 1, "%I:%M:%S %p", tstruct);
fprintf(fp," %s\n\n", buf); fprintf(fp," %s\n\n", buf);
#endif #endif

155
xpath.c
View File

@ -276,7 +276,7 @@ struct _xmlXPathCompExpr {
* *
* Returns the newly allocated xmlXPathCompExprPtr or NULL in case of error * Returns the newly allocated xmlXPathCompExprPtr or NULL in case of error
*/ */
xmlXPathCompExprPtr static xmlXPathCompExprPtr
xmlXPathNewCompExpr(void) { xmlXPathNewCompExpr(void) {
xmlXPathCompExprPtr cur; xmlXPathCompExprPtr cur;
@ -350,7 +350,7 @@ xmlXPathFreeCompExpr(xmlXPathCompExprPtr comp) {
* *
* Returns -1 in case of failure, the index otherwise * Returns -1 in case of failure, the index otherwise
*/ */
int static int
xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2, xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2,
xmlXPathOp op, int value, xmlXPathOp op, int value,
int value2, int value3, void *value4, void *value5) { int value2, int value3, void *value4, void *value5) {
@ -410,7 +410,8 @@ xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), (val), (val2), 0 ,NULL ,NULL
__FILE__, __LINE__); __FILE__, __LINE__);
#ifdef LIBXML_DEBUG_ENABLED #ifdef LIBXML_DEBUG_ENABLED
void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) { static void
xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -433,7 +434,8 @@ void xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
else else
xmlDebugDumpOneNode(output, cur, depth); xmlDebugDumpOneNode(output, cur, depth);
} }
void xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) { static void
xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
xmlNodePtr tmp; xmlNodePtr tmp;
int i; int i;
char shift[100]; char shift[100];
@ -455,7 +457,8 @@ void xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
} }
} }
void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) { static void
xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -478,7 +481,8 @@ void xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
} }
} }
void xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) { static void
xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -499,7 +503,8 @@ void xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
} }
#if defined(LIBXML_XPTR_ENABLED) #if defined(LIBXML_XPTR_ENABLED)
void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth); void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth);
void xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) { static void
xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -617,7 +622,8 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
} }
} }
void xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp, static void
xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
xmlXPathStepOpPtr op, int depth) { xmlXPathStepOpPtr op, int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -788,8 +794,10 @@ finish:
if (op->ch2 >= 0) if (op->ch2 >= 0)
xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch2], depth + 1); xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch2], depth + 1);
} }
void xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
int depth) { void
xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
int depth) {
int i; int i;
char shift[100]; char shift[100];
@ -933,7 +941,7 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
int is_negative; int is_negative;
int use_scientific; int use_scientific;
int exponent; int exponent;
int index; int indx;
int count; int count;
double n; double n;
@ -964,8 +972,8 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
} else { } else {
n = number; n = number;
for (i = 1; i < INTEGER_DIGITS - 1; i++) { for (i = 1; i < INTEGER_DIGITS - 1; i++) {
index = (int)n % 10; indx = (int)n % 10;
*(--pointer) = "0123456789"[index]; *(--pointer) = "0123456789"[indx];
n /= 10.0; n /= 10.0;
if (n < 1.0) if (n < 1.0)
break; break;
@ -989,10 +997,10 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
while (i < FRACTION_DIGITS) { while (i < FRACTION_DIGITS) {
n -= floor(n); n -= floor(n);
n *= 10.0; n *= 10.0;
index = (int)n % 10; indx = (int)n % 10;
*(pointer++) = "0123456789"[index]; *(pointer++) = "0123456789"[indx];
i++; i++;
if ((index != 0) || (count > 0)) if ((indx != 0) || (count > 0))
count++; count++;
if ((n > 10.0) || (count > FRACTION_DIGITS / 2)) if ((n > 10.0) || (count > FRACTION_DIGITS / 2))
break; break;
@ -1494,7 +1502,7 @@ xmlXPathFreeNodeSet(xmlNodeSetPtr obj) {
* Free the NodeSet compound and the actual tree, this is different * Free the NodeSet compound and the actual tree, this is different
* from xmlXPathFreeNodeSet() * from xmlXPathFreeNodeSet()
*/ */
void static void
xmlXPathFreeValueTree(xmlNodeSetPtr obj) { xmlXPathFreeValueTree(xmlNodeSetPtr obj) {
int i; int i;
@ -2326,7 +2334,7 @@ xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
* *
* Returns the xmlXPathParserContext just allocated. * Returns the xmlXPathParserContext just allocated.
*/ */
xmlXPathParserContextPtr static xmlXPathParserContextPtr
xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) { xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
xmlXPathParserContextPtr ret; xmlXPathParserContextPtr ret;
@ -2420,7 +2428,7 @@ void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
* *
* Returns 0 or 1 depending on the results of the test. * Returns 0 or 1 depending on the results of the test.
*/ */
int static int
xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
xmlXPathObjectPtr arg, xmlXPathObjectPtr f) { xmlXPathObjectPtr arg, xmlXPathObjectPtr f) {
int i, ret = 0; int i, ret = 0;
@ -2473,7 +2481,7 @@ xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
* *
* Returns 0 or 1 depending on the results of the test. * Returns 0 or 1 depending on the results of the test.
*/ */
int static int
xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
xmlXPathObjectPtr arg, xmlXPathObjectPtr s) { xmlXPathObjectPtr arg, xmlXPathObjectPtr s) {
int i, ret = 0; int i, ret = 0;
@ -2506,7 +2514,6 @@ xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
/** /**
* xmlXPathCompareNodeSets: * xmlXPathCompareNodeSets:
* @ctxt: the XPath Parser context
* @op: less than (-1), equal (0) or greater than (1) * @op: less than (-1), equal (0) or greater than (1)
* @strict: is the comparison strict * @strict: is the comparison strict
* @arg1: the fist node set object * @arg1: the fist node set object
@ -2533,8 +2540,8 @@ xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
* Conclusion all nodes need to be converted first to their string value * Conclusion all nodes need to be converted first to their string value
* and then the comparison must be done when possible * and then the comparison must be done when possible
*/ */
int static int
xmlXPathCompareNodeSets(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathCompareNodeSets(int inf, int strict,
xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) { xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) {
int i, j, init = 0; int i, j, init = 0;
double val1; double val1;
@ -2624,7 +2631,7 @@ xmlXPathCompareNodeSets(xmlXPathParserContextPtr ctxt, int inf, int strict,
* *
* Returns 0 or 1 depending on the results of the test. * Returns 0 or 1 depending on the results of the test.
*/ */
int static int
xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict, xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
xmlXPathObjectPtr arg, xmlXPathObjectPtr val) { xmlXPathObjectPtr arg, xmlXPathObjectPtr val) {
if ((val == NULL) || (arg == NULL) || if ((val == NULL) || (arg == NULL) ||
@ -2636,7 +2643,7 @@ xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val)); return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val));
case XPATH_NODESET: case XPATH_NODESET:
case XPATH_XSLT_TREE: case XPATH_XSLT_TREE:
return(xmlXPathCompareNodeSets(ctxt, inf, strict, arg, val)); return(xmlXPathCompareNodeSets(inf, strict, arg, val));
case XPATH_STRING: case XPATH_STRING:
return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val)); return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val));
case XPATH_BOOLEAN: case XPATH_BOOLEAN:
@ -2664,7 +2671,7 @@ xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
* *
* Returns 0 or 1 depending on the results of the test. * Returns 0 or 1 depending on the results of the test.
*/ */
int static int
xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar *str) { xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar *str) {
int i; int i;
xmlNodeSetPtr ns; xmlNodeSetPtr ns;
@ -2702,7 +2709,7 @@ xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar *str) {
* *
* Returns 0 or 1 depending on the results of the test. * Returns 0 or 1 depending on the results of the test.
*/ */
int static int
xmlXPathEqualNodeSetFloat(xmlXPathObjectPtr arg, double f) { xmlXPathEqualNodeSetFloat(xmlXPathObjectPtr arg, double f) {
char buf[100] = ""; char buf[100] = "";
@ -2730,7 +2737,7 @@ xmlXPathEqualNodeSetFloat(xmlXPathObjectPtr arg, double f) {
* *
* Returns 0 or 1 depending on the results of the test. * Returns 0 or 1 depending on the results of the test.
*/ */
int static int
xmlXPathEqualNodeSets(xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) { xmlXPathEqualNodeSets(xmlXPathObjectPtr arg1, xmlXPathObjectPtr arg2) {
int i, j; int i, j;
xmlChar **values1; xmlChar **values1;
@ -3034,7 +3041,7 @@ xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
if ((arg2->type == XPATH_NODESET) || (arg1->type == XPATH_NODESET)) { if ((arg2->type == XPATH_NODESET) || (arg1->type == XPATH_NODESET)) {
if ((arg2->type == XPATH_NODESET) && (arg1->type == XPATH_NODESET)) { if ((arg2->type == XPATH_NODESET) && (arg1->type == XPATH_NODESET)) {
ret = xmlXPathCompareNodeSets(ctxt, inf, strict, arg1, arg2); ret = xmlXPathCompareNodeSets(inf, strict, arg1, arg2);
} else { } else {
if (arg1->type == XPATH_NODESET) { if (arg1->type == XPATH_NODESET) {
ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict, ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict,
@ -3468,9 +3475,9 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return((xmlNodePtr) ctxt->context->doc); return((xmlNodePtr) ctxt->context->doc);
return(ctxt->context->node->parent); return(ctxt->context->node->parent);
case XML_ATTRIBUTE_NODE: { case XML_ATTRIBUTE_NODE: {
xmlAttrPtr cur = (xmlAttrPtr) ctxt->context->node; xmlAttrPtr tmp = (xmlAttrPtr) ctxt->context->node;
return(cur->parent); return(tmp->parent);
} }
case XML_DOCUMENT_NODE: case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE: case XML_DOCUMENT_TYPE_NODE:
@ -3756,7 +3763,7 @@ xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
* *
* Returns the new NodeSet resulting from the search. * Returns the new NodeSet resulting from the search.
*/ */
void static void
xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis, xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt, xmlXPathAxisVal axis,
xmlXPathTestVal test, xmlXPathTypeVal type, xmlXPathTestVal test, xmlXPathTypeVal type,
const xmlChar *prefix, const xmlChar *name) { const xmlChar *prefix, const xmlChar *name) {
@ -4393,7 +4400,7 @@ xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* Libxml keep the original prefix so the "real qualified name" used is * Libxml keep the original prefix so the "real qualified name" used is
* returned. * returned.
*/ */
void static void
xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr cur; xmlXPathObjectPtr cur;
@ -4457,7 +4464,7 @@ xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/ */
xmlXPathObjectPtr xmlXPathObjectPtr
xmlXPathConvertString(xmlXPathObjectPtr val) { xmlXPathConvertString(xmlXPathObjectPtr val) {
xmlXPathObjectPtr ret; xmlXPathObjectPtr ret = NULL;
if (val == NULL) if (val == NULL)
return(xmlXPathNewCString("")); return(xmlXPathNewCString(""));
@ -5183,7 +5190,7 @@ not_equal:
*/ */
xmlXPathObjectPtr xmlXPathObjectPtr
xmlXPathConvertNumber(xmlXPathObjectPtr val) { xmlXPathConvertNumber(xmlXPathObjectPtr val) {
xmlXPathObjectPtr ret; xmlXPathObjectPtr ret = NULL;
double res; double res;
if (val == NULL) if (val == NULL)
@ -5447,7 +5454,7 @@ xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) {
* to get the Prefix if any. * to get the Prefix if any.
*/ */
xmlChar * static xmlChar *
xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) { xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) {
xmlChar *ret = NULL; xmlChar *ret = NULL;
@ -5884,7 +5891,7 @@ xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
* Returns the Name parsed or NULL * Returns the Name parsed or NULL
*/ */
xmlChar * static xmlChar *
xmlXPathScanName(xmlXPathParserContextPtr ctxt) { xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
xmlChar buf[XML_MAX_NAMELEN]; xmlChar buf[XML_MAX_NAMELEN];
int len = 0; int len = 0;
@ -6405,7 +6412,7 @@ xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt) {
* *
* Returns the name found and update @test, @type and @prefix appropriately * Returns the name found and update @test, @type and @prefix appropriately
*/ */
xmlChar * static xmlChar *
xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test, xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
xmlXPathTypeVal *type, const xmlChar **prefix, xmlXPathTypeVal *type, const xmlChar **prefix,
xmlChar *name) { xmlChar *name) {
@ -6463,8 +6470,6 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
/* /*
* Specific case: search a PI by name. * Specific case: search a PI by name.
*/ */
xmlXPathObjectPtr cur;
if (name != NULL) if (name != NULL)
xmlFree(name); xmlFree(name);
@ -6539,7 +6544,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
* *
* Returns the axis or 0 * Returns the axis or 0
*/ */
xmlXPathAxisVal static xmlXPathAxisVal
xmlXPathIsAxisName(const xmlChar *name) { xmlXPathIsAxisName(const xmlChar *name) {
xmlXPathAxisVal ret = 0; xmlXPathAxisVal ret = 0;
switch (name[0]) { switch (name[0]) {
@ -6587,41 +6592,6 @@ xmlXPathIsAxisName(const xmlChar *name) {
return(ret); return(ret);
} }
/**
* xmlXPathCompAxisSpecifier:
* @ctxt: the XPath Parser context
*
* Parse an axis value
*
* Returns the axis found
*/
xmlXPathAxisVal
xmlXPathCompAxisSpecifier(xmlXPathParserContextPtr ctxt) {
xmlXPathAxisVal ret = AXIS_CHILD;
int blank = 0;
xmlChar *name;
if (CUR == '@') {
NEXT;
return(AXIS_ATTRIBUTE);
} else {
name = xmlXPathParseNCName(ctxt);
if (name == NULL) {
XP_ERROR0(XPATH_EXPR_ERROR);
}
if (IS_BLANK(CUR))
blank = 1;
SKIP_BLANKS;
if ((CUR == ':') && (NXT(1) == ':')) {
ret = xmlXPathIsAxisName(name);
} else if ((blank) && (CUR == ':'))
XP_ERROR0(XPATH_EXPR_ERROR);
xmlFree(name);
}
return(ret);
}
/** /**
* xmlXPathCompStep: * xmlXPathCompStep:
* @ctxt: the XPath Parser context * @ctxt: the XPath Parser context
@ -7047,20 +7017,20 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
* Hum are we filtering the result of an XPointer expression * Hum are we filtering the result of an XPointer expression
*/ */
if (ctxt->value->type == XPATH_LOCATIONSET) { if (ctxt->value->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr newset = NULL; xmlLocationSetPtr newlocset = NULL;
xmlLocationSetPtr oldset; xmlLocationSetPtr oldlocset;
/* /*
* Extract the old set, and then evaluate the result of the * Extract the old locset, and then evaluate the result of the
* expression for all the element in the set. use it to grow * expression for all the element in the locset. use it to grow
* up a new set. * up a new locset.
*/ */
CHECK_TYPE(XPATH_LOCATIONSET); CHECK_TYPE(XPATH_LOCATIONSET);
obj = valuePop(ctxt); obj = valuePop(ctxt);
oldset = obj->user; oldlocset = obj->user;
ctxt->context->node = NULL; ctxt->context->node = NULL;
if ((oldset == NULL) || (oldset->locNr == 0)) { if ((oldlocset == NULL) || (oldlocset->locNr == 0)) {
ctxt->context->contextSize = 0; ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0; ctxt->context->proximityPosition = 0;
if (op->ch2 != -1) if (op->ch2 != -1)
@ -7072,17 +7042,17 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
CHECK_ERROR; CHECK_ERROR;
return; return;
} }
newset = xmlXPtrLocationSetCreate(NULL); newlocset = xmlXPtrLocationSetCreate(NULL);
for (i = 0; i < oldset->locNr; i++) { for (i = 0; i < oldlocset->locNr; i++) {
/* /*
* Run the evaluation with a node list made of a * Run the evaluation with a node list made of a
* single item in the nodeset. * single item in the nodelocset.
*/ */
ctxt->context->node = oldset->locTab[i]->user; ctxt->context->node = oldlocset->locTab[i]->user;
tmp = xmlXPathNewNodeSet(ctxt->context->node); tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp); valuePush(ctxt, tmp);
ctxt->context->contextSize = oldset->locNr; ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1; ctxt->context->proximityPosition = i + 1;
if (op->ch2 != -1) if (op->ch2 != -1)
@ -7095,8 +7065,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
*/ */
res = valuePop(ctxt); res = valuePop(ctxt);
if (xmlXPathEvaluatePredicateResult(ctxt, res)) { if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
xmlXPtrLocationSetAdd(newset, xmlXPtrLocationSetAdd(newlocset,
xmlXPathObjectCopy(oldset->locTab[i])); xmlXPathObjectCopy(oldlocset->locTab[i]));
} }
/* /*
@ -7113,13 +7083,13 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op) {
} }
/* /*
* The result is used as the new evaluation set. * The result is used as the new evaluation locset.
*/ */
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
ctxt->context->node = NULL; ctxt->context->node = NULL;
ctxt->context->contextSize = -1; ctxt->context->contextSize = -1;
ctxt->context->proximityPosition = -1; ctxt->context->proximityPosition = -1;
valuePush(ctxt, xmlXPtrWrapLocationSet(newset)); valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
ctxt->context->node = oldnode; ctxt->context->node = oldnode;
return; return;
} }
@ -7464,7 +7434,6 @@ xmlXPathCompiledEval(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctx) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"xmlXPathEval: %d object left on the stack\n", "xmlXPathEval: %d object left on the stack\n",
stack); stack);
xmlXPathDebugDumpCompExpr(stdout, ctxt->comp, 0);
} }
if (ctxt->error != XPATH_EXPRESSION_OK) { if (ctxt->error != XPATH_EXPRESSION_OK) {
xmlXPathFreeObject(res); xmlXPathFreeObject(res);

View File

@ -79,7 +79,9 @@ void xmlXPatherror (xmlXPathParserContextPtr ctxt,
void xmlXPathDebugDumpObject (FILE *output, void xmlXPathDebugDumpObject (FILE *output,
xmlXPathObjectPtr cur, xmlXPathObjectPtr cur,
int depth); int depth);
void xmlXPathDebugDumpCompExpr(FILE *output,
xmlXPathCompExprPtr comp,
int depth);
/** /**
* Extending a context * Extending a context
*/ */
@ -139,7 +141,9 @@ xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val); xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur, void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
xmlNodePtr val); xmlNodePtr val);
void xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
xmlNodePtr val);
void xmlXPathNodeSetSort (xmlNodeSetPtr set);
void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt, void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt,
int nargs); int nargs);
@ -193,13 +197,37 @@ void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
void xmlXPathDivValues(xmlXPathParserContextPtr ctxt); void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
void xmlXPathModValues(xmlXPathParserContextPtr ctxt); void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
int xmlXPathIsNodeType(const xmlChar *name);
/* /*
* Some of the axis navigation routines * Some of the axis navigation routines
*/ */
xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); xmlNodePtr cur);
xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
xmlNodePtr cur);
/* /*
* The official core of XPath functions * The official core of XPath functions
*/ */

View File

@ -15,6 +15,18 @@
#include "config.h" #include "config.h"
#endif #endif
/************************************************************************
* *
* When running GCC in vaacum cleaner mode *
* *
************************************************************************/
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif
/** /**
* TODO: better handling of error cases, the full expression should * TODO: better handling of error cases, the full expression should
* be parsed beforehand instead of a progressive evaluation * be parsed beforehand instead of a progressive evaluation
@ -66,7 +78,7 @@ xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur);
* *
* Returns the number of child for an element, -1 in case of error * Returns the number of child for an element, -1 in case of error
*/ */
int static int
xmlXPtrGetArity(xmlNodePtr cur) { xmlXPtrGetArity(xmlNodePtr cur) {
int i; int i;
if (cur == NULL) if (cur == NULL)
@ -89,7 +101,7 @@ xmlXPtrGetArity(xmlNodePtr cur) {
* Returns the index of the node in its parent children list, -1 * Returns the index of the node in its parent children list, -1
* in case of error * in case of error
*/ */
int static int
xmlXPtrGetIndex(xmlNodePtr cur) { xmlXPtrGetIndex(xmlNodePtr cur) {
int i; int i;
if (cur == NULL) if (cur == NULL)
@ -111,7 +123,7 @@ xmlXPtrGetIndex(xmlNodePtr cur) {
* *
* Returns the @no'th element child of @cur or NULL * Returns the @no'th element child of @cur or NULL
*/ */
xmlNodePtr static xmlNodePtr
xmlXPtrGetNthChild(xmlNodePtr cur, int no) { xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
int i; int i;
if (cur == NULL) if (cur == NULL)
@ -149,7 +161,7 @@ xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
* Returns -2 in case of error 1 if first point < second point, 0 if * Returns -2 in case of error 1 if first point < second point, 0 if
* that's the same point, -1 otherwise * that's the same point, -1 otherwise
*/ */
int static int
xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) { xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) {
if ((node1 == NULL) || (node2 == NULL)) if ((node1 == NULL) || (node2 == NULL))
return(-2); return(-2);
@ -169,19 +181,19 @@ xmlXPtrCmpPoints(xmlNodePtr node1, int index1, xmlNodePtr node2, int index2) {
/** /**
* xmlXPtrNewPoint: * xmlXPtrNewPoint:
* @node: the xmlNodePtr * @node: the xmlNodePtr
* @index: the index within the node * @indx: the indx within the node
* *
* Create a new xmlXPathObjectPtr of type point * Create a new xmlXPathObjectPtr of type point
* *
* Returns the newly created object. * Returns the newly created object.
*/ */
xmlXPathObjectPtr static xmlXPathObjectPtr
xmlXPtrNewPoint(xmlNodePtr node, int index) { xmlXPtrNewPoint(xmlNodePtr node, int indx) {
xmlXPathObjectPtr ret; xmlXPathObjectPtr ret;
if (node == NULL) if (node == NULL)
return(NULL); return(NULL);
if (index < 0) if (indx < 0)
return(NULL); return(NULL);
ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject)); ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
@ -193,7 +205,7 @@ xmlXPtrNewPoint(xmlNodePtr node, int index) {
memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
ret->type = XPATH_POINT; ret->type = XPATH_POINT;
ret->user = (void *) node; ret->user = (void *) node;
ret->index = index; ret->index = indx;
return(ret); return(ret);
} }
@ -203,7 +215,7 @@ xmlXPtrNewPoint(xmlNodePtr node, int index) {
* *
* Make sure the points in the range are in the right order * Make sure the points in the range are in the right order
*/ */
void static void
xmlXPtrRangeCheckOrder(xmlXPathObjectPtr range) { xmlXPtrRangeCheckOrder(xmlXPathObjectPtr range) {
int tmp; int tmp;
xmlNodePtr tmp2; xmlNodePtr tmp2;
@ -234,7 +246,7 @@ xmlXPtrRangeCheckOrder(xmlXPathObjectPtr range) {
* *
* Return 1 if equal, 0 otherwise * Return 1 if equal, 0 otherwise
*/ */
int static int
xmlXPtrRangesEqual(xmlXPathObjectPtr range1, xmlXPathObjectPtr range2) { xmlXPtrRangesEqual(xmlXPathObjectPtr range1, xmlXPathObjectPtr range2) {
if (range1 == range2) if (range1 == range2)
return(1); return(1);
@ -862,8 +874,8 @@ xmlXPtrWrapLocationSet(xmlLocationSetPtr val) {
* Move the current node of the nodeset on the stack to the * Move the current node of the nodeset on the stack to the
* given child if found * given child if found
*/ */
void static void
xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int index) { xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int indx) {
xmlNodePtr cur = NULL; xmlNodePtr cur = NULL;
xmlXPathObjectPtr obj; xmlXPathObjectPtr obj;
xmlNodeSetPtr oldset; xmlNodeSetPtr oldset;
@ -871,12 +883,12 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int index) {
CHECK_TYPE(XPATH_NODESET); CHECK_TYPE(XPATH_NODESET);
obj = valuePop(ctxt); obj = valuePop(ctxt);
oldset = obj->nodesetval; oldset = obj->nodesetval;
if ((index <= 0) || (oldset == NULL) || (oldset->nodeNr != 1)) { if ((indx <= 0) || (oldset == NULL) || (oldset->nodeNr != 1)) {
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewNodeSet(NULL)); valuePush(ctxt, xmlXPathNewNodeSet(NULL));
return; return;
} }
cur = xmlXPtrGetNthChild(oldset->nodeTab[0], index); cur = xmlXPtrGetNthChild(oldset->nodeTab[0], indx);
if (cur == NULL) { if (cur == NULL) {
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewNodeSet(NULL)); valuePush(ctxt, xmlXPathNewNodeSet(NULL));
@ -920,7 +932,7 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int index) {
* TODO: there is no new scheme registration mechanism * TODO: there is no new scheme registration mechanism
*/ */
void static void
xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) { xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
xmlChar *buffer, *cur; xmlChar *buffer, *cur;
int len; int len;
@ -1062,7 +1074,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
* Parse and evaluate a Full XPtr i.e. possibly a cascade of XPath based * Parse and evaluate a Full XPtr i.e. possibly a cascade of XPath based
* expressions or other shemes. * expressions or other shemes.
*/ */
void static void
xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) { xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
if (name == NULL) if (name == NULL)
name = xmlXPathParseName(ctxt); name = xmlXPathParseName(ctxt);
@ -1130,7 +1142,7 @@ xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
* Parse and evaluate a Child Sequence. This routine also handle the * Parse and evaluate a Child Sequence. This routine also handle the
* case of a Bare Name used to get a document ID. * case of a Bare Name used to get a document ID.
*/ */
void static void
xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) { xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
/* /*
* XPointer don't allow by syntax to adress in mutirooted trees * XPointer don't allow by syntax to adress in mutirooted trees
@ -1171,7 +1183,7 @@ xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
* *
* Parse and evaluate an XPointer * Parse and evaluate an XPointer
*/ */
void static void
xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) { xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
if (ctxt->valueTab == NULL) { if (ctxt->valueTab == NULL) {
/* Allocate the value stack */ /* Allocate the value stack */
@ -1346,13 +1358,13 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
* Returns an xmlNodePtr list or NULL. * Returns an xmlNodePtr list or NULL.
* the caller has to free the node tree. * the caller has to free the node tree.
*/ */
xmlNodePtr static xmlNodePtr
xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) { xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
/* pointers to generated nodes */ /* pointers to generated nodes */
xmlNodePtr list = NULL, last = NULL, parent = NULL, tmp; xmlNodePtr list = NULL, last = NULL, parent = NULL, tmp;
/* pointers to traversal nodes */ /* pointers to traversal nodes */
xmlNodePtr start, cur, end; xmlNodePtr start, cur, end;
int index, index2; int index1, index2;
if (range == NULL) if (range == NULL)
return(NULL); return(NULL);
@ -1367,7 +1379,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
return(xmlCopyNode(start, 1)); return(xmlCopyNode(start, 1));
cur = start; cur = start;
index = range->index; index1 = range->index;
index2 = range->index2; index2 = range->index2;
while (cur != NULL) { while (cur != NULL) {
if (cur == end) { if (cur == end) {
@ -1379,10 +1391,10 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
tmp = xmlNewTextLen(NULL, 0); tmp = xmlNewTextLen(NULL, 0);
} else { } else {
len = index2; len = index2;
if ((cur == start) && (index > 1)) { if ((cur == start) && (index1 > 1)) {
content += (index - 1); content += (index1 - 1);
len -= (index - 1); len -= (index1 - 1);
index = 0; index1 = 0;
} else { } else {
len = index2; len = index2;
} }
@ -1414,9 +1426,9 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
end = xmlXPtrGetNthChild(cur, index2 - 1); end = xmlXPtrGetNthChild(cur, index2 - 1);
index2 = 0; index2 = 0;
} }
if ((cur == start) && (index > 1)) { if ((cur == start) && (index1 > 1)) {
cur = xmlXPtrGetNthChild(cur, index - 1); cur = xmlXPtrGetNthChild(cur, index1 - 1);
index = 0; index1 = 0;
} else { } else {
cur = cur->children; cur = cur->children;
} }
@ -1433,20 +1445,20 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
if (content == NULL) { if (content == NULL) {
tmp = xmlNewTextLen(NULL, 0); tmp = xmlNewTextLen(NULL, 0);
} else { } else {
if (index > 1) { if (index1 > 1) {
content += (index - 1); content += (index1 - 1);
} }
tmp = xmlNewText(content); tmp = xmlNewText(content);
} }
last = list = tmp; last = list = tmp;
} else { } else {
if ((cur == start) && (index > 1)) { if ((cur == start) && (index1 > 1)) {
tmp = xmlCopyNode(cur, 0); tmp = xmlCopyNode(cur, 0);
list = tmp; list = tmp;
parent = tmp; parent = tmp;
last = NULL; last = NULL;
cur = xmlXPtrGetNthChild(cur, index - 1); cur = xmlXPtrGetNthChild(cur, index1 - 1);
index = 0; index1 = 0;
/* /*
* Now gather the remaining nodes from cur to end * Now gather the remaining nodes from cur to end
*/ */
@ -1580,7 +1592,7 @@ xmlXPtrBuildNodeList(xmlXPathObjectPtr obj) {
* *
* Returns the number of location children * Returns the number of location children
*/ */
int static int
xmlXPtrNbLocChildren(xmlNodePtr node) { xmlXPtrNbLocChildren(xmlNodePtr node) {
int ret = 0; int ret = 0;
if (node == NULL) if (node == NULL)
@ -1619,12 +1631,15 @@ xmlXPtrNbLocChildren(xmlNodePtr node) {
/** /**
* xmlXPtrHereFunction: * xmlXPtrHereFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing here() operation * Function implementing here() operation
* as described in 5.4.3 * as described in 5.4.3
*/ */
void void
xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CHECK_ARITY(0);
if (ctxt->context->here == NULL) if (ctxt->context->here == NULL)
XP_ERROR(XPTR_SYNTAX_ERROR); XP_ERROR(XPTR_SYNTAX_ERROR);
@ -1634,12 +1649,15 @@ xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/** /**
* xmlXPtrOriginFunction: * xmlXPtrOriginFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing origin() operation * Function implementing origin() operation
* as described in 5.4.3 * as described in 5.4.3
*/ */
void void
xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CHECK_ARITY(0);
if (ctxt->context->origin == NULL) if (ctxt->context->origin == NULL)
XP_ERROR(XPTR_SYNTAX_ERROR); XP_ERROR(XPTR_SYNTAX_ERROR);
@ -1649,6 +1667,7 @@ xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/** /**
* xmlXPtrStartPointFunction: * xmlXPtrStartPointFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing start-point() operation * Function implementing start-point() operation
* as described in 5.4.3 * as described in 5.4.3
@ -1740,6 +1759,7 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/** /**
* xmlXPtrEndPointFunction: * xmlXPtrEndPointFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing end-point() operation * Function implementing end-point() operation
* as described in 5.4.3 * as described in 5.4.3
@ -1841,7 +1861,7 @@ xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* *
* Returns a new location or NULL in case of error * Returns a new location or NULL in case of error
*/ */
xmlXPathObjectPtr static xmlXPathObjectPtr
xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) { xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
if (loc == NULL) if (loc == NULL)
return(NULL); return(NULL);
@ -1876,11 +1896,11 @@ xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
case XML_DOCUMENT_NODE: case XML_DOCUMENT_NODE:
case XML_NOTATION_NODE: case XML_NOTATION_NODE:
case XML_HTML_DOCUMENT_NODE: { case XML_HTML_DOCUMENT_NODE: {
int index = xmlXPtrGetIndex(node); int indx = xmlXPtrGetIndex(node);
node = node->parent; node = node->parent;
return(xmlXPtrNewRange(node, index - 1, return(xmlXPtrNewRange(node, indx - 1,
node, index + 1)); node, indx + 1));
} }
default: default:
return(NULL); return(NULL);
@ -1896,6 +1916,7 @@ xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
/** /**
* xmlXPtrRangeFunction: * xmlXPtrRangeFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing the range() function 5.4.3 * Function implementing the range() function 5.4.3
* location-set range(location-set ) * location-set range(location-set )
@ -1956,7 +1977,7 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* *
* Returns a new location or NULL in case of error * Returns a new location or NULL in case of error
*/ */
xmlXPathObjectPtr static xmlXPathObjectPtr
xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) { xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
if (loc == NULL) if (loc == NULL)
return(NULL); return(NULL);
@ -2044,6 +2065,7 @@ xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
/** /**
* xmlXPtrRangeInsideFunction: * xmlXPtrRangeInsideFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing the range-inside() function 5.4.3 * Function implementing the range-inside() function 5.4.3
* location-set range-inside(location-set ) * location-set range-inside(location-set )
@ -2105,6 +2127,7 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
/** /**
* xmlXPtrRangeToFunction: * xmlXPtrRangeToFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Implement the range-to() XPointer function * Implement the range-to() XPointer function
*/ */
@ -2225,25 +2248,25 @@ found:
/** /**
* xmlXPtrAdvanceChar: * xmlXPtrAdvanceChar:
* @node: the node * @node: the node
* @index: the index * @indx: the indx
* @bytes: the number of bytes * @bytes: the number of bytes
* *
* Advance a point of the associated number of bytes (not UTF8 chars) * Advance a point of the associated number of bytes (not UTF8 chars)
* *
* Returns -1 in case of failure, 0 otherwise * Returns -1 in case of failure, 0 otherwise
*/ */
int static int
xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) { xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
xmlNodePtr cur; xmlNodePtr cur;
int pos; int pos;
int len; int len;
if ((node == NULL) || (index == NULL)) if ((node == NULL) || (indx == NULL))
return(-1); return(-1);
cur = *node; cur = *node;
if (cur == NULL) if (cur == NULL)
return(-1); return(-1);
pos = *index; pos = *indx;
while (bytes >= 0) { while (bytes >= 0) {
/* /*
@ -2265,7 +2288,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
if (cur == NULL) { if (cur == NULL) {
*node = NULL; *node = NULL;
*index = 0; *indx = 0;
return(-1); return(-1);
} }
@ -2275,7 +2298,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
if (pos == 0) pos = 1; if (pos == 0) pos = 1;
if (bytes == 0) { if (bytes == 0) {
*node = cur; *node = cur;
*index = pos; *indx = pos;
return(0); return(0);
} }
/* /*
@ -2290,7 +2313,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
#endif #endif
} }
if (pos > len) { if (pos > len) {
/* Strange, the index in the text node is greater than it's len */ /* Strange, the indx in the text node is greater than it's len */
STRANGE STRANGE
pos = len; pos = len;
} }
@ -2301,7 +2324,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
} else if (pos + bytes < len) { } else if (pos + bytes < len) {
pos += bytes; pos += bytes;
*node = cur; *node = cur;
*index = pos; *indx = pos;
return(0); return(0);
} }
} }
@ -2324,7 +2347,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *index, int bytes) {
* of the range and (@end, @endindex) will endicate the end * of the range and (@end, @endindex) will endicate the end
* of the range * of the range
*/ */
int static int
xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex, xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
xmlNodePtr *end, int *endindex) { xmlNodePtr *end, int *endindex) {
xmlNodePtr cur; xmlNodePtr cur;
@ -2422,7 +2445,7 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
* of the range and (@end, @endindex) will endicate the end * of the range and (@end, @endindex) will endicate the end
* of the range * of the range
*/ */
int static int
xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex, xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
xmlNodePtr *end, int *endindex) { xmlNodePtr *end, int *endindex) {
xmlNodePtr cur; xmlNodePtr cur;
@ -2519,15 +2542,15 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
* *
* Returns -1 in case of failure, 0 otherwise * Returns -1 in case of failure, 0 otherwise
*/ */
int static int
xmlXPtrGetLastChar(xmlNodePtr *node, int *index) { xmlXPtrGetLastChar(xmlNodePtr *node, int *indx) {
xmlNodePtr cur; xmlNodePtr cur;
int pos, len = 0; int pos, len = 0;
if ((node == NULL) || (index == NULL)) if ((node == NULL) || (indx == NULL))
return(-1); return(-1);
cur = *node; cur = *node;
pos = *index; pos = *indx;
if (cur == NULL) if (cur == NULL)
return(-1); return(-1);
@ -2557,7 +2580,7 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *index) {
if (cur == NULL) if (cur == NULL)
return(-1); return(-1);
*node = cur; *node = cur;
*index = len; *indx = len;
return(0); return(0);
} }
@ -2565,31 +2588,31 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *index) {
* xmlXPtrGetStartPoint: * xmlXPtrGetStartPoint:
* @obj: an range * @obj: an range
* @node: the resulting node * @node: the resulting node
* @index: the resulting index * @indx: the resulting index
* *
* read the object and return the start point coordinates. * read the object and return the start point coordinates.
* *
* Returns -1 in case of failure, 0 otherwise * Returns -1 in case of failure, 0 otherwise
*/ */
int static int
xmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) { xmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
if ((obj == NULL) || (node == NULL) || (index == NULL)) if ((obj == NULL) || (node == NULL) || (indx == NULL))
return(-1); return(-1);
switch (obj->type) { switch (obj->type) {
case XPATH_POINT: case XPATH_POINT:
*node = obj->user; *node = obj->user;
if (obj->index <= 0) if (obj->index <= 0)
*index = 0; *indx = 0;
else else
*index = obj->index; *indx = obj->index;
return(0); return(0);
case XPATH_RANGE: case XPATH_RANGE:
*node = obj->user; *node = obj->user;
if (obj->index <= 0) if (obj->index <= 0)
*index = 0; *indx = 0;
else else
*index = obj->index; *indx = obj->index;
return(0); return(0);
default: default:
return(-1); return(-1);
@ -2601,31 +2624,31 @@ xmlXPtrGetStartPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) {
* xmlXPtrGetEndPoint: * xmlXPtrGetEndPoint:
* @obj: an range * @obj: an range
* @node: the resulting node * @node: the resulting node
* @index: the resulting index * @indx: the resulting indx
* *
* read the object and return the end point coordinates. * read the object and return the end point coordinates.
* *
* Returns -1 in case of failure, 0 otherwise * Returns -1 in case of failure, 0 otherwise
*/ */
int static int
xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) { xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
if ((obj == NULL) || (node == NULL) || (index == NULL)) if ((obj == NULL) || (node == NULL) || (indx == NULL))
return(-1); return(-1);
switch (obj->type) { switch (obj->type) {
case XPATH_POINT: case XPATH_POINT:
*node = obj->user; *node = obj->user;
if (obj->index <= 0) if (obj->index <= 0)
*index = 0; *indx = 0;
else else
*index = obj->index; *indx = obj->index;
return(0); return(0);
case XPATH_RANGE: case XPATH_RANGE:
*node = obj->user; *node = obj->user;
if (obj->index <= 0) if (obj->index <= 0)
*index = 0; *indx = 0;
else else
*index = obj->index; *indx = obj->index;
return(0); return(0);
default: default:
return(-1); return(-1);
@ -2636,6 +2659,7 @@ xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *index) {
/** /**
* xmlXPtrStringRangeFunction: * xmlXPtrStringRangeFunction:
* @ctxt: the XPointer Parser context * @ctxt: the XPointer Parser context
* @nargs: the number of args
* *
* Function implementing the string-range() function * Function implementing the string-range() function
* range as described in 5.4.2 * range as described in 5.4.2
@ -2678,7 +2702,7 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr string; xmlXPathObjectPtr string;
xmlXPathObjectPtr position = NULL; xmlXPathObjectPtr position = NULL;
xmlXPathObjectPtr number = NULL; xmlXPathObjectPtr number = NULL;
int found, pos, num; int found, pos = 0, num = 0;
/* /*
* Grab the arguments * Grab the arguments
@ -2755,15 +2779,15 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
} else if (xmlXPtrAdvanceChar(&start, &startindex, } else if (xmlXPtrAdvanceChar(&start, &startindex,
pos - 1) == 0) { pos - 1) == 0) {
if ((number != NULL) && (num > 0)) { if ((number != NULL) && (num > 0)) {
int rindex; int rindx;
xmlNodePtr rend; xmlNodePtr rend;
rend = start; rend = start;
rindex = startindex - 1; rindx = startindex - 1;
if (xmlXPtrAdvanceChar(&rend, &rindex, if (xmlXPtrAdvanceChar(&rend, &rindx,
num) == 0) { num) == 0) {
xmlXPtrLocationSetAdd(newset, xmlXPtrLocationSetAdd(newset,
xmlXPtrNewRange(start, startindex, xmlXPtrNewRange(start, startindex,
rend, rindex)); rend, rindx));
} }
} else if ((number != NULL) && (num <= 0)) { } else if ((number != NULL) && (num <= 0)) {
xmlXPtrLocationSetAdd(newset, xmlXPtrLocationSetAdd(newset,

View File

@ -38,11 +38,31 @@ xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2); xmlLocationSetPtr val2);
xmlXPathObjectPtr xmlXPtrNewRange (xmlNodePtr start,
int startindex,
xmlNodePtr end,
int endindex);
xmlXPathObjectPtr xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end);
xmlXPathObjectPtr xmlXPtrNewRangeNodePoint(xmlNodePtr start,
xmlXPathObjectPtr end);
xmlXPathObjectPtr xmlXPtrNewRangePointNode(xmlXPathObjectPtr start,
xmlNodePtr end);
xmlXPathObjectPtr xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end);
xmlXPathObjectPtr xmlXPtrNewLocationSetNodes(xmlNodePtr start,
xmlNodePtr end);
xmlXPathObjectPtr xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
xmlXPathObjectPtr end); xmlXPathObjectPtr end);
xmlXPathObjectPtr xmlXPtrNewCollapsedRange(xmlNodePtr start);
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val); xmlXPathObjectPtr val);
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val); xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
void xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
void xmlXPtrLocationSetRemove(xmlLocationSetPtr cur,
int val);
/* /*
* Functions * Functions