]> git.buserror.net Git - polintos/scott/priv.git/commitdiff
Compare strings as unsigned, regardless of default char signedness.
authorScott Wood <scott@thor.buserror.net>
Mon, 3 Mar 2008 16:46:39 +0000 (10:46 -0600)
committerScott Wood <scott@thor.buserror.net>
Mon, 3 Mar 2008 16:46:39 +0000 (10:46 -0600)
lib/c/freestanding/string.c

index f1ede1e8fee6ec50cb6041016078680b433e126b..04cd22ac9fc74de01d3cec12c3aa65192996cef1 100644 (file)
@@ -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)