From d452fcefe0220893ef1a8f868640809b4766480c Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 26 Oct 2023 08:47:13 +0000 Subject: Modify string_quote/unquote to allow encoding of space as \s Signed-off-by: Laurent Bercot --- src/include/skalibs/skamisc.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/include') diff --git a/src/include/skalibs/skamisc.h b/src/include/skalibs/skamisc.h index 463f63a..657f526 100644 --- a/src/include/skalibs/skamisc.h +++ b/src/include/skalibs/skamisc.h @@ -21,10 +21,17 @@ extern int getlnmaxsep (buffer *, char *, size_t, size_t *, char const *, size_t extern int sauniquename (stralloc *) ; -extern int string_quote (stralloc *, char const *, size_t) ; +extern int string_quote_options (stralloc *, char const *, size_t, uint32_t) ; +#define string_quote(sa, s, len) string_quote_options(sa, s, (len), 0) +#define string_quote_nospace(sa, s, len) string_quote_options(sa, s, (len), 1) #define string_quotes(sa, s) string_quote(sa, (s), strlen(s)) -extern int string_quote_nodelim (stralloc *, char const *, size_t) ; -extern int string_quote_nodelim_mustquote (stralloc *, char const *, size_t, char const *, size_t) ; + +extern int string_quote_nodelim_mustquote_options (stralloc *, char const *, size_t, char const *, size_t, uint32_t) ; +#define string_quote_nodelim_mustquote(sa, s, len, delim, delimlen) string_quote_nodelim_mustquote_options(sa, s, len, delim, (delimlen), 0) +#define string_quote_nodelim_mustquote_nospace(sa, s, len, delim, delimlen) string_quote_nodelim_mustquote_options(sa, s, len, delim, (delimlen), 1) +#define string_quote_nodelim (sa, s, len) string_quote_nodelim_mustquote(sa, s, (len), "\"", 1) +#define string_quote_nodelim_nospace (sa, s, len) string_quote_nodelim_mustquote_nospace(sa, s, (len), "\"", 1) + extern int string_unquote (char *, size_t *, char const *, size_t, size_t *) ; extern ssize_t string_unquote_nodelim (char *, char const *, size_t) ; extern int string_unquote_withdelim (char *, size_t *, char const *, size_t, size_t *, char const *, size_t) ; -- cgit v1.2.3