cpp w/DOS line feeds

Zack Weinberg zack@rabi.columbia.edu
Sat Jan 23 22:41:00 GMT 1999


On Sat, 23 Jan 1999 17:46:21 +0100, "Matthias Urlichs" wrote:
>Hi,
>
>Per Bothner:
>> > Four. When you compile and/or run the code on a Mac, you might get the
>> > equivalent of \n\r when reading DOS files.
>> 
>> Presumably only when opening the file in text mode - not when opining
>> it in binary mode?
>> 
>I've heard of at least one compiler which switches the ASCII codes
>of \r and \n.  Thus, if you use code compiled by this thing, and if you
>open the file in text mode, it would come out OK again.  :-/

'nuff talk - here's some code.  This patch makes cpplib understand any
of \n, \r, \r\n, \n\r as the line terminator.  It also adds trigraph
support, which we didn't have before.  (It was convenient to do them
both in the same place.)  There is a slight performance hit, which I
believe I can win back elsewhere; I didn't want to make this patch too
big.  You'll need the previous patch I posted for cpplib.c to make
this install cleanly.  Bootstrap is successful, libc build is
successful if my cppexp.c patch is present.  I haven't tortured the
alternate-line-terminator code much, but it does work in simple cases.

The switch has the default label at the top to work around an
infelicity in gcc's register allocation; I'll post separately on that.

zw

1999-01-24 01:14 -0500  Zack Weinberg  <zack@midnite.ec.rhno.columbia.edu>

	* cppfiles.c (safe_read): Deleted.  
	(read_and_prescan): New function, replaces safe_read, converts
	and/or warns about trigraphs, silently converts odd line
	terminators (\r, \n\r, \r\n).  Warns about no newline at EOF.
	(finclude): Use read_and_prescan; turn off nonblocking mode on
	the input descriptor; remove file-size-examination and
	no-newline-at-EOF gunk which is	longer necessary; be more
	careful about checking that we've been handed a legitimate
	file to read (only real files, pipes, and ttys are acceptable).
	* cpplib.h (cpp_options): Rename no_trigraphs flag to 
	`trigraphs' and invert its sense.
	(trigraph_table): Declare.
	(cpp_warning_with_line): Prototype.
	* cpplib.c: Remove all references to trigraph_pcp. Define
	trigraph_table; initialize it in initialize_char_syntax.  Open
	files in nonblocking mode.  s/no_trigraphs/trigraphs/
	throughout, and invert sense.  Put cpp_warning_with_line back
	in and export it.

begin 644 nl-tri.diff.gz
M'XL("&>\JC8``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