diff options
author | ache <ache@FreeBSD.org> | 1997-01-16 07:36:14 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-01-16 07:36:14 +0000 |
commit | f8e72105a5622d280aab7ae134a07e8f0f950805 (patch) | |
tree | 74d49b43660e5ce1225c762cde2753cc0cb296ae | |
parent | b29acb422ef5306cddf84016538524c5f60d6570 (diff) | |
download | FreeBSD-src-f8e72105a5622d280aab7ae134a07e8f0f950805.zip FreeBSD-src-f8e72105a5622d280aab7ae134a07e8f0f950805.tar.gz |
Use collate for national [a-z]-like ranges
Should go in 2.2
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index c0699c1..f26db86 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -50,6 +50,9 @@ static const char rcsid[] = #else #include <varargs.h> #endif +#include <string.h> + +#include "collate.h" #include "local.h" #define FLOATING_POINT @@ -665,7 +668,7 @@ __sccl(tab, fmt) register char *tab; register u_char *fmt; { - register int c, n, v; + register int c, n, v, i; /* first `clear' the whole table */ c = *fmt++; /* first char hat => negated scanset */ @@ -674,9 +677,7 @@ __sccl(tab, fmt) c = *fmt++; /* get new first char */ } else v = 0; /* default => reject */ - /* should probably use memset here */ - for (n = 0; n < 256; n++) - tab[n] = v; + (void) memset(tab, v, 256); if (c == 0) return (fmt - 1);/* format ended before closing ] */ @@ -717,15 +718,19 @@ doswitch: * we just stored in the table (c). */ n = *fmt; - if (n == ']' || n < c) { + if (n == ']' || __collate_range_cmp (n, c) < 0) { c = '-'; break; /* resume the for(;;) */ } fmt++; - do { /* fill in the range */ - tab[++c] = v; - } while (c < n); + /* fill in the range */ + for (i = 0; i < 256; i ++) + if ( __collate_range_cmp (c, i) < 0 + && __collate_range_cmp (i, n) <= 0 + ) + tab[i] = v; #if 1 /* XXX another disgusting compatibility hack */ + c = n; /* * Alas, the V7 Unix scanf also treats formats * such as [a-c-e] as `the letters a through e'. |