]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - lib/c/freestanding/string.c
Compare strings as unsigned, regardless of default char signedness.
[polintos/scott/priv.git] / 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)