about summary refs log tree commit diff
path: root/sysdeps/generic/strcasecmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/strcasecmp.c')
-rw-r--r--sysdeps/generic/strcasecmp.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/sysdeps/generic/strcasecmp.c b/sysdeps/generic/strcasecmp.c
index cca51f3dc9..4640372ebd 100644
--- a/sysdeps/generic/strcasecmp.c
+++ b/sysdeps/generic/strcasecmp.c
@@ -25,15 +25,32 @@
 
 #ifndef weak_alias
 # define __strcasecmp strcasecmp
+# define TOLOWER(Ch) tolower (Ch)
+#else
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define __strcasecmp __strcasecmp_l
+#  define TOLOWER(Ch) __tolower_l ((Ch), loc)
+# else
+#  define TOLOWER(Ch) tolower (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
-__strcasecmp (s1, s2)
+__strcasecmp (s1, s2 LOCALE_PARAM)
      const char *s1;
      const char *s2;
+     LOCALE_PARAM_DECL
 {
   const unsigned char *p1 = (const unsigned char *) s1;
   const unsigned char *p2 = (const unsigned char *) s2;
@@ -44,8 +61,8 @@ __strcasecmp (s1, s2)
 
   do
     {
-      c1 = tolower (*p1++);
-      c2 = tolower (*p2++);
+      c1 = TOLOWER (*p1++);
+      c2 = TOLOWER (*p2++);
       if (c1 == '\0')
 	break;
     }
@@ -53,6 +70,6 @@ __strcasecmp (s1, s2)
 
   return c1 - c2;
 }
-#ifdef weak_alias
+#ifndef __strcasecmp
 weak_alias (__strcasecmp, strcasecmp)
 #endif