diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-11-04 23:01:25 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-11-04 23:11:11 +0000 |
commit | 3e4ade272049d08f40315670af65c4bf16618192 (patch) | |
tree | c83826636f404b336e520d62e0255442b6dcfc7f | |
parent | 8780c1786db440a0ef1c0776dfff68134602fcea (diff) | |
download | gnulib-3e4ade272049d08f40315670af65c4bf16618192.tar.gz |
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.
-rw-r--r-- | lib/quotearg.c | 9 | ||||
-rw-r--r-- | lib/quotearg.h | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/quotearg.c b/lib/quotearg.c index 8505081507..a0a0e2565c 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -955,6 +955,15 @@ quotearg_colon_mem (char const *arg, size_t 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 |