about summary refs log tree commit diff
path: root/sysdeps/generic/strncase.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/strncase.c')
-rw-r--r--sysdeps/generic/strncase.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/sysdeps/generic/strncase.c b/sysdeps/generic/strncase.c
index b0b1044777..cd2914955b 100644
--- a/sysdeps/generic/strncase.c
+++ b/sysdeps/generic/strncase.c
@@ -18,11 +18,31 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <string.h>
 #include <ctype.h>
 
 #ifndef weak_alias
 # define __strncasecmp strncasecmp
+# define TOLOWER(Ch) tolower (Ch)
+#else
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+#  define __strncasecmp __strncasecmp_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 no more than N characters of S1 and S2,
@@ -30,10 +50,11 @@
    greater than zero if S1 is lexicographically less
    than, equal to or greater than S2.  */
 int
-__strncasecmp (s1, s2, n)
+__strncasecmp (s1, s2, n LOCALE_PARAM)
      const char *s1;
      const char *s2;
      size_t n;
+     LOCALE_PARAM_DECL
 {
   const unsigned char *p1 = (const unsigned char *) s1;
   const unsigned char *p2 = (const unsigned char *) s2;
@@ -44,14 +65,14 @@ __strncasecmp (s1, s2, n)
 
   do
     {
-      c1 = tolower (*p1++);
-      c2 = tolower (*p2++);
+      c1 = TOLOWER (*p1++);
+      c2 = TOLOWER (*p2++);
       if (c1 == '\0' || c1 != c2)
 	return c1 - c2;
     } while (--n > 0);
 
   return c1 - c2;
 }
-#ifdef weak_alias
+#ifndef __strncasecmp
 weak_alias (__strncasecmp, strncasecmp)
 #endif