1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

- xpath.c: applied another XPath patch from TOM

- xpath.c include/makefile.am: applied another patch from
  china@thewrittenword.com (cleanup on IRIX).
Daniel
This commit is contained in:
Daniel Veillard
2000-10-27 17:04:52 +00:00
parent 211cc0a00b
commit 767662dba5
3 changed files with 26 additions and 16 deletions

View File

@ -1,3 +1,9 @@
Fri Oct 27 18:57:32 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* xpath.c: applied another XPath patch from TOM
* xpath.c include/makefile.am: applied another patch from
china@thewrittenword.com (cleanup on IRIX).
Fri Oct 27 13:45:28 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org> Fri Oct 27 13:45:28 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
* xml-config.1: received a fixed version from Fredrik Hallenberg * xml-config.1: received a fixed version from Fredrik Hallenberg

View File

@ -3,7 +3,6 @@
xmlincdir = $(includedir) xmlincdir = $(includedir)
xmlinc_HEADERS = \ xmlinc_HEADERS = \
libxml/xmlversion.h.in \
libxml/SAX.h \ libxml/SAX.h \
libxml/entities.h \ libxml/entities.h \
libxml/encoding.h \ libxml/encoding.h \
@ -30,4 +29,4 @@ xmlinc_HEADERS = \
install-exec-hook: install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(xmlincdir) $(DESTDIR)$(xmlincdir)/libxml $(mkinstalldirs) $(DESTDIR)$(xmlincdir) $(DESTDIR)$(xmlincdir)/libxml
EXTRA_DIST = win32config.h EXTRA_DIST = win32config.h libxml/xmlversion.h.in

33
xpath.c
View File

@ -3324,8 +3324,8 @@ xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* xmlXPathNormalizeFunction: * xmlXPathNormalizeFunction:
* @ctxt: the XPath Parser context * @ctxt: the XPath Parser context
* *
* Implement the normalize() XPath function * Implement the normalize-space() XPath function
* The normalize function returns the argument string with white * The normalize-space function returns the argument string with white
* space normalized by stripping leading and trailing whitespace * space normalized by stripping leading and trailing whitespace
* and replacing sequences of whitespace characters by a single * and replacing sequences of whitespace characters by a single
* space. Whitespace characters are the same allowed by the S production * space. Whitespace characters are the same allowed by the S production
@ -3568,8 +3568,6 @@ not_equal:
* *
* Implement the number() XPath function * Implement the number() XPath function
* *
* BUG: since we directly call xmlXPathStringEvalNumber(),
* number("-1") isn't evaluated in -1.0 but in NaN.
*/ */
void void
xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) { xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
@ -3648,6 +3646,7 @@ xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
} else { } else {
valuePush(ctxt, valuePush(ctxt,
xmlXPathNewNodeSet(cur->nodesetval->nodeTab[0])); xmlXPathNewNodeSet(cur->nodesetval->nodeTab[0]));
xmlXPathNumberFunction(ctxt, 1);
for (i = 1; i < cur->nodesetval->nodeNr; i++) { for (i = 1; i < cur->nodesetval->nodeNr; i++) {
valuePush(ctxt, valuePush(ctxt,
xmlXPathNewNodeSet(cur->nodesetval->nodeTab[i])); xmlXPathNewNodeSet(cur->nodesetval->nodeTab[i]));
@ -3858,6 +3857,8 @@ xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
* [31] Digits ::= [0-9]+ * [31] Digits ::= [0-9]+
* *
* Parse and evaluate a Number in the string * Parse and evaluate a Number in the string
* In complement of the Number expression, this function also handles
* negative values : '-' Number.
* *
* Returns the double value. * Returns the double value.
*/ */
@ -3867,11 +3868,16 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
double ret = 0.0; double ret = 0.0;
double mult = 1; double mult = 1;
int ok = 0; int ok = 0;
int isneg = 0;
while (*cur == ' ') cur++; while (*cur == ' ') cur++;
if ((*cur != '.') && ((*cur < '0') || (*cur > '9'))) { if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
return(xmlXPathNAN); return(xmlXPathNAN);
} }
if (*cur == '-') {
isneg = 1;
cur++;
}
while ((*cur >= '0') && (*cur <= '9')) { while ((*cur >= '0') && (*cur <= '9')) {
ret = ret * 10 + (*cur - '0'); ret = ret * 10 + (*cur - '0');
ok = 1; ok = 1;
@ -3890,6 +3896,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
} }
while (*cur == ' ') cur++; while (*cur == ' ') cur++;
if (*cur != 0) return(xmlXPathNAN); if (*cur != 0) return(xmlXPathNAN);
if (isneg) ret = -ret;
return(ret); return(ret);
} }
@ -4366,7 +4373,7 @@ xmlXPathEvalPathExpr(xmlXPathParserContextPtr ctxt) {
SKIP(2); SKIP(2);
SKIP_BLANKS; SKIP_BLANKS;
xmlXPathNodeCollectAndTest(ctxt, AXIS_DESCENDANT_OR_SELF, xmlXPathNodeCollectAndTest(ctxt, AXIS_DESCENDANT_OR_SELF,
NODE_TEST_TYPE, XML_ELEMENT_NODE, NULL, NULL); NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL);
ctxt->context->node = NULL; ctxt->context->node = NULL;
xmlXPathEvalRelativeLocationPath(ctxt); xmlXPathEvalRelativeLocationPath(ctxt);
} else if (CUR == '/') { } else if (CUR == '/') {
@ -5083,7 +5090,7 @@ xmlXPathEvalStep(xmlXPathParserContextPtr ctxt) {
SKIP(2); SKIP(2);
SKIP_BLANKS; SKIP_BLANKS;
xmlXPathNodeCollectAndTest(ctxt, AXIS_PARENT, xmlXPathNodeCollectAndTest(ctxt, AXIS_PARENT,
NODE_TEST_TYPE, XML_ELEMENT_NODE, NULL, NULL); NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL);
} else if (CUR == '.') { } else if (CUR == '.') {
NEXT; NEXT;
SKIP_BLANKS; SKIP_BLANKS;
@ -5195,7 +5202,7 @@ xmlXPathEvalRelativeLocationPath(xmlXPathParserContextPtr ctxt) {
SKIP(2); SKIP(2);
SKIP_BLANKS; SKIP_BLANKS;
xmlXPathNodeCollectAndTest(ctxt, AXIS_DESCENDANT_OR_SELF, xmlXPathNodeCollectAndTest(ctxt, AXIS_DESCENDANT_OR_SELF,
NODE_TEST_TYPE, XML_ELEMENT_NODE, NULL, NULL); NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL);
} else if (CUR == '/') { } else if (CUR == '/') {
NEXT; NEXT;
SKIP_BLANKS; SKIP_BLANKS;
@ -5207,7 +5214,7 @@ xmlXPathEvalRelativeLocationPath(xmlXPathParserContextPtr ctxt) {
SKIP(2); SKIP(2);
SKIP_BLANKS; SKIP_BLANKS;
xmlXPathNodeCollectAndTest(ctxt, AXIS_DESCENDANT_OR_SELF, xmlXPathNodeCollectAndTest(ctxt, AXIS_DESCENDANT_OR_SELF,
NODE_TEST_TYPE, XML_ELEMENT_NODE, NULL, NULL); NODE_TEST_TYPE, NODE_TYPE_NODE, NULL, NULL);
xmlXPathEvalStep(ctxt); xmlXPathEvalStep(ctxt);
} else if (CUR == '/') { } else if (CUR == '/') {
NEXT; NEXT;
@ -5249,7 +5256,7 @@ xmlXPathEvalLocationPath(xmlXPathParserContextPtr ctxt) {
SKIP_BLANKS; SKIP_BLANKS;
xmlXPathNodeCollectAndTest(ctxt, xmlXPathNodeCollectAndTest(ctxt,
AXIS_DESCENDANT_OR_SELF, NODE_TEST_TYPE, AXIS_DESCENDANT_OR_SELF, NODE_TEST_TYPE,
XML_ELEMENT_NODE, NULL, NULL); NODE_TYPE_NODE, NULL, NULL);
xmlXPathEvalRelativeLocationPath(ctxt); xmlXPathEvalRelativeLocationPath(ctxt);
} else if (CUR == '/') { } else if (CUR == '/') {
NEXT; NEXT;
@ -5292,9 +5299,9 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
xmlXPathRoot(ctxt); xmlXPathRoot(ctxt);
xmlXPathEvalExpr(ctxt); xmlXPathEvalExpr(ctxt);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) { if (ctxt->value == NULL) {
xmlGenericError(xmlGenericErrorContext, xmlGenericError(xmlGenericErrorContext,
"xmlXPathEval: evaluation failed to return a node set\n"); "xmlXPathEval: evaluation failed\n");
} else { } else {
res = valuePop(ctxt); res = valuePop(ctxt);
} }
@ -5394,8 +5401,6 @@ xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
xmlXPathNamespaceURIFunction); xmlXPathNamespaceURIFunction);
xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space", xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space",
xmlXPathNormalizeFunction); xmlXPathNormalizeFunction);
xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize",
xmlXPathNormalizeFunction);
xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number", xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number",
xmlXPathNumberFunction); xmlXPathNumberFunction);
xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position", xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position",