1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-26 17:21:02 +03:00

exslt: Use C99 NAN macro

This commit is contained in:
Nick Wellnhofer
2024-09-19 21:45:01 +02:00
parent 06baf50dbc
commit cb1e47d98b
2 changed files with 71 additions and 71 deletions

View File

@ -1961,15 +1961,15 @@ exsltDateYear (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) && if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
(dt->type != XS_GYEARMONTH) && (dt->type != XS_GYEAR)) { (dt->type != XS_GYEARMONTH) && (dt->type != XS_GYEAR)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2020,7 +2020,7 @@ exsltDateLeapYear (const xmlChar *dateTime)
} }
if (dt == NULL) { if (dt == NULL) {
ret = xmlXPathNewFloat(xmlXPathNAN); ret = xmlXPathNewFloat(NAN);
} }
else { else {
ret = xmlXPathNewBoolean(IS_LEAP(dt->year)); ret = xmlXPathNewBoolean(IS_LEAP(dt->year));
@ -2060,16 +2060,16 @@ exsltDateMonthInYear (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) && if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
(dt->type != XS_GYEARMONTH) && (dt->type != XS_GMONTH) && (dt->type != XS_GYEARMONTH) && (dt->type != XS_GMONTH) &&
(dt->type != XS_GMONTHDAY)) { (dt->type != XS_GMONTHDAY)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2207,14 +2207,14 @@ exsltDateWeekInYear (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2273,14 +2273,14 @@ exsltDateWeekInMonth (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2325,14 +2325,14 @@ exsltDateDayInYear (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2372,15 +2372,15 @@ exsltDateDayInMonth (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) && if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
(dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) { (dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2418,14 +2418,14 @@ exsltDateDayOfWeekInMonth (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2465,14 +2465,14 @@ exsltDateDayInWeek (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2594,14 +2594,14 @@ exsltDateHourInDay (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2638,14 +2638,14 @@ exsltDateMinuteInHour (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2684,14 +2684,14 @@ exsltDateSecondInMinute (const xmlChar *dateTime)
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) { if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt); exsltDateFreeDate(dt);
return xmlXPathNAN; return NAN;
} }
} }
@ -2951,12 +2951,12 @@ exsltDateSeconds (const xmlChar *dateTime)
{ {
exsltDateValPtr dt; exsltDateValPtr dt;
exsltDateDurValPtr dur = NULL; exsltDateDurValPtr dur = NULL;
double ret = xmlXPathNAN; double ret = NAN;
if (dateTime == NULL) { if (dateTime == NULL) {
dt = exsltDateCurrent(); dt = exsltDateCurrent();
if (dt == NULL) if (dt == NULL)
return xmlXPathNAN; return NAN;
} else { } else {
dt = exsltDateParse(dateTime); dt = exsltDateParse(dateTime);
if (dt == NULL) if (dt == NULL)

View File

@ -22,7 +22,7 @@
* number math:min (node-set) * number math:min (node-set)
* *
* Returns the minimum value of the nodes passed as the argument, or * Returns the minimum value of the nodes passed as the argument, or
* xmlXPathNAN if @ns is NULL or empty or if one of the nodes * NAN if @ns is NULL or empty or if one of the nodes
* turns into NaN. * turns into NaN.
*/ */
static double static double
@ -31,14 +31,14 @@ exsltMathMin (xmlNodeSetPtr ns) {
int i; int i;
if ((ns == NULL) || (ns->nodeNr == 0)) if ((ns == NULL) || (ns->nodeNr == 0))
return(xmlXPathNAN); return(NAN);
ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]); ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]);
if (xmlXPathIsNaN(ret)) if (xmlXPathIsNaN(ret))
return(xmlXPathNAN); return(NAN);
for (i = 1; i < ns->nodeNr; i++) { for (i = 1; i < ns->nodeNr; i++) {
cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]); cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]);
if (xmlXPathIsNaN(cur)) if (xmlXPathIsNaN(cur))
return(xmlXPathNAN); return(NAN);
if (cur < ret) if (cur < ret)
ret = cur; ret = cur;
} }
@ -91,7 +91,7 @@ exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* number math:max (node-set) * number math:max (node-set)
* *
* Returns the maximum value of the nodes passed as arguments, or * Returns the maximum value of the nodes passed as arguments, or
* xmlXPathNAN if @ns is NULL or empty or if one of the nodes * NAN if @ns is NULL or empty or if one of the nodes
* turns into NaN. * turns into NaN.
*/ */
static double static double
@ -100,14 +100,14 @@ exsltMathMax (xmlNodeSetPtr ns) {
int i; int i;
if ((ns == NULL) || (ns->nodeNr == 0)) if ((ns == NULL) || (ns->nodeNr == 0))
return(xmlXPathNAN); return(NAN);
ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]); ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]);
if (xmlXPathIsNaN(ret)) if (xmlXPathIsNaN(ret))
return(xmlXPathNAN); return(NAN);
for (i = 1; i < ns->nodeNr; i++) { for (i = 1; i < ns->nodeNr; i++) {
cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]); cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]);
if (xmlXPathIsNaN(cur)) if (xmlXPathIsNaN(cur))
return(xmlXPathNAN); return(NAN);
if (cur > ret) if (cur > ret)
ret = cur; ret = cur;
} }
@ -339,7 +339,7 @@ exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* number math:constant(string, number) * number math:constant(string, number)
* *
* Returns a number value of the given constant with the given precision or * Returns a number value of the given constant with the given precision or
* xmlXPathNAN if name is unknown. * NAN if name is unknown.
* The constants are PI, E, SQRRT2, LN2, LN10, LOG2E, and SQRT1_2 * The constants are PI, E, SQRRT2, LN2, LN10, LOG2E, and SQRT1_2
*/ */
static double static double
@ -348,7 +348,7 @@ exsltMathConstant (xmlChar *name, double precision) {
double ret; double ret;
if ((name == NULL) || (xmlXPathIsNaN(precision)) || (precision < 1.0)) { if ((name == NULL) || (xmlXPathIsNaN(precision)) || (precision < 1.0)) {
return xmlXPathNAN; return NAN;
} }
if (xmlStrEqual(name, BAD_CAST "PI")) { if (xmlStrEqual(name, BAD_CAST "PI")) {
@ -411,7 +411,7 @@ exsltMathConstant (xmlChar *name, double precision) {
str = NULL; str = NULL;
} }
if (str == NULL) if (str == NULL)
return xmlXPathNAN; return NAN;
ret = xmlXPathCastStringToNumber(str); ret = xmlXPathCastStringToNumber(str);
xmlFree(str); xmlFree(str);
return ret; return ret;
@ -494,14 +494,14 @@ exsltMathRandomFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math abs() function: * Implements the EXSLT - Math abs() function:
* number math:abs (number) * number math:abs (number)
* *
* Returns the absolute value of the argument, or xmlXPathNAN if @num is Nan. * Returns the absolute value of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathAbs (double num) { exsltMathAbs (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = fabs(num); ret = fabs(num);
return(ret); return(ret);
} }
@ -537,14 +537,14 @@ exsltMathAbsFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math sqrt() function: * Implements the EXSLT - Math sqrt() function:
* number math:sqrt (number) * number math:sqrt (number)
* *
* Returns the square root of the argument, or xmlXPathNAN if @num is Nan. * Returns the square root of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathSqrt (double num) { exsltMathSqrt (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = sqrt(num); ret = sqrt(num);
return(ret); return(ret);
} }
@ -581,7 +581,7 @@ exsltMathSqrtFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math power() function: * Implements the EXSLT - Math power() function:
* number math:power (number, number) * number math:power (number, number)
* *
* Returns the power base and power arguments, or xmlXPathNAN * Returns the power base and power arguments, or NAN
* if either @base or @power is Nan. * if either @base or @power is Nan.
*/ */
static double static double
@ -589,7 +589,7 @@ exsltMathPower (double base, double power) {
double ret; double ret;
if ((xmlXPathIsNaN(base) || xmlXPathIsNaN(power))) if ((xmlXPathIsNaN(base) || xmlXPathIsNaN(power)))
return(xmlXPathNAN); return(NAN);
ret = pow(base, power); ret = pow(base, power);
return(ret); return(ret);
} }
@ -630,14 +630,14 @@ exsltMathPowerFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math log() function: * Implements the EXSLT - Math log() function:
* number math:log (number) * number math:log (number)
* *
* Returns the natural log of the argument, or xmlXPathNAN if @num is Nan. * Returns the natural log of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathLog (double num) { exsltMathLog (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = log(num); ret = log(num);
return(ret); return(ret);
} }
@ -673,14 +673,14 @@ exsltMathLogFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math sin() function: * Implements the EXSLT - Math sin() function:
* number math:sin (number) * number math:sin (number)
* *
* Returns the sine of the argument, or xmlXPathNAN if @num is Nan. * Returns the sine of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathSin (double num) { exsltMathSin (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = sin(num); ret = sin(num);
return(ret); return(ret);
} }
@ -716,14 +716,14 @@ exsltMathSinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math cos() function: * Implements the EXSLT - Math cos() function:
* number math:cos (number) * number math:cos (number)
* *
* Returns the cosine of the argument, or xmlXPathNAN if @num is Nan. * Returns the cosine of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathCos (double num) { exsltMathCos (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = cos(num); ret = cos(num);
return(ret); return(ret);
} }
@ -759,14 +759,14 @@ exsltMathCosFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math tan() function: * Implements the EXSLT - Math tan() function:
* number math:tan (number) * number math:tan (number)
* *
* Returns the tangent of the argument, or xmlXPathNAN if @num is Nan. * Returns the tangent of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathTan (double num) { exsltMathTan (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = tan(num); ret = tan(num);
return(ret); return(ret);
} }
@ -802,14 +802,14 @@ exsltMathTanFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math asin() function: * Implements the EXSLT - Math asin() function:
* number math:asin (number) * number math:asin (number)
* *
* Returns the arc sine of the argument, or xmlXPathNAN if @num is Nan. * Returns the arc sine of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathAsin (double num) { exsltMathAsin (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = asin(num); ret = asin(num);
return(ret); return(ret);
} }
@ -845,14 +845,14 @@ exsltMathAsinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math acos() function: * Implements the EXSLT - Math acos() function:
* number math:acos (number) * number math:acos (number)
* *
* Returns the arc cosine of the argument, or xmlXPathNAN if @num is Nan. * Returns the arc cosine of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathAcos (double num) { exsltMathAcos (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = acos(num); ret = acos(num);
return(ret); return(ret);
} }
@ -888,14 +888,14 @@ exsltMathAcosFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math atan() function: * Implements the EXSLT - Math atan() function:
* number math:atan (number) * number math:atan (number)
* *
* Returns the arc tangent of the argument, or xmlXPathNAN if @num is Nan. * Returns the arc tangent of the argument, or NAN if @num is Nan.
*/ */
static double static double
exsltMathAtan (double num) { exsltMathAtan (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = atan(num); ret = atan(num);
return(ret); return(ret);
} }
@ -932,7 +932,7 @@ exsltMathAtanFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math atan2() function: * Implements the EXSLT - Math atan2() function:
* number math:atan2 (number, number) * number math:atan2 (number, number)
* *
* Returns the arc tangent function of the y/x arguments, or xmlXPathNAN * Returns the arc tangent function of the y/x arguments, or NAN
* if either @y or @x is Nan. * if either @y or @x is Nan.
*/ */
static double static double
@ -940,7 +940,7 @@ exsltMathAtan2 (double y, double x) {
double ret; double ret;
if ((xmlXPathIsNaN(y) || xmlXPathIsNaN(x))) if ((xmlXPathIsNaN(y) || xmlXPathIsNaN(x)))
return(xmlXPathNAN); return(NAN);
ret = atan2(y, x); ret = atan2(y, x);
return(ret); return(ret);
} }
@ -981,7 +981,7 @@ exsltMathAtan2Function (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math exp() function: * Implements the EXSLT - Math exp() function:
* number math:exp (number) * number math:exp (number)
* *
* Returns the exponential function of the argument, or xmlXPathNAN if * Returns the exponential function of the argument, or NAN if
* @num is Nan. * @num is Nan.
*/ */
static double static double
@ -989,7 +989,7 @@ exsltMathExp (double num) {
double ret; double ret;
if (xmlXPathIsNaN(num)) if (xmlXPathIsNaN(num))
return(xmlXPathNAN); return(NAN);
ret = exp(num); ret = exp(num);
return(ret); return(ret);
} }