Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gPb-00018R-0w for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 15:02:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3gPZ-0001Mb-60 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Jul 2021 15:02:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gPY-0001MT-UR for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 15:02:56 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3gPV-0002nh-RQ for pgsql-hackers@lists.postgresql.org; Wed, 14 Jul 2021 15:02:56 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BF78F5C00EC; Wed, 14 Jul 2021 11:02:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 14 Jul 2021 11:02:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=7wX6znSFaYtf78sEnhQ5FBuEmBzQ7XbTGkg//DgObWo=; b=ns6FWhEN Dmt5jEZ1WPQTeuI2vOlgDmpNit08I869q29pDFBH8SQW5gP41LcVSfRPtGlItBKp Qyfrj9qwXkVHCNY4CwKmmLlT/imKJeG4ZnDC3966ftYgX+ogQM/0nXk2vtlA+FSH Mzc8bbC+o/rzhh+fmrQI6CXFMe6SKr1neRE3xgqgLzlFrxQ9ec+HTfCyx73Ttk6w mbEHAWym+cS20mDXoAFs9rqC0/OlGMiTFxXmzBXiahxeM4MqeBb6PvMnA5U4kK4+ /ydrCldItKrfDsIkp1HLWppdMpcn8FsnVR6LJLV9MUk061TDXuFCv0VIayLGXdY8 mG15+HohpUoWCQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggugfgjsehtkeertd dttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvges rghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpeefudelkeetiefgge eltddvvddvtdeludfgfefhtdeiveetfedtueeuheduuedvleenucffohhmrghinhepvghn thgvrhhprhhishgvuggsrdgtohhmpdhpohhsthhgrhgvshhqlhdrohhrghenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvges rghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Jul 2021 11:02:50 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id A72F82A038C; Wed, 14 Jul 2021 11:02:47 -0400 (-04) Date: Wed, 14 Jul 2021 11:02:47 -0400 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: michael@paquier.xyz, bharath.rupireddyforpostgres@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: Incorrect usage of strtol, atoi for non-numeric junk inputs Message-ID: <202107141502.hmecfak3hd2y@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210714.103556.2157482390190763832.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Jul-14, Kyotaro Horiguchi wrote: > > > pg_log_error("extra_float_digits must be in range -15..3"); > > > exit_nicely(1); > > > > Should we take this occasion to reduce the burden of translators and > > reword that as "%s must be in range %d..%d"? That could be a separate > > patch. Yes, please, let's do it here. > The first %s is not always an invariable symbol name so it could > result in concatenating several phrases into one, like this. > > pg_log..("%s must be in range %s..%s", _("compression level"), "0", "9")) > > It is translatable at least into Japanese but I'm not sure about other > languages. No, this doesn't work. When the first word is something that is not to be translated (a literal parameter name), let's use a %s (but of course the values must be taken out of the phrase too). But when it is a translatable phrase, it must be present a full phrase, no substitution: pg_log_error("%s must be in range %s..%s", "extra_float_digits", "-15", "3"); pg_log..("compression level must be in range %s..%s", "0", "9")) I think the purity test is whether you want to use a _() around the argument, then you have to include it into the original message. Thanks -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "After a quick R of TFM, all I can say is HOLY CR** THAT IS COOL! PostgreSQL was amazing when I first started using it at 7.2, and I'm continually astounded by learning new features and techniques made available by the continuing work of the development team." Berend Tober, http://archives.postgresql.org/pgsql-hackers/2007-08/msg01009.php