+++ /dev/null
-/* $NetBSD: strlcat.c,v 1.3 2007/06/04 18:19:27 christos Exp $ */\r
-/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */\r
-\r
-/*\r
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>\r
- *\r
- * Permission to use, copy, modify, and distribute this software for any\r
- * purpose with or without fee is hereby granted, provided that the above\r
- * copyright notice and this permission notice appear in all copies.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL\r
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE\r
- * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\r
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION\r
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\r
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\r
- */\r
-#include <LibConfig.h>\r
-\r
-#if !defined(_KERNEL) && !defined(_STANDALONE)\r
-#if HAVE_NBTOOL_CONFIG_H\r
-#include "nbtool_config.h"\r
-#endif\r
-\r
-#include <sys/cdefs.h>\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-__RCSID("$NetBSD: strlcat.c,v 1.3 2007/06/04 18:19:27 christos Exp $");\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#ifdef _LIBC\r
-#include "namespace.h"\r
-#endif\r
-#include <sys/types.h>\r
-#include <assert.h>\r
-#include <string.h>\r
-\r
-#ifdef _LIBC\r
-# ifdef __weak_alias\r
-__weak_alias(strlcat, _strlcat)\r
-# endif\r
-#endif\r
-\r
-#else\r
-#include <lib/libkern/libkern.h>\r
-#endif /* !_KERNEL && !_STANDALONE */\r
-\r
-#ifndef HAVE_STRLCAT\r
-/*\r
- * Appends src to string dst of size siz (unlike strncat, siz is the\r
- * full size of dst, not space left). At most siz-1 characters\r
- * will be copied. Always NUL terminates (unless siz <= strlen(dst)).\r
- * Returns strlen(src) + MIN(siz, strlen(initial dst)).\r
- * If retval >= siz, truncation occurred.\r
- */\r
-size_t\r
-strlcat(char *dst, const char *src, size_t siz)\r
-{\r
- char *d = dst;\r
- const char *s = src;\r
- size_t n = siz;\r
- size_t dlen;\r
-\r
- _DIAGASSERT(dst != NULL);\r
- _DIAGASSERT(src != NULL);\r
-\r
- /* Find the end of dst and adjust bytes left but don't go past end */\r
- while (n-- != 0 && *d != '\0')\r
- d++;\r
- dlen = d - dst;\r
- n = siz - dlen;\r
-\r
- if (n == 0)\r
- return(dlen + strlen(s));\r
- while (*s != '\0') {\r
- if (n != 1) {\r
- *d++ = *s;\r
- n--;\r
- }\r
- s++;\r
- }\r
- *d = '\0';\r
-\r
- return(dlen + (s - src)); /* count does not include NUL */\r
-}\r
-#endif\r