Fixed comparison functions: unsigned char!
This commit is contained in:
parent
7c7475bb3a
commit
87cf9446fe
|
@ -15,7 +15,7 @@ memcmp(const void *s1, const void *s2, size_t n)
|
||||||
n++;
|
n++;
|
||||||
while (--n > 0) {
|
while (--n > 0) {
|
||||||
if (*p1++ == *p2++) continue;
|
if (*p1++ == *p2++) continue;
|
||||||
return *--p1 - *--p2;
|
return (unsigned char) *--p1 - (unsigned char) *--p2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -16,5 +16,5 @@ strcmp(register const char *s1, register const char *s2)
|
||||||
}
|
}
|
||||||
if (*s1 == '\0') return -1;
|
if (*s1 == '\0') return -1;
|
||||||
if (*--s2 == '\0') return 1;
|
if (*--s2 == '\0') return 1;
|
||||||
return *s1 - *s2;
|
return (unsigned char) *s1 - (unsigned char) *s2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ strncmp(register const char *s1, register const char *s2, register size_t n)
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
if (*s1 == '\0') return -1;
|
if (*s1 == '\0') return -1;
|
||||||
if (*--s2 == '\0') return 1;
|
if (*--s2 == '\0') return 1;
|
||||||
return *s1 - *s2;
|
return (unsigned char) *s1 - (unsigned char) *s2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue