Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewYLc-00013v-UE for pgsql-committers@arkaria.postgresql.org; Thu, 15 Mar 2018 19:15:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewYLb-0002lQ-C9 for pgsql-committers@arkaria.postgresql.org; Thu, 15 Mar 2018 19:15:31 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewYLb-0002lG-3s for pgsql-committers@lists.postgresql.org; Thu, 15 Mar 2018 19:15:31 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewYLY-0005AO-8H for pgsql-committers@postgresql.org; Thu, 15 Mar 2018 19:15:29 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 51FA213E9; Thu, 15 Mar 2018 15:15:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Thu, 15 Mar 2018 15:15:27 -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-sender:x-me-sender:x-sasl-enc; s=fm2; bh=uQ7cFqqMvquTDad6U 63lojXI97aJGzGGOHD606eJAlk=; b=TzM4cFB3Zb/tq1H4lqTfmj7T0NpAjo21M u0GfRFAI/ki9Pck4+UPbVa00iuD8gVGYG7M+JrlJ8o7HS6iZ2pf/zHi2Fk0M+E1i 7RuJBSRaj2fjR2fjUHB1VBxaVUD+ejgg0lZ3SkhPkDUPjagLrg1sau/E8kAbvPWX pe4H1CzRiz+FH7xHHelKGh0ojA8GZXFbLVHXr4kHWM2iZ6dh/s2IRvb68ZuWEQ/P 3/PxTDjqZdXhPm8X57iYygxqJfagg6AZ6pvbSVVfPXQpz+XC0R/LifU5sQwCaoWV N2UpsaWluMfZ3aQKSNFcsJT2bUbdK+X7aJsCNST/K5NgFY3cCzaVA== X-ME-Sender: Received: from alvin.alvh.no-ip.org (unknown [179.56.29.253]) by mail.messagingengine.com (Postfix) with ESMTPA id 6FBCF7E13B; Thu, 15 Mar 2018 15:15:26 -0400 (EDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 0F6A8842; Thu, 15 Mar 2018 16:15:24 -0300 (-03) Date: Thu, 15 Mar 2018 16:15:24 -0300 From: Alvaro Herrera To: Tom Lane Cc: Michael Paquier , Peter Eisentraut , David Rowley , pgsql-committers Subject: Re: pgsql: Move strtoint() to common Message-ID: <20180315191524.ga2fdjbnuz4y43fg@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <27178.1521132652@sss.pgh.pa.us> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane wrote: > Alvaro Herrera writes: > > Michael Paquier wrote: > >> Attached is a patch which fixes the compilation failure on Windows for > >> me. That should put the buildfarm back to green. > > > Pushed, thanks -- let's see how that goes. > > build now works, ecpg tests fail. I stared at the code for a while, didn't notice anything amiss. I'm mystified. Peter? I think the guilty bit is the one below, but 1) I don't see how the new code fails to work exactly like the old code 2) I don't understand why it would only fail on Windows. I thought it may be a port difference in strtol, but I don't see what it'd be. Also: it seems strtol per spec returns LONG_MAX/LONG_MIN on overflow/underflow, and our strtoint doesn't do (an equivalent of) that. But I don't see how that would affect the failing ecpg test. diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index ba1798c77e..405dee73b0 100644 *** a/src/interfaces/ecpg/preproc/pgc.l --- b/src/interfaces/ecpg/preproc/pgc.l *************** *** 723,744 **** cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ return Op; } {param} { base_yylval.ival = atol(yytext+1); return PARAM; } {integer} { ! long val; char* endptr; errno = 0; ! val = strtol((char *)yytext, &endptr,10); ! if (*endptr != '\0' || errno == ERANGE || ! /* check for overflow of int */ ! val != (int) val) { errno = 0; base_yylval.str = mm_strdup(yytext); return FCONST; } base_yylval.ival = val; return ICONST; --- 725,744 ---- return Op; } {param} { base_yylval.ival = atol(yytext+1); return PARAM; } {integer} { ! int val; char* endptr; errno = 0; ! val = strtoint(yytext, &endptr, 10); ! if (*endptr != '\0' || errno == ERANGE) { errno = 0; base_yylval.str = mm_strdup(yytext); return FCONST; } base_yylval.ival = val; return ICONST; -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services