Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkXtK-0007jt-SM for pgsql-bugs@arkaria.postgresql.org; Sun, 24 Nov 2013 11:30:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VkXtK-000823-C9 for pgsql-bugs@arkaria.postgresql.org; Sun, 24 Nov 2013 11:30:18 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkXtJ-00081k-6t for pgsql-bugs@postgresql.org; Sun, 24 Nov 2013 11:30:17 +0000 Received: from gauss.credativ.com ([93.94.130.89]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkXtF-0007lj-Gx; Sun, 24 Nov 2013 11:30:16 +0000 Received: from feivel (p4FE08F25.dip0.t-ipconnect.de [79.224.143.37]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mme@gauss.credativ.com) by gauss.credativ.com (Postfix) with ESMTPSA id 058D41B60AC; Sun, 24 Nov 2013 12:30:11 +0100 (CET) Received: by feivel (Postfix, from userid 1000) id ADC949F12B; Sun, 24 Nov 2013 12:30:10 +0100 (CET) Date: Sun, 24 Nov 2013 12:30:10 +0100 From: Michael Meskes To: Tom Lane Cc: Michael Meskes , alexsav23@gmail.com, pgsql-bugs@postgresql.org Subject: Re: BUG #8611: ECPG: unclosed comment "/*" Message-ID: <20131124113010.GC28081@feivel.credativ.lan> References: <20131122184613.GA13590@feivel.credativ.lan> <24807.1385151550@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7AUc2qLy4jB3hD7Z" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <24807.1385151550@sss.pgh.pa.us> User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --7AUc2qLy4jB3hD7Z Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Nov 22, 2013 at 03:19:10PM -0500, Tom Lane wrote: > I don't see any way to "fix" it --- the best you can do is have a > different set of users complaining, because C and SQL aren't consistent > about this, and it's not obvious which convention should be followed > where. Well, I think we can in ecpg as ecpg knows whether it's parsing C code or SQL code. Alexei, could you please try the attached patch? IT's already in HEAD but I'd prefer to have you run your sources through the changed ecpg before backporting the patch. Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org Jabber: michael.meskes at gmail dot com VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL --7AUc2qLy4jB3hD7Z Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ecpg.comment.diff" commit 8ac5e88f9fc54c480ed1419c0ce94f54653fe8c3 Author: Michael Meskes Date: Sun Nov 24 12:26:00 2013 +0100 Distinguish between C and SQL mode for C-style comments. SQL standard asks for allowing nested comments, while C does not. Therefore the two comments, while mostly similar, have to be parsed seperately. diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 24936ea..6deef59 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -102,7 +102,8 @@ static struct _if_value * and to eliminate parsing troubles for numeric strings. * Exclusive states: * bit string literal - * extended C-style comments - thomas 1997-07-12 + * extended C-style comments in C + * extended C-style comments in SQL * delimited identifiers (double-quoted identifiers) - thomas 1997-10-27 * hexadecimal numeric string - thomas 1997-11-16 * standard quoted strings - thomas 1997-07-30 @@ -115,7 +116,8 @@ static struct _if_value */ %x xb -%x xc +%x xcc +%x xcsql %x xd %x xdc %x xh @@ -369,23 +371,32 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. {whitespace} { /* ignore */ } -{xcstart} { +{xcstart} { token_start = yytext; state_before = YYSTATE; xcdepth = 0; - BEGIN(xc); + BEGIN(xcc); /* Put back any characters past slash-star; see above */ yyless(2); fputs("/*", yyout); } -{xcstart} { +{xcstart} { + token_start = yytext; + state_before = YYSTATE; + xcdepth = 0; + BEGIN(xcsql); + /* Put back any characters past slash-star; see above */ + yyless(2); + fputs("/*", yyout); + } +{xcstart} { ECHO; } +{xcstart} { xcdepth++; /* Put back any characters past slash-star; see above */ yyless(2); fputs("/*", yyout); } - -{xcstop} { +{xcstop} { ECHO; if (xcdepth <= 0) { @@ -395,12 +406,16 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. else xcdepth--; } +{xcstop} { + ECHO; + BEGIN(state_before); + token_start = NULL; + } +{xcinside} { ECHO; } +{op_chars} { ECHO; } +\*+ { ECHO; } -{xcinside} { ECHO; } -{op_chars} { ECHO; } -\*+ { ECHO; } - -<> { mmfatal(PARSE_ERROR, "unterminated /* comment"); } +<> { mmfatal(PARSE_ERROR, "unterminated /* comment"); } {xbstart} { token_start = yytext; --7AUc2qLy4jB3hD7Z Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --7AUc2qLy4jB3hD7Z--