From: Scott Wood Date: Mon, 3 Mar 2008 16:46:39 +0000 (-0600) Subject: Compare strings as unsigned, regardless of default char signedness. X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=commitdiff_plain;h=1d7b46b41c709c3788755c1538e86bb63de8f001 Compare strings as unsigned, regardless of default char signedness. --- diff --git a/lib/c/freestanding/string.c b/lib/c/freestanding/string.c index f1ede1e..04cd22a 100644 --- a/lib/c/freestanding/string.c +++ b/lib/c/freestanding/string.c @@ -150,7 +150,7 @@ int strcmp(const char *s1, const char *s2) s2++; } - return *s2 - *s1; + return (unsigned char)*s2 - (unsigned char)*s1; } int strncmp(const char *s1, const char *s2, int n) @@ -163,7 +163,7 @@ int strncmp(const char *s1, const char *s2, int n) if (i == n) return 0; - return *s2 - *s1; + return (unsigned char)*s2 - (unsigned char)*s1; } char *strchr(const char *s, int c)