From bd5d2162efae9913f2666c80bdf944a65ea95590 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 2 Sep 2015 04:44:53 +0200 Subject: fix more errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strcmp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/string/strcmp.c') diff --git a/src/string/strcmp.c b/src/string/strcmp.c index f626f91..56b4d1b 100644 --- a/src/string/strcmp.c +++ b/src/string/strcmp.c @@ -17,7 +17,7 @@ */ #include #include -#include +#include #include @@ -108,7 +108,7 @@ int strncmp(const char* a, const char* b, size_t length) int strncasecmp(const char* a, const char* b, size_t length) { int c1, c2; - for (; size--; a++, b++) + for (; length--; a++, b++) if (*a != *b) { c1 = isalpha(*a) ? tolower(*a) : (int)*a; @@ -116,6 +116,9 @@ int strncasecmp(const char* a, const char* b, size_t length) if ((c1 -= c2)) return c1; } + else if (!*a && !*b) return 0; + else if (!*a) return -1; + else if (!*b) return +1; return 0; } -- cgit v1.2.3-70-g09d2