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:
committed by
Iker Pedrosa
parent
e0e9e57a72
commit
709e6b4497
@@ -62,6 +62,7 @@ libmisc_la_SOURCES = \
|
||||
setugid.c \
|
||||
setupenv.c \
|
||||
shell.c \
|
||||
stpecpy.c \
|
||||
stpeprintf.c \
|
||||
strtoday.c \
|
||||
sub.c \
|
||||
|
20
libmisc/stpecpy.c
Normal file
20
libmisc/stpecpy.c
Normal 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
|
Reference in New Issue
Block a user