diff options
author | Thomas Broyer <tbroyer@src.gnome.org> | 2001-07-31 23:38:57 +0000 |
---|---|---|
committer | Thomas Broyer <tbroyer@src.gnome.org> | 2001-07-31 23:38:57 +0000 |
commit | cbb27d05552531dc29ed52369135b97e833d8de5 (patch) | |
tree | 34473f00658abe7d0a3adc44e91c2f172ffc0bdc | |
parent | 35d2ba83dfc19d82ec8761f88f1a1066b8326dbf (diff) | |
download | libxslt-cbb27d05552531dc29ed52369135b97e833d8de5.tar.gz libxslt-cbb27d05552531dc29ed52369135b97e833d8de5.tar.bz2 libxslt-cbb27d05552531dc29ed52369135b97e833d8de5.zip |
fixed bugs in exsltTrailingFunction and exsltLeadingFunction when passing
* libexslt/sets.c: fixed bugs in exsltTrailingFunction and
exsltLeadingFunction when passing an empty node-set as the
second argument
* libxslt/functions.[ch]: gave priority to context-level functions
over extension module functions. This allows a function declared
with a func:function element to override an extension module
function for example. This is a bit hackish...
* tests/exslt/sets/{lead,trail}ing.1.out: fixed errors. The result
values didn't conform to the expected values. This is a bug in
the EXSLT official use cases.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | libexslt/sets.c | 20 | ||||
-rw-r--r-- | libxslt/functions.c | 10 | ||||
-rw-r--r-- | libxslt/functions.h | 5 | ||||
-rw-r--r-- | tests/exslt/sets/leading.1.out | 2 | ||||
-rw-r--r-- | tests/exslt/sets/trailing.1.out | 2 |
6 files changed, 45 insertions, 7 deletions
@@ -1,3 +1,16 @@ +Wed Aug 1 01:37:41 CEST 2001 Thomas Broyer <tbroyer@ltgt.net> + + * libexslt/sets.c: fixed bugs in exsltTrailingFunction and + exsltLeadingFunction when passing an empty node-set as the + second argument + * libxslt/functions.[ch]: gave priority to context-level functions + over extension module functions. This allows a function declared + with a func:function element to override an extension module + function for example. This is a bit hackish... + * tests/exslt/sets/{lead,trail}ing.1.out: fixed errors. The result + values didn't conform to the expected values. This is a bug in + the EXSLT official use cases. + Tue Jul 31 23:53:55 CEST 2001 Daniel Veillard <daniel@veillard.com> * config.h.in configure.in libxslt/extra.c: tried to integrate diff --git a/libexslt/sets.c b/libexslt/sets.c index 1c04d5b6..bb427b50 100644 --- a/libexslt/sets.c +++ b/libexslt/sets.c @@ -175,6 +175,16 @@ exsltSetsLeadingFunction (xmlXPathParserContextPtr ctxt, int nargs) { return; } + /* If the second node set is empty, then the first node set is + * returned. + */ + if (xmlXPathNodeSetIsEmpty(arg2)) { + xmlXPathReturnNodeSet(ctxt, arg1); + + xmlXPathFreeNodeSet(arg2); + + return; + } /* !!! must be sorted */ ret = xmlXPathNodeLeadingSorted(arg1, xmlXPathNodeSetItem(arg2, 0)); @@ -212,6 +222,16 @@ exsltSetsTrailingFunction (xmlXPathParserContextPtr ctxt, int nargs) { return; } + /* If the second node set is empty, then the first node set is + * returned. + */ + if (xmlXPathNodeSetIsEmpty(arg2)) { + xmlXPathReturnNodeSet(ctxt, arg1); + + xmlXPathFreeNodeSet(arg2); + + return; + } /* !!! mist be sorted */ ret = xmlXPathNodeTrailingSorted(arg1, xmlXPathNodeSetItem(arg2, 0)); diff --git a/libxslt/functions.c b/libxslt/functions.c index 4e9a6f9c..87ec1560 100644 --- a/libxslt/functions.c +++ b/libxslt/functions.c @@ -63,11 +63,11 @@ * Returns the callback function or NULL if not found */ xmlXPathFunction -xsltXPathFunctionLookup (void *ctxt ATTRIBUTE_UNUSED, +xsltXPathFunctionLookup (xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri) { xmlXPathFunction ret; - if ((name == NULL) || (ns_uri == NULL)) + if ((ctxt == NULL) || (name == NULL) || (ns_uri == NULL)) return (NULL); #ifdef WITH_XSLT_DEBUG_FUNCTION @@ -75,7 +75,11 @@ xsltXPathFunctionLookup (void *ctxt ATTRIBUTE_UNUSED, "Lookup function {%s}%s\n", ns_uri, name); #endif - ret = xsltExtModuleFunctionLookup(name, ns_uri); + /* give priority to context-level functions */ + ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri); + + if (ret == NULL) + ret = xsltExtModuleFunctionLookup(name, ns_uri); #ifdef WITH_XSLT_DEBUG_FUNCTION if (ret != NULL) diff --git a/libxslt/functions.h b/libxslt/functions.h index a52470eb..3d0d59f8 100644 --- a/libxslt/functions.h +++ b/libxslt/functions.h @@ -25,10 +25,11 @@ extern "C" { */ #define XSLT_REGISTER_FUNCTION_LOOKUP(ctxt) \ xmlXPathRegisterFuncLookup((ctxt)->xpathCtxt, \ - xsltXPathFunctionLookup, (void *)(ctxt)); + xsltXPathFunctionLookup, (void *)(ctxt->xpathCtxt)); xmlXPathFunction - xsltXPathFunctionLookup (void *ctxt, const xmlChar *name, + xsltXPathFunctionLookup (xmlXPathContextPtr ctxt, + const xmlChar *name, const xmlChar *ns_uri); /* diff --git a/tests/exslt/sets/leading.1.out b/tests/exslt/sets/leading.1.out index 9c1d1a89..bc81b5e9 100644 --- a/tests/exslt/sets/leading.1.out +++ b/tests/exslt/sets/leading.1.out @@ -4,7 +4,7 @@ 1; 3; 0; + 8; 0; 0; - 3; </out> diff --git a/tests/exslt/sets/trailing.1.out b/tests/exslt/sets/trailing.1.out index f80a1782..d906b0a7 100644 --- a/tests/exslt/sets/trailing.1.out +++ b/tests/exslt/sets/trailing.1.out @@ -3,7 +3,7 @@ 4; 6; 7; + 8; 0; 0; - 3; </out> |