Cygwin: convert __collate_range_cmp to __wcollate_range_cmp
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=179721 After FreeBSD eventually picked up the bugreport from within only 5 years, rename __collate_range_cmp to __wcollate_range_cmp as suggested all along, and make it type safe (wint_t instead of wchar_t for hopefully obvious reasons...) While at it, drop __collate_load_error and fix the checks for it in glob and fnmatch. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
f0417a6201
commit
064e4bb8bb
|
@ -879,10 +879,14 @@ match(Char *name, Char *pat, Char *patend)
|
||||||
if (is_unicode_equiv (k, *pat++))
|
if (is_unicode_equiv (k, *pat++))
|
||||||
ok = 1;
|
ok = 1;
|
||||||
} else if ((*pat & M_MASK) == M_RNG) {
|
} else if ((*pat & M_MASK) == M_RNG) {
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
if ((!__get_current_collate_locale ()->lcid) ?
|
||||||
|
#else
|
||||||
if (__collate_load_error ?
|
if (__collate_load_error ?
|
||||||
|
#endif
|
||||||
CCHAR(c) <= CCHAR(k) && CCHAR(k) <= CCHAR(pat[1]) :
|
CCHAR(c) <= CCHAR(k) && CCHAR(k) <= CCHAR(pat[1]) :
|
||||||
__collate_range_cmp(CCHAR(c), CCHAR(k)) <= 0
|
__wcollate_range_cmp(CCHAR(c), CCHAR(k)) <= 0
|
||||||
&& __collate_range_cmp(CCHAR(k), CCHAR(pat[1])) <= 0
|
&& __wcollate_range_cmp(CCHAR(k), CCHAR(pat[1])) <= 0
|
||||||
)
|
)
|
||||||
ok = 1;
|
ok = 1;
|
||||||
pat += 2;
|
pat += 2;
|
||||||
|
|
|
@ -96,9 +96,6 @@ char NO_COPY almost_null[1];
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
/* We never have a collate load error. */
|
|
||||||
const int __collate_load_error = 0;
|
|
||||||
|
|
||||||
/* Heavily-used const UNICODE_STRINGs are defined here once. The idea is a
|
/* Heavily-used const UNICODE_STRINGs are defined here once. The idea is a
|
||||||
speed improvement by not having to initialize a UNICODE_STRING every time
|
speed improvement by not having to initialize a UNICODE_STRING every time
|
||||||
we make a string comparison. The _RDATA trick allows defining the strings
|
we make a string comparison. The _RDATA trick allows defining the strings
|
||||||
|
|
|
@ -330,18 +330,14 @@ rangematch(const char *pattern, wint_t test, int flags, char **newp,
|
||||||
c2 = towlower(c2);
|
c2 = towlower(c2);
|
||||||
|
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
if (__collate_load_error ?
|
if ((!__get_current_collate_locale ()->lcid) ?
|
||||||
c <= test && test <= c2 :
|
|
||||||
__collate_range_cmp(c, test) <= 0
|
|
||||||
&& __collate_range_cmp(test, c2) <= 0
|
|
||||||
)
|
|
||||||
#else
|
#else
|
||||||
if (table->__collate_load_error ?
|
if (table->__collate_load_error ?
|
||||||
c <= test && test <= c2 :
|
|
||||||
__collate_range_cmp(table, c, test) <= 0
|
|
||||||
&& __collate_range_cmp(table, test, c2) <= 0
|
|
||||||
)
|
|
||||||
#endif
|
#endif
|
||||||
|
c <= test && test <= c2 :
|
||||||
|
__wcollate_range_cmp(c, test) <= 0
|
||||||
|
&& __wcollate_range_cmp(test, c2) <= 0
|
||||||
|
)
|
||||||
ok = 1;
|
ok = 1;
|
||||||
} else if (c == test)
|
} else if (c == test)
|
||||||
ok = 1;
|
ok = 1;
|
||||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
||||||
|
|
||||||
extern const int __collate_load_error;
|
extern const int __collate_load_error;
|
||||||
|
|
||||||
extern int __collate_range_cmp (int c1, int c2);
|
extern int __wcollate_range_cmp (wint_t, wint_t);
|
||||||
|
|
||||||
int is_unicode_equiv (wint_t, wint_t);
|
int is_unicode_equiv (wint_t, wint_t);
|
||||||
|
|
||||||
|
|
|
@ -1172,11 +1172,9 @@ strcoll (const char *__restrict s1, const char *__restrict s2)
|
||||||
return strcoll_l (s1, s2, __get_current_locale ());
|
return strcoll_l (s1, s2, __get_current_locale ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* BSD. Used from glob.cc, fnmatch.c and regcomp.c. Make sure caller is
|
/* BSD. Used from glob.cc, fnmatch.c and regcomp.c. */
|
||||||
using wide chars. Unfortunately the definition of this functions hides
|
|
||||||
the required input type. */
|
|
||||||
extern "C" int
|
extern "C" int
|
||||||
__collate_range_cmp (int c1, int c2)
|
__wcollate_range_cmp (wint_t c1, wint_t c2)
|
||||||
{
|
{
|
||||||
wchar_t s1[3] = { (wchar_t) c1, L'\0', L'\0' };
|
wchar_t s1[3] = { (wchar_t) c1, L'\0', L'\0' };
|
||||||
wchar_t s2[3] = { (wchar_t) c2, L'\0', L'\0' };
|
wchar_t s2[3] = { (wchar_t) c2, L'\0', L'\0' };
|
||||||
|
|
|
@ -834,10 +834,10 @@ p_b_term(struct parse *p, cset *cs)
|
||||||
(void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE);
|
(void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE);
|
||||||
CHaddrange(p, cs, start, finish);
|
CHaddrange(p, cs, start, finish);
|
||||||
} else {
|
} else {
|
||||||
(void)REQUIRE(__collate_range_cmp(start, finish) <= 0, REG_ERANGE);
|
(void)REQUIRE(__wcollate_range_cmp(start, finish) <= 0, REG_ERANGE);
|
||||||
for (i = 0; i <= UCHAR_MAX; i++) {
|
for (i = 0; i <= UCHAR_MAX; i++) {
|
||||||
if ( __collate_range_cmp(start, i) <= 0
|
if ( __wcollate_range_cmp(start, i) <= 0
|
||||||
&& __collate_range_cmp(i, finish) <= 0
|
&& __wcollate_range_cmp(i, finish) <= 0
|
||||||
)
|
)
|
||||||
CHadd(p, cs, i);
|
CHadd(p, cs, i);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue