From: Julian Seward Date: Fri, 27 Sep 2002 01:26:34 +0000 (+0000) Subject: merge rev 1.7.2.3: X-Git-Tag: svn/VALGRIND_1_9_4~306 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f7cd4c3f4b31569b50bf1be238ca08c0350dadc;p=thirdparty%2Fvalgrind.git merge rev 1.7.2.3: 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 --- diff --git a/coregrind/vg_clientfuncs.c b/coregrind/vg_clientfuncs.c index b37059b7a0..559276fe55 100644 --- a/coregrind/vg_clientfuncs.c +++ b/coregrind/vg_clientfuncs.c @@ -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; }