From patchwork Mon Oct 22 20:22:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 054F913A4 for ; Mon, 22 Oct 2018 20:23:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E600328AF1 for ; Mon, 22 Oct 2018 20:23:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8EF728F64; Mon, 22 Oct 2018 20:23:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79EC028AF1 for ; Mon, 22 Oct 2018 20:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbeJWEn3 (ORCPT ); Tue, 23 Oct 2018 00:43:29 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40615 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeJWEn3 (ORCPT ); Tue, 23 Oct 2018 00:43:29 -0400 Received: by mail-ed1-f67.google.com with SMTP id r1-v6so39231191edd.7 for ; Mon, 22 Oct 2018 13:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1+fcDj7ZfJP3kInABRlsVqqGzJy3P3k3Cx5F8SYWi14=; b=QnmcRcMT4s34WDY4y22i3uAW/0LuWAZ+34QNgPy/SY3CI4xXDwYW/oopL6O6nPGRkA 6eUaNQ8C95KYF1/FxDidI2JvFrtuecJeFGfgt1nySuE9NBnNozFuEL+ZftzjN/CH0sYf QD5OdA1FGFj/MhkK+4vu+sB+hG7uPm2e6sj80/B/E8CvW1+hhpT922PPxpfuv6AyFDH6 PnQzuqUvNXQKyz+XtiDNgANVB5Z2qfAZ1AJkqLjOaLc0i3hUar6DF6yL5U8pRI+jo5PQ fg2eaWXteWu93W97E9oFE9Vl8LEMdDy7lstmJeRjvY6gXk7czd/51WziD+Vmy9zkFfNa M9VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1+fcDj7ZfJP3kInABRlsVqqGzJy3P3k3Cx5F8SYWi14=; b=dsLB7JICWv4EO7qbUlatKV6D9zyw8QYpiCrp+fBDSZsK7oQQQgSkMQB3l2wePOzKCF F6Y3KjpC6dqQSowI3HVBjBRKUC7ZEyTzlDItEP8Gef5zceWFZRhA4BF1xP4Orms9gFxN tX/tAlC3ar52tQ2xKPjVgKVt47XLYG8XdofU9ZMWWRlfc05IYHxp+5A1fXbx54llMj0A OVo6PVlFdC0jL4zjQxmApwXM9NQ4Qf+uYzWACIaigPjGw8yEKsW665WRnR8UfB+cr0a6 2WQudBlh3VdPDYGZeghnd2Ggix9eSBaxTmfGxi6kZdQ40xrLnYfSBFwQbo0vkxR9GrnI zYiQ== X-Gm-Message-State: AGRZ1gIjzSxervftmdEUPqwR0CenbZSSG9n7SInedSoQu2TfhPfFOMLa eIfEq0FIp3Pu81Ww747VzIkF8hbN X-Google-Smtp-Source: AJdET5erRCqsCIG1CSGb5I4OtG2UMSyqmWq0NuKH4eVnEJFOmqn9Vy5gokXtINrke4eoVwo6vjPjMA== X-Received: by 2002:a05:6402:135a:: with SMTP id y26mr2463421edw.286.1540239808581; Mon, 22 Oct 2018 13:23:28 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:27 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 1/8] test-lib.sh: preserve GIT_GETTEXT_POISON from the environment Date: Mon, 22 Oct 2018 22:22:34 +0200 Message-Id: <20181022202241.18629-2-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Setting GIT_GETTEXT_POISON can be useful when testing translated builds. However, preserving its value from the environment is not as simple as adding it to the list of GIT_* variables that should not be scrubbed from the environment: - GIT_GETTEXT_POISON should not influence git commands executed during initialization of test-lib and the test repo. Save its value before it gets scrubbed from the environment, so it will be unset for the duration of the initialization, and restore its original value after initialization is finished. - When testing a GETTEXT_POISON build, 'test-lib.sh' always sets GIT_GETTEXT_POISON to 'YesPlease'. This was fine while all that mattered was whether it's set or not. However, the following patches will introduce meaningful values (e.g. "set but empty" to disable poisoning even in a GETTEXT_POISON build), so only set it like this if GIT_GETTEXT_POISON was not set in the environment. Signed-off-by: SZEDER Gábor --- t/test-lib.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index ea2bbaaa7a..282c05110d 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -95,6 +95,16 @@ PAGER=cat TZ=UTC export LANG LC_ALL PAGER TZ EDITOR=: + +# GIT_GETTEXT_POISON should not influence git commands executed during +# initialization of test-lib and the test repo. +# Back it up, unset and then restore after initialization is finished. +if test -n "${GIT_GETTEXT_POISON-set}" +then + git_gettext_poison_backup=$GIT_GETTEXT_POISON + unset GIT_GETTEXT_POISON +fi + # A call to "unset" with no arguments causes at least Solaris 10 # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets # deriving from the command substitution clustered with the other @@ -1073,7 +1083,12 @@ test -z "$NO_GETTEXT" && test_set_prereq GETTEXT # Can we rely on git's output in the C locale? if test -n "$GETTEXT_POISON" then - GIT_GETTEXT_POISON=YesPlease + if test -n "${git_gettext_poison_backup-set}" + then + GIT_GETTEXT_POISON=$git_gettext_poison_backup + else + GIT_GETTEXT_POISON=YesPlease + fi export GIT_GETTEXT_POISON test_set_prereq GETTEXT_POISON else From patchwork Mon Oct 22 20:22:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 002DB14BB for ; Mon, 22 Oct 2018 20:23:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19F928AF1 for ; Mon, 22 Oct 2018 20:23:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5ADA28F64; Mon, 22 Oct 2018 20:23:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8287B28AF1 for ; Mon, 22 Oct 2018 20:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727557AbeJWEnb (ORCPT ); Tue, 23 Oct 2018 00:43:31 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41019 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeJWEnb (ORCPT ); Tue, 23 Oct 2018 00:43:31 -0400 Received: by mail-ed1-f68.google.com with SMTP id x31-v6so39212408edd.8 for ; Mon, 22 Oct 2018 13:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RLV53ZJf7uA43yB6DIG8Qt6G8DsPOzNy3uqbadk3Efc=; b=O7KcWvECGperumr2JAo5GWbidJ1kJ6KdosUkwYi6Dhmwmv4e4L7dy4F3GJ8xYOwAGN AMm0uGdL1C6dD3yeOYu/T98IS7WIGHr6WvNhTh2wBMhgOtyEQro4Zpn1wpPWtXleqWB7 oF5usooexHe6xSJyaUJ8CfAU/WzEJOaRdHtujkUzjhTkiLb3aVW5qmfuo7kwMzs0MNqF u1bAWzQYKwubqGwunlL+m9E7VpHjAjBVoPlF5iU5tbVIcT0/QlCw/NTfdg47PO3Flw/i UxMJQCeoKe4LrGksQ3JtFCwBJpJEHm5Wu4icPmZ+T+MHhRhX7+P/99If2E2++aTXpiM5 R3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RLV53ZJf7uA43yB6DIG8Qt6G8DsPOzNy3uqbadk3Efc=; b=ay7dbFgGJ4HGzZy0IHQxzgsDhj/+KMMwQ4SfEtrUM3w6ZSOHIOFMKxiihkQBXWxjSQ sDGdWi9vTLULJQhq1gPM5hv70uUEmrCzHEcBE07smHckQsEdGNiYO07YQHpDDF/37ld9 swFbhUn9JUGgJ8o/iQPhfY+p+OW3BVSC5n9VD0Ms2zEIRAeiWfchEPFloUG4cf1RiLWS 4m8L1uptjir5+VMQUi1Ud/dQjOiRPStPFtrY4VLjz0G/MZe0pAC5FSNgpPUPHPL4TnXP 4WvgrDrPbLd0bC/8/3RgfSFg/LAIYFE+jx2R7MLBes/OTeBrQ+6+70VTLmXr78JPKU9C Y4QA== X-Gm-Message-State: ABuFfogNMY4h7I7abs0Iqw7GEQvZ/yAh4qnSaqbkvzI6rgTQtfYAv+4w OlF2zNq22WW9RLoOWguJzjChtEtH X-Google-Smtp-Source: ACcGV62qX+3jXcnFm7K/y8m1KWQ7rPjHLdetKrUTmQIpJ6be9CRCEXaXXF2g69wfXhqGL0jL1XfFDw== X-Received: by 2002:a17:906:344b:: with SMTP id d11-v6mr37237774ejb.130.1540239810076; Mon, 22 Oct 2018 13:23:30 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:29 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 2/8] gettext: don't poison if GIT_GETTEXT_POISON is set but empty Date: Mon, 22 Oct 2018 22:22:35 +0200 Message-Id: <20181022202241.18629-3-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows us to run test with non-GETTEXT POISON-ed behavior even in a GETTEXT POISON build by running: GIT_GETTEXT_POISON= ./t1234-foo.sh Signed-off-by: SZEDER Gábor --- Makefile | 2 +- gettext.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ad880d1fc5..7a165445cd 100644 --- a/Makefile +++ b/Makefile @@ -365,7 +365,7 @@ all:: # Define GETTEXT_POISON if you are debugging the choice of strings marked # for translation. In a GETTEXT_POISON build, you can turn all strings marked # for translation into gibberish by setting the GIT_GETTEXT_POISON variable -# (to any value) in your environment. +# to a non-empty value in your environment. # # Define JSMIN to point to JavaScript minifier that functions as # a filter to have gitweb.js minified. diff --git a/gettext.c b/gettext.c index 7272771c8e..a9509a5df3 100644 --- a/gettext.c +++ b/gettext.c @@ -50,8 +50,13 @@ const char *get_preferred_languages(void) int use_gettext_poison(void) { static int poison_requested = -1; - if (poison_requested == -1) - poison_requested = getenv("GIT_GETTEXT_POISON") ? 1 : 0; + if (poison_requested == -1) { + const char *v = getenv("GIT_GETTEXT_POISON"); + if (v && *v) + poison_requested = 1; + else + poison_requested = 0; + } return poison_requested; } #endif From patchwork Mon Oct 22 20:22:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E74DF14BB for ; Mon, 22 Oct 2018 20:23:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA1428EA4 for ; Mon, 22 Oct 2018 20:23:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFFE029139; Mon, 22 Oct 2018 20:23:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 593B728F64 for ; Mon, 22 Oct 2018 20:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727607AbeJWEnd (ORCPT ); Tue, 23 Oct 2018 00:43:33 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:41020 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727073AbeJWEnd (ORCPT ); Tue, 23 Oct 2018 00:43:33 -0400 Received: by mail-ed1-f66.google.com with SMTP id x31-v6so39212479edd.8 for ; Mon, 22 Oct 2018 13:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oQZ1PrnKpZLn+VJuEjDpXFOi2wBoTm7OGvW5SJ/9Hso=; b=hwfwFAX+DtFkZzgF2Z0esWrfvzc2aGVyOL9ePalF8GoUD42M9L/irwnVcNXozLLthe OeBLebcU1ccSX7/r5pl2PM9UqzVENc3+5InZhQiTIvhffhTJi53IjxOxYLVp+4ril24Q GcCrP/iTXANTsUQSy/d017uEmgmSBpAXwaRT73EUN+/Vj2xaVTfcDE/toU/L81+pg+9y xNkkOhS64rWgML7qzLFkL0PeFFzdHbCFpWAFxjXTanfYCMOIhPGFAZKUDPfKbBhyuDIH Slmok2vQ8P0+AA0Kppoq/mxQciAx06msUFXB6QGOTUvrmsW/Hrj/l45W8lvm2Kftgil0 iQpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oQZ1PrnKpZLn+VJuEjDpXFOi2wBoTm7OGvW5SJ/9Hso=; b=m6troYOFK2aK89wybg0PV8xtOqYj/0hfCCZs8+7DYHOpn+iOMPlAF/lQNYkqTvq9vK DIXeTuSCVZ5ZASDBoZmVA/v72NsrpqfkdsnqdZhmhI082/m2ADnf0G8iikz6sPMpRXPc 1MIcI6in2ZxQE8pcqqBACvynoqFrXtaJZLY6dN+/LvmNLQkR124V4wZQvwHrZEdtkXNI gJ5MdFar+28h0qRAJU47l0naieBb2L/e/A6Yl95XscMPl72eHQS95eJ6Fu6HW6ULr04f ONjPf/hHr+x5l8sli7ckve26u3epYO4AjiujocbF77vOzNIAGPYVYmVkpMtfAj8ypV67 mzlg== X-Gm-Message-State: ABuFfogyjJ440AJfS0B+RAWgl6NSL4cxBTlHxeUsdwGytJljfk9WX+FT 6X+AvOE4tKGd/tTv3t1xB4pSDNqk X-Google-Smtp-Source: ACcGV62+a9fSOxPnc59HqyuOdSg1Btkzj4lnAOoKd0zhs8HJLH81jqvaOjhTvHBM2ilmKC24EqGulQ== X-Received: by 2002:a17:906:5583:: with SMTP id y3-v6mr1606503ejp.79.1540239811412; Mon, 22 Oct 2018 13:23:31 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:30 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 3/8] lib-rebase: loosen GETTEXT_POISON check in fake editor Date: Mon, 22 Oct 2018 22:22:36 +0200 Message-Id: <20181022202241.18629-4-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fake editor script created by 't/lib-rebase.sh' recognizes GETTEXT POSION output when the first line of the file to be edited consists solely of the GETTEXT POISON magic string as a comment. However, a later patch will include additional text after that magic string, so that check won't work anymore. So instead of expecting an exact match in the first line, check whether there are any lines starting with the commented out magic string. Signed-off-by: SZEDER Gábor --- t/lib-rebase.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 25a77ee5cb..530f8ec0a8 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -29,7 +29,7 @@ set_fake_editor () { */COMMIT_EDITMSG) test -z "$EXPECT_HEADER_COUNT" || test "$EXPECT_HEADER_COUNT" = "$(sed -n '1s/^# This is a combination of \(.*\) commits\./\1/p' < "$1")" || - test "# # GETTEXT POISON #" = "$(sed -n '1p' < "$1")" || + ! grep -q "^# # GETTEXT POISON #" || exit test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1" test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1" From patchwork Mon Oct 22 20:22:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AC4813A4 for ; Mon, 22 Oct 2018 20:23:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 599C828EA4 for ; Mon, 22 Oct 2018 20:23:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DEB129139; Mon, 22 Oct 2018 20:23:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED2FF28EA4 for ; Mon, 22 Oct 2018 20:23:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727830AbeJWEne (ORCPT ); Tue, 23 Oct 2018 00:43:34 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40623 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeJWEne (ORCPT ); Tue, 23 Oct 2018 00:43:34 -0400 Received: by mail-ed1-f68.google.com with SMTP id r1-v6so39231370edd.7 for ; Mon, 22 Oct 2018 13:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h8Rnf92giVsilwCazR1h6BjeSuQ5sDGeK8YqIJ9U7cg=; b=J2FxuqF1pNLnY8yY7uN7WXh6EAXn6OEC43paV6dlkuT39nXYbsaZmx4LnOUFHWKGyj SBsWCxjT3WmDeiuONzCXNmqqp30JjUPCZ8nVLZ8Tm0ga6LEqaYbh2TBPxc3F2rNxhd2b 804nRSjOYk2m/7s6pmMBVUTudJp/IZGeEjNkqgWGTs0me8Z7PTOfP866tfnAQEBQHKMD ba6y30MY5YShRKTKR/mUzrZAVcLzzSN4r3N5I6uMdc7YWgr8k3LoRRiUZ2eBtie15/93 U7Jio4CGaYNbVzwZRJzO7zxE9y7LfgMWDMYGL8KiEfJsx4E2ZZrmQPHtZSETHvTxI6TB OQ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h8Rnf92giVsilwCazR1h6BjeSuQ5sDGeK8YqIJ9U7cg=; b=GsvBd3hD8pFAKqYvrAt6FfXzsSowTcmD2IUa5ikH5i6IBZgY1WqpPfwDlbo3N9kypg WdGHrbK0B0Ekq/9m5ZwtrRvqkT2m4BbqoIqpOk9vqTjOsHyGEGE+3nQcBSTjVUfkZTip 1BeFckJG5IElINPhkXI1EBYDARzP6bQp5hvI1n7ARXzYCQd9KCiR+o1wQ835GsCZc7zb GAnZBx4dnCMFs8qu4UBbXuP6x/Ow8r7PCCRBMdY9vyYLHduj2EcrteBcAT8d71hsSwKK DRy96qHwBM5PrtNXQPn7ZJpYOBgiglY7FLOqu2RZZlB7NDl9018ZUa1kiFLo8q3YA6W8 na9A== X-Gm-Message-State: ABuFfogiNq18HLsHiAzZsqoVF01xeSkajv1H2/NJjIo5jHIVz0FE5UOA mp9iz7pZNj2QpwC7zyxC81J3sZJj X-Google-Smtp-Source: ACcGV60sB6HnBXZ5WnlGOTbIRnFznDHunkSZ8HzD/2gzVC5SN8R5JGBN2i+rEyfwBQAuo+TrXxKVZw== X-Received: by 2002:aa7:d58a:: with SMTP id r10-v6mr14908252edq.161.1540239812841; Mon, 22 Oct 2018 13:23:32 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:32 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 4/8] gettext: #ifdef away GETTEXT POISON-related code from _() and Q_() Date: Mon, 22 Oct 2018 22:22:37 +0200 Message-Id: <20181022202241.18629-5-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The gettext wrapper functions _() and Q_() contain a GETTEXT POISON-related conditional construct even in non-GETTEXT POISON builds, though both of those conditions are #define-d to be false already at compile time. Both constructs will grow in a later patch, using a GETTEXT POISON-specific enum type and calling another GETTEXT POISON-specific function. Prepare for those future changes and hide the GETTEXT POISON-related parts of those functions behind an #ifdef. Signed-off-by: SZEDER Gábor --- gettext.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gettext.h b/gettext.h index 7eee64a34f..c658942f7d 100644 --- a/gettext.h +++ b/gettext.h @@ -43,22 +43,26 @@ static inline int gettext_width(const char *s) #ifdef GETTEXT_POISON extern int use_gettext_poison(void); -#else -#define use_gettext_poison() 0 #endif static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) { if (!*msgid) return ""; - return use_gettext_poison() ? "# GETTEXT POISON #" : gettext(msgid); +#ifdef GETTEXT_POISON + if (use_gettext_poison()) + return "# GETTEXT POISON #"; +#endif + return gettext(msgid); } static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2) const char *Q_(const char *msgid, const char *plu, unsigned long n) { +#ifdef GETTEXT_POISON if (use_gettext_poison()) return "# GETTEXT POISON #"; +#endif return ngettext(msgid, plu, n); } From patchwork Mon Oct 22 20:22:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DB0A14BB for ; Mon, 22 Oct 2018 20:23:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C73D28AF1 for ; Mon, 22 Oct 2018 20:23:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 50E3028F64; Mon, 22 Oct 2018 20:23:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F215628EA4 for ; Mon, 22 Oct 2018 20:23:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728266AbeJWEng (ORCPT ); Tue, 23 Oct 2018 00:43:36 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:40626 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728012AbeJWEnf (ORCPT ); Tue, 23 Oct 2018 00:43:35 -0400 Received: by mail-ed1-f66.google.com with SMTP id r1-v6so39231431edd.7 for ; Mon, 22 Oct 2018 13:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yor/xvYCFqsusn7AH2IBYEgikd2httNufrUhiNDaZfY=; b=bVrRmUqJE0PomMNxL6fGKeqtvHwjekcy/6cEf+n0uIw99JnXxpdqfIigDI+vjUSZio tyTKS9gWLtWdrPEiX2VTGGd/CtNYGpKjlw8Q4fzNphOpKvk2QjuslZFOTqj0Z0Lpl6Hr JAMtroKoEk+ffNHfMKWbT8EPAt3sO/JtY26ab8QV74ruC/8HLF/djsTzp00/Fj2eMFX7 vlZwBHfNXM4U4ad9jZyiVzDKvsXIxhs9ET1LoCyFuhsil8dxv8kx/7L0uVYBKf2uJOVn JhX8Uzr2jVIi0wKr9bk23OSsjKUi+SKjyOu3ME4rfMajtHZcoRSSdMIAqVH8+d0Dm/K6 DpYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Yor/xvYCFqsusn7AH2IBYEgikd2httNufrUhiNDaZfY=; b=HhGAJ3qPxThsYQrIDMYt8O7eIEJAqX/dtVQ4eWTxDRzhbsHpEvNZ9ALs4JTpKNNvuT iKSEpzgkkk+5MZPRdyD/S38U260YcJ/AaMiBA0MbuCLkUqfKs6gnPKJqP3otgdMEIwGW CIOBi/Y3Ql9kvaaf+HPUjB5oypBOvLDeL38qY2Vd3WKNhsAlwQ6pAIwL8W602CxIVQjq jZVSwh6pZE1ATWAdVa24hWMOztoofwH8oYQe22IgNC4RFfAUOSPJA2IREEdBxPM/dOsq kDUQTuDfIfsXEI8n7sHK4oZT0gsACsbpUVzVFTG3hX06mWVRjMdU6HBdddC9ugDC8Pe3 +pxQ== X-Gm-Message-State: ABuFfog43IY5YHT9UYh7lvFwo1J7eIkiDEtjQ+ozfCZMoni4ZTIKjdP7 SITR72/VYQu5Kphiyh0dN04iy/Ay X-Google-Smtp-Source: ACcGV63Nazn/q+BXkNBHiR5jvBRcA9jMREzx820YJ+8aC329sV9T5rIovDYapBNT+9uXwO1QJkFj9Q== X-Received: by 2002:aa7:d889:: with SMTP id u9-v6mr13419646edq.29.1540239814183; Mon, 22 Oct 2018 13:23:34 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:33 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 5/8] gettext: put "# GETTEXT POISON #" string literal into a macro Date: Mon, 22 Oct 2018 22:22:38 +0200 Message-Id: <20181022202241.18629-6-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "# GETTEXT POISON #" string literal is currently used in two functions in 'gettext.h'. A later patch will add a function to 'gettext.c' using this string literal as well. Avoid this duplication and put that string literal into a macro which is only available in GETTEXT POISON builds. Signed-off-by: SZEDER Gábor --- gettext.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gettext.h b/gettext.h index c658942f7d..8e279622f6 100644 --- a/gettext.h +++ b/gettext.h @@ -43,6 +43,8 @@ static inline int gettext_width(const char *s) #ifdef GETTEXT_POISON extern int use_gettext_poison(void); + +#define GETTEXT_POISON_MAGIC "# GETTEXT POISON #" #endif static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) @@ -51,7 +53,7 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) return ""; #ifdef GETTEXT_POISON if (use_gettext_poison()) - return "# GETTEXT POISON #"; + return GETTEXT_POISON_MAGIC; #endif return gettext(msgid); } @@ -61,7 +63,7 @@ const char *Q_(const char *msgid, const char *plu, unsigned long n) { #ifdef GETTEXT_POISON if (use_gettext_poison()) - return "# GETTEXT POISON #"; + return GETTEXT_POISON_MAGIC; #endif return ngettext(msgid, plu, n); } From patchwork Mon Oct 22 20:22:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED06014BB for ; Mon, 22 Oct 2018 20:23:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBFE428AF1 for ; Mon, 22 Oct 2018 20:23:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D048F28F64; Mon, 22 Oct 2018 20:23:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7919628AF1 for ; Mon, 22 Oct 2018 20:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbeJWEnh (ORCPT ); Tue, 23 Oct 2018 00:43:37 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:36474 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeJWEnh (ORCPT ); Tue, 23 Oct 2018 00:43:37 -0400 Received: by mail-ed1-f68.google.com with SMTP id x2-v6so4323067eds.3 for ; Mon, 22 Oct 2018 13:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+IdKjyf31efNmGF2qSdKh34ykgC2kG6Vu4Viul2FQQA=; b=VLC79HvWStHP2VttfrtXuyTfAIgLGwHkxBhAoyE49C11hPNd9ftvPmI4PyoIytRpzU s3nkPEXc8K1AdyHxvD6yDJA60IuIjxHVCtE3dwnnn0DZkwloi7GQaLnm247KAiq35uqk DFsg6NZRGgV+UZFTqyxbRw1BmXbNKMYEW2D7sLgUWtCZkZkMQkE1ZvrzthPXuwXMeSZc 71jJMCGjV+4KdTArnjH3asZhty2IJG2pvQ7WQnAjD2Zz+kVnnR27+NL0mpHuxMmWT4N0 mQrYodwyqTGcS6aatY61m3MARtQk3rMecztqfEOGYSZDtxuYWdMzf5JiHhKUgGsf3Zka yJSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+IdKjyf31efNmGF2qSdKh34ykgC2kG6Vu4Viul2FQQA=; b=AzIxPNOvzyaLNJseoNRegBp2FyUiZKxYH0CxZfwa7uFw5kGNs/rk+5TBb6BImWasGl qialCBIHmSe12tx1jtcixYzcbSf7oStf4+QcYyToBHfRdJoNGId0FKXvh6y76zOlYxz7 Su3d5kUogUY76GiuYDoO7UfO+PFYmrJmxLLgKt9RahqRCJWgxhwDJG2gcwtBLFO/Yh6r uT4WT4OHwZbbShgcern9MMDTanZym7sfFHxo8Gg9nFLl74qHMv8CbzjN31BT15IK0OFh zTO5zCH4tdByeE6vIx2KNs4rXroXCuTHlpBlR5pcXoGPiikiI4op1dDMW8vx+R4F8Js1 VHhw== X-Gm-Message-State: ABuFfogp1ob+B0kWonBSru6oF1mfEz6pMVI2ha03qGmZ4aKSTzJvFyvA DF2zKKB2zpTnEx6Kr2DYPiF4FYoH X-Google-Smtp-Source: ACcGV61++Z1ZY9yRHUWpsBavyPMmtdIhmWyxRqzZsLc88+ef2zSwZM/oVtpTrgRHRquYf+q6WlDKkg== X-Received: by 2002:a50:e38d:: with SMTP id b13-v6mr14257183edm.263.1540239815639; Mon, 22 Oct 2018 13:23:35 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:34 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 6/8] gettext: use an enum for the mode of GETTEXT POISONing Date: Mon, 22 Oct 2018 22:22:39 +0200 Message-Id: <20181022202241.18629-7-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The next patch will add a different mode of GETTEXT POISON-ing, therefore named constants will be better than magic numbers. Signed-off-by: SZEDER Gábor --- gettext.c | 12 ++++++------ gettext.h | 12 +++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/gettext.c b/gettext.c index a9509a5df3..c50d1e0377 100644 --- a/gettext.c +++ b/gettext.c @@ -47,17 +47,17 @@ const char *get_preferred_languages(void) } #ifdef GETTEXT_POISON -int use_gettext_poison(void) +enum poison_mode use_gettext_poison(void) { - static int poison_requested = -1; - if (poison_requested == -1) { + static enum poison_mode poison_mode = poison_mode_uninitialized; + if (poison_mode == poison_mode_uninitialized) { const char *v = getenv("GIT_GETTEXT_POISON"); if (v && *v) - poison_requested = 1; + poison_mode = poison_mode_default; else - poison_requested = 0; + poison_mode = poison_mode_none; } - return poison_requested; + return poison_mode; } #endif diff --git a/gettext.h b/gettext.h index 8e279622f6..fcb6bfaa2c 100644 --- a/gettext.h +++ b/gettext.h @@ -42,7 +42,13 @@ static inline int gettext_width(const char *s) #endif #ifdef GETTEXT_POISON -extern int use_gettext_poison(void); +enum poison_mode { + poison_mode_uninitialized = -1, + poison_mode_none = 0, + poison_mode_default +}; + +extern enum poison_mode use_gettext_poison(void); #define GETTEXT_POISON_MAGIC "# GETTEXT POISON #" #endif @@ -52,7 +58,7 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) if (!*msgid) return ""; #ifdef GETTEXT_POISON - if (use_gettext_poison()) + if (use_gettext_poison() == poison_mode_default) return GETTEXT_POISON_MAGIC; #endif return gettext(msgid); @@ -62,7 +68,7 @@ static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2) const char *Q_(const char *msgid, const char *plu, unsigned long n) { #ifdef GETTEXT_POISON - if (use_gettext_poison()) + if (use_gettext_poison() == poison_mode_default) return GETTEXT_POISON_MAGIC; #endif return ngettext(msgid, plu, n); From patchwork Mon Oct 22 20:22:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3DB4E13A4 for ; Mon, 22 Oct 2018 20:23:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BF3228AF1 for ; Mon, 22 Oct 2018 20:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2049428F64; Mon, 22 Oct 2018 20:23:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 860D128AF1 for ; Mon, 22 Oct 2018 20:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728384AbeJWEnj (ORCPT ); Tue, 23 Oct 2018 00:43:39 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35737 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728012AbeJWEnj (ORCPT ); Tue, 23 Oct 2018 00:43:39 -0400 Received: by mail-ed1-f67.google.com with SMTP id e2-v6so2784174edn.2 for ; Mon, 22 Oct 2018 13:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sbMCBemiClCpEe4BT6RReSAvKd3cL9gs3PF4yHi5rU0=; b=n1RuHKOo9dwLergc1znmkvHAEL0MSMtHcedffwj6nsI4afMxZtB02fn8rcQH1MTLaa 12gr8MAX0TuRoLqHWv8Q36geoqygoGbz0P9in6T1i55oznvts7GCO0O3izJjM01ElVrD 8VhrqAoaV+56Hld5gl3nvlxBgPRGJZiQw7wB2pQL+VeyIHL0PAvSAsoNbbS6mima+Fsk d2lWBcCueCV1k5DhS1MxJlmsFZVCD23l4ZoLOnTQOdC8FtW3adCZb5Vgrk6TkXFWGX9W sDtLN3ppSU26ZYaML1eonQunoaBQwPu4OFKDQTVqyVjN8AHZGbTe7zeUBA3ARh6ydGrj n6Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sbMCBemiClCpEe4BT6RReSAvKd3cL9gs3PF4yHi5rU0=; b=oQLHKHf/9LbmIPA4/2a4c1IDCPLm9WEBnwgbWKagoNrNZCQu/EqVlAFRBz/KXSU8Rh bdRfS2Sau61W4PATk9K8FObgx3SUmxUDsUvSYyUI0WZttzz9TQCM3A3JZrRPCbRX4Z/T SQ8IXSC9icqpTv+sPa+aL+WTnZFdBKu72Pgv1OzqocnyoEGi39yeoQHgrwrtpR1+6DaF eJFI54y4x6jwIUOB/eqWxjP86X4K0/F5ib3vs6GfFXAdEYUUMOFjEvz4YQZ19cXMvl1Y /Vsurb4xi898ihihcX4u7KvVOf/g+XvIrSJfzDAqgqtJYFfXKybxydHeBvheIO+ttxPz 0RkQ== X-Gm-Message-State: ABuFfoiNOp8TwayHf7eAKVhv0NeYYkpMXFhUbLlJs1Qa/mAa8dZ11avU 1Wttz8wivv0eKgHmFp6Bvped3QEc X-Google-Smtp-Source: ACcGV623ccG9Q0Xiao/feTrlholoZB29EnSIKLIR+ieVlpPoZ9mmIqHuXQ9gmssiLwqDJj4mUdP/rA== X-Received: by 2002:a50:9583:: with SMTP id w3-v6mr14724007eda.33.1540239817169; Mon, 22 Oct 2018 13:23:37 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:36 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 7/8] gettext: introduce GIT_GETTEXT_POISON=scrambled Date: Mon, 22 Oct 2018 22:22:40 +0200 Message-Id: <20181022202241.18629-8-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes tests run with GETTEXT POISON fail because of a reason other than a translated string that should not have been translated. In such a case an error message from a git command in the test's verbose output is usually, well, less than helpful: error: # GETTEXT POISON # or fatal: # GETTEXT POISON #: No such file or directory It's especially annoying on those rare occasions when a heisenbug decides it's a good time to suddenly reveal its presence during a GETTEXT POISON test run, and all we get is an error message like these (yes, I did actually see both of the above error messages only once). Make builtin commands' GETTEXT POISON-ed error messages more useful for debugging failures by introducing a new mode of poisoning: if $GIT_GETTEXT_POISON is set to 'scrambled', then include the original untranslated message after that "# GETTEXT_POISON #" string in a scrambled form, interspersing a '.' after each character. This way the messages will remain gibberish enough for machine consumption as they were before, but at the same time they will be relatively easily legible for humans. Take extra care to preserve printf() format conversion specifiers unaltered when inserting those dots. Leave 'git-sh-i18n.sh' unchanged, because translatable messages in scripts often include shell variables, and they could (though currently they don't) include printf format specifiers, parameter expansions, command substitutions and whatnot, too. Dealing with those in a shell script would be too much hassle without its worth. There is an additional benefit: as this change considerably increases the size of translated messages, it could detect cases when we try to format a translated string into a too small buffer. E.g. this change applied on old versions causes test failures because of the bug that was fixed in 2cfa83574c (bisect_next_all: convert xsnprintf to xstrfmt, 2017-02-16). [TODO: Fallout? A 'printf(_("foo: %s"), var);' call includes the contents of 'var' unscrambled in the output. Could that hide the translation of a string that should not have been translated? I'm afraid yes: to check the output of that printf() a sloppy test could do: git plumbing-cmd >out && grep "var's content" out which would fail in a regular GETTEXT_POISON test run, but would succeed in a scrambled test run. Does this matter in practice, do we care at all? Does gettext_scramble() need a FORMAT_PRESERVING annotation? Seems to work fine without it so far...] Signed-off-by: SZEDER Gábor --- gettext.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- gettext.h | 11 +++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/gettext.c b/gettext.c index c50d1e0377..8ba7fd0bea 100644 --- a/gettext.c +++ b/gettext.c @@ -52,13 +52,61 @@ enum poison_mode use_gettext_poison(void) static enum poison_mode poison_mode = poison_mode_uninitialized; if (poison_mode == poison_mode_uninitialized) { const char *v = getenv("GIT_GETTEXT_POISON"); - if (v && *v) - poison_mode = poison_mode_default; - else + if (v && *v) { + if (!strcmp(v, "scrambled")) + poison_mode = poison_mode_scrambled; + else + poison_mode = poison_mode_default; + } else poison_mode = poison_mode_none; } return poison_mode; } + +static int conversion_specifier_len(const char *s) +{ + const char printf_conversion_specifiers[] = "diouxXeEfFgGaAcsCSpnm%"; + const char *format_end; + + if (*s != '%') + return 0; + + format_end = strpbrk(s + 1, printf_conversion_specifiers); + if (format_end) + return format_end - s; + else + return 0; +} + +const char *gettext_scramble(const char *msg) +{ + struct strbuf sb; + + strbuf_init(&sb, + /* "# GETTEXT_POISON #" + ' ' + "m.e.s.s.a.g.e." + '\0' */ + strlen(GETTEXT_POISON_MAGIC) + 1 + 2 * strlen(msg) + 1); + + strbuf_addch(&sb, ' '); + while (*msg) { + if (*msg == '\n') { + strbuf_addch(&sb, *(msg++)); + continue; + } else if (*msg == '%') { + int spec_len = conversion_specifier_len(msg); + if (spec_len) { + strbuf_add(&sb, msg, spec_len); + msg += spec_len; + continue; + } + } + + strbuf_addch(&sb, *(msg++)); + strbuf_addch(&sb, '.'); + } + + /* This will be leaked... */ + return strbuf_detach(&sb, NULL); +} #endif #ifndef NO_GETTEXT diff --git a/gettext.h b/gettext.h index fcb6bfaa2c..d21346d9fa 100644 --- a/gettext.h +++ b/gettext.h @@ -45,10 +45,12 @@ static inline int gettext_width(const char *s) enum poison_mode { poison_mode_uninitialized = -1, poison_mode_none = 0, - poison_mode_default + poison_mode_default, + poison_mode_scrambled }; extern enum poison_mode use_gettext_poison(void); +extern const char *gettext_scramble(const char *msg); #define GETTEXT_POISON_MAGIC "# GETTEXT POISON #" #endif @@ -60,6 +62,8 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) #ifdef GETTEXT_POISON if (use_gettext_poison() == poison_mode_default) return GETTEXT_POISON_MAGIC; + else if (use_gettext_poison() == poison_mode_scrambled) + return gettext_scramble(gettext(msgid)); #endif return gettext(msgid); } @@ -67,11 +71,14 @@ static inline FORMAT_PRESERVING(1) const char *_(const char *msgid) static inline FORMAT_PRESERVING(1) FORMAT_PRESERVING(2) const char *Q_(const char *msgid, const char *plu, unsigned long n) { + const char *msg = ngettext(msgid, plu, n); #ifdef GETTEXT_POISON if (use_gettext_poison() == poison_mode_default) return GETTEXT_POISON_MAGIC; + else if (use_gettext_poison() == poison_mode_scrambled) + return gettext_scramble(msg); #endif - return ngettext(msgid, plu, n); + return msg; } /* Mark msgid for translation but do not translate it. */ From patchwork Mon Oct 22 20:22:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 10652463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D854B5BB5 for ; Mon, 22 Oct 2018 20:23:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4CA728AF1 for ; Mon, 22 Oct 2018 20:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B931C28F64; Mon, 22 Oct 2018 20:23:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BE4F28AF1 for ; Mon, 22 Oct 2018 20:23:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728418AbeJWEnk (ORCPT ); Tue, 23 Oct 2018 00:43:40 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40633 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeJWEnj (ORCPT ); Tue, 23 Oct 2018 00:43:39 -0400 Received: by mail-ed1-f68.google.com with SMTP id r1-v6so39231604edd.7 for ; Mon, 22 Oct 2018 13:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r1gn7DQ/FT3+RFxwntpp1sYdJnLbw5//PTT/vn2/2CQ=; b=tbgozHQYNTo/O3FZwH8z4zCUj1WSdGoMnLRmdD83BgiZ0fMP4KkLFYY2qAWkq0EMFJ ZyF34ToVzX1Uclus47FBZr34E4FGCI4nghdnjjozNhdwi79RAuNVrzDIILktj/vMhaJJ 1MCUJjZjsGh430xaYuYnxFK5+76lQ3d6EYzVwTNzSC+3i80HezPtWvlVBIH7QjVBkhpK rrRV18zQykuGHTvqZMLdtQDwXQdBJm9Yy1CltR1ZbjTbE6aPOXxbb5B0LPc0/ZHtPo25 nHJ/Pjf1fyTwJy+mLzhhuRuUUysN8iGCRB+g2giVd3ZRbiRL59oCiHqQ+cjmCSkNmSWQ j7BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r1gn7DQ/FT3+RFxwntpp1sYdJnLbw5//PTT/vn2/2CQ=; b=auRfNHdRw12wtOVUMlwbLrAqJR38+buY++2PgO87dvVYnUTy4tSQ0koccs0ZBFM6NU PejITOB+y5+0KPYkFhASL0dKWqsHZ2xoXeDYFWHYnWlINK+sbSBMbxiAbqArygHBzJBc WY/FIBBQjFycxZ9Q5TJGX+tD4XKg9aA9UKZbs8Vd9wQ3bsQwXN6Zv3bvFOjql2ZhMlDV sw9NLGfPUCSVx6RJWdj31bh5vH9ydLs5lP7/UlPK+cU2w20iIGQ5/faEez2accRyjV5u H+6Vv+HB67rUffbYlctsHSaMjnVRMluQcjMad5fFoZyRO5vZgvTQwuPsNohIpQGVru10 R/iw== X-Gm-Message-State: ABuFfohxhCSbS1tiWTXDncYD2bxltqHJCfpjoLKdjfEAaBqihye9SX56 9+Zi8nBtDlRwkIVh5FMPzOgLIPym X-Google-Smtp-Source: ACcGV60zDJX/8zrSPBqabZTvSAI6pQ8lj2A8V8ASYm3h2ozzXeny0ZNPL4hwb3fnO+B2TY4VaI9nZg== X-Received: by 2002:a50:f9c7:: with SMTP id a7-v6mr13598249edq.138.1540239818398; Mon, 22 Oct 2018 13:23:38 -0700 (PDT) Received: from localhost.localdomain (x4db968d4.dyn.telefonica.de. [77.185.104.212]) by smtp.gmail.com with ESMTPSA id h21-v6sm16882228eda.23.2018.10.22.13.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Oct 2018 13:23:37 -0700 (PDT) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= Subject: [PATCH 8/8] travis-ci: run GETTEXT POISON build job in scrambled mode, too Date: Mon, 22 Oct 2018 22:22:41 +0200 Message-Id: <20181022202241.18629-9-szeder.dev@gmail.com> X-Mailer: git-send-email 2.19.1.681.g6bd79da3f5 In-Reply-To: <20181022202241.18629-1-szeder.dev@gmail.com> References: <20181022153633.31757-1-pclouds@gmail.com> <20181022202241.18629-1-szeder.dev@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Run the test suite twice in the GETTEXT POISON build: first with GIT_GETTEXT_POISON=scrambled and then with "regular" poisoning, to see whether the scrambled mode hid any mis-translations. Signed-off-by: SZEDER Gábor --- ci/lib-travisci.sh | 1 + ci/run-build-and-tests.sh | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh index 109ef280da..fdfa4e035b 100755 --- a/ci/lib-travisci.sh +++ b/ci/lib-travisci.sh @@ -122,5 +122,6 @@ osx-clang|osx-gcc) ;; GETTEXT_POISON) export GETTEXT_POISON=YesPlease + export GIT_GETTEXT_POISON=scrambled ;; esac diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index 3735ce413f..74ba05e152 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -9,10 +9,14 @@ ln -s "$cache_dir/.prove" t/.prove make --jobs=2 make --quiet test -if test "$jobname" = "linux-gcc" -then +case "$jobname" in +linux-gcc) GIT_TEST_SPLIT_INDEX=YesPlease make --quiet test -fi + ;; +GETTEXT_POISON) + GIT_GETTEXT_POISON=YesPlease make --quiet test + ;; +esac check_unignored_build_artifacts