Completely changed the way the XPath evaluation is done, likely to break
stuff like libxslt right now:
- Makefile.am: detect XPath memleaks in regreson tests
- error.c: fixed and error w.r.t. error reporting still using
stderr
- hash.c: added new line at end of file
- tree.h: minor cleanup
- xpath.[ch] xpointer.[ch]: Major changes ! Separated XPath
expression parsing from evaluation, resulted in a number of
changes internally, and in XPointer. Likely to break stuff
using xpathInternals.h but should remain binary compatible,
new interfaces will be added.
Daniel
diff --git a/xpointer.c b/xpointer.c
index 9380d15..da6ac7f 100644
--- a/xpointer.c
+++ b/xpointer.c
@@ -981,8 +981,8 @@
const xmlChar *left = CUR_PTR;
CUR_PTR = buffer;
- xmlXPathRoot(ctxt);
xmlXPathEvalExpr(ctxt);
+ xmlXPathRunEval(ctxt);
CUR_PTR=left;
#ifdef XPTR_XMLNS_SCHEME
} else if (xmlStrEqual(name, (xmlChar *) "xmlns")) {
@@ -1174,6 +1174,20 @@
*/
void
xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
+ if (ctxt->valueTab == NULL) {
+ /* Allocate the value stack */
+ ctxt->valueTab = (xmlXPathObjectPtr *)
+ xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
+ if (ctxt->valueTab == NULL) {
+ xmlFree(ctxt);
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlXPathRunEval: out of memory\n");
+ return;
+ }
+ ctxt->valueNr = 0;
+ ctxt->valueMax = 10;
+ ctxt->value = NULL;
+ }
SKIP_BLANKS;
if (CUR == '/') {
xmlXPathRoot(ctxt);
@@ -1279,12 +1293,6 @@
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) &&