aboutsummaryrefslogtreecommitdiffstats
path: root/src/string/strcmp.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-02 04:44:53 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-02 04:44:53 +0200
commitbd5d2162efae9913f2666c80bdf944a65ea95590 (patch)
tree7cfda8110528b22a8377bf9fdf526b9e203beda9 /src/string/strcmp.c
parentremove old debug line (diff)
downloadslibc-bd5d2162efae9913f2666c80bdf944a65ea95590.tar.gz
slibc-bd5d2162efae9913f2666c80bdf944a65ea95590.tar.bz2
slibc-bd5d2162efae9913f2666c80bdf944a65ea95590.tar.xz
fix more errors
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/string/strcmp.c7
1 files changed, 5 insertions, 2 deletions
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 <string.h>
#include <strings.h>
-#include <inttypes.h>
+#include <stdint.h>
#include <ctype.h>
@@ -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;
}