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
diff --git a/ChangeLog b/ChangeLog
index 5160be6..3154ede 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/result/XPath/expr/floats b/result/XPath/expr/floats
index 176081b..bc3801d 100644
--- a/result/XPath/expr/floats
+++ b/result/XPath/expr/floats
@@ -202,3 +202,23 @@
 ========================
 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 30b4771..10cc27e 100644
--- a/result/XPath/expr/functions
+++ b/result/XPath/expr/functions
@@ -16,6 +16,10 @@
 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 5d052d6..2453186 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 d8c9e10..d168b18 100644
--- a/test/XPath/expr/functions
+++ b/test/XPath/expr/functions
@@ -2,6 +2,7 @@
 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 dc303fc..b56c462 100644
--- a/xpath.c
+++ b/xpath.c
@@ -4732,7 +4732,13 @@
 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 @@
 
     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 @@
     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);