git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf, part 2

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 15, 2016, 20:01 UTC
Message-ID
<xmqq7fadnd9s.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<79f6cfb5-3b9b-2ae7-d9a3-5c1c65c7d4cf@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 8 quoted lines
> 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.

Ahh, OK, so "This use of addf only has format part and nothing else, hence the format part can be taken as-is" which is the Coccinelle rule used to produce this patch is incomplete and always needs manual inspection, in case the format part wanted to give a literal % in the output. E.g. it is a bug to convert this

	strbuf_addf(&buf, _("this is 100%% wrong!"));
to
	strbuf_addstr(&buf, _("this is 100%% wrong!"));

Thanks for clarification. Perhaps the strbuf.cocci rule file can have some comment to warn the person who builds *.patch file to look for % in E2, or something?

Previous: René ScharfeNext: René Scharfe
Message 6 of 10 in “use strbuf_addstr() for adding constant strings to a strbuf, part 2”
  1. use strbuf_addstr() for adding constant strings to a strbuf, part 2René Scharfe, Sep 15, 2016
  2. Jeff KingSep 15, 2016
  3. Junio C HamanoSep 15, 2016
  4. Jeff KingSep 15, 2016
  5. René ScharfeSep 15, 2016
  6. Junio C HamanoSep 15, 2016
  7. René ScharfeSep 15, 2016
  8. Junio C HamanoSep 15, 2016
  9. René ScharfeOct 2, 2016
  10. brian m. carlsonSep 15, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.