libkern: use nul for terminating char rather than 0

Akin to the change made in r188080 for lib/libc/string/.

Reported by:	bde
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
emaste 2018-02-13 19:17:48 +00:00
parent bda3956278
commit adb4ef6fb8
5 changed files with 9 additions and 9 deletions

View File

@ -44,7 +44,7 @@ int
strcmp(const char *s1, const char *s2)
{
while (*s1 == *s2++)
if (*s1++ == 0)
if (*s1++ == '\0')
return (0);
return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1));
}

View File

@ -53,11 +53,11 @@ strncat(char *dst, const char *src, size_t n)
while (*d != 0)
d++;
do {
if ((*d = *s++) == 0)
if ((*d = *s++) == '\0')
break;
d++;
} while (--n != 0);
*d = 0;
*d = '\0';
}
return (dst);
}

View File

@ -49,10 +49,10 @@ strncpy(char * __restrict dst, const char * __restrict src, size_t n)
const char *s = src;
do {
if ((*d++ = *s++) == 0) {
if ((*d++ = *s++) == '\0') {
/* NUL pad the remaining n-1 bytes */
while (--n != 0)
*d++ = 0;
*d++ = '\0';
break;
}
} while (--n != 0);

View File

@ -64,14 +64,14 @@ strsep(char **stringp, const char *delim)
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
if (c == '\0')
s = NULL;
else
s[-1] = 0;
s[-1] = '\0';
*stringp = s;
return (tok);
}
} while (sc != 0);
} while (sc != '\0');
}
/* NOTREACHED */
}

View File

@ -51,7 +51,7 @@ strstr(const char *s, const char *find)
len = strlen(find);
do {
do {
if ((sc = *s++) == 0)
if ((sc = *s++) == '\0')
return (NULL);
} while (sc != c);
} while (strncmp(s, find, len) != 0);