]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Rework the strcasecmp stuff a little, based on Jakub Jelinek's patch
authorTom Hughes <tom@compton.nu>
Fri, 12 Nov 2010 10:40:20 +0000 (10:40 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 12 Nov 2010 10:40:20 +0000 (10:40 +0000)
on bug #256600 because the original version turned out to somewhat
fragile across different glibc versions.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11479

configure.in
memcheck/mc_replace_strmem.c

index 130d22989139f0145e72efbb91346947f5b565c2..cfe9b8a32e9c6543060078406655be2e7ac8e105 100644 (file)
@@ -1549,7 +1549,6 @@ AC_CHECK_FUNCS([     \
         strstr       \
         syscall      \
         timerfd      \
-        tolower_l    \
         utimensat    \
         ])
 
index 64cb7849c04bf5f73600af76b275e72cf84523f5..ebef4d8e43fc0716c23186dd8f544cbec4528f8b 100644 (file)
 #include "pub_tool_redir.h"
 #include "pub_tool_tooliface.h"
 #include "valgrind.h"
-#include "config.h"
 
 #include "mc_include.h"
 #include "memcheck.h"
 
-#include <ctype.h>
-
 /* ---------------------------------------------------------------------
    We have our own versions of these functions for two reasons:
    (a) it allows us to do overlap checking
@@ -412,6 +409,7 @@ STRNCMP(VG_Z_DYLD,        strncmp)
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
           ( const char* s1, const char* s2 ) \
    { \
+      extern int tolower(int); \
       register unsigned char c1; \
       register unsigned char c2; \
       while (True) { \
@@ -438,6 +436,7 @@ STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp)
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
           ( const char* s1, const char* s2, SizeT nmax ) \
    { \
+      extern int tolower(int); \
       SizeT n = 0; \
       while (True) { \
          if (n >= nmax) return 0; \
@@ -460,15 +459,13 @@ STRNCASECMP(VG_Z_DYLD,        strncasecmp)
 #endif
 
 
-#ifdef HAVE_TOLOWER_L
-
-
 #define STRCASECMP_L(soname, fnname) \
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
-          ( const char* s1, const char* s2, locale_t locale ); \
+          ( const char* s1, const char* s2, void* locale ); \
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
-          ( const char* s1, const char* s2, locale_t locale ) \
+          ( const char* s1, const char* s2, void* locale ) \
    { \
+      extern int tolower_l(int, void*) __attribute__((weak));    \
       register unsigned char c1; \
       register unsigned char c2; \
       while (True) { \
@@ -491,10 +488,11 @@ STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l)
 
 #define STRNCASECMP_L(soname, fnname) \
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
-          ( const char* s1, const char* s2, SizeT nmax, locale_t locale ); \
+          ( const char* s1, const char* s2, SizeT nmax, void* locale ); \
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
-          ( const char* s1, const char* s2, SizeT nmax, locale_t locale ) \
+          ( const char* s1, const char* s2, SizeT nmax, void* locale ) \
    { \
+      extern int tolower_l(int, void*) __attribute__((weak));    \
       SizeT n = 0; \
       while (True) { \
          if (n >= nmax) return 0; \
@@ -517,9 +515,6 @@ STRNCASECMP_L(VG_Z_DYLD,        strncasecmp_l)
 #endif
 
 
-#endif
-
-
 #define STRCMP(soname, fnname) \
    int VG_REPLACE_FUNCTION_ZU(soname,fnname) \
           ( const char* s1, const char* s2 ); \