Skip to content
Snippets Groups Projects
Commit 2e39f3d2 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Cpoy/paste strlcat() from FreeBSD 13.3-RELEASE

parent 4ed27ca9
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6242 passed
......@@ -81,6 +81,34 @@ size_t strlcpy(char *dst, const char *src, size_t size)
*dst = 0;
return i;
}
size_t
strlcat(char *dst, const char *src, size_t dsize)
{
const char *odst = dst;
const char *osrc = src;
size_t n = dsize;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end. */
while (n-- != 0 && *dst != '\0')
dst++;
dlen = dst - odst;
n = dsize - dlen;
if (n-- == 0)
return(dlen + strlen(src));
while (*src != '\0') {
if (n != 0) {
*dst++ = *src;
n--;
}
src++;
}
*dst = '\0';
return(dlen + (src - osrc)); /* count does not include NUL */
}
#endif
#ifdef _WIN32
......
......@@ -260,6 +260,7 @@ extern "C" {
#if defined(NEEDS_STRLCPY)
size_t strlcpy(char *dst, const char *src, size_t size);
size_t strlcat(char *dst, const char *src, size_t dstsize);
#endif
#if defined(_WIN32)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment