Subject: RE: ASCII and BINARY files. Why?
From: [email-masked] (Stephan Mueller)

27 Jan 1997 11:28:53 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <c=US%a=_%p=msft%l=[email-masked]>
Original-To: "'Paul Shirley'" <[email-masked]>,
        "[email-masked]'"
	 <[email-masked]>
Original-Cc: "[email-masked]'" <[email-masked]>,
        "[email-masked]'"
	 <[email-masked]>
X-Mailer: Microsoft Exchange Server Internet Mail Connector Version 4.0.994.63
Encoding: 48 TEXT
Original-Sender: [email-masked]

ANSI C does not define that a 't' in the second argument to fopen
indicates text mode.  ANSI only defines that a 'b' indicates binary
mode.  Text mode is the default.  That doesn't mean that an
implementation can't define 't' to mean 'force text mode,' just that not
doing so doesn't constitute a bug.  It appears there is no standard way
to force text mode.  Things get even murkier: my C reference (H&S 3rd
ed) suggests that ANSI allows any of the update file types (i.e. opening
a file with a '+' in the mode string) to assume binary mode.  If this is
true, then there's no way to portably open a file for update in text
mode.

I agree that the 't' flag is really handy to have around.

IMO, the only way to truly solve this problem once and for all is to
gradually incorporate text/binary mode awareness into the official GNU
sources.  That means that all fopens that really mean to open in binary
should have the 'b' added, and all code that follows fopens that really
mean text mode should be examined and changed if they assume things like
'the size of the file equals the number of charcters in a read of the
whole file'.  The code isn't 'bad' the way it is, it's just
Unix-centric, and not entirely ANSI conformant.  It will be more useful
and more portable if these things are fixed, and I'm sure in time they
will be.

stephan();

>-----Original Message-----
>From:	Paul Shirley [SMTP:[email-masked]]
>Sent:	Sunday, January 26, 1997 3:12 PM
>To:	[email-masked]
>Cc:	[email-masked]; [email-masked]
>Subject:	Re: ASCII and BINARY files. Why?
>
>In message <[email-masked]>,
>[email-masked] writes
>>I don't know a standard way of forcing open in text mode,
>>i.e. the negation of "b" or O_BINARY is missing!
>>
>
>You mean 'fopen("file","rt");' does not open in text mode?
>
>And what about O_TEXT, if its not implemented it should be.
>
>-- 
>Paul Shirley
>-
>For help on using this list, send a message to
>"[email-masked]" with one line of text: "help".
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".