Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf, part 2
- From
René Scharfe <l.s.r@web.de>
- Date
- Sep 15, 2016, 19:55 UTC
- Message-ID
- <79f6cfb5-3b9b-2ae7-d9a3-5c1c65c7d4cf@web.de>
- In-Reply-To
- <20160915193804.d2mmmeard2rj6vye@sigill.intra.peff.net>
Am 15.09.2016 um 21:38 schrieb Jeff King:
Show 21 quoted lines
> On Thu, Sep 15, 2016 at 12:25:43PM -0700, Junio C Hamano wrote: > >>>> Silly question: Is there a natural language that uses percent signs >>>> as letters or e.g. instead of commas? :) >>> >>> I don't know, but if they do, they'd better get used to escaping them. >>> :) >> >> I do not know either, but I am curious where that question comes >> from. I stared at this patch for a few minutes but couldn't guess. > > My initial thought is that the next step after picking this low-hanging > fruit would be to find cases where the strings do not contain "%", and > thus we do not have to care about formatting. But a case like: > > strbuf_addf(&buf, "this does not have any percents!", foo); > > is simply broken (albeit in a way that we ignore foo, so it's just ugly > code, not a real bug). > > So I dunno. I too am curious.
Take this for example:
- strbuf_addf(&o->obuf, _("(bad commit)\n")); + strbuf_addstr(&o->obuf, _("(bad commit)\n"));
If there's a language that uses percent signs instead of parens or as regular letters, then they need to be escaped in the translated string before, but not after the patch. As I wrote: silly.
René