diff --git a/ChangeLog b/ChangeLog index 5160be6b..3154ede5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Apr 24 13:41:03 CEST 2002 Daniel Veillard + + * 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 * xmlschemas.c: fixed validation of attribute groups. diff --git a/result/XPath/expr/floats b/result/XPath/expr/floats index 176081b5..bc3801d7 100644 --- a/result/XPath/expr/floats +++ b/result/XPath/expr/floats @@ -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 diff --git a/result/XPath/expr/functions b/result/XPath/expr/functions index 30b47715..10cc27ef 100644 --- a/result/XPath/expr/functions +++ b/result/XPath/expr/functions @@ -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 diff --git a/test/XPath/expr/floats b/test/XPath/expr/floats index 5d052d6a..2453186f 100644 --- a/test/XPath/expr/floats +++ b/test/XPath/expr/floats @@ -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 diff --git a/test/XPath/expr/functions b/test/XPath/expr/functions index d8c9e10d..d168b189 100644 --- a/test/XPath/expr/functions +++ b/test/XPath/expr/functions @@ -2,6 +2,7 @@ true() false() number("1.5") number('abc') +-number('abc') floor(0.1) floor(-0.1) floor(-0) diff --git a/xpath.c b/xpath.c index dc303fcf..b56c462f 100644 --- a/xpath.c +++ b/xpath.c @@ -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);