]> Savannah Git Hosting - gnulib.git/commitdiff
quotearg: add quotearg_n_style_colon()
authorPádraig Brady <P@draigBrady.com>
Wed, 4 Nov 2015 23:01:25 +0000 (23:01 +0000)
committerPádraig Brady <P@draigBrady.com>
Wed, 4 Nov 2015 23:11:11 +0000 (23:11 +0000)
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.

lib/quotearg.c
lib/quotearg.h

index 85050815073350850f930fb3ebba5ad3faaa2e4e..a0a0e2565cbfea0c3b1b341713557538fbeaa440 100644 (file)
@@ -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)
index edee3b59298d284e5772962d15b75032dcd8cb15..b9eb31d9f3d817d0e5381cb05777d6483e270dd9 100644 (file)
@@ -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