From: Pádraig Brady
Date: Wed, 4 Nov 2015 23:01:25 +0000 (+0000) Subject: quotearg: add quotearg_n_style_colon() X-Git-Tag: v1.0~6901 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3e4ade272049d08f40315670af65c4bf16618192;p=gnulib.git quotearg: add quotearg_n_style_colon() This quotes with default options of the specified style, but with quoting enabled for instances of ':'. While this can be simulated by temporarily modifying the default quoting style, this is a little awkward, and care must be taken with such an implementation to avoid inlining leading to bloated text. * lib/quotearg.h (quotearg_n_style_colon): Description and declaration. * lib/quotearg.c (quotearg_n_style_colon): New function implementation. --- diff --git a/lib/quotearg.c b/lib/quotearg.c index 8505081507..a0a0e2565c 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -954,6 +954,15 @@ quotearg_colon_mem (char const *arg, size_t argsize) return quotearg_char_mem (arg, argsize, ':'); } +char * +quotearg_n_style_colon (int n, enum quoting_style s, char const *arg) +{ + struct quoting_options options; + options = quoting_options_from_style (s); + set_char_quoting (&options, ':', 1); + return quotearg_n_options (n, arg, SIZE_MAX, &options); +} + char * quotearg_n_custom (int n, char const *left_quote, char const *right_quote, char const *arg) diff --git a/lib/quotearg.h b/lib/quotearg.h index edee3b5929..b9eb31d9f3 100644 --- a/lib/quotearg.h +++ b/lib/quotearg.h @@ -393,6 +393,9 @@ char *quotearg_colon (char const *arg); /* Like quotearg_colon (ARG), except it can quote null bytes. */ char *quotearg_colon_mem (char const *arg, size_t argsize); +/* Like quotearg_n_style, except with ':' quoting enabled. */ +char *quotearg_n_style_colon (int n, enum quoting_style s, char const *arg); + /* Like quotearg_n_style (N, S, ARG) but with S as custom_quoting_style with left quote as LEFT_QUOTE and right quote as RIGHT_QUOTE. See set_custom_quoting for a description of acceptable LEFT_QUOTE and