/*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2023 Robert Clausecker */ #include #include #undef strlcat /* FORTIFY_SOURCE */ void *__memchr(const void *, int, size_t); size_t __strlcpy(char *restrict, const char *restrict, size_t); size_t strlcat(char *restrict dst, const char *restrict src, size_t dstsize) { char *loc = __memchr(dst, '\0', dstsize); if (loc != NULL) { size_t dstlen = (size_t)(loc - dst); return (dstlen + __strlcpy(loc, src, dstsize - dstlen)); } else return (dstsize + strlen(src)); }