summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-11-29 03:03:55 +0000
committerache <ache@FreeBSD.org>2001-11-29 03:03:55 +0000
commit0c2addad83d4e772edd16bb6aaea7b585bca9506 (patch)
treecf8cf5a8af36a117ceb01961a37e4d4159baf2a9 /lib/libc/stdlib
parent15d306084a1841d222472de6e9a54c232504f0e3 (diff)
downloadFreeBSD-src-0c2addad83d4e772edd16bb6aaea7b585bca9506.zip
FreeBSD-src-0c2addad83d4e772edd16bb6aaea7b585bca9506.tar.gz
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.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/strtod.c48
-rw-r--r--lib/libc/stdlib/strtoimax.c2
-rw-r--r--lib/libc/stdlib/strtol.c2
-rw-r--r--lib/libc/stdlib/strtoll.c2
-rw-r--r--lib/libc/stdlib/strtoul.c2
-rw-r--r--lib/libc/stdlib/strtoull.c2
-rw-r--r--lib/libc/stdlib/strtoumax.c2
7 files changed, 30 insertions, 30 deletions
diff --git a/lib/libc/stdlib/strtod.c b/lib/libc/stdlib/strtod.c
index 72bb8bf..97b668c87 100644
--- a/lib/libc/stdlib/strtod.c
+++ b/lib/libc/stdlib/strtod.c
@@ -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.
diff --git a/lib/libc/stdlib/strtoimax.c b/lib/libc/stdlib/strtoimax.c
index e5e0442..f8ff09b 100644
--- a/lib/libc/stdlib/strtoimax.c
+++ b/lib/libc/stdlib/strtoimax.c
@@ -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;
diff --git a/lib/libc/stdlib/strtol.c b/lib/libc/stdlib/strtol.c
index 9ff4ec4..3d19693 100644
--- a/lib/libc/stdlib/strtol.c
+++ b/lib/libc/stdlib/strtol.c
@@ -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;
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
index c4fcfef..1fd7d9c 100644
--- a/lib/libc/stdlib/strtoll.c
+++ b/lib/libc/stdlib/strtoll.c
@@ -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;
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c
index 4d08b2c..e431dc8 100644
--- a/lib/libc/stdlib/strtoul.c
+++ b/lib/libc/stdlib/strtoul.c
@@ -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;
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
index 34678fe..adb6556 100644
--- a/lib/libc/stdlib/strtoull.c
+++ b/lib/libc/stdlib/strtoull.c
@@ -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;
diff --git a/lib/libc/stdlib/strtoumax.c b/lib/libc/stdlib/strtoumax.c
index bdcfbd7..ea59245 100644
--- a/lib/libc/stdlib/strtoumax.c
+++ b/lib/libc/stdlib/strtoumax.c
@@ -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;
OpenPOWER on IntegriCloud