Fixing #74186, made sure all boolean expressions get fully parenthesized,

* c14n.c: Fixing #74186, made sure all boolean expressions
  get fully parenthesized, ran indent on the output
* configure.in HTMLtree.c SAX.c c14n.c debugXML.c tree.c xpointer.c
  include/libxml/tree.h: also #74186 related, removed the
  --with-buffers option, and all the preprocessor conditional
  sections that were resulting from it.
Daniel
This commit is contained in:
Daniel Veillard 2002-03-11 09:15:32 +00:00
parent bb4e46d5c0
commit 9ff8817e67
9 changed files with 798 additions and 1119 deletions

View File

@ -1,3 +1,12 @@
Mon Mar 11 10:10:30 CET 2002 Daniel Veillard <daniel@veillard.com>
* c14n.c: Fixing #74186, made sure all boolean expressions
get fully parenthesized, ran indent on the output
* configure.in HTMLtree.c SAX.c c14n.c debugXML.c tree.c xpointer.c
include/libxml/tree.h: also #74186 related, removed the
--with-buffers option, and all the preprocessor conditional
sections that were resulting from it.
Sun Mar 10 17:47:58 CET 2002 Daniel Veillard <daniel@veillard.com>
* valid.c: applied patch from Dodji Seketeli fixing an

View File

@ -102,11 +102,7 @@ found_meta:
if ((attr->children != NULL) &&
(attr->children->type == XML_TEXT_NODE) &&
(attr->children->next == NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
value = attr->children->content;
#else
value = xmlBufferContent(attr->children->content);
#endif
if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv"))
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
http = 1;
@ -249,11 +245,7 @@ found_meta:
if ((attr->children != NULL) &&
(attr->children->type == XML_TEXT_NODE) &&
(attr->children->next == NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
value = attr->children->content;
#else
value = xmlBufferContent(attr->children->content);
#endif
if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv"))
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
http = 1;
@ -449,12 +441,7 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
(!xmlStrEqual(cur->parent->name, BAD_CAST "script")))) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
#else
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlBufferWriteCHAR(buf, buffer);
xmlFree(buffer);
@ -468,11 +455,7 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
if (cur->type == HTML_COMMENT_NODE) {
if (cur->content != NULL) {
xmlBufferWriteChar(buf, "<!--");
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
xmlBufferWriteChar(buf, "-->");
}
return;
@ -484,11 +467,7 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
xmlBufferWriteCHAR(buf, cur->name);
if (cur->content != NULL) {
xmlBufferWriteChar(buf, " ");
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
}
xmlBufferWriteChar(buf, ">");
return;
@ -501,11 +480,7 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
}
if (cur->type == HTML_PRESERVE_NODE) {
if (cur->content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
}
return;
}
@ -553,12 +528,7 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
#else
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlBufferWriteCHAR(buf, buffer);
xmlFree(buffer);
@ -944,12 +914,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
(!xmlStrEqual(cur->parent->name, BAD_CAST "script")))) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
#else
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlOutputBufferWriteString(buf, (const char *)buffer);
xmlFree(buffer);
@ -963,12 +928,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
if (cur->type == HTML_COMMENT_NODE) {
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, "<!--");
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *)cur->content);
#else
xmlOutputBufferWriteString(buf, (const char *)
xmlBufferContent(cur->content));
#endif
xmlOutputBufferWriteString(buf, "-->");
}
return;
@ -980,12 +940,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, " ");
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *)cur->content);
#else
xmlOutputBufferWriteString(buf, (const char *)
xmlBufferContent(cur->content));
#endif
}
xmlOutputBufferWriteString(buf, ">");
return;
@ -998,12 +953,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
}
if (cur->type == HTML_PRESERVE_NODE) {
if (cur->content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *)cur->content);
#else
xmlOutputBufferWriteString(buf, (const char *)
xmlBufferContent(cur->content));
#endif
}
return;
}
@ -1058,12 +1008,7 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
* invalids to charrefs
*/
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *) cur->content);
#else
xmlOutputBufferWriteString(buf,
(const char *) xmlBufferContent(cur->content));
#endif
}
if (cur->children != NULL) {
if ((format) && (info != NULL) && (!info->isinline) &&

8
SAX.c
View File

@ -1453,18 +1453,15 @@ characters(void *ctx, const xmlChar *ch, int len)
if (lastChild == NULL) {
/* first node, first time */
xmlNodeAddContentLen(ctxt->node, ch, len);
#ifndef XML_USE_BUFFER_CONTENT
if (ctxt->node->children != NULL) {
ctxt->nodelen = len;
ctxt->nodemem = len + 1;
}
#endif
} else {
int coalesceText = (lastChild != NULL) &&
(lastChild->type == XML_TEXT_NODE) &&
(lastChild->name == xmlStringText);
if ((coalesceText) && (ctxt->nodemem != 0)) {
#ifndef XML_USE_BUFFER_CONTENT
/*
* The whole point of maintaining nodelen and nodemem,
* xmlTextConcat is too costly, i.e. compute length,
@ -1491,9 +1488,6 @@ characters(void *ctx, const xmlChar *ch, int len)
memcpy(&lastChild->content[ctxt->nodelen], ch, len);
ctxt->nodelen += len;
lastChild->content[ctxt->nodelen] = 0;
#else
xmlTextConcat(lastChild, ch, len);
#endif
} else if (coalesceText) {
xmlTextConcat(lastChild, ch, len);
if (ctxt->node->children != NULL) {
@ -1504,12 +1498,10 @@ characters(void *ctx, const xmlChar *ch, int len)
/* Mixed content, first time */
lastChild = xmlNewTextLen(ch, len);
xmlAddChild(ctxt->node, lastChild);
#ifndef XML_USE_BUFFER_CONTENT
if (ctxt->node->children != NULL) {
ctxt->nodelen = len;
ctxt->nodemem = len + 1;
}
#endif
}
}
}

1530
c14n.c

File diff suppressed because it is too large Load Diff

View File

@ -233,17 +233,6 @@ if test "$with_python" != "no" ; then
fi
AM_CONDITIONAL(WITH_PYTHON, test "$PYTHON_INCLUDES" != "")
dnl
dnl Use buffers for content
dnl
AC_ARG_WITH(buffers, [ --with-buffers Use buffers for node content])
if test "$with_buffers" = "yes" ; then
CFLAGS="${CFLAGS} -DXML_USE_BUFFER_CONTENT"
XML_CFLAGS="${XML_CFLAGS} -DXML_USE_BUFFER_CONTENT"
fi
dnl
dnl Tester makes use of readline if present
dnl

View File

@ -695,11 +695,7 @@ xmlDebugDumpOneNode(FILE * output, xmlNodePtr node, int depth)
shift[2 * i + 2] = shift[2 * i + 3] = 0;
fprintf(output, shift);
fprintf(output, "content=");
#ifndef XML_USE_BUFFER_CONTENT
xmlDebugDumpString(output, node->content);
#else
xmlDebugDumpString(output, xmlBufferContent(node->content));
#endif
fprintf(output, "\n");
}
} else {
@ -1105,11 +1101,7 @@ xmlLsCountNode(xmlNodePtr node) {
case XML_PI_NODE:
case XML_COMMENT_NODE:
if (node->content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
ret = xmlStrlen(node->content);
#else
ret = xmlBufferLength(node->content);
#endif
}
break;
case XML_ENTITY_REF_NODE:
@ -1215,11 +1207,7 @@ xmlLsOneNode(FILE *output, xmlNodePtr node) {
break;
case XML_TEXT_NODE:
if (node->content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
xmlDebugDumpString(output, node->content);
#else
xmlDebugDumpString(output, xmlBufferContent(node->content));
#endif
}
break;
case XML_CDATA_SECTION_NODE:

View File

@ -439,11 +439,7 @@ struct _xmlNode {
/* End of common part */
xmlNs *ns; /* pointer to the associated namespace */
#ifndef XML_USE_BUFFER_CONTENT
xmlChar *content; /* the content */
#else
xmlBufferPtr content; /* the content in a buffer */
#endif
struct _xmlAttr *properties;/* properties list */
xmlNs *nsDef; /* namespace definitions on this node */
};

243
tree.c
View File

@ -888,20 +888,11 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
if ((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) {
if (inLine) {
#ifndef XML_USE_BUFFER_CONTENT
ret = xmlStrcat(ret, node->content);
#else
ret = xmlStrcat(ret, xmlBufferContent(node->content));
#endif
} else {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeEntitiesReentrant(doc, node->content);
#else
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(node->content));
#endif
if (buffer != NULL) {
ret = xmlStrcat(ret, buffer);
xmlFree(buffer);
@ -913,11 +904,7 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
if (ent != NULL)
ret = xmlStrcat(ret, ent->content);
else {
#ifndef XML_USE_BUFFER_CONTENT
ret = xmlStrcat(ret, node->content);
#else
ret = xmlStrcat(ret, xmlBufferContent(node->content));
#endif
}
} else {
xmlChar buf[2];
@ -964,20 +951,11 @@ xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
if ((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) {
if (inLine) {
#ifndef XML_USE_BUFFER_CONTENT
ret = xmlStrcat(ret, node->content);
#else
ret = xmlStrcat(ret, xmlBufferContent(node->content));
#endif
} else {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeSpecialChars(doc, node->content);
#else
buffer = xmlEncodeSpecialChars(doc,
xmlBufferContent(node->content));
#endif
if (buffer != NULL) {
ret = xmlStrcat(ret, buffer);
xmlFree(buffer);
@ -989,11 +967,7 @@ xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
if (ent != NULL)
ret = xmlStrcat(ret, ent->content);
else {
#ifndef XML_USE_BUFFER_CONTENT
ret = xmlStrcat(ret, node->content);
#else
ret = xmlStrcat(ret, xmlBufferContent(node->content));
#endif
}
} else {
xmlChar buf[2];
@ -1353,14 +1327,7 @@ xmlNewPI(const xmlChar *name, const xmlChar *content) {
cur->name = xmlStrdup(name);
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrdup(content);
#else
cur->content = xmlBufferCreateSize(0);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, -1);
#endif
}
return(cur);
}
@ -1516,14 +1483,7 @@ xmlNewText(const xmlChar *content) {
cur->name = xmlStringText;
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrdup(content);
#else
cur->content = xmlBufferCreateSize(0);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, -1);
#endif
}
return(cur);
}
@ -1667,20 +1627,7 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
ent = xmlGetDocEntity(doc, cur->name);
if (ent != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = ent->content;
#else
/*
* CJN 11.18.99 this might be a problem, since the xmlBuffer gets
* a copy of this pointer. Let's hope we don't manipulate it
* later
*/
cur->content = xmlBufferCreateSize(0);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
if (ent->content != NULL)
xmlBufferAdd(cur->content, ent->content, -1);
#endif
/*
* The parent pointer in entity is a DTD pointer and thus is NOT
* updated. Not sure if this is 100% correct.
@ -1735,14 +1682,7 @@ xmlNewTextLen(const xmlChar *content, int len) {
cur->name = xmlStringText;
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrndup(content, len);
#else
cur->content = xmlBufferCreateSize(len);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, len);
#endif
}
return(cur);
}
@ -1791,14 +1731,7 @@ xmlNewComment(const xmlChar *content) {
cur->name = xmlStringComment;
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrdup(content);
#else
cur->content = xmlBufferCreateSize(0);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, -1);
#endif
}
return(cur);
}
@ -1830,14 +1763,7 @@ xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len) {
cur->doc = doc;
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrndup(content, len);
#else
cur->content = xmlBufferCreateSize(len);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, len);
#endif
}
return(cur);
}
@ -2020,28 +1946,18 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
if (elem->type == XML_TEXT_NODE) {
if (cur->type == XML_TEXT_NODE) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(cur, elem->content);
#else
xmlNodeAddContent(cur, xmlBufferContent(elem->content));
#endif
xmlFreeNode(elem);
return(cur);
}
if ((cur->next != NULL) && (cur->next->type == XML_TEXT_NODE) &&
(cur->name == cur->next->name)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlChar *tmp;
tmp = xmlStrdup(elem->content);
tmp = xmlStrcat(tmp, cur->next->content);
xmlNodeSetContent(cur->next, tmp);
xmlFree(tmp);
#else
xmlBufferAddHead(cur->next->content,
xmlBufferContent(elem->content),
xmlBufferLength(elem->content));
#endif
xmlFreeNode(elem);
return(cur->next);
}
@ -2108,27 +2024,18 @@ xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
if (elem->type == XML_TEXT_NODE) {
if (cur->type == XML_TEXT_NODE) {
#ifndef XML_USE_BUFFER_CONTENT
xmlChar *tmp;
tmp = xmlStrdup(elem->content);
tmp = xmlStrcat(tmp, cur->content);
xmlNodeSetContent(cur, tmp);
xmlFree(tmp);
#else
xmlBufferAddHead(cur->content, xmlBufferContent(elem->content),
xmlBufferLength(elem->content));
#endif
xmlFreeNode(elem);
return(cur);
}
if ((cur->prev != NULL) && (cur->prev->type == XML_TEXT_NODE) &&
(cur->name == cur->prev->name)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(cur->prev, elem->content);
#else
xmlNodeAddContent(cur->prev, xmlBufferContent(elem->content));
#endif
xmlFreeNode(elem);
return(cur->prev);
}
@ -2217,11 +2124,7 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
xmlUnlinkNode(elem);
if ((cur->type == XML_TEXT_NODE) && (elem->type == XML_TEXT_NODE)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(cur, elem->content);
#else
xmlNodeAddContent(cur, xmlBufferContent(elem->content));
#endif
xmlFreeNode(elem);
return(cur);
}
@ -2290,11 +2193,7 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
if ((cur->type == XML_TEXT_NODE) &&
(parent->last->type == XML_TEXT_NODE) &&
(cur->name == parent->last->name)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(parent->last, cur->content);
#else
xmlNodeAddContent(parent->last, xmlBufferContent(cur->content));
#endif
/*
* if it's the only child, nothing more to be done.
*/
@ -2365,21 +2264,13 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
if (cur->type == XML_TEXT_NODE) {
if ((parent->type == XML_TEXT_NODE) &&
(parent->content != NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(parent, cur->content);
#else
xmlNodeAddContent(parent, xmlBufferContent(cur->content));
#endif
xmlFreeNode(cur);
return(parent);
}
if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE) &&
(parent->last->name == cur->name)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(parent->last, cur->content);
#else
xmlNodeAddContent(parent->last, xmlBufferContent(cur->content));
#endif
xmlFreeNode(cur);
return(parent->last);
}
@ -2398,11 +2289,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
*/
if ((parent->type == XML_TEXT_NODE) &&
(parent->content != NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(parent, cur->content);
#else
xmlNodeAddContent(parent, xmlBufferContent(cur->content));
#endif
xmlFreeNode(cur);
return(parent);
}
@ -2496,11 +2383,7 @@ xmlFreeNodeList(xmlNodePtr cur) {
(cur->type != XML_XINCLUDE_START) &&
(cur->type != XML_XINCLUDE_END) &&
(cur->type != XML_ENTITY_REF_NODE)) {
#ifndef XML_USE_BUFFER_CONTENT
if (cur->content != NULL) xmlFree(cur->content);
#else
if (cur->content != NULL) xmlBufferFree(cur->content);
#endif
}
if (((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_XINCLUDE_START) ||
@ -2574,11 +2457,7 @@ xmlFreeNode(xmlNodePtr cur) {
(cur->type != XML_ENTITY_REF_NODE) &&
(cur->type != XML_XINCLUDE_END) &&
(cur->type != XML_XINCLUDE_START)) {
#ifndef XML_USE_BUFFER_CONTENT
xmlFree(cur->content);
#else
xmlBufferFree(cur->content);
#endif
}
/*
@ -3014,16 +2893,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
(node->type != XML_ENTITY_REF_NODE) &&
(node->type != XML_XINCLUDE_END) &&
(node->type != XML_XINCLUDE_START)) {
#ifndef XML_USE_BUFFER_CONTENT
ret->content = xmlStrdup(node->content);
#else
ret->content = xmlBufferCreateSize(xmlBufferLength(node->content));
xmlBufferSetAllocationScheme(ret->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(ret->content,
xmlBufferContent(node->content),
xmlBufferLength(node->content));
#endif
}else{
if (node->type == XML_ELEMENT_NODE)
ret->content = (void*)(long) node->content;
@ -3885,12 +3755,7 @@ xmlNodeGetContent(xmlNodePtr cur) {
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
if (tmp->content != NULL)
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferCat(buffer, tmp->content);
#else
xmlBufferCat(buffer,
xmlBufferContent(tmp->content));
#endif
break;
case XML_ENTITY_REF_NODE: {
xmlEntityPtr ent;
@ -3949,11 +3814,7 @@ xmlNodeGetContent(xmlNodePtr cur) {
case XML_COMMENT_NODE:
case XML_PI_NODE:
if (cur->content != NULL)
#ifndef XML_USE_BUFFER_CONTENT
return(xmlStrdup(cur->content));
#else
return(xmlStrdup(xmlBufferContent(cur->content)));
#endif
return(NULL);
case XML_ENTITY_REF_NODE:
/*
@ -3987,11 +3848,7 @@ xmlNodeGetContent(xmlNodePtr cur) {
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
if (cur->content != NULL)
#ifndef XML_USE_BUFFER_CONTENT
return(xmlStrdup(cur->content));
#else
return(xmlStrdup(xmlBufferContent(cur->content)));
#endif
return(xmlStrdup(cur->content));
return(NULL);
}
return(NULL);
@ -4028,23 +3885,12 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
case XML_PI_NODE:
case XML_COMMENT_NODE:
if (cur->content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
xmlFree(cur->content);
#else
xmlBufferFree(cur->content);
#endif
}
if (cur->children != NULL) xmlFreeNodeList(cur->children);
cur->last = cur->children = NULL;
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrdup(content);
#else
cur->content = xmlBufferCreateSize(0);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, -1);
#endif
} else
cur->content = NULL;
break;
@ -4108,23 +3954,12 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
case XML_COMMENT_NODE:
case XML_NOTATION_NODE:
if (cur->content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
xmlFree(cur->content);
#else
xmlBufferFree(cur->content);
#endif
}
if (cur->children != NULL) xmlFreeNodeList(cur->children);
cur->children = cur->last = NULL;
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrndup(content, len);
#else
cur->content = xmlBufferCreateSize(len);
xmlBufferSetAllocationScheme(cur->content,
xmlGetBufferAllocationScheme());
xmlBufferAdd(cur->content, content, len);
#endif
} else
cur->content = NULL;
break;
@ -4196,11 +4031,7 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
case XML_COMMENT_NODE:
case XML_NOTATION_NODE:
if (content != NULL) {
#ifndef XML_USE_BUFFER_CONTENT
cur->content = xmlStrncat(cur->content, content, len);
#else
xmlBufferAdd(cur->content, content, len);
#endif
}
case XML_DOCUMENT_NODE:
case XML_DTD_NODE:
@ -4259,11 +4090,7 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
if (second->type != XML_TEXT_NODE) return(first);
if (second->name != first->name)
return(first);
#ifndef XML_USE_BUFFER_CONTENT
xmlNodeAddContent(first, second->content);
#else
xmlNodeAddContent(first, xmlBufferContent(second->content));
#endif
xmlUnlinkNode(second);
xmlFreeNode(second);
return(first);
@ -5216,11 +5043,7 @@ xmlIsBlankNode(xmlNodePtr node) {
(node->type != XML_CDATA_SECTION_NODE))
return(0);
if (node->content == NULL) return(1);
#ifndef XML_USE_BUFFER_CONTENT
cur = node->content;
#else
cur = xmlBufferContent(node->content);
#endif
while (*cur != 0) {
if (!IS_BLANK(*cur)) return(0);
cur++;
@ -5250,11 +5073,7 @@ xmlTextConcat(xmlNodePtr node, const xmlChar *content, int len) {
#endif
return;
}
#ifndef XML_USE_BUFFER_CONTENT
node->content = xmlStrncat(node->content, content, len);
#else
xmlBufferAdd(node->content, content, len);
#endif
}
/************************************************************************
@ -6145,12 +5964,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
(cur->name != xmlStringTextNoenc)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
#else
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlBufferWriteCHAR(buf, buffer);
xmlFree(buffer);
@ -6159,11 +5973,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
/*
* Disable escaping, needed for XSLT
*/
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
}
}
return;
@ -6173,11 +5983,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
xmlBufferWriteCHAR(buf, cur->name);
if (cur->content != NULL) {
xmlBufferWriteChar(buf, " ");
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
}
xmlBufferWriteChar(buf, "?>");
return;
@ -6185,11 +5991,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
if (cur->type == XML_COMMENT_NODE) {
if (cur->content != NULL) {
xmlBufferWriteChar(buf, "<!--");
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
xmlBufferWriteChar(buf, "-->");
}
return;
@ -6203,11 +6005,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
if (cur->type == XML_CDATA_SECTION_NODE) {
xmlBufferWriteChar(buf, "<![CDATA[");
if (cur->content != NULL)
#ifndef XML_USE_BUFFER_CONTENT
xmlBufferWriteCHAR(buf, cur->content);
#else
xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content));
#endif
xmlBufferWriteChar(buf, "]]>");
return;
}
@ -6245,12 +6043,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
#else
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlBufferWriteCHAR(buf, buffer);
xmlFree(buffer);
@ -6551,19 +6344,10 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
(cur->name != xmlStringTextNoenc)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
if (encoding == NULL)
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
else
buffer = xmlEncodeSpecialChars(doc, cur->content);
#else
if (encoding == NULL)
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
else
buffer = xmlEncodeSpecialChars(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlOutputBufferWriteString(buf, (const char *)buffer);
xmlFree(buffer);
@ -6572,11 +6356,7 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
/*
* Disable escaping, needed for XSLT
*/
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *) cur->content);
#else
xmlOutputBufferWriteString(buf, xmlBufferContent(cur->content));
#endif
}
}
@ -6588,11 +6368,7 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, " ");
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *)cur->content);
#else
xmlOutputBufferWriteString(buf, (const char *)xmlBufferContent(cur->content));
#endif
}
xmlOutputBufferWriteString(buf, "?>");
} else {
@ -6605,11 +6381,7 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
if (cur->type == XML_COMMENT_NODE) {
if (cur->content != NULL) {
xmlOutputBufferWriteString(buf, "<!--");
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *)cur->content);
#else
xmlOutputBufferWriteString(buf, (const char *)xmlBufferContent(cur->content));
#endif
xmlOutputBufferWriteString(buf, "-->");
}
return;
@ -6623,11 +6395,7 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
if (cur->type == XML_CDATA_SECTION_NODE) {
xmlOutputBufferWriteString(buf, "<![CDATA[");
if (cur->content != NULL)
#ifndef XML_USE_BUFFER_CONTENT
xmlOutputBufferWriteString(buf, (const char *)cur->content);
#else
xmlOutputBufferWriteString(buf, (const char *)xmlBufferContent(cur->content));
#endif
xmlOutputBufferWriteString(buf, "]]>");
return;
}
@ -6664,19 +6432,10 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
if (encoding == NULL)
buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
else
buffer = xmlEncodeSpecialChars(doc, cur->content);
#else
if (encoding == NULL)
buffer = xmlEncodeEntitiesReentrant(doc,
xmlBufferContent(cur->content));
else
buffer = xmlEncodeSpecialChars(doc,
xmlBufferContent(cur->content));
#endif
if (buffer != NULL) {
xmlOutputBufferWriteString(buf, (const char *)buffer);
xmlFree(buffer);

View File

@ -1628,11 +1628,7 @@ xmlXPtrNbLocChildren(xmlNodePtr node) {
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
#ifndef XML_USE_BUFFER_CONTENT
ret = xmlStrlen(node->content);
#else
ret = xmlBufferLength(node->content);
#endif
break;
default:
return(-1);
@ -2007,13 +2003,8 @@ xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
if (node->content == NULL) {
return(xmlXPtrNewRange(node, 0, node, 0));
} else {
#ifndef XML_USE_BUFFER_CONTENT
return(xmlXPtrNewRange(node, 0, node,
xmlStrlen(node->content)));
#else
return(xmlXPtrNewRange(node, 0, node,
xmlBufferLength(node->content)));
#endif
}
}
case XML_ATTRIBUTE_NODE:
@ -2044,13 +2035,8 @@ xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
if (node->content == NULL) {
return(xmlXPtrNewRange(node, 0, node, 0));
} else {
#ifndef XML_USE_BUFFER_CONTENT
return(xmlXPtrNewRange(node, 0, node,
xmlStrlen(node->content)));
#else
return(xmlXPtrNewRange(node, 0, node,
xmlBufferLength(node->content)));
#endif
}
}
case XML_ATTRIBUTE_NODE:
@ -2319,11 +2305,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
len = 0;
if ((cur->type != XML_ELEMENT_NODE) &&
(cur->content != NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
len = xmlStrlen(cur->content);
#else
len = xmlBufferLength(cur->content);
#endif
}
if (pos > len) {
/* Strange, the indx in the text node is greater than it's len */
@ -2386,18 +2368,9 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
return(0);
if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
len = xmlStrlen(cur->content);
#else
len = xmlBufferLength(cur->content);
#endif
if (len >= pos + stringlen) {
#ifndef XML_USE_BUFFER_CONTENT
match = (!xmlStrncmp(&cur->content[pos], string, stringlen));
#else
len = (!xmlStrncmp(&xmlBufferContent(cur->content)[pos],
string, stringlen));
#endif
if (match) {
#ifdef DEBUG_RANGES
xmlGenericError(xmlGenericErrorContext,
@ -2414,12 +2387,7 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
}
} else {
int sub = len - pos;
#ifndef XML_USE_BUFFER_CONTENT
match = (!xmlStrncmp(&cur->content[pos], string, sub));
#else
len = (!xmlStrncmp(&xmlBufferContent(cur->content)[pos],
string, sub));
#endif
if (match) {
#ifdef DEBUG_RANGES
xmlGenericError(xmlGenericErrorContext,
@ -2482,19 +2450,10 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
while (cur != NULL) {
if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
len = xmlStrlen(cur->content);
#else
len = xmlBufferLength(cur->content);
#endif
while (pos <= len) {
if (first != 0) {
#ifndef XML_USE_BUFFER_CONTENT
str = xmlStrchr(&cur->content[pos], first);
#else
str = xmlStrchr(&xmlBufferContent(cur->content)[pos],
first);
#endif
if (str != NULL) {
pos = (str - (xmlChar *)(cur->content));
#ifdef DEBUG_RANGES
@ -2580,11 +2539,7 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *indx) {
cur = cur->last;
else if ((cur->type != XML_ELEMENT_NODE) &&
(cur->content != NULL)) {
#ifndef XML_USE_BUFFER_CONTENT
len = xmlStrlen(cur->content);
#else
len = xmlBufferLength(cur->content);
#endif
break;
} else {
return(-1);