Fixed size_t comparison in memxxx and strxxx finctions.
This commit is contained in:
@@ -18,7 +18,7 @@ memccpy(vt, vf, c, n)
|
||||
register char *t = vt;
|
||||
register const char *f = vf;
|
||||
|
||||
while (--n >= 0)
|
||||
while (n-- > 0)
|
||||
if ((*t++ = *f++) == c)
|
||||
return (t);
|
||||
return (0);
|
||||
|
||||
@@ -16,7 +16,7 @@ memchr(vs, c, n)
|
||||
{
|
||||
register const char *s = vs;
|
||||
|
||||
while (--n >= 0)
|
||||
while (n-- > 0)
|
||||
if (*s++ == c)
|
||||
return (void*) --s;
|
||||
return (0);
|
||||
|
||||
@@ -15,7 +15,7 @@ memcmp (vs1, vs2, n)
|
||||
{
|
||||
register const char *s1 = vs1, *s2 = vs2;
|
||||
|
||||
while (--n >= 0)
|
||||
while (n-- > 0)
|
||||
if (*s1++ != *s2++)
|
||||
return (*--s1 - *--s2);
|
||||
return (0);
|
||||
|
||||
@@ -17,7 +17,7 @@ memcpy (vt, vf, n)
|
||||
register char *t = vt;
|
||||
register const char *f = vf;
|
||||
|
||||
while (--n >= 0)
|
||||
while (n-- > 0)
|
||||
*t++ = *f++;
|
||||
|
||||
return vt;
|
||||
|
||||
@@ -16,7 +16,7 @@ memset (vs, c, n)
|
||||
{
|
||||
register char *s = vs;
|
||||
|
||||
while (--n >= 0)
|
||||
while (n-- > 0)
|
||||
*s++ = c;
|
||||
|
||||
return vs;
|
||||
|
||||
@@ -64,8 +64,8 @@ strncasecmp(s1, s2, n)
|
||||
{
|
||||
register char *cm = charmap;
|
||||
|
||||
while (--n >= 0 && cm[(unsigned char)*s1] == cm[(unsigned char)*s2++])
|
||||
while (n-- > 0 && cm[(unsigned char)*s1] == cm[(unsigned char)*s2++])
|
||||
if (*s1++ == '\0')
|
||||
return(0);
|
||||
return(n < 0 ? 0 : cm[(unsigned char)*s1] - cm[(unsigned char)*--s2]);
|
||||
return(n == 0 ? 0 : cm[(unsigned char)*s1] - cm[(unsigned char)*--s2]);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ strncat(s1, s2, n)
|
||||
;
|
||||
--s1;
|
||||
while ((*s1++ = *s2++))
|
||||
if (--n < 0) {
|
||||
if (n-- == 0) {
|
||||
*--s1 = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ strncpy(s1, s2, n)
|
||||
register const char *s2;
|
||||
size_t n;
|
||||
{
|
||||
register int i;
|
||||
size_t i;
|
||||
register char *os1;
|
||||
|
||||
os1 = s1;
|
||||
|
||||
Reference in New Issue
Block a user