1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-25 06:22:00 +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) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
(dt->type != XS_GYEARMONTH) && (dt->type != XS_GYEAR)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2020,7 +2020,7 @@ exsltDateLeapYear (const xmlChar *dateTime)
}
if (dt == NULL) {
ret = xmlXPathNewFloat(xmlXPathNAN);
ret = xmlXPathNewFloat(NAN);
}
else {
ret = xmlXPathNewBoolean(IS_LEAP(dt->year));
@ -2060,16 +2060,16 @@ exsltDateMonthInYear (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
(dt->type != XS_GYEARMONTH) && (dt->type != XS_GMONTH) &&
(dt->type != XS_GMONTHDAY)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2207,14 +2207,14 @@ exsltDateWeekInYear (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2273,14 +2273,14 @@ exsltDateWeekInMonth (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2325,14 +2325,14 @@ exsltDateDayInYear (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2372,15 +2372,15 @@ exsltDateDayInMonth (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
(dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2418,14 +2418,14 @@ exsltDateDayOfWeekInMonth (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2465,14 +2465,14 @@ exsltDateDayInWeek (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2594,14 +2594,14 @@ exsltDateHourInDay (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2638,14 +2638,14 @@ exsltDateMinuteInHour (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2684,14 +2684,14 @@ exsltDateSecondInMinute (const xmlChar *dateTime)
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
return NAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
return NAN;
}
}
@ -2951,12 +2951,12 @@ exsltDateSeconds (const xmlChar *dateTime)
{
exsltDateValPtr dt;
exsltDateDurValPtr dur = NULL;
double ret = xmlXPathNAN;
double ret = NAN;
if (dateTime == NULL) {
dt = exsltDateCurrent();
if (dt == NULL)
return xmlXPathNAN;
return NAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)

View File

@ -22,7 +22,7 @@
* number math:min (node-set)
*
* 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.
*/
static double
@ -31,14 +31,14 @@ exsltMathMin (xmlNodeSetPtr ns) {
int i;
if ((ns == NULL) || (ns->nodeNr == 0))
return(xmlXPathNAN);
return(NAN);
ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]);
if (xmlXPathIsNaN(ret))
return(xmlXPathNAN);
return(NAN);
for (i = 1; i < ns->nodeNr; i++) {
cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]);
if (xmlXPathIsNaN(cur))
return(xmlXPathNAN);
return(NAN);
if (cur < ret)
ret = cur;
}
@ -91,7 +91,7 @@ exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* number math:max (node-set)
*
* 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.
*/
static double
@ -100,14 +100,14 @@ exsltMathMax (xmlNodeSetPtr ns) {
int i;
if ((ns == NULL) || (ns->nodeNr == 0))
return(xmlXPathNAN);
return(NAN);
ret = xmlXPathCastNodeToNumber(ns->nodeTab[0]);
if (xmlXPathIsNaN(ret))
return(xmlXPathNAN);
return(NAN);
for (i = 1; i < ns->nodeNr; i++) {
cur = xmlXPathCastNodeToNumber(ns->nodeTab[i]);
if (xmlXPathIsNaN(cur))
return(xmlXPathNAN);
return(NAN);
if (cur > ret)
ret = cur;
}
@ -339,7 +339,7 @@ exsltMathLowestFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* number math:constant(string, number)
*
* 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
*/
static double
@ -348,7 +348,7 @@ exsltMathConstant (xmlChar *name, double precision) {
double ret;
if ((name == NULL) || (xmlXPathIsNaN(precision)) || (precision < 1.0)) {
return xmlXPathNAN;
return NAN;
}
if (xmlStrEqual(name, BAD_CAST "PI")) {
@ -411,7 +411,7 @@ exsltMathConstant (xmlChar *name, double precision) {
str = NULL;
}
if (str == NULL)
return xmlXPathNAN;
return NAN;
ret = xmlXPathCastStringToNumber(str);
xmlFree(str);
return ret;
@ -494,14 +494,14 @@ exsltMathRandomFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math abs() function:
* 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
exsltMathAbs (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = fabs(num);
return(ret);
}
@ -537,14 +537,14 @@ exsltMathAbsFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math sqrt() function:
* 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
exsltMathSqrt (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = sqrt(num);
return(ret);
}
@ -581,7 +581,7 @@ exsltMathSqrtFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math power() function:
* 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.
*/
static double
@ -589,7 +589,7 @@ exsltMathPower (double base, double power) {
double ret;
if ((xmlXPathIsNaN(base) || xmlXPathIsNaN(power)))
return(xmlXPathNAN);
return(NAN);
ret = pow(base, power);
return(ret);
}
@ -630,14 +630,14 @@ exsltMathPowerFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math log() function:
* 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
exsltMathLog (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = log(num);
return(ret);
}
@ -673,14 +673,14 @@ exsltMathLogFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math sin() function:
* 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
exsltMathSin (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = sin(num);
return(ret);
}
@ -716,14 +716,14 @@ exsltMathSinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math cos() function:
* 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
exsltMathCos (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = cos(num);
return(ret);
}
@ -759,14 +759,14 @@ exsltMathCosFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math tan() function:
* 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
exsltMathTan (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = tan(num);
return(ret);
}
@ -802,14 +802,14 @@ exsltMathTanFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math asin() function:
* 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
exsltMathAsin (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = asin(num);
return(ret);
}
@ -845,14 +845,14 @@ exsltMathAsinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math acos() function:
* 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
exsltMathAcos (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = acos(num);
return(ret);
}
@ -888,14 +888,14 @@ exsltMathAcosFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math atan() function:
* 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
exsltMathAtan (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = atan(num);
return(ret);
}
@ -932,7 +932,7 @@ exsltMathAtanFunction (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math atan2() function:
* 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.
*/
static double
@ -940,7 +940,7 @@ exsltMathAtan2 (double y, double x) {
double ret;
if ((xmlXPathIsNaN(y) || xmlXPathIsNaN(x)))
return(xmlXPathNAN);
return(NAN);
ret = atan2(y, x);
return(ret);
}
@ -981,7 +981,7 @@ exsltMathAtan2Function (xmlXPathParserContextPtr ctxt, int nargs) {
* Implements the EXSLT - Math exp() function:
* 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.
*/
static double
@ -989,7 +989,7 @@ exsltMathExp (double num) {
double ret;
if (xmlXPathIsNaN(num))
return(xmlXPathNAN);
return(NAN);
ret = exp(num);
return(ret);
}