diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2016-07-10 03:49:38 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2016-07-10 03:49:38 +0000 |
commit | 5a5807dd4ca34467ac5fb458bc19f12bf62075a5 (patch) | |
tree | 061b849a08366eb8c72a8fe3e86c5d7a46eb3e1b /lib/libc/stdio | |
parent | d6f7a4fb17b6dd7a08f9acb28443b16fd5772f67 (diff) | |
download | src-5a5807dd4ca34467ac5fb458bc19f12bf62075a5.tar.gz src-5a5807dd4ca34467ac5fb458bc19f12bf62075a5.zip |
Remove broken support for collation in [a-z] type ranges.
Only first 256 wide chars are considered currently, all other are just
dropped from the range. Proper implementation require reverse tables
database lookup, since objects are really big as max UTF-8 (1114112
code points), so just the same scanning as it was for 256 chars will
slow things down.
POSIX does not require collation for [a-z] type ranges and does not
prohibit it for non-POSIX locales. POSIX require collation for ranges
only for POSIX (or C) locale which is equal to ASCII and binary for
other chars, so we already have it.
No other *BSD implements collation for [a-z] type ranges.
Restore ABI compatibility with unused now __collate_range_cmp() which
is visible from outside (will be removed later).
Notes
Notes:
svn path=/head/; revision=302512
Diffstat (limited to 'lib/libc/stdio')
-rw-r--r-- | lib/libc/stdio/vfscanf.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c index e09a5b22eef9..f3cb1fb67bcb 100644 --- a/lib/libc/stdio/vfscanf.c +++ b/lib/libc/stdio/vfscanf.c @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include <wctype.h> #include "un-namespace.h" -#include "collate.h" #include "libc_private.h" #include "local.h" #include "xlocale_private.h" @@ -816,9 +815,7 @@ match_failure: static const u_char * __sccl(char *tab, const u_char *fmt) { - int c, n, v, i; - struct xlocale_collate *table = - (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE]; + int c, n, v; /* first `clear' the whole table */ c = *fmt++; /* first char hat => negated scanset */ @@ -871,29 +868,15 @@ doswitch: * we just stored in the table (c). */ n = *fmt; - if (n == ']' - || (table->__collate_load_error ? n < c : - __wcollate_range_cmp(table, n, c) < 0 - ) - ) { + if (n == ']' || n < c) { c = '-'; break; /* resume the for(;;) */ } fmt++; - /* fill in the range */ - if (table->__collate_load_error) { - do { - tab[++c] = v; - } while (c < n); - } else { - for (i = 0; i < 256; i ++) - if (__wcollate_range_cmp(table, c, i) < 0 && - __wcollate_range_cmp(table, i, n) <= 0 - ) - tab[i] = v; - } + do { /* fill in the range */ + tab[++c] = v; + } while (c < n); #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'. |