From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.9 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id BA8512070F for ; Thu, 15 Sep 2016 21:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756199AbcIOV0h (ORCPT ); Thu, 15 Sep 2016 17:26:37 -0400 Received: from mout.web.de ([212.227.15.3]:52565 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753255AbcIOV0f (ORCPT ); Thu, 15 Sep 2016 17:26:35 -0400 Received: from [192.168.178.36] ([79.213.113.239]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0MMIdp-1beroE08CL-0085ro; Thu, 15 Sep 2016 23:26:11 +0200 Subject: Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf, part 2 To: Junio C Hamano References: <20160915184448.awipvg2kmlq7weei@sigill.intra.peff.net> <20160915193804.d2mmmeard2rj6vye@sigill.intra.peff.net> <79f6cfb5-3b9b-2ae7-d9a3-5c1c65c7d4cf@web.de> Cc: Jeff King , Git List , "brian m. carlson" From: =?UTF-8?Q?Ren=c3=a9_Scharfe?= Message-ID: <67756074-836f-2238-37c3-0d186325bd00@web.de> Date: Thu, 15 Sep 2016 23:25:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=ut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/TOhzJ8PKzRO42Q9nBFewkZIsddk9URjPblkJKLUhk5p80rh+JS qSD4IdP Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Am 15.09.2016 um 22:01 schrieb Junio C Hamano: > René Scharfe writes: > >> 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!")); Right. Such strings seem to be quite rare in practice, though. > 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? Something like this? --- contrib/coccinelle/strbuf.cocci | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/coccinelle/strbuf.cocci b/contrib/coccinelle/strbuf.cocci index 7932d48..3f535ca 100644 --- a/contrib/coccinelle/strbuf.cocci +++ b/contrib/coccinelle/strbuf.cocci @@ -1,3 +1,5 @@ +// Careful, this is not fully equivalent: "%" is no longer treated +// specially. Check for "%%", "%m" etc. in the format string (E2). @@ expression E1, E2; @@ -- 2.10.0