1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-28 00:21:53 +03:00

another XPath conformance patch from Richard Jinks Daniel

* test/XPath/expr/floats test/XPath/expr/functions
  result/XPath/expr/floats result/XPath/expr/functions
  xpath.c: another XPath conformance patch from Richard Jinks
Daniel
This commit is contained in:
Daniel Veillard
2002-04-24 11:42:02 +00:00
parent 13e04c6c12
commit eca82810f0
6 changed files with 47 additions and 3 deletions

View File

@ -1,3 +1,9 @@
Wed Apr 24 13:41:03 CEST 2002 Daniel Veillard <daniel@veillard.com>
* test/XPath/expr/floats test/XPath/expr/functions
result/XPath/expr/floats result/XPath/expr/functions
xpath.c: another XPath conformance patch from Richard Jinks
Tue Apr 23 19:50:40 CEST 2002 Daniel Veillard <daniel@veillard.com>
* xmlschemas.c: fixed validation of attribute groups.

View File

@ -202,3 +202,23 @@ Object is a number : -Infinity
========================
Expression: 1 div round(0)
Object is a number : Infinity
========================
Expression: 1 div number('f')
Object is a number : NaN
========================
Expression: number('f') div 1
Object is a number : NaN
========================
Expression: 1 div (1 div 0)
Object is a number : 0
========================
Expression: (1 div 0) div 1
Object is a number : Infinity
========================
Expression: -(1 div 0) div 1
Object is a number : -Infinity

View File

@ -15,6 +15,10 @@ Object is a number : 1.5
Expression: number('abc')
Object is a number : NaN
========================
Expression: -number('abc')
Object is a number : NaN
========================
Expression: floor(0.1)
Object is a number : 0

View File

@ -49,3 +49,8 @@
1 div round(-0.1)
1 div round(-0)
1 div round(0)
1 div number('f')
number('f') div 1
1 div (1 div 0)
(1 div 0) div 1
-(1 div 0) div 1

View File

@ -2,6 +2,7 @@ true()
false()
number("1.5")
number('abc')
-number('abc')
floor(0.1)
floor(-0.1)
floor(-0)

14
xpath.c
View File

@ -4732,7 +4732,13 @@ void
xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
CAST_TO_NUMBER;
CHECK_TYPE(XPATH_NUMBER);
if (ctxt->value->floatval == 0) {
if (xmlXPathIsNaN(ctxt->value->floatval))
ctxt->value->floatval=xmlXPathNAN;
else if (xmlXPathIsInf(ctxt->value->floatval) == 1)
ctxt->value->floatval=xmlXPathNINF;
else if (xmlXPathIsInf(ctxt->value->floatval) == -1)
ctxt->value->floatval=xmlXPathPINF;
else if (ctxt->value->floatval == 0) {
if (xmlXPathGetSign(ctxt->value->floatval) == 0)
ctxt->value->floatval = xmlXPathNZERO;
else
@ -4835,7 +4841,9 @@ xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
CAST_TO_NUMBER;
CHECK_TYPE(XPATH_NUMBER);
if (val == 0 && xmlXPathGetSign(val) != 0) {
if (xmlXPathIsNaN(val) || xmlXPathIsNaN(ctxt->value->floatval))
ctxt->value->floatval = xmlXPathNAN;
else if (val == 0 && xmlXPathGetSign(val) != 0) {
if (ctxt->value->floatval == 0)
ctxt->value->floatval = xmlXPathNAN;
else if (ctxt->value->floatval > 0)
@ -7045,7 +7053,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
unsigned long tmp = 0;
double temp;
#endif
if (cur == NULL) return(0);
while (IS_BLANK(*cur)) cur++;
if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
return(xmlXPathNAN);