]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
merge rev 1.7.2.3:
authorJulian Seward <jseward@acm.org>
Fri, 27 Sep 2002 01:26:34 +0000 (01:26 +0000)
committerJulian Seward <jseward@acm.org>
Fri, 27 Sep 2002 01:26:34 +0000 (01:26 +0000)
valgrind's strcmp() implementation (to clients) treats char as signed
whereas the libc implementation it replaces treats char as unsigned.
Fix!  God knows how anything much ever worked before now.

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

coregrind/vg_clientfuncs.c

index b37059b7a0a7d9efd662652824c242b627ee2feb..559276fe550ad834b05be9dbc5f1f951283819c4 100644 (file)
@@ -445,7 +445,8 @@ char* strcpy ( char* dest, const char* src )
    return dest_orig;
 }
 
-int strncmp ( const char* s1, const char* s2, unsigned int nmax )
+int strncmp ( const unsigned char* s1, const unsigned char* s2, 
+              unsigned int nmax )
 {
    unsigned int n = 0;
    while (True) {
@@ -454,8 +455,8 @@ int strncmp ( const char* s1, const char* s2, unsigned int nmax )
       if (*s1 == 0) return -1;
       if (*s2 == 0) return 1;
 
-      if (*(UChar*)s1 < *(UChar*)s2) return -1;
-      if (*(UChar*)s1 > *(UChar*)s2) return 1;
+      if (*(unsigned char*)s1 < *(unsigned char*)s2) return -1;
+      if (*(unsigned char*)s1 > *(unsigned char*)s2) return 1;
 
       s1++; s2++; n++;
    }
@@ -463,16 +464,17 @@ int strncmp ( const char* s1, const char* s2, unsigned int nmax )
 
 int strcmp ( const char* s1, const char* s2 )
 {
-   register char c1, c2;
+   register unsigned char c1;
+   register unsigned char c2;
    while (True) {
-      c1 = *s1;
-      c2 = *s2;
+      c1 = *(unsigned char *)s1;
+      c2 = *(unsigned char *)s2;
       if (c1 != c2) break;
       if (c1 == 0) break;
       s1++; s2++;
    }
-   if (c1 < c2) return -1;
-   if (c1 > c2) return 1;
+   if ((unsigned char)c1 < (unsigned char)c2) return -1;
+   if ((unsigned char)c1 > (unsigned char)c2) return 1;
    return 0;
 }