Re: [PATCH 6/6] quote: turn 'nodq' parameter into a set of flags
- From
Jeff King <peff@peff.net>
- Date
- Sep 10, 2020, 12:38 UTC
- Message-ID
- <20200910123843.GC57925@coredump.intra.peff.net>
- In-Reply-To
- <20200908205224.4126551-7-gitster@pobox.com>
On Tue, Sep 08, 2020 at 01:52:24PM -0700, Junio C Hamano wrote:
> quote_c_style() and its friend quote_two_c_style() both take an > optional "please omit the double quotes around the quoted body" > parameter. Turn it into a flag word, assign one bit out of it, > and call it CQUOTE_NODQ bit.
Sounds reasonable.
If this shared the same "flags" namespace as quote_path(), then we really could pass quote_path() flags along. And in fact, that could be the first step to just teaching quote_c_style() the "if it has spaces, then quote it" rule. Maybe not worth spending more time on, but just thinking out loud after my earlier comments.
Show 7 quoted lines
> @@ -272,6 +272,7 @@ static size_t quote_c_style_counted(const char *name, ssize_t maxlen, > count += (l); \ > } while (0) > > + int no_dq = !!(flags & CQUOTE_NODQ); > size_t len, count = 0; > const char *p = name;
Looking at the context, I wondered how this was not adding a decl-after-statement (and how we were not already complaining about the existing ones). But the reason is that the code above it is part of a macro.
-Peff