Back out national digits support, POSIX explicetely disallows it:

The definition of character class digit requires that only ten characters
-the ones defining digits- can be specified; alternate digits (for
example, Hindi or Kanji) cannot be specified here. However, the encoding
may vary if an implementation supports more than one encoding.

The definition of character class xdigit requires that the characters
included in character class digit are included here also and allows for
different symbols for the hexadecimal digits 10 through 15.
This commit is contained in:
Andrey A. Chernov 2001-11-29 03:03:55 +00:00
parent e1a5ca24ca
commit 2209d8a27c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87078
9 changed files with 87 additions and 85 deletions

View file

@ -470,6 +470,55 @@ again: c = *fmt++;
*/
switch (c) {
/*
* The digit 0 is always legal, but is
* special. For %i conversions, if no
* digits (zero or nonzero) have been
* scanned (only signs), we will have
* base==0. In that case, we should set
* it to 8 and enable 0x prefixing.
* Also, if we have not scanned zero digits
* before this, do not turn off prefixing
* (someone else will turn it off if we
* have scanned any nonzero digits).
*/
case '0':
if (base == 0) {
base = 8;
flags |= PFXOK;
}
if (flags & NZDIGITS)
flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
else
flags &= ~(SIGNOK|PFXOK|NDIGITS);
goto ok;
/* 1 through 7 always legal */
case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
base = basefix[base];
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
/* digits 8 and 9 ok iff decimal or hex */
case '8': case '9':
base = basefix[base];
if (base <= 8)
break; /* not legal here */
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
/* letters ok iff hex */
case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F':
case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f':
/* no need to fix base here */
if (base <= 10)
break; /* not legal here */
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
/* sign ok only as first character */
case '+': case '-':
if (flags & SIGNOK) {
@ -486,56 +535,6 @@ again: c = *fmt++;
goto ok;
}
break;
default:
if (!isdigit(c) && (base != 16 || !isxdigit(c)))
break;
n = digittoint(c);
if (n >= 16)
break;
else if (n >= 10) {
/* letters ok iff hex */
/* no need to fix base here */
if (base <= 10)
break; /* not legal here */
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
} else if (n >= 8) {
/* digits 8 and 9 ok iff decimal or hex */
base = basefix[base];
if (base <= 8)
break; /* not legal here */
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
} else if (n > 0) {
/* 1 through 7 always legal */
base = basefix[base];
flags &= ~(SIGNOK | PFXOK | NDIGITS);
goto ok;
} else {
/*
* The digit 0 is always legal, but is
* special. For %i conversions, if no
* digits (zero or nonzero) have been
* scanned (only signs), we will have
* base==0. In that case, we should set
* it to 8 and enable 0x prefixing.
* Also, if we have not scanned zero digits
* before this, do not turn off prefixing
* (someone else will turn it off if we
* have scanned any nonzero digits).
*/
if (base == 0) {
base = 8;
flags |= PFXOK;
}
if (flags & NZDIGITS)
flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
else
flags &= ~(SIGNOK|PFXOK|NDIGITS);
goto ok;
}
/* NOTREACHED */
}
/*
@ -612,6 +611,12 @@ again: c = *fmt++;
*/
switch (c) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
flags &= ~(SIGNOK | NDIGITS);
goto fok;
case '+': case '-':
if (flags & SIGNOK) {
flags &= ~SIGNOK;
@ -632,9 +637,6 @@ again: c = *fmt++;
(flags & DPTOK)) {
flags &= ~(SIGNOK | DPTOK);
goto fok;
} else if (isdigit(c) && digittoint(c) <= 9) {
flags &= ~(SIGNOK | NDIGITS);
goto fok;
}
break;
}

View file

@ -481,13 +481,13 @@ s2b
if (9 < nd0) {
s += 9;
do
b = multadd(b, 10, digittoint((unsigned char)*s++));
b = multadd(b, 10, *s++ - '0');
while (++i < nd0);
s++;
} else
s += 10;
for (; i < nd; i++)
b = multadd(b, 10, digittoint((unsigned char)*s++));
b = multadd(b, 10, *s++ - '0');
return b;
}
@ -1192,7 +1192,7 @@ strtod
#endif
{
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
e, e1, esign, i, j, k, n, nd, nd0, nf, nz, nz0, sign;
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
CONST char *s, *s0, *s1;
double aadj, aadj1, adj, rv, rv0;
long L;
@ -1219,26 +1219,26 @@ strtod
goto break2;
}
break2:
if (isdigit(c = (unsigned char)*s) && digittoint(c) == 0) {
if (*s == '0') {
nz0 = 1;
while (isdigit(c = (unsigned char)*++s) && digittoint(c) == 0) ;
while (*++s == '0') ;
if (!*s)
goto ret;
}
s0 = s;
y = z = 0;
for (nd = nf = 0; isdigit(c = (unsigned char)*s) && (n = digittoint(c)) <= 9; nd++, s++)
for (nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
if (nd < 9)
y = 10*y + n;
y = 10*y + c - '0';
else if (nd < 16)
z = 10*z + n;
z = 10*z + c - '0';
nd0 = nd;
if ((char)c == decimal_point) {
c = (unsigned char)*++s;
c = *++s;
if (!nd) {
for (; isdigit(c) && digittoint(c) == 0; c = (unsigned char)*++s)
for (; c == '0'; c = *++s)
nz++;
if (isdigit(c) && (n = digittoint(c)) <= 9) {
if (c > '0' && c <= '9') {
s0 = s;
nf += nz;
nz = 0;
@ -1246,10 +1246,10 @@ strtod
}
goto dig_done;
}
for (; isdigit(c) && (n = digittoint(c)) <= 9; c = (unsigned char)*++s) {
for (; c >= '0' && c <= '9'; c = *++s) {
have_dig:
nz++;
if (n > 0) {
if (c - '0' > 0) {
nf += nz;
for (i = 1; i < nz; i++)
if (nd++ < 9)
@ -1257,9 +1257,9 @@ strtod
else if (nd <= DBL_DIG + 1)
z *= 10;
if (nd++ < 9)
y = 10*y + n;
y = 10*y + c - '0';
else if (nd <= DBL_DIG + 1)
z = 10*z + n;
z = 10*z + c - '0';
nz = 0;
}
}
@ -1273,20 +1273,20 @@ strtod
}
s00 = s;
esign = 0;
switch(c = (unsigned char)*++s) {
switch(c = *++s) {
case '-':
esign = 1;
case '+':
c = (unsigned char)*++s;
c = *++s;
}
if (isdigit(c) && digittoint(c) <= 9) {
while (isdigit(c) && digittoint(c) == 0)
c = (unsigned char)*++s;
if (isdigit(c) && (n = digittoint(c)) <= 9) {
L = n;
if (c >= '0' && c <= '9') {
while (c == '0')
c = *++s;
if (c > '0' && c <= '9') {
L = c - '0';
s1 = s;
while (isdigit(c = (unsigned char)*++s) && (n = digittoint(c)) <= 9)
L = 10*L + n;
while ((c = *++s) >= '0' && c <= '9')
L = 10*L + c - '0';
if (s - s1 > 8 || L > 19999)
/* Avoid confusion from exponents
* so large that e might overflow.

View file

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

View file

@ -11,13 +11,13 @@ ENCODING "NONE"
ALPHA 'A' - 'Z' 'a' - 'z' '¡' - 'ê'
CONTROL 0x00 - 0x1f 0x7f
DIGIT '0' - '9' 'ń' - 'ú'
DIGIT '0' - '9'
GRAPH 0x21 - 0x7e
LOWER 'a' - 'z'
PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
SPACE 0x09 - 0x0d 0x20
UPPER 'A' - 'Z'
XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F' 'ń' - 'ú'
XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
BLANK ' ' '\t'
PRINT 0x20 - 0xfa
# IDEOGRAM