From 5a2b697af8bf01efef3693ff2d531d62ee8d732f Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Sat, 20 Jan 2001 21:15:50 +0000 Subject: [PATCH] - xpath.c: seems I finally killed that ugly path evaluation context bug (tagged 9999 in case is is wrong) Daniel --- ChangeLog | 5 +++++ include/libxml/tree.h | 4 ++++ tree.h | 4 ++++ xpath.c | 15 +++++++++++++-- xpointer.c | 2 ++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40566c46..4a5fbe4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jan 19 18:15:50 CET 2001 Daniel Veillard + + * xpath.c: seems I finally killed that ugly path evaluation + context bug (tagged 9999 in case is is wrong) + Fri Jan 19 06:30:38 CET 2001 Daniel Veillard * xpath.[ch] xpathInternals.h: added xmlXPathRegisterVariableLookup() diff --git a/include/libxml/tree.h b/include/libxml/tree.h index 536f8591..de7cf796 100644 --- a/include/libxml/tree.h +++ b/include/libxml/tree.h @@ -570,6 +570,10 @@ xmlChar * xmlGetProp (xmlNodePtr node, const xmlChar *name); xmlAttrPtr xmlHasProp (xmlNodePtr node, const xmlChar *name); +xmlAttrPtr xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); xmlChar * xmlGetNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace); diff --git a/tree.h b/tree.h index 536f8591..de7cf796 100644 --- a/tree.h +++ b/tree.h @@ -570,6 +570,10 @@ xmlChar * xmlGetProp (xmlNodePtr node, const xmlChar *name); xmlAttrPtr xmlHasProp (xmlNodePtr node, const xmlChar *name); +xmlAttrPtr xmlSetNsProp (xmlNodePtr node, + xmlNsPtr ns, + const xmlChar *name, + const xmlChar *value); xmlChar * xmlGetNsProp (xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace); diff --git a/xpath.c b/xpath.c index a1d407b5..9abbd5e9 100644 --- a/xpath.c +++ b/xpath.c @@ -1241,7 +1241,10 @@ xmlXPathNewString(const xmlChar *val) { } memset(ret, 0 , (size_t) sizeof(xmlXPathObject)); ret->type = XPATH_STRING; - ret->stringval = xmlStrdup(val); + if (val != NULL) + ret->stringval = xmlStrdup(val); + else + ret->stringval = xmlStrdup((const xmlChar *)""); return(ret); } @@ -3481,7 +3484,8 @@ xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) { int i = 0; /* Should be first in document order !!!!! */ res = xmlNodeGetContent(cur->nodesetval->nodeTab[i]); valuePush(ctxt, xmlXPathNewString(res)); - xmlFree(res); + if (res != NULL) + xmlFree(res); } xmlXPathFreeObject(cur); return; @@ -4560,6 +4564,7 @@ xmlXPathEvalVariableReference(xmlXPathParserContextPtr ctxt) { if (CUR != '$') { XP_ERROR(XPATH_VARIABLE_REF_ERROR); } + NEXT; name = xmlXPathParseQName(ctxt, &prefix); if (name == NULL) { XP_ERROR(XPATH_VARIABLE_REF_ERROR); @@ -4922,6 +4927,10 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) { if (lc) { if (CUR == '/') xmlXPathRoot(ctxt); + else { + /* TAG:9999 */ + valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node)); + } xmlXPathEvalLocationPath(ctxt); } else { xmlXPathEvalFilterExpr(ctxt); @@ -5869,10 +5878,12 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) { CHECK_CONTEXT(ctx) ctxt = xmlXPathNewParserContext(str, ctx); + /**** TAG:9999 if (ctx->node != NULL) { init = xmlXPathNewNodeSet(ctx->node); valuePush(ctxt, init); } + ****/ xmlXPathEvalExpr(ctxt); if (ctxt->value == NULL) { diff --git a/xpointer.c b/xpointer.c index 1b2efe7f..4ff76cb1 100644 --- a/xpointer.c +++ b/xpointer.c @@ -1337,10 +1337,12 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) { return(NULL); ctxt = xmlXPathNewParserContext(str, ctx); + /* TAG:9999 if (ctx->node != NULL) { init = xmlXPathNewNodeSet(ctx->node); valuePush(ctxt, init); } + */ xmlXPtrEvalXPointer(ctxt); if ((ctxt->value != NULL) &&