From f6eea27b3801f0d2a5b9977098d99880d0c30d42 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 18 Jan 2001 12:17:12 +0000 Subject: [PATCH] Bugfixes, extesion and optimizations for XSLT: - xpath.c: removed an error found by XSLT usage - tree.c parserInternals.h: use a predefined static string for text and comment nodes, avoid freeing them in xmlFreeNode, exported the string name in parserInternals.h and added another value to disable encoding at output (for XSLT), gain memory, time. Daniel --- ChangeLog | 9 +++++++ configure.in | 15 +++++++++++ include/libxml/parserInternals.h | 3 +++ parserInternals.h | 3 +++ tree.c | 44 ++++++++++++++++++++++---------- xpath.c | 5 ++-- 6 files changed, 64 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index d6d70216..357c0152 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Jan 18 13:11:50 CET 2001 Daniel Veillard + + * xpath.c: removed an error found by XSLT usage + * tree.c parserInternals.h: use a predefined static string + for text and comment nodes, avoid freeing them in xmlFreeNode, + exported the string name in parserInternals.h and added + another value to disable encoding at output (for XSLT), + gain memory, time. + Wed Jan 17 09:15:16 CET 2001 Daniel Veillard * win32/README.MSDev win32/libxml2/libxml2_a.dsp diff --git a/configure.in b/configure.in index 0894a72b..bf17b751 100644 --- a/configure.in +++ b/configure.in @@ -221,6 +221,21 @@ LDFLAGS=${_ldflags} AC_SUBST(RDL_LIBS) +dnl +dnl specific tests to setup DV's devel environment with debug etc ... +dnl +if test "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XML" ; then + if test "${with_mem_debug}" = "" ; then + with_mem_debug="yes" + fi +dnl if test "${with_docbook}" = "" ; then +dnl with_docbook="yes" +dnl fi + if test "${with_xptr}" = "" ; then + with_xptr="yes" + fi + CFLAGS="-Wall -g -pedantic" +fi dnl dnl Aloow to disable various pieces dnl diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h index 6588bd6c..b0dda648 100644 --- a/include/libxml/parserInternals.h +++ b/include/libxml/parserInternals.h @@ -112,6 +112,9 @@ LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue; LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue; LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue; LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue; +LIBXML_DLL_IMPORT extern xmlChar xmlStringText[]; +LIBXML_DLL_IMPORT extern xmlChar xmlStringTextNoenc[]; +LIBXML_DLL_IMPORT extern xmlChar xmlStringComment[]; /* * Function to finish teh work of the macros where needed diff --git a/parserInternals.h b/parserInternals.h index 6588bd6c..b0dda648 100644 --- a/parserInternals.h +++ b/parserInternals.h @@ -112,6 +112,9 @@ LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue; LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue; LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue; LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue; +LIBXML_DLL_IMPORT extern xmlChar xmlStringText[]; +LIBXML_DLL_IMPORT extern xmlChar xmlStringTextNoenc[]; +LIBXML_DLL_IMPORT extern xmlChar xmlStringComment[]; /* * Function to finish teh work of the macros where needed diff --git a/tree.c b/tree.c index 3c4dd0fc..fbe7269c 100644 --- a/tree.c +++ b/tree.c @@ -37,8 +37,10 @@ #include #include -static xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; -static xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 }; +xmlChar xmlStringText[] = { 't', 'e', 'x', 't', 0 }; +xmlChar xmlStringTextNoenc[] = + { 't', 'e', 'x', 't', 'n', 'o', 'e', 'n', 'c', 0 }; +xmlChar xmlStringComment[] = { 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 }; int oldXMLWDcompatibility = 0; int xmlIndentTreeOutput = 0; xmlBufferAllocationScheme xmlBufferAllocScheme = XML_BUFFER_ALLOC_EXACT; @@ -1347,7 +1349,7 @@ xmlNewText(const xmlChar *content) { memset(cur, 0, sizeof(xmlNode)); cur->type = XML_TEXT_NODE; - cur->name = xmlStrdup(xmlStringText); + cur->name = xmlStringText; if (content != NULL) { #ifndef XML_USE_BUFFER_CONTENT cur->content = xmlStrdup(content); @@ -1566,7 +1568,7 @@ xmlNewTextLen(const xmlChar *content, int len) { memset(cur, 0, sizeof(xmlNode)); cur->type = XML_TEXT_NODE; - cur->name = xmlStrdup(xmlStringText); + cur->name = xmlStringText; if (content != NULL) { #ifndef XML_USE_BUFFER_CONTENT cur->content = xmlStrndup(content, len); @@ -1622,7 +1624,7 @@ xmlNewComment(const xmlChar *content) { memset(cur, 0, sizeof(xmlNode)); cur->type = XML_COMMENT_NODE; - cur->name = xmlStrdup(xmlStringComment); + cur->name = xmlStringComment; if (content != NULL) { #ifndef XML_USE_BUFFER_CONTENT cur->content = xmlStrdup(content); @@ -2286,7 +2288,11 @@ xmlFreeNode(xmlNodePtr cur) { #else if (cur->content != NULL) xmlBufferFree(cur->content); #endif - if (cur->name != NULL) xmlFree((char *) cur->name); + if ((cur->name != NULL) && + (cur->name != xmlStringText) && + (cur->name != xmlStringTextNoenc) && + (cur->name != xmlStringComment)) + xmlFree((char *) cur->name); if (cur->nsDef != NULL) xmlFreeNsList(cur->nsDef); memset(cur, -1, sizeof(xmlNode)); xmlFree(cur); @@ -5006,17 +5012,29 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, } if (cur->type == XML_TEXT_NODE) { if (cur->content != NULL) { - xmlChar *buffer; + if ((cur->name == xmlStringText) || + (cur->name != xmlStringTextNoenc)) { + xmlChar *buffer; #ifndef XML_USE_BUFFER_CONTENT - buffer = xmlEncodeEntitiesReentrant(doc, cur->content); + buffer = xmlEncodeEntitiesReentrant(doc, cur->content); #else - buffer = xmlEncodeEntitiesReentrant(doc, - xmlBufferContent(cur->content)); + buffer = xmlEncodeEntitiesReentrant(doc, + xmlBufferContent(cur->content)); +#endif + if (buffer != NULL) { + xmlBufferWriteCHAR(buf, buffer); + xmlFree(buffer); + } + } else { + /* + * Disable escaping, needed for XSLT + */ +#ifndef XML_USE_BUFFER_CONTENT + xmlBufferWriteCHAR(buf, cur->content); +#else + xmlBufferWriteCHAR(buf, xmlBufferContent(cur->content)); #endif - if (buffer != NULL) { - xmlBufferWriteCHAR(buf, buffer); - xmlFree(buffer); } } return; diff --git a/xpath.c b/xpath.c index 45976a58..c63266b7 100644 --- a/xpath.c +++ b/xpath.c @@ -4326,7 +4326,7 @@ xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) { /** * xmlXPathParseName: - * @ctxt: the XPointer Parser context + * @ctxt: the XPath Parser context * * parse an XML name * @@ -4863,7 +4863,8 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) { lc = 1; break; } else { - XP_ERROR(XPATH_EXPR_ERROR); + lc = 1; + break; } len++; }