diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 2016-07-14 08:18:12 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 2016-07-14 08:18:12 +0000 |
commit | 1daad8f5ad767dfe7896b8d1959a329785c9a76b (patch) | |
tree | bf196533ea985957cd24b17400eda1d88b348daa /lib/libc/regex | |
parent | 7e70f1cbaf29d9cdd3125c1eeec12af43175aebf (diff) |
Notes
Diffstat (limited to 'lib/libc/regex')
-rw-r--r-- | lib/libc/regex/regcomp.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 91398eedcb428..53332334fed7c 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -51,9 +51,12 @@ __FBSDID("$FreeBSD$"); #include <limits.h> #include <stdlib.h> #include <regex.h> +#include <runetype.h> #include <wchar.h> #include <wctype.h> +#include "collate.h" + #include "utils.h" #include "regex2.h" @@ -764,6 +767,9 @@ p_b_term(struct parse *p, cset *cs) { char c; wint_t start, finish; + wint_t i; + struct xlocale_collate *table = + (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE]; /* classify what we've got */ switch ((MORE()) ? PEEK() : '\0') { @@ -811,8 +817,18 @@ p_b_term(struct parse *p, cset *cs) if (start == finish) CHadd(p, cs, start); else { - (void)REQUIRE(start <= finish, REG_ERANGE); - CHaddrange(p, cs, start, finish); + if (table->__collate_load_error) { + (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE); + CHaddrange(p, cs, start, finish); + } else { + (void)REQUIRE(__wcollate_range_cmp(table, start, finish) <= 0, REG_ERANGE); + for (i = 0; i <= UCHAR_MAX; i++) { + if ( __wcollate_range_cmp(table, start, i) <= 0 + && __wcollate_range_cmp(table, i, finish) <= 0 + ) + CHadd(p, cs, i); + } + } } break; } |