diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-02-17 17:30:13 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2022-02-17 17:30:13 (GMT) |
commit | e246b44499e406683adac8035e53d08b4dc0192a (patch) | |
tree | 871f197c9b3896ee27b62f946ee1b42f7062ceb9 /generic | |
parent | aa93fba41a6764dce6c1f918388efd0f46136ada (diff) | |
download | tcl-e246b44499e406683adac8035e53d08b4dc0192a.zip tcl-e246b44499e406683adac8035e53d08b4dc0192a.tar.gz tcl-e246b44499e406683adac8035e53d08b4dc0192a.tar.bz2 |
Deprecate internal macro's TclIsInfinite() and TclIsNan(), since C99 has isinf() and isnan()
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclBasic.c | 6 | ||||
-rw-r--r-- | generic/tclExecute.c | 12 | ||||
-rw-r--r-- | generic/tclInt.h | 15 | ||||
-rw-r--r-- | generic/tclLink.c | 6 | ||||
-rw-r--r-- | generic/tclObj.c | 4 | ||||
-rw-r--r-- | generic/tclStrToD.c | 2 | ||||
-rw-r--r-- | generic/tclTest.c | 2 | ||||
-rw-r--r-- | generic/tclUtil.c | 4 |
8 files changed, 22 insertions, 29 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 714bd80..ae7a3dc 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -7841,7 +7841,7 @@ ExprSqrtFunc( if (code != TCL_OK) { return TCL_ERROR; } - if ((d >= 0.0) && TclIsInfinite(d) + if ((d >= 0.0) && isinf(d) && (Tcl_GetBignumFromObj(NULL, objv[1], &big) == TCL_OK)) { mp_int root; mp_err err; @@ -7906,12 +7906,12 @@ CheckDoubleResult( double dResult) { #ifndef ACCEPT_NAN - if (TclIsNaN(dResult)) { + if (isnan(dResult)) { TclExprFloatError(interp, dResult); return TCL_ERROR; } #endif - if ((errno == ERANGE) && ((dResult == 0.0) || TclIsInfinite(dResult))) { + if ((errno == ERANGE) && ((dResult == 0.0) || isinf(dResult))) { /* * When ERANGE signals under/overflow, just accept 0.0 or +/-Inf */ diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 403f3c9..dfb195a 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -514,7 +514,7 @@ VarHashCreateVar( *(ptrPtr) = (ClientData) \ (&((objPtr)->internalRep.wideValue)), TCL_OK) : \ TclHasInternalRep((objPtr), &tclDoubleType) \ - ? (((TclIsNaN((objPtr)->internalRep.doubleValue)) \ + ? (((isnan((objPtr)->internalRep.doubleValue)) \ ? (*(tPtr) = TCL_NUMBER_NAN) \ : (*(tPtr) = TCL_NUMBER_DOUBLE)), \ *(ptrPtr) = (ClientData) \ @@ -8653,7 +8653,7 @@ ExecuteExtendedBinaryMathOp( * Check now for IEEE floating-point error. */ - if (TclIsNaN(dResult)) { + if (isnan(dResult)) { TclExprFloatError(interp, dResult); return GENERAL_ARITHMETIC_ERROR; } @@ -8966,7 +8966,7 @@ TclCompareTwoNumbers( w1 = (Tcl_WideInt)d1; goto wideCompare; case TCL_NUMBER_BIG: - if (TclIsInfinite(d1)) { + if (isinf(d1)) { return (d1 > 0.0) ? MP_GT : MP_LT; } Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2); @@ -8999,7 +8999,7 @@ TclCompareTwoNumbers( return compare; case TCL_NUMBER_DOUBLE: d2 = *((const double *)ptr2); - if (TclIsInfinite(d2)) { + if (isinf(d2)) { compare = (d2 > 0.0) ? MP_LT : MP_GT; mp_clear(&big1); return compare; @@ -9602,11 +9602,11 @@ TclExprFloatError( { const char *s; - if ((errno == EDOM) || TclIsNaN(value)) { + if ((errno == EDOM) || isnan(value)) { s = "domain error: argument not in valid range"; Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1)); Tcl_SetErrorCode(interp, "ARITH", "DOMAIN", s, NULL); - } else if ((errno == ERANGE) || TclIsInfinite(value)) { + } else if ((errno == ERANGE) || isinf(value)) { if (value == 0.0) { s = "floating-point value too small to represent"; Tcl_SetObjResult(interp, Tcl_NewStringObj(s, -1)); diff --git a/generic/tclInt.h b/generic/tclInt.h index b82a473..75cd6e5 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4965,22 +4965,15 @@ MODULE_SCOPE Tcl_LibraryInitProc Procbodytest_SafeInit; /* *---------------------------------------------------------------- * Macros used by the Tcl core to test for some special double values. - * The ANSI C "prototypes" for these macros are: + * (deprecated) The ANSI C "prototypes" for these macros are: * * MODULE_SCOPE int TclIsInfinite(double d); * MODULE_SCOPE int TclIsNaN(double d); */ -#ifdef _MSC_VER -# define TclIsInfinite(d) (!(_finite((d)))) -# define TclIsNaN(d) (_isnan((d))) -#else -# define TclIsInfinite(d) ((d) > DBL_MAX || (d) < -DBL_MAX) -# ifdef NO_ISNAN -# define TclIsNaN(d) ((d) != (d)) -# else -# define TclIsNaN(d) (isnan(d)) -# endif +#if !defined(TCL_NO_DEPRECATED) && !defined(BUILD_tcl) +# define TclIsInfinite(d) isinf(d) +# define TclIsNaN(d) isnan(d) #endif /* diff --git a/generic/tclLink.c b/generic/tclLink.c index 5baa092..39f5345 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -606,7 +606,7 @@ EqualDouble( { return (a == b) #ifdef ACCEPT_NAN - || (TclIsNaN(a) && TclIsNaN(b)) + || (isnan(a) && isnan(b)) #endif /* ACCEPT_NAN */ ; } @@ -615,9 +615,9 @@ static inline int IsSpecial( double a) { - return TclIsInfinite(a) + return isinf(a) #ifdef ACCEPT_NAN - || TclIsNaN(a) + || isnan(a) #endif /* ACCEPT_NAN */ ; } diff --git a/generic/tclObj.c b/generic/tclObj.c index 4ac9936..a06b8fd 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -2547,7 +2547,7 @@ Tcl_GetDoubleFromObj( { do { if (objPtr->typePtr == &tclDoubleType) { - if (TclIsNaN(objPtr->internalRep.doubleValue)) { + if (isnan(objPtr->internalRep.doubleValue)) { if (interp != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "floating point value is Not a Number", -1)); @@ -3880,7 +3880,7 @@ TclGetNumberFromObj( { do { if (objPtr->typePtr == &tclDoubleType) { - if (TclIsNaN(objPtr->internalRep.doubleValue)) { + if (isnan(objPtr->internalRep.doubleValue)) { *typePtr = TCL_NUMBER_NAN; } else { *typePtr = TCL_NUMBER_DOUBLE; diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 5ee5945..a7986b0 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -4832,7 +4832,7 @@ Tcl_InitBignumFromDouble( * Infinite values can't convert to bignum. */ - if (TclIsInfinite(d)) { + if (isinf(d)) { if (interp != NULL) { const char *s = "integer value too large to represent"; diff --git a/generic/tclTest.c b/generic/tclTest.c index 0db8587..009c95f 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -1652,7 +1652,7 @@ TestdoubledigitsObjCmd( if (status != TCL_OK) { doubleType = Tcl_GetObjType("double"); if (Tcl_FetchInternalRep(objv[1], doubleType) - && TclIsNaN(objv[1]->internalRep.doubleValue)) { + && isnan(objv[1]->internalRep.doubleValue)) { status = TCL_OK; memcpy(&d, &(objv[1]->internalRep.doubleValue), sizeof(double)); } diff --git a/generic/tclUtil.c b/generic/tclUtil.c index a96c752..66d1009 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -3231,7 +3231,7 @@ Tcl_PrintDouble( * Handle NaN. */ - if (TclIsNaN(value)) { + if (isnan(value)) { TclFormatNaN(value, dst); return; } @@ -3240,7 +3240,7 @@ Tcl_PrintDouble( * Handle infinities. */ - if (TclIsInfinite(value)) { + if (isinf(value)) { /* * Remember to copy the terminating NUL too. */ |