X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fquotearg.c;h=3f9e628cf03581065b9a58a28dabbfdbf31d95f1;hb=f6fe750d033c40b403688dc3eee9dbff468aa8f3;hp=339bf34942854b0c59192058f24ec09576087275;hpb=3293597efd0255a347b8a71890f08f605ef267b4;p=gnulib.git diff --git a/lib/quotearg.c b/lib/quotearg.c index 339bf3494..3f9e628cf 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -280,6 +280,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { unsigned char c; unsigned char esc; + bool is_right_quote = false; if (backslash_escapes && quote_string_len @@ -288,7 +289,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, { if (elide_outer_quotes) goto force_outer_quoting_style; - STORE ('\\'); + is_right_quote = true; } c = arg[i]; @@ -521,6 +522,11 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, STORE ('0' + ((c >> 3) & 7)); c = '0' + (c & 7); } + else if (is_right_quote) + { + STORE ('\\'); + is_right_quote = false; + } if (ilim <= i + 1) break; STORE (c); @@ -534,7 +540,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, if (! ((backslash_escapes || elide_outer_quotes) && quote_these_too - && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS)))) + && quote_these_too[c / INT_BITS] & (1 << (c % INT_BITS))) + && !is_right_quote) goto store_c; store_escape: