diff options
author | Mike Hommey <mh@glandium.org> | 2004-10-13 08:57:08 +0000 |
---|---|---|
committer | Mike Hommey <mh@glandium.org> | 2004-10-13 08:57:08 +0000 |
commit | 0732be88d054db33fa0ca479eab9988c8e6be42e (patch) | |
tree | 8b9cf70e04bd32115caebeb74cb0d841d1eced3b /parser.c | |
parent | 09deb06614c3408ec0816a3c88920138bae2083c (diff) | |
download | libxml2-0732be88d054db33fa0ca479eab9988c8e6be42e.tar.gz |
Load /tmp/tmp.zzO3vU/libxml2-2.6.14 intoupstream/2.6.14
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 123 |
1 files changed, 84 insertions, 39 deletions
@@ -645,8 +645,8 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt, } /* - * plit the element name into prefix:localname , the string found - * are within the DTD and hen not associated to namespace names. + * split the element name into prefix:localname , the string found + * are within the DTD and then not associated to namespace names. */ name = xmlSplitQName3(fullname, &len); if (name == NULL) { @@ -663,17 +663,20 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt, defaults = xmlHashLookup2(ctxt->attsDefault, name, prefix); if (defaults == NULL) { defaults = (xmlDefAttrsPtr) xmlMalloc(sizeof(xmlDefAttrs) + - 12 * sizeof(const xmlChar *)); + (4 * 4) * sizeof(const xmlChar *)); if (defaults == NULL) goto mem_error; - defaults->maxAttrs = 4; defaults->nbAttrs = 0; + defaults->maxAttrs = 4; xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, defaults, NULL); } else if (defaults->nbAttrs >= defaults->maxAttrs) { - defaults = (xmlDefAttrsPtr) xmlRealloc(defaults, sizeof(xmlDefAttrs) + + xmlDefAttrsPtr temp; + + temp = (xmlDefAttrsPtr) xmlRealloc(defaults, sizeof(xmlDefAttrs) + (2 * defaults->maxAttrs * 4) * sizeof(const xmlChar *)); - if (defaults == NULL) + if (temp == NULL) goto mem_error; + defaults = temp; defaults->maxAttrs *= 2; xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, defaults, NULL); } @@ -943,7 +946,7 @@ mem_error: * * Returns 0 in case of error, the index in the stack otherwise */ -extern int +int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value) { if (ctxt->inputNr >= ctxt->inputMax) { @@ -969,7 +972,7 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value) * * Returns the input just removed */ -extern xmlParserInputPtr +xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt) { xmlParserInputPtr ret; @@ -994,7 +997,7 @@ inputPop(xmlParserCtxtPtr ctxt) * * Returns 0 in case of error, the index in the stack otherwise */ -extern int +int nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value) { if (ctxt->nodeNr >= ctxt->nodeMax) { @@ -1027,7 +1030,7 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value) * * Returns the node just removed */ -extern xmlNodePtr +xmlNodePtr nodePop(xmlParserCtxtPtr ctxt) { xmlNodePtr ret; @@ -1126,7 +1129,7 @@ nameNsPop(xmlParserCtxtPtr ctxt) * * Returns -1 in case of error, the index in the stack otherwise */ -extern int +int namePush(xmlParserCtxtPtr ctxt, const xmlChar * value) { if (ctxt->nameNr >= ctxt->nameMax) { @@ -1156,7 +1159,7 @@ mem_error: * * Returns the name just removed */ -extern const xmlChar * +const xmlChar * namePop(xmlParserCtxtPtr ctxt) { const xmlChar *ret; @@ -2212,13 +2215,17 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { memcpy(buffer, buf, len); while ((c != 0) && (c != ':')) { /* tested bigname.xml */ if (len + 10 > max) { + xmlChar *tmp; + max *= 2; - buffer = (xmlChar *) xmlRealloc(buffer, + tmp = (xmlChar *) xmlRealloc(buffer, max * sizeof(xmlChar)); - if (buffer == NULL) { + if (tmp == NULL) { + xmlFree(tmp); xmlErrMemory(ctxt, NULL); return(NULL); } + buffer = tmp; } buffer[len++] = c; c = *cur++; @@ -2285,13 +2292,17 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) { memcpy(buffer, buf, len); while (c != 0) { /* tested bigname2.xml */ if (len + 10 > max) { + xmlChar *tmp; + max *= 2; - buffer = (xmlChar *) xmlRealloc(buffer, + tmp = (xmlChar *) xmlRealloc(buffer, max * sizeof(xmlChar)); - if (buffer == NULL) { + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buffer); return(NULL); } + buffer = tmp; } buffer[len++] = c; c = *cur++; @@ -2331,7 +2342,7 @@ static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, * * [5] Name ::= (Letter | '_' | ':') (NameChar)* * - * [6] Names ::= Name (S Name)* + * [6] Names ::= Name (#x20 Name)* * * Returns the Name parsed or NULL */ @@ -2456,7 +2467,7 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) { * * [5] Name ::= (Letter | '_' | ':') (NameChar)* * - * [6] Names ::= Name (S Name)* + * [6] Names ::= Name (#x20 Name)* * * Returns the Name parsed or NULL. The @str pointer * is updated to the current location in the string. @@ -2504,13 +2515,16 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) { (IS_COMBINING(c)) || (IS_EXTENDER(c))) { if (len + 10 > max) { + xmlChar *tmp; max *= 2; - buffer = (xmlChar *) xmlRealloc(buffer, + tmp = (xmlChar *) xmlRealloc(buffer, max * sizeof(xmlChar)); - if (buffer == NULL) { + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buffer); return(NULL); } + buffer = tmp; } COPY_BUF(l,buffer,len,c); cur += l; @@ -2533,7 +2547,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) { * * [7] Nmtoken ::= (NameChar)+ * - * [8] Nmtokens ::= Nmtoken (S Nmtoken)* + * [8] Nmtokens ::= Nmtoken (#x20 Nmtoken)* * * Returns the Nmtoken parsed or NULL */ @@ -2584,13 +2598,17 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) { GROW; } if (len + 10 > max) { + xmlChar *tmp; + max *= 2; - buffer = (xmlChar *) xmlRealloc(buffer, + tmp = (xmlChar *) xmlRealloc(buffer, max * sizeof(xmlChar)); - if (buffer == NULL) { + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buffer); return(NULL); } + buffer = tmp; } COPY_BUF(l,buffer,len,c); NEXTL(l); @@ -2662,12 +2680,16 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) { while ((IS_CHAR(c)) && ((c != stop) || /* checked */ (ctxt->input != input))) { if (len + 5 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buf); return(NULL); } + buf = tmp; } COPY_BUF(l,buf,len,c); NEXTL(l); @@ -3015,13 +3037,17 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) { cur = CUR_CHAR(l); while ((IS_CHAR(cur)) && (cur != stop)) { /* checked */ if (len + 5 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlFree(buf); xmlErrMemory(ctxt, NULL); ctxt->instate = (xmlParserInputState) state; return(NULL); } + buf = tmp; } count++; if (count > 50) { @@ -3088,12 +3114,16 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) { cur = CUR; while ((IS_PUBIDCHAR_CH(cur)) && (cur != stop)) { /* checked */ if (len + 1 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buf); return(NULL); } + buf = tmp; } buf[len++] = cur; count++; @@ -3702,13 +3732,17 @@ xmlParsePI(xmlParserCtxtPtr ctxt) { while (IS_CHAR(cur) && /* checked */ ((cur != '?') || (NXT(1) != '>'))) { if (len + 5 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buf); ctxt->instate = state; return; } + buf = tmp; } count++; if (count > 50) { @@ -7437,6 +7471,7 @@ failed: if (!IS_BLANK_CH(RAW)) { xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "attributes construct error\n"); + break; } SKIP_BLANKS; if ((cons == ctxt->input->consumed) && (q == CUR_PTR) && @@ -7635,8 +7670,7 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, } SKIP(2); - if ((tlen > 0) && (strncmp(ctxt->input->cur, - (const char *)ctxt->name, tlen) == 0)) { + if ((tlen > 0) && (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) { if (ctxt->input->cur[tlen] == '>') { ctxt->input->cur += tlen + 1; goto done; @@ -7741,12 +7775,16 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) { while (IS_CHAR(cur) && ((r != ']') || (s != ']') || (cur != '>'))) { if (len + 5 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { + xmlFree(buf); xmlErrMemory(ctxt, NULL); return; } + buf = tmp; } COPY_BUF(rl,buf,len,r); r = s; @@ -8059,12 +8097,15 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) { (cur == '_') || (cur == '.') || (cur == ':') || (cur == '-')) { if (len + 1 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); return(NULL); } + buf = tmp; } buf[len++] = cur; NEXT; @@ -8156,12 +8197,16 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) { (cur == '.') || (cur == '_') || (cur == '-')) { if (len + 1 >= size) { + xmlChar *tmp; + size *= 2; - buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (buf == NULL) { + tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); + if (tmp == NULL) { xmlErrMemory(ctxt, NULL); + xmlFree(buf); return(NULL); } + buf = tmp; } buf[len++] = cur; NEXT; |