Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsuvg-00040S-PB for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Aug 2018 19:06:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fsuve-00077L-R7 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Aug 2018 19:05:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsuve-00077E-KM for pgsql-hackers@lists.postgresql.org; Thu, 23 Aug 2018 19:05:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fsuvc-0007B0-47 for pgsql-hackers@postgresql.org; Thu, 23 Aug 2018 19:05:58 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7NJ5r1r004516; Thu, 23 Aug 2018 15:05:54 -0400 From: Tom Lane To: Andrew Gierth cc: pgsql-hackers@postgresql.org Subject: Re: A really subtle lexer bug In-reply-to: <87r2ipylw4.fsf@news-spur.riddles.org.uk> References: <87va851ppl.fsf@news-spur.riddles.org.uk> <87ftz90yma.fsf@news-spur.riddles.org.uk> <18470.1535036115@sss.pgh.pa.us> <871sap1658.fsf@news-spur.riddles.org.uk> <29360.1535039670@sss.pgh.pa.us> <87r2ipylw4.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Thu, 23 Aug 2018 19:43:50 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4514.1535051153.1@sss.pgh.pa.us> Date: Thu, 23 Aug 2018 15:05:53 -0400 Message-ID: <4515.1535051153@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > Here's what I will push unless there's something important I missed. Stylistic nitpick: I don't especially like "continue" as the body of a for-loop. How about instead of this: for (nchars--; nchars > 1 && (yytext[nchars - 1] == '+' || yytext[nchars - 1] == '-'); nchars--) continue; do this: do { nchars--; } while (nchars > 1 && (yytext[nchars - 1] == '+' || yytext[nchars - 1] == '-')); That's a clearer separation between loop action and loop test, and it makes it more obvious that you're relying on the loop condition to be true at the start. Also, I'm not entirely convinced that replacing the strchr() with a handmade equivalent is a good idea. Some versions of strchr() are pretty quick. No objections beyond that. regards, tom lane