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

fixing bug 118559

This commit is contained in:
William M. Brack
2003-07-31 14:47:38 +00:00
parent 97e018861b
commit 78637da0ea
12 changed files with 82 additions and 40 deletions

View File

@ -1,3 +1,17 @@
Thu Jul 31 22:44:33 HKT 2003 William Brack <wbrack@mmm.com.hk>
Working on bug 118559
* error.c: deleted unused variable
* parserInternals.c: deleted unneeded 'const' qualifier
* parser.c: changed variable type for enum temp storage
* xmlIO.c: changed debugging var to be inside #ifdef
* valid.c: removed unused variable
* HTMLparser.c: removed some unneeded 'const' qualifiers
* xpath.c: added some type casts, removed some unused vars
* xinclude.c: added one type cast
* nanohttp.c: repositioned some #ifdef to avoid unused var
* nanoftp.c: removed unused var
Wed Jul 30 14:57:55 EDT 2003 Daniel Veillard <daniel@veillard.com> Wed Jul 30 14:57:55 EDT 2003 Daniel Veillard <daniel@veillard.com>
* HTMLparser.c: applied a patch from William Brack about * HTMLparser.c: applied a patch from William Brack about

View File

@ -962,7 +962,7 @@ htmlTagLookup(const xmlChar *tag) {
for (i = 0; i < (sizeof(html40ElementTable) / for (i = 0; i < (sizeof(html40ElementTable) /
sizeof(html40ElementTable[0]));i++) { sizeof(html40ElementTable[0]));i++) {
if (!xmlStrcasecmp(tag, BAD_CAST html40ElementTable[i].name)) if (!xmlStrcasecmp(tag, BAD_CAST html40ElementTable[i].name))
return((const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) (const htmlElemDescPtr) &html40ElementTable[i]); return((htmlElemDescPtr) &html40ElementTable[i]);
} }
return(NULL); return(NULL);
} }
@ -1688,7 +1688,7 @@ htmlEntityLookup(const xmlChar *name) {
#ifdef DEBUG #ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", name); xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", name);
#endif #endif
return((const htmlEntityDescPtr) &html40EntitiesTable[i]); return((htmlEntityDescPtr) &html40EntitiesTable[i]);
} }
} }
return(NULL); return(NULL);
@ -1719,7 +1719,7 @@ htmlEntityValueLookup(unsigned int value) {
#ifdef DEBUG #ifdef DEBUG
xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name); xmlGenericError(xmlGenericErrorContext,"Found entity %s\n", html40EntitiesTable[i].name);
#endif #endif
return((const htmlEntityDescPtr) &html40EntitiesTable[i]); return((htmlEntityDescPtr) &html40EntitiesTable[i]);
} }
#ifdef DEBUG #ifdef DEBUG
if (lv > html40EntitiesTable[i].value) { if (lv > html40EntitiesTable[i].value) {
@ -4317,7 +4317,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
* @first: the first char to lookup * @first: the first char to lookup
* @next: the next char to lookup or zero * @next: the next char to lookup or zero
* @third: the next char to lookup or zero * @third: the next char to lookup or zero
* @iscomment: flag to force checking inside comments * @comment: flag to force checking inside comments
* *
* Try to find if a sequence (first, next, third) or just (first next) or * Try to find if a sequence (first, next, third) or just (first next) or
* (first) is available in the input stream. * (first) is available in the input stream.
@ -4331,7 +4331,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
*/ */
static int static int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first, htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
xmlChar next, xmlChar third, int iscomment) { xmlChar next, xmlChar third, int comment) {
int base, len; int base, len;
htmlParserInputPtr in; htmlParserInputPtr in;
const xmlChar *buf; const xmlChar *buf;
@ -4354,7 +4354,7 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
if (third) len -= 2; if (third) len -= 2;
else if (next) len --; else if (next) len --;
for (;base < len;base++) { for (;base < len;base++) {
if (!incomment && (base + 4 < len) && !iscomment) { if (!incomment && (base + 4 < len) && !comment) {
if ((buf[base] == '<') && (buf[base + 1] == '!') && if ((buf[base] == '<') && (buf[base + 1] == '!') &&
(buf[base + 2] == '-') && (buf[base + 3] == '-')) { (buf[base + 2] == '-') && (buf[base + 3] == '-')) {
incomment = 1; incomment = 1;

View File

@ -350,7 +350,6 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
char * str; char * str;
int len = xmlStrlen((const xmlChar *) msg); int len = xmlStrlen((const xmlChar *) msg);
static int had_info = 0; static int had_info = 0;
int need_context = 0;
if ((len > 1) && (msg[len - 2] != ':')) { if ((len > 1) && (msg[len - 2] != ':')) {
if (ctxt != NULL) { if (ctxt != NULL) {
@ -363,7 +362,6 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
} }
} }
xmlGenericError(xmlGenericErrorContext, "validity error: "); xmlGenericError(xmlGenericErrorContext, "validity error: ");
need_context = 1;
had_info = 0; had_info = 0;
} else { } else {
had_info = 1; had_info = 1;

View File

@ -978,14 +978,13 @@ xmlNanoFTPQuit(void *ctx) {
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx; xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
char buf[200]; char buf[200];
int len; int len;
int res;
snprintf(buf, sizeof(buf), "QUIT\r\n"); snprintf(buf, sizeof(buf), "QUIT\r\n");
len = strlen(buf); len = strlen(buf);
#ifdef DEBUG_FTP #ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */ xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
#endif #endif
res = send(ctxt->controlFd, buf, len, 0); send(ctxt->controlFd, buf, len, 0);
return(0); return(0);
} }

View File

@ -1214,9 +1214,11 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
char *bp, *p; char *bp, *p;
int blen, ret; int blen, ret;
int head; int head;
int xmt_bytes;
int nbRedirects = 0; int nbRedirects = 0;
char *redirURL = NULL; char *redirURL = NULL;
#ifdef DEBUG_HTTP
int xmt_bytes;
#endif
if (URL == NULL) return(NULL); if (URL == NULL) return(NULL);
if (method == NULL) method = "GET"; if (method == NULL) method = "GET";
@ -1328,26 +1330,30 @@ retry:
ctxt->outptr = ctxt->out = bp; ctxt->outptr = ctxt->out = bp;
ctxt->state = XML_NANO_HTTP_WRITE; ctxt->state = XML_NANO_HTTP_WRITE;
blen = strlen( ctxt->out ); blen = strlen( ctxt->out );
xmt_bytes = xmlNanoHTTPSend(ctxt, ctxt->out, blen );
#ifdef DEBUG_HTTP #ifdef DEBUG_HTTP
xmt_bytes = xmlNanoHTTPSend(ctxt, ctxt->out, blen );
if ( xmt_bytes != blen ) if ( xmt_bytes != blen )
xmlGenericError( xmlGenericErrorContext, xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n", "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n",
xmt_bytes, blen, xmt_bytes, blen,
"bytes of HTTP headers sent to host", "bytes of HTTP headers sent to host",
ctxt->hostname ); ctxt->hostname );
#else
xmlNanoHTTPSend(ctxt, ctxt->out, blen );
#endif #endif
if ( input != NULL ) { if ( input != NULL ) {
#ifdef DEBUG_HTTP
xmt_bytes = xmlNanoHTTPSend( ctxt, input, ilen ); xmt_bytes = xmlNanoHTTPSend( ctxt, input, ilen );
#ifdef DEBUG_HTTP
if ( xmt_bytes != ilen ) if ( xmt_bytes != ilen )
xmlGenericError( xmlGenericErrorContext, xmlGenericError( xmlGenericErrorContext,
"xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n", "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n",
xmt_bytes, ilen, xmt_bytes, ilen,
"bytes of HTTP content sent to host", "bytes of HTTP content sent to host",
ctxt->hostname ); ctxt->hostname );
#else
xmlNanoHTTPSend( ctxt, input, ilen );
#endif #endif
} }

View File

@ -5111,7 +5111,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
} else if ((RAW == 'I') && (NXT(1) == 'G') && (NXT(2) == 'N') && } else if ((RAW == 'I') && (NXT(1) == 'G') && (NXT(2) == 'N') &&
(NXT(3) == 'O') && (NXT(4) == 'R') && (NXT(5) == 'E')) { (NXT(3) == 'O') && (NXT(4) == 'R') && (NXT(5) == 'E')) {
int state; int state;
int instate; xmlParserInputState instate;
int depth = 0; int depth = 0;
SKIP(6); SKIP(6);

View File

@ -2530,7 +2530,7 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
unsigned long pos; unsigned long pos;
/* Find pos and check to see if node is already in the sequence */ /* Find pos and check to see if node is already in the sequence */
pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (const xmlNodePtr) pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)
info->node); info->node);
if (pos < ctxt->node_seq.length if (pos < ctxt->node_seq.length
&& ctxt->node_seq.buffer[pos].node == info->node) { && ctxt->node_seq.buffer[pos].node == info->node) {

View File

@ -624,7 +624,6 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
*/ */
int int
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) { xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
xmlAutomataStatePtr start;
if ((ctxt == NULL) || (elem == NULL)) if ((ctxt == NULL) || (elem == NULL))
return(0); return(0);
@ -647,7 +646,7 @@ xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
elem->name); elem->name);
return(0); return(0);
} }
start = ctxt->state = xmlAutomataGetInitState(ctxt->am); ctxt->state = xmlAutomataGetInitState(ctxt->am);
xmlValidBuildAContentModel(elem->content, ctxt, elem->name); xmlValidBuildAContentModel(elem->content, ctxt, elem->name);
xmlAutomataSetFinalState(ctxt->am, ctxt->state); xmlAutomataSetFinalState(ctxt->am, ctxt->state);
elem->contModel = xmlAutomataCompile(ctxt->am); elem->contModel = xmlAutomataCompile(ctxt->am);

View File

@ -1436,7 +1436,7 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlChar *URL; xmlChar *URL;
int i; int i;
xmlChar *encoding = NULL; xmlChar *encoding = NULL;
xmlCharEncoding enc = 0; xmlCharEncoding enc = (xmlCharEncoding) 0;
/* /*
* Check the URL and remove any fragment identifier * Check the URL and remove any fragment identifier

View File

@ -721,19 +721,23 @@ append_reverse_ulong( xmlZMemBuff * buff, unsigned long data ) {
static void static void
xmlFreeZMemBuff( xmlZMemBuffPtr buff ) { xmlFreeZMemBuff( xmlZMemBuffPtr buff ) {
#ifdef DEBUG_HTTP
int z_err; int z_err;
#endif
if ( buff == NULL ) if ( buff == NULL )
return; return;
xmlFree( buff->zbuff ); xmlFree( buff->zbuff );
z_err = deflateEnd( &buff->zctrl );
#ifdef DEBUG_HTTP #ifdef DEBUG_HTTP
z_err = deflateEnd( &buff->zctrl );
if ( z_err != Z_OK ) if ( z_err != Z_OK )
xmlGenericError( xmlGenericErrorContext, xmlGenericError( xmlGenericErrorContext,
"xmlFreeZMemBuff: Error releasing zlib context: %d\n", "xmlFreeZMemBuff: Error releasing zlib context: %d\n",
z_err ); z_err );
#endif #else
deflateEnd( &buff->zctrl );
#endif;
xmlFree( buff ); xmlFree( buff );
return; return;

View File

@ -145,7 +145,6 @@ static int stream = 0;
static int chkregister = 0; static int chkregister = 0;
static const char *output = NULL; static const char *output = NULL;
/* /*
* Internal timing routines to remove the necessity to have unix-specific * Internal timing routines to remove the necessity to have unix-specific
* function calls * function calls
@ -755,6 +754,31 @@ static void parseAndPrintFile(char *filename) {
} }
#endif #endif
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
else if ((html) && (push)) {
FILE *f;
f = fopen(filename, "r");
if (f != NULL) {
int res, size = 3;
char chars[4096];
htmlParserCtxtPtr ctxt;
/* if (repeat) */
size = 4096;
res = fread(chars, 1, 4, f);
if (res > 0) {
ctxt = htmlCreatePushParserCtxt(NULL, NULL,
chars, res, filename, 0);
while ((res = fread(chars, 1, size, f)) > 0) {
htmlParseChunk(ctxt, chars, res, 0);
}
htmlParseChunk(ctxt, chars, 0, 1);
doc = ctxt->myDoc;
htmlFreeParserCtxt(ctxt);
}
fclose(f);
}
}
else if (html) { else if (html) {
doc = htmlParseFile(filename, NULL); doc = htmlParseFile(filename, NULL);
} }

34
xpath.c
View File

@ -738,9 +738,9 @@ xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
case XPATH_OP_SORT: case XPATH_OP_SORT:
fprintf(output, "SORT"); break; fprintf(output, "SORT"); break;
case XPATH_OP_COLLECT: { case XPATH_OP_COLLECT: {
xmlXPathAxisVal axis = op->value; xmlXPathAxisVal axis = (xmlXPathAxisVal)op->value;
xmlXPathTestVal test = op->value2; xmlXPathTestVal test = (xmlXPathTestVal)op->value2;
xmlXPathTypeVal type = op->value3; xmlXPathTypeVal type = (xmlXPathTypeVal)op->value3;
const xmlChar *prefix = op->value4; const xmlChar *prefix = op->value4;
const xmlChar *name = op->value5; const xmlChar *name = op->value5;
@ -1945,7 +1945,7 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
*/ */
static xmlNodeSetPtr static xmlNodeSetPtr
xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) { xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
int i, initNr; int i;
if (val2 == NULL) return(val1); if (val2 == NULL) return(val1);
if (val1 == NULL) { if (val1 == NULL) {
@ -1953,7 +1953,6 @@ xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
} }
/* @@ with_ns to check wether namespace nodes should be looked at @@ */ /* @@ with_ns to check wether namespace nodes should be looked at @@ */
initNr = val1->nodeNr;
for (i = 0;i < val2->nodeNr;i++) { for (i = 0;i < val2->nodeNr;i++) {
/* /*
@ -7937,7 +7936,6 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
xmlFree(name); xmlFree(name);
} else if (name != NULL) { } else if (name != NULL) {
int len =xmlStrlen(name); int len =xmlStrlen(name);
int blank = 0;
while (NXT(len) != 0) { while (NXT(len) != 0) {
@ -7950,8 +7948,8 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
lc = 1; lc = 1;
break; break;
} else if (IS_BLANK(NXT(len))) { } else if (IS_BLANK(NXT(len))) {
/* skip to next */ /* ignore blanks */
blank = 1; ;
} else if (NXT(len) == ':') { } else if (NXT(len) == ':') {
#ifdef DEBUG_STEP #ifdef DEBUG_STEP
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
@ -8377,8 +8375,8 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
STRANGE; STRANGE;
return(NULL); return(NULL);
} }
*type = 0; *type = (xmlXPathTypeVal) 0;
*test = 0; *test = (xmlXPathTestVal) 0;
*prefix = NULL; *prefix = NULL;
SKIP_BLANKS; SKIP_BLANKS;
@ -8504,7 +8502,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
*/ */
static xmlXPathAxisVal static xmlXPathAxisVal
xmlXPathIsAxisName(const xmlChar *name) { xmlXPathIsAxisName(const xmlChar *name) {
xmlXPathAxisVal ret = 0; xmlXPathAxisVal ret = (xmlXPathAxisVal) 0;
switch (name[0]) { switch (name[0]) {
case 'a': case 'a':
if (xmlStrEqual(name, BAD_CAST "ancestor")) if (xmlStrEqual(name, BAD_CAST "ancestor"))
@ -8602,7 +8600,7 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
xmlChar *name = NULL; xmlChar *name = NULL;
const xmlChar *prefix = NULL; const xmlChar *prefix = NULL;
xmlXPathTestVal test; xmlXPathTestVal test;
xmlXPathAxisVal axis = 0; xmlXPathAxisVal axis = (xmlXPathAxisVal) 0;
xmlXPathTypeVal type; xmlXPathTypeVal type;
int op1; int op1;
@ -8832,9 +8830,9 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
xmlXPathStepOpPtr op, xmlXPathStepOpPtr op,
xmlNodePtr * first, xmlNodePtr * last) xmlNodePtr * first, xmlNodePtr * last)
{ {
xmlXPathAxisVal axis = op->value; xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value;
xmlXPathTestVal test = op->value2; xmlXPathTestVal test = (xmlXPathTestVal) op->value2;
xmlXPathTypeVal type = op->value3; xmlXPathTypeVal type = (xmlXPathTypeVal) op->value3;
const xmlChar *prefix = op->value4; const xmlChar *prefix = op->value4;
const xmlChar *name = op->value5; const xmlChar *name = op->value5;
const xmlChar *URI = NULL; const xmlChar *URI = NULL;
@ -9253,9 +9251,9 @@ xmlXPathNodeCollectAndTestNth(xmlXPathParserContextPtr ctxt,
xmlXPathStepOpPtr op, int indx, xmlXPathStepOpPtr op, int indx,
xmlNodePtr * first, xmlNodePtr * last) xmlNodePtr * first, xmlNodePtr * last)
{ {
xmlXPathAxisVal axis = op->value; xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value;
xmlXPathTestVal test = op->value2; xmlXPathTestVal test = (xmlXPathTestVal) op->value2;
xmlXPathTypeVal type = op->value3; xmlXPathTypeVal type = (xmlXPathTypeVal) op->value3;
const xmlChar *prefix = op->value4; const xmlChar *prefix = op->value4;
const xmlChar *name = op->value5; const xmlChar *name = op->value5;
const xmlChar *URI = NULL; const xmlChar *URI = NULL;