Commit eca82810 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

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
parent 13e04c6c
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.
......
......@@ -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
......@@ -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
......
......@@ -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
......@@ -2,6 +2,7 @@ true()
false()
number("1.5")
number('abc')
-number('abc')
floor(0.1)
floor(-0.1)
floor(-0)
......
......@@ -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);
......
Supports Markdown
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