1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-10 08:58:16 +03:00

- xpath.c: seems I finally killed that ugly path evaluation

context bug (tagged 9999 in case is is wrong)
Daniel
This commit is contained in:
Daniel Veillard 2001-01-20 21:15:50 +00:00
parent 8f4d97579a
commit 5a2b697af8
5 changed files with 28 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Fri Jan 19 18:15:50 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* 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 <Daniel.Veillard@imag.fr>
* xpath.[ch] xpathInternals.h: added xmlXPathRegisterVariableLookup()

View File

@ -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);

4
tree.h
View File

@ -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);

15
xpath.c
View File

@ -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) {

View File

@ -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) &&