diff options
author | ache <ache@FreeBSD.org> | 2016-07-22 14:24:17 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2016-07-22 14:24:17 +0000 |
commit | 3f56839b4888f5f2140b74ea536b9a0cee3a5084 (patch) | |
tree | de0154f18a175a32c0020a7fc90088448957417c /lib/libc/locale | |
parent | e3c997f56b8acb47dd382a8e4ced061d664ae7b2 (diff) | |
download | FreeBSD-src-3f56839b4888f5f2140b74ea536b9a0cee3a5084.zip FreeBSD-src-3f56839b4888f5f2140b74ea536b9a0cee3a5084.tar.gz |
MFC: r302824
1) Eliminate possibility to call __*collate_range_cmp() with inclomplete
locale (which cause core dump) by removing whole 'table' argument
by which it passed.
2) Restore __collate_range_cmp() in __sccl().
3) Collating [a-z] range in regcomp() works for single byte locales only
(we can't do it for other ones). In previous state only first 256
wide chars are considered and all others are just silently dropped from the
range.
Diffstat (limited to 'lib/libc/locale')
-rw-r--r-- | lib/libc/locale/collate.h | 3 | ||||
-rw-r--r-- | lib/libc/locale/collcmp.c | 19 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/libc/locale/collate.h b/lib/libc/locale/collate.h index ad034d4..496e0ac 100644 --- a/lib/libc/locale/collate.h +++ b/lib/libc/locale/collate.h @@ -72,7 +72,8 @@ u_char *__collate_strdup(u_char *); u_char *__collate_substitute(struct xlocale_collate *, const u_char *); int __collate_load_tables(const char *); void __collate_lookup(struct xlocale_collate *, const u_char *, int *, int *, int *); -int __collate_range_cmp(struct xlocale_collate *, int, int); +int __collate_range_cmp(char, char); +int __wcollate_range_cmp(wchar_t, wchar_t); #ifdef COLLATE_DEBUG void __collate_print_tables(void); #endif diff --git a/lib/libc/locale/collcmp.c b/lib/libc/locale/collcmp.c index aa17afd..4921e71 100644 --- a/lib/libc/locale/collcmp.c +++ b/lib/libc/locale/collcmp.c @@ -33,20 +33,29 @@ __FBSDID("$FreeBSD$"); #include <string.h> -#include <xlocale.h> +#include <wchar.h> #include "collate.h" /* * Compare two characters using collate */ -int __collate_range_cmp(struct xlocale_collate *table, int c1, int c2) +int __collate_range_cmp(char c1, char c2) { static char s1[2], s2[2]; s1[0] = c1; s2[0] = c2; - struct _xlocale l = {{0}}; - l.components[XLC_COLLATE] = (struct xlocale_component *)table; - return (strcoll_l(s1, s2, &l)); + return (strcoll(s1, s2)); +} + +int __wcollate_range_cmp(wchar_t c1, wchar_t c2) +{ + wchar_t s1[2], s2[2]; + + s1[0] = c1; + s1[1] = L'\0'; + s2[0] = c2; + s2[1] = L'\0'; + return (wcscoll(s1, s2)); } |