Don't ever assume that isdigit() is always subset of isxdigit()

This commit is contained in:
Andrey A. Chernov 2001-11-28 06:06:27 +00:00
parent 7bbd0c8b5b
commit 87c25490c8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87042
7 changed files with 7 additions and 7 deletions

View File

@ -488,7 +488,7 @@ again: c = *fmt++;
break;
default:
if (!isxdigit(c))
if (!isdigit(c) && (base != 16 || !isxdigit(c)))
break;
n = digittoint(c);
if (n >= 16)

View File

@ -112,7 +112,7 @@ strtoimax(nptr, endptr, base)
cutlim = cutoff % base;
cutoff /= base;
for ( ; ; c = *s++) {
if (isxdigit(c))
if (isdigit(c) || (base == 16 && isxdigit(c)))
c = digittoint(c);
else if (isascii(c) && isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;

View File

@ -112,7 +112,7 @@ strtol(nptr, endptr, base)
cutlim = cutoff % base;
cutoff /= base;
for ( ; ; c = *s++) {
if (isxdigit(c))
if (isdigit(c) || (base == 16 && isxdigit(c)))
c = digittoint(c);
else if (isascii(c) && isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;

View File

@ -112,7 +112,7 @@ strtoll(nptr, endptr, base)
cutlim = cutoff % base;
cutoff /= base;
for ( ; ; c = *s++) {
if (isxdigit(c))
if (isdigit(c) || (base == 16 && isxdigit(c)))
c = digittoint(c);
else if (isascii(c) && isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;

View File

@ -90,7 +90,7 @@ strtoul(nptr, endptr, base)
cutoff = ULONG_MAX / base;
cutlim = ULONG_MAX % base;
for ( ; ; c = *s++) {
if (isxdigit(c))
if (isdigit(c) || (base == 16 && isxdigit(c)))
c = digittoint(c);
else if (isascii(c) && isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;

View File

@ -90,7 +90,7 @@ strtoull(nptr, endptr, base)
cutoff = ULLONG_MAX / base;
cutlim = ULLONG_MAX % base;
for ( ; ; c = *s++) {
if (isxdigit(c))
if (isdigit(c) || (base == 16 && isxdigit(c)))
c = digittoint(c);
else if (isascii(c) && isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;

View File

@ -90,7 +90,7 @@ strtoumax(nptr, endptr, base)
cutoff = UINTMAX_MAX / base;
cutlim = UINTMAX_MAX % base;
for ( ; ; c = *s++) {
if (isxdigit(c))
if (isdigit(c) || (base == 16 && isxdigit(c)))
c = digittoint(c);
else if (isascii(c) && isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;