cpplib: backslash-newline

Zack Weinberg zack@wolery.cumb.org
Tue Aug 29 23:50:00 GMT 2000


On Mon, Aug 28, 2000 at 03:55:32PM -0400, Dave Brolley wrote:
> Zack Weinberg wrote:
> 
> > On Sun, Aug 27, 2000 at 02:34:29PM +0100, Neil Booth wrote:
> > > It has been requested by Zack and Per that a backslash and newline
> > > separated by whitespace still be treated as a backslash-newline.
> > This
> > > does that, and keeps the warning.  At the moment, a comment falls
> > into
> > > the definition of "whitespace" here, but let's leave it be for the
> > > moment.  That'll be simpler to fix with the lexer rewrite I hope to
> > > start soon.
> >
> > While this does hit all of the important situations that users
> > complain about, you haven't handled backslash space newline inside
> > comments or strings.  This makes the behavior inconsistent.  I don't
> > think we want that.
> >
> > Also it should be turned off by -ansi; I'm not 100% persuaded this is
> > standards-conforming behavior.
> >
> I believe that it is conforming. Wherever the standard refers to
> 'newline', they are referring to an 'end-of-line indicator' (see phase 1
> of the phases of translation) which can defined as anything that's
> reasonable. Certainly ignoring extraneous whitespaces at the end of a
> line is resonable, since it is more likely to be a bug than anything
> intentional.

I went around this a few times with the comp.std.c readership.  Yes,
it does appear to be conforming, but only because "phase 1" of
translation is allowed to get away with murder.  Running the entire
file through tr A-Z a-z in phase 1 is legitimate.  And I could argue
that this is (another) problem with the standard, not something that
implementations should make use of.

Having said that, I do agree that in noncontrived code, stray
whitespace at the end of a line is more likely to be a bug than
anything else, and that we should probably strip it.

Paul Eggert pointed out (in the c.s.c discussion) that the multiline
string extension preserves trailing whitespace on intermediate lines.
So it is possible that a noncontrived program using that extension
will be unhappy if the backslash, space, and newline mysteriously
disappear from

   char x[] = "\_
blah";

where _ is a space.  I don't find this argument terribly persuasive,
myself... 

(If I sound like I'm arguing both sides at once, that's because I am
personally divided about this feature.)

zw


More information about the Gcc-patches mailing list