summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-05-08 23:12:33 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2023-05-08 23:15:30 +0200
commit01723fc68f8be8ee9b986f3266c81013f8f66d03 (patch)
treeec4d083ef56767c3046e8802822a2dec6174a1ee
parent235b15a590eecf97b09e87bdb7e4f8333e9de129 (diff)
downloadlibxml2-01723fc68f8be8ee9b986f3266c81013f8f66d03.tar.gz
xpath: Fix build without LIBXML_XPATH_ENABLED
Move static function declaration into XPATH block. Also move comparison functions. Fixes #537.
-rw-r--r--xpath.c216
1 files changed, 108 insertions, 108 deletions
diff --git a/xpath.c b/xpath.c
index 0f969950..8df7974f 100644
--- a/xpath.c
+++ b/xpath.c
@@ -145,6 +145,114 @@
* any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT)
*/
+#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+
+/************************************************************************
+ * *
+ * Floating point stuff *
+ * *
+ ************************************************************************/
+
+double xmlXPathNAN = 0.0;
+double xmlXPathPINF = 0.0;
+double xmlXPathNINF = 0.0;
+
+/**
+ * xmlXPathInit:
+ *
+ * DEPRECATED: Alias for xmlInitParser.
+ */
+void
+xmlXPathInit(void) {
+ xmlInitParser();
+}
+
+/**
+ * xmlInitXPathInternal:
+ *
+ * Initialize the XPath environment
+ */
+ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
+void
+xmlInitXPathInternal(void) {
+#if defined(NAN) && defined(INFINITY)
+ xmlXPathNAN = NAN;
+ xmlXPathPINF = INFINITY;
+ xmlXPathNINF = -INFINITY;
+#else
+ /* MSVC doesn't allow division by zero in constant expressions. */
+ double zero = 0.0;
+ xmlXPathNAN = 0.0 / zero;
+ xmlXPathPINF = 1.0 / zero;
+ xmlXPathNINF = -xmlXPathPINF;
+#endif
+}
+
+/**
+ * xmlXPathIsNaN:
+ * @val: a double value
+ *
+ * Returns 1 if the value is a NaN, 0 otherwise
+ */
+int
+xmlXPathIsNaN(double val) {
+#ifdef isnan
+ return isnan(val);
+#else
+ return !(val == val);
+#endif
+}
+
+/**
+ * xmlXPathIsInf:
+ * @val: a double value
+ *
+ * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise
+ */
+int
+xmlXPathIsInf(double val) {
+#ifdef isinf
+ return isinf(val) ? (val > 0 ? 1 : -1) : 0;
+#else
+ if (val >= xmlXPathPINF)
+ return 1;
+ if (val <= -xmlXPathPINF)
+ return -1;
+ return 0;
+#endif
+}
+
+#endif /* SCHEMAS or XPATH */
+
+#ifdef LIBXML_XPATH_ENABLED
+
+/*
+ * TODO: when compatibility allows remove all "fake node libxslt" strings
+ * the test should just be name[0] = ' '
+ */
+#ifdef DEBUG_XPATH_EXPRESSION
+#define DEBUG_STEP
+#define DEBUG_EXPR
+#define DEBUG_EVAL_COUNTS
+#endif
+
+static xmlNs xmlXPathXMLNamespaceStruct = {
+ NULL,
+ XML_NAMESPACE_DECL,
+ XML_XML_NAMESPACE,
+ BAD_CAST "xml",
+ NULL,
+ NULL
+};
+static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct;
+#ifndef LIBXML_THREAD_ENABLED
+/*
+ * Optimizer is disabled only when threaded apps are detected while
+ * the library ain't compiled for thread safety.
+ */
+static int xmlXPathDisableOptimizer = 0;
+#endif
+
static void
xmlXPathNodeSetClear(xmlNodeSetPtr set, int hasNsNodes);
@@ -475,114 +583,6 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
#include "timsort.h"
#endif /* WITH_TIM_SORT */
-#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-
-/************************************************************************
- * *
- * Floating point stuff *
- * *
- ************************************************************************/
-
-double xmlXPathNAN = 0.0;
-double xmlXPathPINF = 0.0;
-double xmlXPathNINF = 0.0;
-
-/**
- * xmlXPathInit:
- *
- * DEPRECATED: Alias for xmlInitParser.
- */
-void
-xmlXPathInit(void) {
- xmlInitParser();
-}
-
-/**
- * xmlInitXPathInternal:
- *
- * Initialize the XPath environment
- */
-ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
-void
-xmlInitXPathInternal(void) {
-#if defined(NAN) && defined(INFINITY)
- xmlXPathNAN = NAN;
- xmlXPathPINF = INFINITY;
- xmlXPathNINF = -INFINITY;
-#else
- /* MSVC doesn't allow division by zero in constant expressions. */
- double zero = 0.0;
- xmlXPathNAN = 0.0 / zero;
- xmlXPathPINF = 1.0 / zero;
- xmlXPathNINF = -xmlXPathPINF;
-#endif
-}
-
-/**
- * xmlXPathIsNaN:
- * @val: a double value
- *
- * Returns 1 if the value is a NaN, 0 otherwise
- */
-int
-xmlXPathIsNaN(double val) {
-#ifdef isnan
- return isnan(val);
-#else
- return !(val == val);
-#endif
-}
-
-/**
- * xmlXPathIsInf:
- * @val: a double value
- *
- * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise
- */
-int
-xmlXPathIsInf(double val) {
-#ifdef isinf
- return isinf(val) ? (val > 0 ? 1 : -1) : 0;
-#else
- if (val >= xmlXPathPINF)
- return 1;
- if (val <= -xmlXPathPINF)
- return -1;
- return 0;
-#endif
-}
-
-#endif /* SCHEMAS or XPATH */
-
-#ifdef LIBXML_XPATH_ENABLED
-
-/*
- * TODO: when compatibility allows remove all "fake node libxslt" strings
- * the test should just be name[0] = ' '
- */
-#ifdef DEBUG_XPATH_EXPRESSION
-#define DEBUG_STEP
-#define DEBUG_EXPR
-#define DEBUG_EVAL_COUNTS
-#endif
-
-static xmlNs xmlXPathXMLNamespaceStruct = {
- NULL,
- XML_NAMESPACE_DECL,
- XML_XML_NAMESPACE,
- BAD_CAST "xml",
- NULL,
- NULL
-};
-static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct;
-#ifndef LIBXML_THREAD_ENABLED
-/*
- * Optimizer is disabled only when threaded apps are detected while
- * the library ain't compiled for thread safety.
- */
-static int xmlXPathDisableOptimizer = 0;
-#endif
-
/************************************************************************
* *
* Error handling routines *