X-Git-Url: http://git.buserror.net/cgi-bin/gitweb.cgi?p=polintos%2Fscott%2Fpriv.git;a=blobdiff_plain;f=lib%2Fc%2Ffreestanding%2Fstring.c;h=45eb2463284af43fd33ffe4f043e999dd0069537;hp=0241f91b5c10176ef2fb8f54fc3b179e16717699;hb=07f827f6957bfb9b3c29f8730670bf1ed51581ff;hpb=28d0cc04e24ba27bfcfa1aabae10b5d409f05a14 diff --git a/lib/c/freestanding/string.c b/lib/c/freestanding/string.c index 0241f91..45eb246 100644 --- a/lib/c/freestanding/string.c +++ b/lib/c/freestanding/string.c @@ -51,8 +51,6 @@ int memcmp(const void *b1, const void *b2, size_t len) for (pos = 0; pos < len; pos++) { if (c1[pos] != c2[pos]) return c1[pos] - c2[pos]; - - pos++; } return 0; @@ -152,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) @@ -165,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[i] - (unsigned char)s1[i]; } char *strchr(const char *s, int c)