1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-19 14:50:07 +03:00

NaN and Inf fixes for pre-C99 compilers

On some pre-C99 compilers, the NAN and INFINITY macros don't expand to
constant expressions.

Some MSVC versions complain about floating point division by zero in
constants.

Thanks to Fabrice Manfroi for the report.
This commit is contained in:
Nick Wellnhofer 2018-03-15 19:33:52 +01:00
parent 18890f471c
commit 7abec67147

21
xpath.c
View File

@ -477,27 +477,28 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
* *
************************************************************************/
#ifndef NAN
#define NAN (0.0 / 0.0)
#endif
#ifndef INFINITY
#define INFINITY HUGE_VAL
#define INFINITY (DBL_MAX * DBL_MAX)
#endif
double xmlXPathNAN = NAN;
double xmlXPathPINF = INFINITY;
double xmlXPathNINF = -INFINITY;
#ifndef NAN
#define NAN (INFINITY / INFINITY)
#endif
double xmlXPathNAN;
double xmlXPathPINF;
double xmlXPathNINF;
/**
* xmlXPathInit:
*
* Initialize the XPath environment
*
* Does nothing but must be kept as public function.
*/
void
xmlXPathInit(void) {
xmlXPathNAN = NAN;
xmlXPathPINF = INFINITY;
xmlXPathNINF = -INFINITY;
}
/**