From: smueller AT microsoft DOT com (Stephan Mueller) Subject: RE: ASCII and BINARY files. Why? 27 Jan 1997 11:28:53 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: Original-To: "'Paul Shirley'" , "'dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de'" Original-Cc: "'aurel AT xylo DOT owl DOT de'" , "'gnu-win32 AT cygnus DOT com'" X-Mailer: Microsoft Exchange Server Internet Mail Connector Version 4.0.994.63 Encoding: 48 TEXT Original-Sender: owner-gnu-win32 AT cygnus DOT com 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:Paul AT chocolat DOT foobar DOT co DOT uk] >Sent: Sunday, January 26, 1997 3:12 PM >To: dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de >Cc: aurel AT xylo DOT owl DOT de; gnu-win32 AT cygnus DOT com >Subject: Re: ASCII and BINARY files. Why? > >In message <009AEAA3 DOT 93F1B0A0 DOT 7685 AT ifk20 DOT mach DOT uni-karlsruhe DOT de>, >dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de 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 >"gnu-win32-request AT cygnus DOT com" with one line of text: "help". - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".