about summary refs log tree commit diff
path: root/wcsmbs/wcscasecmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'wcsmbs/wcscasecmp.c')
-rw-r--r--wcsmbs/wcscasecmp.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/wcsmbs/wcscasecmp.c b/wcsmbs/wcscasecmp.c
index 74908229a0..f32b4a14d2 100644
--- a/wcsmbs/wcscasecmp.c
+++ b/wcsmbs/wcscasecmp.c
@@ -25,15 +25,32 @@
 
 #ifndef weak_alias
 # define __wcscasecmp wcscasecmp
+# define TOLOWER(Ch) towlower (Ch)
+#else
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define __wcscasecmp __wcscasecmp_l
+#  define TOLOWER(Ch) __towlower_l ((Ch), loc)
+# else
+#  define TOLOWER(Ch) towlower (Ch)
+# endif
+#endif
+
+#ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# define LOCALE_PARAM , loc
+# define LOCALE_PARAM_DECL __locale_t loc;
+#else
+# define LOCALE_PARAM
+# define LOCALE_PARAM_DECL
 #endif
 
 /* Compare S1 and S2, ignoring case, returning less than, equal to or
    greater than zero if S1 is lexicographically less than,
    equal to or greater than S2.  */
 int
-__wcscasecmp (s1, s2)
+__wcscasecmp (s1, s2 LOCALE_PARAM)
      const wchar_t *s1;
      const wchar_t *s2;
+     LOCALE_PARAM_DECL
 {
   wint_t c1, c2;
 
@@ -42,15 +59,15 @@ __wcscasecmp (s1, s2)
 
   do
     {
-      c1 = towlower (*s1++);
-      c2 = towlower (*s2++);
-      if (c1 == '\0')
+      c1 = TOLOWER (*s1++);
+      c2 = TOLOWER (*s2++);
+      if (c1 == L'\0')
 	break;
     }
   while (c1 == c2);
 
   return c1 - c2;
 }
-#ifdef weak_alias
+#ifndef __wcscasecmp
 weak_alias (__wcscasecmp, wcscasecmp)
 #endif