Commit 9e7160d4 authored by Daniel Veillard's avatar Daniel Veillard

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
parent 480363bd
Mon Mar 19 00:11:18 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* 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.
Wed Mar 14 20:34:02 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* configure.in: fixed a couple of problems reported by
......
......@@ -253,6 +253,7 @@ URItests : testURI
fi ; fi ; done)
XPathtests : testXPath
@(rm -f .memdump ; touch .memdump)
@echo "##"
@echo "## XPath regression tests"
@echo "##"
......@@ -262,9 +263,11 @@ XPathtests : testXPath
if [ ! -f $(srcdir)/result/XPath/expr/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/testXPath -f --expr $$i > $(srcdir)/result/XPath/expr/$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
else \
echo Testing $$name ; \
$(top_builddir)/testXPath -f --expr $$i > result.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/XPath/expr/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done)
......@@ -278,9 +281,11 @@ XPathtests : testXPath
if [ ! -f $(srcdir)/result/XPath/tests/$$name ] ; then \
echo New test file $$name ; \
$(top_builddir)/testXPath -f -i $$i $$j > $(srcdir)/result/XPath/tests/$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
else \
echo Testing $$name ; \
$(top_builddir)/testXPath -f -i $$i $$j > result.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/XPath/tests/$$name result.$$name ; \
rm result.$$name ; \
fi ; fi ; done ; fi ; done)
......
......@@ -214,7 +214,8 @@ xmlParserError(void *ctx, const char *msg, ...)
str = xmlGetVarStr(msg, args);
va_end(args);
xmlGenericError(xmlGenericErrorContext, str);
xmlFree(str);
if (str != NULL)
xmlFree(str);
if (ctxt != NULL) {
xmlParserPrintFileContext(input);
......@@ -259,7 +260,8 @@ xmlParserWarning(void *ctx, const char *msg, ...)
str = xmlGetVarStr(msg, args);
va_end(args);
xmlGenericError(xmlGenericErrorContext, str);
xmlFree(str);
if (str != NULL)
xmlFree(str);
if (ctxt != NULL) {
xmlParserPrintFileContext(input);
......@@ -291,6 +293,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input = NULL;
char * str;
va_list args;
if (ctxt != NULL) {
......@@ -303,8 +306,11 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
xmlGenericError(xmlGenericErrorContext, "validity error: ");
va_start(args, msg);
vfprintf(xmlGenericErrorContext, msg, args);
str = xmlGetVarStr(msg, args);
va_end(args);
xmlGenericError(xmlGenericErrorContext, str);
if (str != NULL)
xmlFree(str);
if (ctxt != NULL) {
xmlParserPrintFileContext(input);
......@@ -325,6 +331,7 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input = NULL;
char * str;
va_list args;
if (ctxt != NULL) {
......@@ -337,8 +344,11 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
va_start(args, msg);
vfprintf(xmlGenericErrorContext, msg, args);
str = xmlGetVarStr(msg, args);
va_end(args);
xmlGenericError(xmlGenericErrorContext, str);
if (str != NULL)
xmlFree(str);
if (ctxt != NULL) {
xmlParserPrintFileContext(input);
......
......@@ -617,4 +617,5 @@ int xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
}
return(-1);
}
}
\ No newline at end of file
}
......@@ -83,7 +83,7 @@ typedef unsigned char xmlChar;
typedef struct _xmlNotation xmlNotation;
typedef xmlNotation *xmlNotationPtr;
struct _xmlNotation {
const xmlChar *name; /* Notation name */
const xmlChar *name; /* Notation name */
const xmlChar *PublicID; /* Public identifier, if any */
const xmlChar *SystemID; /* System identifier, if any */
};
......
......@@ -220,6 +220,13 @@ struct _xmlXPathContext {
void *extra; /* needed for XSLT */
};
/*
* The structure of a compiled expression form is not public
*/
typedef struct _xmlXPathCompExpr xmlXPathCompExpr;
typedef xmlXPathCompExpr *xmlXPathCompExprPtr;
/*
* An XPath parser context, it contains pure parsing informations,
* an xmlXPathContext, and the stack of objects.
......@@ -230,6 +237,8 @@ struct _xmlXPathParserContext {
int error; /* error code */
xmlXPathCompExprPtr comp; /* the precompiled expression */
xmlXPathContextPtr context; /* the evaluation context */
xmlXPathObjectPtr value; /* the current value */
int valueNr; /* number of values stacked */
......
......@@ -34,9 +34,15 @@ struct _xmlLocationSet {
* Handling of location sets
*/
xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
xmlXPathObjectPtr end);
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
/*
* Functions
......
......@@ -83,7 +83,7 @@ typedef unsigned char xmlChar;
typedef struct _xmlNotation xmlNotation;
typedef xmlNotation *xmlNotationPtr;
struct _xmlNotation {
const xmlChar *name; /* Notation name */
const xmlChar *name; /* Notation name */
const xmlChar *PublicID; /* Public identifier, if any */
const xmlChar *SystemID; /* System identifier, if any */
};
......
This diff is collapsed.
......@@ -220,6 +220,13 @@ struct _xmlXPathContext {
void *extra; /* needed for XSLT */
};
/*
* The structure of a compiled expression form is not public
*/
typedef struct _xmlXPathCompExpr xmlXPathCompExpr;
typedef xmlXPathCompExpr *xmlXPathCompExprPtr;
/*
* An XPath parser context, it contains pure parsing informations,
* an xmlXPathContext, and the stack of objects.
......@@ -230,6 +237,8 @@ struct _xmlXPathParserContext {
int error; /* error code */
xmlXPathCompExprPtr comp; /* the precompiled expression */
xmlXPathContextPtr context; /* the evaluation context */
xmlXPathObjectPtr value; /* the current value */
int valueNr; /* number of values stacked */
......
......@@ -981,8 +981,8 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
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 @@ xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
*/
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 @@ 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) &&
......
......@@ -34,9 +34,15 @@ struct _xmlLocationSet {
* Handling of location sets
*/
xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
xmlXPathObjectPtr end);
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
/*
* Functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment