From c1d6d0547036543038d5687373813bdc84088eba Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 19 Jun 2013 15:24:48 +0000 Subject: [PATCH] * nlsfuncs.cc (__collate_range_cmp): Convert input to wchar_t and call wcscoll since all calling functions are using wide chars. Explain in preceeding comment. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/nlsfuncs.cc | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7c3eb28e8..4eeac6ae4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2013-06-18 Corinna Vinschen + + * nlsfuncs.cc (__collate_range_cmp): Convert input to wchar_t and call + wcscoll since all calling functions are using wide chars. Explain in + preceeding comment. + 2013-06-18 Corinna Vinschen * spawn.cc (child_info_spawn::worker): Eliminate wascygexec. diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc index 0bbd4759c..0388f32fd 100644 --- a/winsup/cygwin/nlsfuncs.cc +++ b/winsup/cygwin/nlsfuncs.cc @@ -1187,13 +1187,15 @@ strcoll (const char *s1, const char *s2) return ret - CSTR_EQUAL; } -/* BSD. Used in glob.cc and regcomp.c, for instance. */ +/* BSD. Used from glob.cc, fnmatch.c and regcomp.c. Make sure caller is + using wide chars. Unfortunately the definition of this functions hides + the required input type. */ extern "C" int __collate_range_cmp (int c1, int c2) { - char s1[2] = { (char) c1, '\0' }; - char s2[2] = { (char) c2, '\0' }; - return strcoll (s1, s2); + wchar_t s1[2] = { (wchar_t) c1, L'\0' }; + wchar_t s2[2] = { (wchar_t) c2, L'\0' }; + return wcscoll (s1, s2); } extern "C" size_t -- 2.43.5