Changeset View
Changeset View
Standalone View
Standalone View
sys/libkern/strncat.c
Show All 37 Lines | |||||
#include <sys/libkern.h> | #include <sys/libkern.h> | ||||
/* | /* | ||||
* Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes | * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes | ||||
* are written at dst (at most n+1 bytes being appended). Return dst. | * are written at dst (at most n+1 bytes being appended). Return dst. | ||||
*/ | */ | ||||
char * | char * | ||||
strncat(char *dst, const char *src, size_t n) | strncat(char * __restrict dst, const char * __restrict src, size_t n) | ||||
{ | { | ||||
if (n != 0) { | if (n != 0) { | ||||
char *d = dst; | char *d = dst; | ||||
const char *s = src; | |||||
while (*d != 0) | while (*d != '\0') | ||||
d++; | d++; | ||||
do { | do { | ||||
if ((*d = *s++) == '\0') | if ((*d = *src) == '\0') | ||||
break; | return (dst); | ||||
d++; | d++, src++; | ||||
jrtc27: Comma operator? Really? | |||||
} while (--n != 0); | } while (--n != 0); | ||||
*d = '\0'; | *d = '\0'; | ||||
} | } | ||||
return (dst); | return (dst); | ||||
} | } |
Comma operator? Really?