Add stpecpy()

strncat(3), strlcpy(3), and many other functions are often misused for
catenating strings, when they should never be used for that.  strlcat(3)
is good.  However, there's no equivalent to strlcat(3) similar to
snprintf(3).  Let's add stpecpy(), which is similar to strlcat(3), but
it is also the only function compatible with stpeprintf(), which makes
it more useful than strlcat(3).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar authored and Iker Pedrosa committed 2023-02-16 11:29:33 +01:00
1 parent e0e9e57a72
commit 709e6b4497
4 files changed
+114 -1

No files matched your search

+1
View File
@@ -62,6 +62,7 @@ libmisc_la_SOURCES = \
setugid.c \
setupenv.c \
shell.c \
stpecpy.c \
stpeprintf.c \
strtoday.c \
sub.c \
+20
View File
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2022 - 2023, Alejandro Colomar <alx@kernel.org>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
#if !defined(HAVE_STPECPY)
#ident "$Id$"
#include "stpecpy.h"
extern inline char *stpecpy(char *dst, char *end, const char *restrict src);
#endif // !HAVE_STPECPY