From: Eric Backus Subject: Re: O_TEXT/O_BINARY grief To: jes AT mbio DOT med DOT upenn DOT edu (Joe Smith) (Joe Smith) Date: Tue, 21 Jun 94 14:27:59 PDT Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Mailer: Elm [revision: 70.85] Joe Smith wrote: > OTOH, can anyone give me a for-instance where treating all six of the > above characters as 'whitespace' leads to incorrect semantics? And I > don't think quoted strings that span source lines count, since there > are perfectly portable ways to do that without embedding control > characters in the source. In the case mentioned (cpp macros), so you > remove backslash-linefeed pairs and leave the carriage-return: the > compiler will see the carriage-return as just another 'whitespace', > the same as the tab(s) you might add at the beginning of the following > line. > > Is cpp *required* by the standard to remove backslash-linefeed pairs? > It might conceivably keep the newline as part of the macro body. If > you write macros that *depend* on one behavior or another (say, > splitting and identifier or operator), then you will justly suffer for > it. In the ANSI C standard, the first thing that the preprocessor does is translate the physical file into the C character set. This translation includes fixing trigraphs, and converting the physical file's end-of-line indications into single linefeeds. After this translation is done, everything is done UNIX-like with single linefeeds. The standard doesn't specify anything about what the physical file's end-of-line indication must look like. Presumably, this is system or implementation dependant. Presumably, if the physical file is read in text mode, then everything works out. This is why text mode *MUST* understand the system's convention for text files. Yes, the preprocessor is *required* to remove backslash-linefeed pairs. This happens after the above translation, but before almost everything else. Whitespace is NOT ignored inside of a quoted string. So, if text mode does not translate CRLF to LF, then the preprocessor will see backslash-cr-lf rather than backslash-lf, and will not remove them. This would be wrong. -- Eric Backus ericb AT lsid DOT hp DOT com (206) 335-2495