From 71d97264ff059a530d86584f690a43831468dc69 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 27 Sep 2009 18:12:46 +0800 Subject: [PATCH] Fixed strncmp --- Kernel/lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Kernel/lib.c b/Kernel/lib.c index c1063516..3399d3d8 100644 --- a/Kernel/lib.c +++ b/Kernel/lib.c @@ -141,7 +141,8 @@ int strcmp(char *str1, char *str2) */ int strncmp(char *Str1, char *Str2, size_t num) { - while(num-- && *Str1 && *Str1 == *Str2) + if(num == 0) return 0; // TODO: Check what should officially happen here + while(--num && *Str1 && *Str1 == *Str2) Str1++, Str2++; return *Str1-*Str2; } -- 2.20.1