Usermode/libc - Fixing some bugs in environment handling
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / string.c
index 86ecb6f..ceafd99 100644 (file)
@@ -26,11 +26,15 @@ EXPORT int strcmp(const char *s1, const char *s2)
  */
 EXPORT int strncmp(const char *s1, const char *s2, size_t n)
 {
-       if( n == 0 )    return 0;
-       while(n -- && *s1 == *s2 && *s1 != '\0' && *s2 != '\0') {
+       while(n && *s1 == *s2 && *s1 != '\0' && *s2 != '\0')
+       {
                s1++; s2++;
+               n --;
        }
-       return (int)*s1 - (int)*s2;
+       if( n == 0 )
+               return 0;
+       else
+               return (int)*s1 - (int)*s2;
 }
 
 EXPORT int strcasecmp(const char *s1, const char *s2)

UCC git Repository :: git.ucc.asn.au