From ad4c7a03b7ca435630c9f77c85536dca2ca07f2a Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 7 Jan 2021 14:45:40 +0000 Subject: Revise UWIDE_MAX and friends --- generic/tclPort.h | 6 +++--- generic/tclStrToD.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generic/tclPort.h b/generic/tclPort.h index d3f6233..e927620 100644 --- a/generic/tclPort.h +++ b/generic/tclPort.h @@ -24,8 +24,8 @@ #endif #include "tcl.h" -#define UWIDE_MAX ((Tcl_WideUInt)-1) -#define WIDE_MAX ((Tcl_WideInt)(UWIDE_MAX >> 1)) -#define WIDE_MIN ((Tcl_WideInt)((Tcl_WideUInt)WIDE_MAX+1)) +#define UWIDE_MAX ULLONG_MAX +#define WIDE_MAX LLONG_MAX +#define WIDE_MIN LLONG_MIN #endif /* _TCLPORT */ diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 2f870c6..b5c0ca2 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -538,7 +538,7 @@ TclParseNumber( int under = 0; /* Flag trailing '_' as error if true once * number is accepted. */ -#define ALL_BITS ((Tcl_WideUInt)-1) +#define ALL_BITS UWIDE_MAX #define MOST_BITS (ALL_BITS >> 1) /* @@ -725,7 +725,7 @@ TclParseNumber( && (((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt)) || (octalSignificandWide > - ((Tcl_WideUInt)-1 >> shift)))) { + (UWIDE_MAX >> shift)))) { octalSignificandOverflow = 1; err = mp_init_u64(&octalSignificandBig, octalSignificandWide); @@ -865,7 +865,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > ((Tcl_WideUInt)-1 >> shift))) { + significandWide > (UWIDE_MAX >> shift))) { significandOverflow = 1; err = mp_init_u64(&significandBig, significandWide); @@ -917,7 +917,7 @@ TclParseNumber( if (significandWide != 0 && ((size_t)shift >= CHAR_BIT*sizeof(Tcl_WideUInt) || - significandWide > ((Tcl_WideUInt)-1 >> shift))) { + significandWide > (UWIDE_MAX >> shift))) { significandOverflow = 1; err = mp_init_u64(&significandBig, significandWide); @@ -1597,7 +1597,7 @@ AccumulateDecimalDigit( *wideRepPtr = digit; return 0; } else if (numZeros >= maxpow10_wide - || w > ((Tcl_WideUInt)-1-digit)/pow10_wide[numZeros+1]) { + || w > (UWIDE_MAX-digit)/pow10_wide[numZeros+1]) { /* * Wide multiplication will overflow. Expand the number to a * bignum and fall through into the bignum case. -- cgit v0.12