pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Meskes <meskes@postgresql.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Meskes <meskes@postgresql.org>
Cc: alexsav23@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #8611: ECPG: unclosed comment "/*"
Date: Sun, 24 Nov 2013 12:30:10 +0100
Message-ID: <20131124113010.GC28081@feivel.credativ.lan> (raw)
In-Reply-To: <24807.1385151550@sss.pgh.pa.us>
References: <E1Vj5nW-0001fr-Hi@wrigleys.postgresql.org>
	<20131122184613.GA13590@feivel.credativ.lan>
	<24807.1385151550@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

ecpg.comment.diff (text/x-diff, 2.6K) download commit 8ac5e88f9fc54c480ed1419c0ce94f54653fe8c3 Author: Michael Meskes <meskes@postgresql.org> 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: * <xb> bit string literal - * <xc> extended C-style comments - thomas 1997-07-12 + * <xcc> extended C-style comments in C + * <xcsql> extended C-style comments in SQL * <xd> delimited identifiers (double-quoted identifiers) - thomas 1997-10-27 * <xh> hexadecimal numeric string - thomas 1997-11-16 * <xq> 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})*. <SQL>{whitespace} { /* ignore */ } -<C,SQL>{xcstart} { +<C>{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); } -<xc>{xcstart} { +<SQL>{xcstart} { + token_start = yytext; + state_before = YYSTATE; + xcdepth = 0; + BEGIN(xcsql); + /* Put back any characters past slash-star; see above */ + yyless(2); + fputs("/*", yyout); + } +<xcc>{xcstart} { ECHO; } +<xcsql>{xcstart} { xcdepth++; /* Put back any characters past slash-star; see above */ yyless(2); fputs("/*", yyout); } - -<xc>{xcstop} { +<xcsql>{xcstop} { ECHO; if (xcdepth <= 0) { @@ -395,12 +406,16 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})(.*\\{space})*. else xcdepth--; } +<xcc>{xcstop} { + ECHO; + BEGIN(state_before); + token_start = NULL; + } +<xcc,xcsql>{xcinside} { ECHO; } +<xcc,xcsql>{op_chars} { ECHO; } +<xcc,xcsql>\*+ { ECHO; } -<xc>{xcinside} { ECHO; } -<xc>{op_chars} { ECHO; } -<xc>\*+ { ECHO; } - -<xc><<EOF>> { mmfatal(PARSE_ERROR, "unterminated /* comment"); } +<xcc,xcsql><<EOF>> { mmfatal(PARSE_ERROR, "unterminated /* comment"); } <SQL>{xbstart} { token_start = yytext;

view thread (11+ messages)  latest in thread

Message-ID: <20131124113010.GC28081@feivel.credativ.lan>
Permalink:  ../20131124113010.GC28081@feivel.credativ.lan/
Also on:    postgresql.org/message-id/20131124113010.GC28081@feivel.credativ.lan

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: meskes@postgresql.org, tgl@sss.pgh.pa.us, alexsav23@gmail.com
  Subject: Re: BUG #8611: ECPG: unclosed comment "/*"
  In-Reply-To: <20131124113010.GC28081@feivel.credativ.lan>
  References: <E1Vj5nW-0001fr-Hi@wrigleys.postgresql.org> <20131122184613.GA13590@feivel.credativ.lan> <24807.1385151550@sss.pgh.pa.us> <20131124113010.GC28081@feivel.credativ.lan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox