From 187ef092b6ea0f92dac53fbd2deb71379400446e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 6 Jul 2023 14:16:20 -0400 Subject: wordesc: Also escape non-printable chars --- src/bfstd.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/bfstd.h') diff --git a/src/bfstd.h b/src/bfstd.h index ebbcdb9..832db66 100644 --- a/src/bfstd.h +++ b/src/bfstd.h @@ -134,6 +134,38 @@ int ynprompt(void); */ void *xmemdup(const void *src, size_t size); +/** + * A nice string copying function. + * + * @param dest + * The NUL terminator of the destination string, or `end` if it is + * already truncated. + * @param end + * The end of the destination buffer. + * @param src + * The string to copy from. + * @return + * The new NUL terminator of the destination, or `end` on truncation. + */ +char *xstpecpy(char *dest, char *end, const char *src); + +/** + * A nice string copying function. + * + * @param dest + * The NUL terminator of the destination string, or `end` if it is + * already truncated. + * @param end + * The end of the destination buffer. + * @param src + * The string to copy from. + * @param n + * The maximum number of characters to copy. + * @return + * The new NUL terminator of the destination, or `end` on truncation. + */ +char *xstpencpy(char *dest, char *end, const char *src, size_t n); + /** * Format a mode like ls -l (e.g. -rw-r--r--). * -- cgit v1.2.3