X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fquotearg.c;h=75fbc72f3d5174559161bdd35b9237d777dc9830;hb=a7c16e4cf6306739249469d4dd3a3fe3263c02f2;hp=c2de86fcc265dc89f0f1b5440416914c3bacf225;hpb=05230b809c6fec84e0505ef1240f37b9d5b40356;p=gnulib.git diff --git a/lib/quotearg.c b/lib/quotearg.c index c2de86fcc..75fbc72f3 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -202,7 +202,7 @@ static size_t quotearg_buffer_restyled (char *buffer, size_t buffersize, char const *arg, size_t argsize, enum quoting_style quoting_style, int flags, - unsigned int *quote_these_too) + unsigned int const *quote_these_too) { size_t i; size_t len = 0; @@ -337,7 +337,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, break; case c_quoting_style: - if (i + 2 < argsize && arg[i + 1] == '?') + if ((flags & QA_SPLIT_TRIGRAPHS) + && i + 2 < argsize && arg[i + 1] == '?') switch (arg[i + 2]) { case '!': case '\'': @@ -372,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