From 1d7b46b41c709c3788755c1538e86bb63de8f001 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Mon, 3 Mar 2008 10:46:39 -0600 Subject: [PATCH] Compare strings as unsigned, regardless of default char signedness. --- lib/c/freestanding/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.39.2