[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] quotearg: add quotearg_n_style_colon()
From: |
Pádraig Brady |
Subject: |
[PATCH] quotearg: add quotearg_n_style_colon() |
Date: |
Wed, 4 Nov 2015 23:17:48 +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 | 9 +++++++++
lib/quotearg.h | 3 +++
2 files changed, 12 insertions(+)
diff --git a/lib/quotearg.c b/lib/quotearg.c
index 8505081..a0a0e25 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 edee3b5..b9eb31d 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
--
2.5.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] quotearg: add quotearg_n_style_colon(),
Pádraig Brady <=