Portability fix: use unsigned cast to guaranteed positive part of expression

in case {L}LONG_MAX > abs({L}LONG_MIN).  Non-functional change - we don't
have any such platforms.
This commit is contained in:
ache 2001-09-04 21:28:01 +00:00
parent 5ee68af4e9
commit 36a7b5dd63
2 changed files with 2 additions and 2 deletions

View File

@ -107,7 +107,7 @@ strtol(nptr, endptr, base)
* Set 'any' if any `digits' consumed; make it negative to indicate
* overflow.
*/
cutoff = neg ? (unsigned long)-(LONG_MIN + LONG_MAX) + LONG_MAX
cutoff = neg ? -(LONG_MIN + LONG_MAX) + (unsigned long)LONG_MAX
: LONG_MAX;
cutlim = cutoff % base;
cutoff /= base;

View File

@ -107,7 +107,7 @@ strtoll(nptr, endptr, base)
* Set 'any' if any `digits' consumed; make it negative to indicate
* overflow.
*/
cutoff = neg ? (unsigned long long)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX
cutoff = neg ? -(LLONG_MIN + LLONG_MAX) + (unsigned long long)LLONG_MAX
: LLONG_MAX;
cutlim = cutoff % base;
cutoff /= base;