From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h
Date: Sat, 6 Feb 2016 19:10:08 +0100
Message-ID: <20160206181008.GC8832@hjp.at> (raw)
In-Reply-To: <20160201121620.GA20662@feivel>
References: <20160129002202.2534.66092@wrigleys.postgresql.org>
<1454155301.23207.80.camel@postgresql.org>
<37edb08437e746b9bfa4d430ec4f738a@se10mbx02.org.nasdaqomx.com>
<20160201085656.GA5967@feivel>
<5dd13ee64104460c83de2e113a5907ce@se10mbx02.org.nasdaqomx.com>
<20160201094337.GA9280@feivel>
<68728.1454320604@sss.pgh.pa.us>
<20160201121620.GA20662@feivel>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 2016-02-01 13:16:20 +0100, Michael Meskes wrote:
> > and ends on an ordinary line. I am not sure what the C standard says
> > about such cases, but I can certainly imagine that some tools might not
> > be very happy with that.
>
> We/I have to figure out what the standard says, because if it allows
> these comments, the lexer itself has to be fixed to work correctly
> instead of just fixing the header files.
The relevant translation phases are 3 and 4 according to the C standard
(section 5.1.1.2 in C11):
| 3. The source file is decomposed into preprocessing tokens7) and
| sequences of white-space characters (including comments). A source
| file shall not end in a partial preprocessing token or in a partial
| comment. Each comment is replaced by one space character. New-line
| characters are retained. Whether each nonempty sequence of
| white-space characters other than new-line is retained or replaced
| by one space character is implementation-defined.
|
| 4. Preprocessing directives are executed, macro invocations are
| expanded, and _Pragma unary operator expressions are executed. If a
| character sequence that matches the syntax of a universal character
| name is produced by token concatenation (6.10.3.3), the behavior is
| undefined. A #include preprocessing directive causes the named
| header or source file to be processed from phase 1 through phase 4,
| recursively. All preprocessing directives are then deleted.
Comments are replaced with whitespace in phase 3, preprocessing
directives are are only considered in phase 4. So code like
----------------------------------------------------------------------------
#ifndef _ECPGLIB_H /* source created by ecpg which defines these
* symbols */
----------------------------------------------------------------------------
is valid C and should be exactly equivalent to
----------------------------------------------------------------------------
#ifndef _ECPGLIB_H 

----------------------------------------------------------------------------
( denotes a newline character here)
hp
--
_ | Peter J. Holzer | I want to forget all about both belts and
|_|_) | | suspenders; instead, I want to buy pants
| | | hjp@hjp.at | that actually fit.
__/ | http://www.hjp.at/ | -- http://noncombatant.org/Attachments:
signature.asc (application/pgp-signature, 810B) download
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: hjp-pgsql@hjp.at
Subject: Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h
In-Reply-To: <20160206181008.GC8832@hjp.at>
References: <20160129002202.2534.66092@wrigleys.postgresql.org> <1454155301.23207.80.camel@postgresql.org> <37edb08437e746b9bfa4d430ec4f738a@se10mbx02.org.nasdaqomx.com> <20160201085656.GA5967@feivel> <5dd13ee64104460c83de2e113a5907ce@se10mbx02.org.nasdaqomx.com> <20160201094337.GA9280@feivel> <68728.1454320604@sss.pgh.pa.us> <20160201121620.GA20662@feivel> <20160206181008.GC8832@hjp.at>
* 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