diff options
author | Eric Blake <ebb9@byu.net> | 2008-02-16 07:40:47 -0700 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2008-02-16 07:41:39 -0700 |
commit | 3d986f521cac261e29c043be50bb626f7641d841 (patch) | |
tree | 7283da65093dc208326a0df22a889ed5009e27f1 /lib/quotearg.c | |
parent | df4e570bc75f0ec8234ded88b130d934a630dedd (diff) | |
download | gnulib-3d986f521cac261e29c043be50bb626f7641d841.tar.gz |
Avoid doubling \ in common case of "c-maybe" quoting style.
* lib/quotearg.c (quotearg_buffer_restyled): Don't escape \ when
eliding outer quotes.
* lib/quotearg.h: Document this.
* tests/test-quotearg.c (result_strings, inputs, results_g)
(flag_results, locale_results): Test it by adding a new string to
each test group.
(compare_strings): Test new string.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'lib/quotearg.c')
-rw-r--r-- | lib/quotearg.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/quotearg.c b/lib/quotearg.c index c599acdbbc..75fbc72f3d 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -373,7 +373,11 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, case '\r': esc = 'r'; goto c_and_shell_escape; case '\t': esc = 't'; goto c_and_shell_escape; case '\v': esc = 'v'; goto c_escape; - case '\\': esc = c; goto c_and_shell_escape; + case '\\': esc = c; + /* No need to escape the escape if we are trying to elide + outer quotes and nothing else is problematic. */ + if (backslash_escapes && elide_outer_quotes && quote_string_len) + goto store_c; c_and_shell_escape: if (quoting_style == shell_always_quoting_style |