more work on the XML catalog support. small cleanup seems using list as a
* Makefile.am catalog.c xmlcatalog.c include/libxml/catalog.h:
more work on the XML catalog support.
* parser.c include/libxml/parser.h: small cleanup seems using
list as a public parameter name can give portability troubles
* trionan.c trionan.h xpath.c include/libxml/trionan.h
include/libxml/xpath.h include/libxml/Makefile.am: removed
trionan from the libxml API, added xmlXPathIsInf and xmlXPathIsNaN
wrappers
Daniel
diff --git a/xpath.c b/xpath.c
index 984752a..b716fa6 100644
--- a/xpath.c
+++ b/xpath.c
@@ -51,7 +51,6 @@
#include <libxml/debugXML.h>
#endif
#include <libxml/xmlerror.h>
-#include <libxml/trionan.h>
/* #define DEBUG */
/* #define DEBUG_STEP */
@@ -69,6 +68,9 @@
* *
************************************************************************/
+#define TRIO_PUBLIC static
+#include "trionan.c"
+
/*
* The lack of portability of this section of the libc is annoying !
*/
@@ -94,6 +96,36 @@
initialized = 1;
}
+/**
+ * xmlXPathIsNaN:
+ * @val: a double value
+ *
+ * Provides a portable isnan() function to detect whether a double
+ * is a NotaNumber. Based on trio code
+ * http://sourceforge.net/projects/ctrio/
+ *
+ * Returns 1 if the value is a NaN, 0 otherwise
+ */
+int
+xmlXPathIsNaN(double val) {
+ return(trio_isnan(val));
+}
+
+/**
+ * xmlXPathIsInf:
+ * @val: a double value
+ *
+ * Provides a portable isinf() function to detect whether a double
+ * is a +Infinite or -Infinite. Based on trio code
+ * http://sourceforge.net/projects/ctrio/
+ *
+ * Returns 1 vi the value is +Infinite, -1 if -Infinite, 0 otherwise
+ */
+int
+xmlXPathIsInf(double val) {
+ return(trio_isinf(val));
+}
+
/************************************************************************
* *
* Parser Types *
@@ -526,7 +558,7 @@
else fprintf(output, "false\n");
break;
case XPATH_NUMBER:
- switch (trio_isinf(cur->floatval)) {
+ switch (xmlXPathIsInf(cur->floatval)) {
case 1:
fprintf(output, "Object is a number : +Infinity\n");
break;
@@ -534,7 +566,7 @@
fprintf(output, "Object is a number : -Infinity\n");
break;
default:
- if (trio_isnan(cur->floatval)) {
+ if (xmlXPathIsNaN(cur->floatval)) {
fprintf(output, "Object is a number : NaN\n");
} else {
fprintf(output, "Object is a number : %0g\n", cur->floatval);
@@ -1055,7 +1087,7 @@
static void
xmlXPathFormatNumber(double number, char buffer[], int buffersize)
{
- switch (trio_isinf(number)) {
+ switch (xmlXPathIsInf(number)) {
case 1:
if (buffersize > (int)sizeof("+Infinity"))
sprintf(buffer, "+Infinity");
@@ -1065,7 +1097,7 @@
sprintf(buffer, "-Infinity");
break;
default:
- if (trio_isnan(number)) {
+ if (xmlXPathIsNaN(number)) {
if (buffersize > (int)sizeof("NaN"))
sprintf(buffer, "NaN");
} else {
@@ -2813,7 +2845,7 @@
xmlChar *
xmlXPathCastNumberToString (double val) {
xmlChar *ret;
- switch (trio_isinf(val)) {
+ switch (xmlXPathIsInf(val)) {
case 1:
ret = xmlStrdup((const xmlChar *) "+Infinity");
break;
@@ -2821,7 +2853,7 @@
ret = xmlStrdup((const xmlChar *) "-Infinity");
break;
default:
- if (trio_isnan(val)) {
+ if (xmlXPathIsNaN(val)) {
ret = xmlStrdup((const xmlChar *) "NaN");
} else {
/* could be improved */
@@ -3107,7 +3139,7 @@
*/
int
xmlXPathCastNumberToBoolean (double val) {
- if (trio_isnan(val) || (val == 0.0))
+ if (xmlXPathIsNaN(val) || (val == 0.0))
return(0);
return(1);
}
@@ -3714,13 +3746,13 @@
}
for (i = 0;i < ns1->nodeNr;i++) {
val1 = xmlXPathCastNodeToNumber(ns1->nodeTab[i]);
- if (trio_isnan(val1))
+ if (xmlXPathIsNaN(val1))
continue;
for (j = 0;j < ns2->nodeNr;j++) {
if (init == 0) {
values2[j] = xmlXPathCastNodeToNumber(ns2->nodeTab[j]);
}
- if (trio_isnan(values2[j]))
+ if (xmlXPathIsNaN(values2[j]))
continue;
if (inf && strict)
ret = (val1 < values2[j]);
@@ -6177,9 +6209,9 @@
CAST_TO_NUMBER;
CHECK_TYPE(XPATH_NUMBER);
- if ((trio_isnan(ctxt->value->floatval)) ||
- (trio_isinf(ctxt->value->floatval) == 1) ||
- (trio_isinf(ctxt->value->floatval) == -1) ||
+ if ((xmlXPathIsNaN(ctxt->value->floatval)) ||
+ (xmlXPathIsInf(ctxt->value->floatval) == 1) ||
+ (xmlXPathIsInf(ctxt->value->floatval) == -1) ||
(ctxt->value->floatval == 0.0))
return;