Fixed comparison functions: unsigned char!

This commit is contained in:
ceriel 1992-07-22 12:51:53 +00:00
parent 7c7475bb3a
commit 87cf9446fe
3 changed files with 3 additions and 3 deletions

View file

@ -15,7 +15,7 @@ memcmp(const void *s1, const void *s2, size_t n)
n++;
while (--n > 0) {
if (*p1++ == *p2++) continue;
return *--p1 - *--p2;
return (unsigned char) *--p1 - (unsigned char) *--p2;
}
}
return 0;

View file

@ -16,5 +16,5 @@ strcmp(register const char *s1, register const char *s2)
}
if (*s1 == '\0') return -1;
if (*--s2 == '\0') return 1;
return *s1 - *s2;
return (unsigned char) *s1 - (unsigned char) *s2;
}

View file

@ -19,7 +19,7 @@ strncmp(register const char *s1, register const char *s2, register size_t n)
if (n > 0) {
if (*s1 == '\0') return -1;
if (*--s2 == '\0') return 1;
return *s1 - *s2;
return (unsigned char) *s1 - (unsigned char) *s2;
}
}
return 0;