mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 13:16:07 +00:00
[LIBXML2] Update to version 2.9.8. CORE-15280
This commit is contained in:
parent
61fed54064
commit
5bb277a54b
37 changed files with 545 additions and 493 deletions
178
sdk/lib/3rdparty/libxml2/xpath.c
vendored
178
sdk/lib/3rdparty/libxml2/xpath.c
vendored
|
@ -477,84 +477,66 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
|
|||
* *
|
||||
************************************************************************/
|
||||
|
||||
#ifndef TRIO_REPLACE_STDIO
|
||||
#define TRIO_PUBLIC static
|
||||
#ifndef NAN
|
||||
#define NAN (0.0 / 0.0)
|
||||
#endif
|
||||
#include "trionan.c"
|
||||
|
||||
/*
|
||||
* The lack of portability of this section of the libc is annoying !
|
||||
*/
|
||||
double xmlXPathNAN = 0;
|
||||
double xmlXPathPINF = 1;
|
||||
double xmlXPathNINF = -1;
|
||||
static double xmlXPathNZERO = 0; /* not exported from headers */
|
||||
static int xmlXPathInitialized = 0;
|
||||
#ifndef INFINITY
|
||||
#define INFINITY HUGE_VAL
|
||||
#endif
|
||||
|
||||
double xmlXPathNAN = NAN;
|
||||
double xmlXPathPINF = INFINITY;
|
||||
double xmlXPathNINF = -INFINITY;
|
||||
|
||||
/**
|
||||
* xmlXPathInit:
|
||||
*
|
||||
* Initialize the XPath environment
|
||||
*
|
||||
* Does nothing but must be kept as public function.
|
||||
*/
|
||||
void
|
||||
xmlXPathInit(void) {
|
||||
if (xmlXPathInitialized) return;
|
||||
|
||||
xmlXPathPINF = trio_pinf();
|
||||
xmlXPathNINF = trio_ninf();
|
||||
xmlXPathNAN = trio_nan();
|
||||
xmlXPathNZERO = trio_nzero();
|
||||
|
||||
xmlXPathInitialized = 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));
|
||||
#ifdef isnan
|
||||
return isnan(val);
|
||||
#else
|
||||
return !(val == val);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise
|
||||
*/
|
||||
int
|
||||
xmlXPathIsInf(double val) {
|
||||
return(trio_isinf(val));
|
||||
#ifdef isinf
|
||||
return isinf(val) ? (val > 0 ? 1 : -1) : 0;
|
||||
#else
|
||||
if (val >= HUGE_VAL)
|
||||
return 1;
|
||||
if (val <= -HUGE_VAL)
|
||||
return -1;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* SCHEMAS or XPATH */
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
/**
|
||||
* xmlXPathGetSign:
|
||||
* @val: a double value
|
||||
*
|
||||
* Provides a portable function to detect the sign of a double
|
||||
* Modified from trio code
|
||||
* http://sourceforge.net/projects/ctrio/
|
||||
*
|
||||
* Returns 1 if the value is Negative, 0 if positive
|
||||
*/
|
||||
static int
|
||||
xmlXPathGetSign(double val) {
|
||||
return(trio_signbit(val));
|
||||
}
|
||||
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
|
||||
/*
|
||||
* TODO: when compatibility allows remove all "fake node libxslt" strings
|
||||
|
@ -978,6 +960,8 @@ static int
|
|||
xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathStepOpPtr op,
|
||||
int isPredicate);
|
||||
static void
|
||||
xmlXPathFreeObjectEntry(void *obj, const xmlChar *name);
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
|
@ -1421,7 +1405,8 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
|
|||
default:
|
||||
if (xmlXPathIsNaN(cur->floatval)) {
|
||||
fprintf(output, "Object is a number : NaN\n");
|
||||
} else if (cur->floatval == 0 && xmlXPathGetSign(cur->floatval) != 0) {
|
||||
} else if (cur->floatval == 0) {
|
||||
/* Omit sign for negative zero. */
|
||||
fprintf(output, "Object is a number : 0\n");
|
||||
} else {
|
||||
fprintf(output, "Object is a number : %0g\n", cur->floatval);
|
||||
|
@ -3117,7 +3102,8 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
|
|||
if (xmlXPathIsNaN(number)) {
|
||||
if (buffersize > (int)sizeof("NaN"))
|
||||
snprintf(buffer, buffersize, "NaN");
|
||||
} else if (number == 0 && xmlXPathGetSign(number) != 0) {
|
||||
} else if (number == 0) {
|
||||
/* Omit sign for negative zero. */
|
||||
snprintf(buffer, buffersize, "0");
|
||||
} else if ((number > INT_MIN) && (number < INT_MAX) &&
|
||||
(number == (int) number)) {
|
||||
|
@ -4582,7 +4568,7 @@ xmlXPathDistinctSorted (xmlNodeSetPtr nodes) {
|
|||
xmlFree(strval);
|
||||
}
|
||||
}
|
||||
xmlHashFree(hash, (xmlHashDeallocator) xmlFree);
|
||||
xmlHashFree(hash, xmlHashDefaultDeallocator);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
@ -4894,7 +4880,9 @@ xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||
return(-1);
|
||||
if (f == NULL)
|
||||
return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
|
||||
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, XML_CAST_FPTR(f)));
|
||||
XML_IGNORE_PEDANTIC_WARNINGS
|
||||
return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
|
||||
XML_POP_WARNINGS
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4975,7 +4963,9 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||
if (ctxt->funcHash == NULL)
|
||||
return(NULL);
|
||||
|
||||
XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
|
||||
XML_IGNORE_PEDANTIC_WARNINGS
|
||||
ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
|
||||
XML_POP_WARNINGS
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
@ -5044,10 +5034,9 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
|
|||
return(-1);
|
||||
if (value == NULL)
|
||||
return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
|
||||
(xmlHashDeallocator)xmlXPathFreeObject));
|
||||
xmlXPathFreeObjectEntry));
|
||||
return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri,
|
||||
(void *) value,
|
||||
(xmlHashDeallocator)xmlXPathFreeObject));
|
||||
(void *) value, xmlXPathFreeObjectEntry));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5137,7 +5126,7 @@ xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
|
|||
if (ctxt == NULL)
|
||||
return;
|
||||
|
||||
xmlHashFree(ctxt->varHash, (xmlHashDeallocator)xmlXPathFreeObject);
|
||||
xmlHashFree(ctxt->varHash, xmlXPathFreeObjectEntry);
|
||||
ctxt->varHash = NULL;
|
||||
}
|
||||
|
||||
|
@ -5168,9 +5157,9 @@ xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
|
|||
return(-1);
|
||||
if (ns_uri == NULL)
|
||||
return(xmlHashRemoveEntry(ctxt->nsHash, prefix,
|
||||
(xmlHashDeallocator)xmlFree));
|
||||
xmlHashDefaultDeallocator));
|
||||
return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri),
|
||||
(xmlHashDeallocator)xmlFree));
|
||||
xmlHashDefaultDeallocator));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5219,7 +5208,7 @@ xmlXPathRegisteredNsCleanup(xmlXPathContextPtr ctxt) {
|
|||
if (ctxt == NULL)
|
||||
return;
|
||||
|
||||
xmlHashFree(ctxt->nsHash, (xmlHashDeallocator)xmlFree);
|
||||
xmlHashFree(ctxt->nsHash, xmlHashDefaultDeallocator);
|
||||
ctxt->nsHash = NULL;
|
||||
}
|
||||
|
||||
|
@ -5533,6 +5522,11 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
|
|||
xmlFree(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
xmlXPathFreeObjectEntry(void *obj, const xmlChar *name ATTRIBUTE_UNUSED) {
|
||||
xmlXPathFreeObject((xmlXPathObjectPtr) obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlXPathReleaseObject:
|
||||
* @obj: the xmlXPathObjectPtr to free or to cache
|
||||
|
@ -5722,7 +5716,8 @@ xmlXPathCastNumberToString (double val) {
|
|||
default:
|
||||
if (xmlXPathIsNaN(val)) {
|
||||
ret = xmlStrdup((const xmlChar *) "NaN");
|
||||
} else if (val == 0 && xmlXPathGetSign(val) != 0) {
|
||||
} else if (val == 0) {
|
||||
/* Omit sign for negative zero. */
|
||||
ret = xmlStrdup((const xmlChar *) "0");
|
||||
} else {
|
||||
/* could be improved */
|
||||
|
@ -5904,10 +5899,10 @@ xmlXPathCastNodeToNumber (xmlNodePtr node) {
|
|||
double ret;
|
||||
|
||||
if (node == NULL)
|
||||
return(xmlXPathNAN);
|
||||
return(NAN);
|
||||
strval = xmlXPathCastNodeToString(node);
|
||||
if (strval == NULL)
|
||||
return(xmlXPathNAN);
|
||||
return(NAN);
|
||||
ret = xmlXPathCastStringToNumber(strval);
|
||||
xmlFree(strval);
|
||||
|
||||
|
@ -5928,7 +5923,7 @@ xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns) {
|
|||
double ret;
|
||||
|
||||
if (ns == NULL)
|
||||
return(xmlXPathNAN);
|
||||
return(NAN);
|
||||
str = xmlXPathCastNodeSetToString(ns);
|
||||
ret = xmlXPathCastStringToNumber(str);
|
||||
xmlFree(str);
|
||||
|
@ -5948,13 +5943,13 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
|
|||
double ret = 0.0;
|
||||
|
||||
if (val == NULL)
|
||||
return(xmlXPathNAN);
|
||||
return(NAN);
|
||||
switch (val->type) {
|
||||
case XPATH_UNDEFINED:
|
||||
#ifdef DEGUB_EXPR
|
||||
xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n");
|
||||
#endif
|
||||
ret = xmlXPathNAN;
|
||||
ret = NAN;
|
||||
break;
|
||||
case XPATH_NODESET:
|
||||
case XPATH_XSLT_TREE:
|
||||
|
@ -5974,7 +5969,7 @@ xmlXPathCastToNumber(xmlXPathObjectPtr val) {
|
|||
case XPATH_RANGE:
|
||||
case XPATH_LOCATIONSET:
|
||||
TODO;
|
||||
ret = xmlXPathNAN;
|
||||
ret = NAN;
|
||||
break;
|
||||
}
|
||||
return(ret);
|
||||
|
@ -7478,20 +7473,7 @@ xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
|
|||
if ((ctxt == NULL) || (ctxt->context == NULL)) return;
|
||||
CAST_TO_NUMBER;
|
||||
CHECK_TYPE(XPATH_NUMBER);
|
||||
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
|
||||
ctxt->value->floatval = 0;
|
||||
}
|
||||
else
|
||||
ctxt->value->floatval = - ctxt->value->floatval;
|
||||
ctxt->value->floatval = -ctxt->value->floatval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7583,25 +7565,7 @@ xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
|
|||
xmlXPathReleaseObject(ctxt->context, arg);
|
||||
CAST_TO_NUMBER;
|
||||
CHECK_TYPE(XPATH_NUMBER);
|
||||
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)
|
||||
ctxt->value->floatval = xmlXPathNINF;
|
||||
else if (ctxt->value->floatval < 0)
|
||||
ctxt->value->floatval = xmlXPathPINF;
|
||||
}
|
||||
else if (val == 0) {
|
||||
if (ctxt->value->floatval == 0)
|
||||
ctxt->value->floatval = xmlXPathNAN;
|
||||
else if (ctxt->value->floatval > 0)
|
||||
ctxt->value->floatval = xmlXPathPINF;
|
||||
else if (ctxt->value->floatval < 0)
|
||||
ctxt->value->floatval = xmlXPathNINF;
|
||||
} else
|
||||
ctxt->value->floatval /= val;
|
||||
ctxt->value->floatval /= val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7626,7 +7590,7 @@ xmlXPathModValues(xmlXPathParserContextPtr ctxt) {
|
|||
CHECK_TYPE(XPATH_NUMBER);
|
||||
arg1 = ctxt->value->floatval;
|
||||
if (arg2 == 0)
|
||||
ctxt->value->floatval = xmlXPathNAN;
|
||||
ctxt->value->floatval = NAN;
|
||||
else {
|
||||
ctxt->value->floatval = fmod(arg1, arg2);
|
||||
}
|
||||
|
@ -9745,13 +9709,9 @@ xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||
|
||||
f = ctxt->value->floatval;
|
||||
|
||||
/* Test for zero to keep negative zero unchanged. */
|
||||
if ((xmlXPathIsNaN(f)) || (f == 0.0))
|
||||
return;
|
||||
|
||||
if ((f >= -0.5) && (f < 0.0)) {
|
||||
/* Negative zero. */
|
||||
ctxt->value->floatval = xmlXPathNZERO;
|
||||
if ((f >= -0.5) && (f < 0.5)) {
|
||||
/* Handles negative zero. */
|
||||
ctxt->value->floatval *= 0.0;
|
||||
}
|
||||
else {
|
||||
double rounded = floor(f);
|
||||
|
@ -10098,7 +10058,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
|
|||
if (cur == NULL) return(0);
|
||||
while (IS_BLANK_CH(*cur)) cur++;
|
||||
if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
|
||||
return(xmlXPathNAN);
|
||||
return(NAN);
|
||||
}
|
||||
if (*cur == '-') {
|
||||
isneg = 1;
|
||||
|
@ -10134,7 +10094,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
|
|||
|
||||
cur++;
|
||||
if (((*cur < '0') || (*cur > '9')) && (!ok)) {
|
||||
return(xmlXPathNAN);
|
||||
return(NAN);
|
||||
}
|
||||
while (*cur == '0') {
|
||||
frac = frac + 1;
|
||||
|
@ -10167,7 +10127,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
|
|||
}
|
||||
}
|
||||
while (IS_BLANK_CH(*cur)) cur++;
|
||||
if (*cur != 0) return(xmlXPathNAN);
|
||||
if (*cur != 0) return(NAN);
|
||||
if (isneg) ret = -ret;
|
||||
if (is_exponent_negative) exponent = -exponent;
|
||||
ret *= pow(10.0, (double)exponent);
|
||||
|
@ -12426,7 +12386,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} else if (cur->type == type) {
|
||||
} else if (cur->type == (xmlElementType) type) {
|
||||
if (cur->type == XML_NAMESPACE_DECL)
|
||||
XP_TEST_HIT_NS
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue