summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio
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/stdio
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/stdio')
-rw-r--r--lib/libc/stdio/vfscanf.c108
1 files changed, 55 insertions, 53 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 6072112..5181a4e 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -470,6 +470,55 @@ literal:
*/
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 @@ literal:
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 @@ literal:
*/
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 @@ literal:
(flags & DPTOK)) {
flags &= ~(SIGNOK | DPTOK);
goto fok;
- } else if (isdigit(c) && digittoint(c) <= 9) {
- flags &= ~(SIGNOK | NDIGITS);
- goto fok;
}
break;
}
OpenPOWER on IntegriCloud