mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-01 10:06:59 +03:00
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
This commit is contained in:
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
Wed Mar 14 20:34:02 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* configure.in: fixed a couple of problems reported by
|
* configure.in: fixed a couple of problems reported by
|
||||||
|
@ -253,6 +253,7 @@ URItests : testURI
|
|||||||
fi ; fi ; done)
|
fi ; fi ; done)
|
||||||
|
|
||||||
XPathtests : testXPath
|
XPathtests : testXPath
|
||||||
|
@(rm -f .memdump ; touch .memdump)
|
||||||
@echo "##"
|
@echo "##"
|
||||||
@echo "## XPath regression tests"
|
@echo "## XPath regression tests"
|
||||||
@echo "##"
|
@echo "##"
|
||||||
@ -262,9 +263,11 @@ XPathtests : testXPath
|
|||||||
if [ ! -f $(srcdir)/result/XPath/expr/$$name ] ; then \
|
if [ ! -f $(srcdir)/result/XPath/expr/$$name ] ; then \
|
||||||
echo New test file $$name ; \
|
echo New test file $$name ; \
|
||||||
$(top_builddir)/testXPath -f --expr $$i > $(srcdir)/result/XPath/expr/$$name ; \
|
$(top_builddir)/testXPath -f --expr $$i > $(srcdir)/result/XPath/expr/$$name ; \
|
||||||
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||||
else \
|
else \
|
||||||
echo Testing $$name ; \
|
echo Testing $$name ; \
|
||||||
$(top_builddir)/testXPath -f --expr $$i > result.$$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 ; \
|
diff $(srcdir)/result/XPath/expr/$$name result.$$name ; \
|
||||||
rm result.$$name ; \
|
rm result.$$name ; \
|
||||||
fi ; fi ; done)
|
fi ; fi ; done)
|
||||||
@ -278,9 +281,11 @@ XPathtests : testXPath
|
|||||||
if [ ! -f $(srcdir)/result/XPath/tests/$$name ] ; then \
|
if [ ! -f $(srcdir)/result/XPath/tests/$$name ] ; then \
|
||||||
echo New test file $$name ; \
|
echo New test file $$name ; \
|
||||||
$(top_builddir)/testXPath -f -i $$i $$j > $(srcdir)/result/XPath/tests/$$name ; \
|
$(top_builddir)/testXPath -f -i $$i $$j > $(srcdir)/result/XPath/tests/$$name ; \
|
||||||
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||||
else \
|
else \
|
||||||
echo Testing $$name ; \
|
echo Testing $$name ; \
|
||||||
$(top_builddir)/testXPath -f -i $$i $$j > result.$$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 ; \
|
diff $(srcdir)/result/XPath/tests/$$name result.$$name ; \
|
||||||
rm result.$$name ; \
|
rm result.$$name ; \
|
||||||
fi ; fi ; done ; fi ; done)
|
fi ; fi ; done ; fi ; done)
|
||||||
|
14
error.c
14
error.c
@ -214,6 +214,7 @@ xmlParserError(void *ctx, const char *msg, ...)
|
|||||||
str = xmlGetVarStr(msg, args);
|
str = xmlGetVarStr(msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
xmlGenericError(xmlGenericErrorContext, str);
|
xmlGenericError(xmlGenericErrorContext, str);
|
||||||
|
if (str != NULL)
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
@ -259,6 +260,7 @@ xmlParserWarning(void *ctx, const char *msg, ...)
|
|||||||
str = xmlGetVarStr(msg, args);
|
str = xmlGetVarStr(msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
xmlGenericError(xmlGenericErrorContext, str);
|
xmlGenericError(xmlGenericErrorContext, str);
|
||||||
|
if (str != NULL)
|
||||||
xmlFree(str);
|
xmlFree(str);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
@ -291,6 +293,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
|||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
xmlParserInputPtr input = NULL;
|
xmlParserInputPtr input = NULL;
|
||||||
|
char * str;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
@ -303,8 +306,11 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(xmlGenericErrorContext, msg, args);
|
str = xmlGetVarStr(msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
xmlGenericError(xmlGenericErrorContext, str);
|
||||||
|
if (str != NULL)
|
||||||
|
xmlFree(str);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
xmlParserPrintFileContext(input);
|
xmlParserPrintFileContext(input);
|
||||||
@ -325,6 +331,7 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
|||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
xmlParserInputPtr input = NULL;
|
xmlParserInputPtr input = NULL;
|
||||||
|
char * str;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
@ -337,8 +344,11 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
|||||||
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
vfprintf(xmlGenericErrorContext, msg, args);
|
str = xmlGetVarStr(msg, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
xmlGenericError(xmlGenericErrorContext, str);
|
||||||
|
if (str != NULL)
|
||||||
|
xmlFree(str);
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
xmlParserPrintFileContext(input);
|
xmlParserPrintFileContext(input);
|
||||||
|
1
hash.c
1
hash.c
@ -618,3 +618,4 @@ int xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +220,13 @@ struct _xmlXPathContext {
|
|||||||
void *extra; /* needed for XSLT */
|
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 XPath parser context, it contains pure parsing informations,
|
||||||
* an xmlXPathContext, and the stack of objects.
|
* an xmlXPathContext, and the stack of objects.
|
||||||
@ -230,6 +237,8 @@ struct _xmlXPathParserContext {
|
|||||||
|
|
||||||
int error; /* error code */
|
int error; /* error code */
|
||||||
|
|
||||||
|
xmlXPathCompExprPtr comp; /* the precompiled expression */
|
||||||
|
|
||||||
xmlXPathContextPtr context; /* the evaluation context */
|
xmlXPathContextPtr context; /* the evaluation context */
|
||||||
xmlXPathObjectPtr value; /* the current value */
|
xmlXPathObjectPtr value; /* the current value */
|
||||||
int valueNr; /* number of values stacked */
|
int valueNr; /* number of values stacked */
|
||||||
|
@ -34,9 +34,15 @@ struct _xmlLocationSet {
|
|||||||
* Handling of location sets
|
* Handling of location sets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
|
||||||
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
|
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
|
||||||
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
|
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
|
||||||
xmlLocationSetPtr val2);
|
xmlLocationSetPtr val2);
|
||||||
|
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
|
||||||
|
xmlXPathObjectPtr end);
|
||||||
|
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
|
||||||
|
xmlXPathObjectPtr val);
|
||||||
|
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions
|
* Functions
|
||||||
|
9
xpath.h
9
xpath.h
@ -220,6 +220,13 @@ struct _xmlXPathContext {
|
|||||||
void *extra; /* needed for XSLT */
|
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 XPath parser context, it contains pure parsing informations,
|
||||||
* an xmlXPathContext, and the stack of objects.
|
* an xmlXPathContext, and the stack of objects.
|
||||||
@ -230,6 +237,8 @@ struct _xmlXPathParserContext {
|
|||||||
|
|
||||||
int error; /* error code */
|
int error; /* error code */
|
||||||
|
|
||||||
|
xmlXPathCompExprPtr comp; /* the precompiled expression */
|
||||||
|
|
||||||
xmlXPathContextPtr context; /* the evaluation context */
|
xmlXPathContextPtr context; /* the evaluation context */
|
||||||
xmlXPathObjectPtr value; /* the current value */
|
xmlXPathObjectPtr value; /* the current value */
|
||||||
int valueNr; /* number of values stacked */
|
int valueNr; /* number of values stacked */
|
||||||
|
22
xpointer.c
22
xpointer.c
@ -981,8 +981,8 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
|
|||||||
const xmlChar *left = CUR_PTR;
|
const xmlChar *left = CUR_PTR;
|
||||||
|
|
||||||
CUR_PTR = buffer;
|
CUR_PTR = buffer;
|
||||||
xmlXPathRoot(ctxt);
|
|
||||||
xmlXPathEvalExpr(ctxt);
|
xmlXPathEvalExpr(ctxt);
|
||||||
|
xmlXPathRunEval(ctxt);
|
||||||
CUR_PTR=left;
|
CUR_PTR=left;
|
||||||
#ifdef XPTR_XMLNS_SCHEME
|
#ifdef XPTR_XMLNS_SCHEME
|
||||||
} else if (xmlStrEqual(name, (xmlChar *) "xmlns")) {
|
} else if (xmlStrEqual(name, (xmlChar *) "xmlns")) {
|
||||||
@ -1174,6 +1174,20 @@ xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
|
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;
|
SKIP_BLANKS;
|
||||||
if (CUR == '/') {
|
if (CUR == '/') {
|
||||||
xmlXPathRoot(ctxt);
|
xmlXPathRoot(ctxt);
|
||||||
@ -1279,12 +1293,6 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
ctxt = xmlXPathNewParserContext(str, ctx);
|
ctxt = xmlXPathNewParserContext(str, ctx);
|
||||||
/* TAG:9999
|
|
||||||
if (ctx->node != NULL) {
|
|
||||||
init = xmlXPathNewNodeSet(ctx->node);
|
|
||||||
valuePush(ctxt, init);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
xmlXPtrEvalXPointer(ctxt);
|
xmlXPtrEvalXPointer(ctxt);
|
||||||
|
|
||||||
if ((ctxt->value != NULL) &&
|
if ((ctxt->value != NULL) &&
|
||||||
|
@ -34,9 +34,15 @@ struct _xmlLocationSet {
|
|||||||
* Handling of location sets
|
* Handling of location sets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
xmlLocationSetPtr xmlXPtrLocationSetCreate(xmlXPathObjectPtr val);
|
||||||
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
|
void xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
|
||||||
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
|
xmlLocationSetPtr xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
|
||||||
xmlLocationSetPtr val2);
|
xmlLocationSetPtr val2);
|
||||||
|
xmlXPathObjectPtr xmlXPtrNewRangeNodeObject(xmlNodePtr start,
|
||||||
|
xmlXPathObjectPtr end);
|
||||||
|
void xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
|
||||||
|
xmlXPathObjectPtr val);
|
||||||
|
xmlXPathObjectPtr xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions
|
* Functions
|
||||||
|
Reference in New Issue
Block a user