Subject: Re: ASCII and BINARY files. Why?
From: [email-masked] (Geoffrey Noer)

27 Jan 1997 22:32:59 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Content-Type: text
Original-To: [email-masked] (Stephan Mueller)
Original-Cc: [email-masked], [email-masked],
        [email-masked], [email-masked],
        [email-masked] (Geoffrey Noer)
In-Reply-To: <c=US%a=_%p=msft%l=[email-masked]> from "Stephan Mueller" at Jan 27, 97 10:31:14 am
X-Mailer: ELM [version 2.4 PL23]
Content-Length: 2112      
Original-Sender: [email-masked]

Stephan Mueller wrote:
[...]
> 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.

I agree completely with what was said here.  The text/binary problem
is solveable but requires a small amount of work on each and every
Unix program ported.  If I could assume binary mode and fix everything at
the expense of violating the ANSI standards, I might well go ahead and
do so.  However, assuming either mode makes some programs happy at the
expense of others which is why we've stuck to the ANSI specs and made
text mode the default for I/O.

In beta 17.x, many programs mostly do the right thing (eg. gzip and tar),
but some haven't been thought through yet at all (eg. tr, wc, other
textutils), and others need optional binary flags (eg. cat) because people
want to use them in text and binary mode...

FYI, in the case of pipes, the program opening the pipe is responsible for
calling the cygwin32 setmode(fd, mode) function.  See bash/execute_cmd.c
for an example as to how to use it.  The implementation is in
winsup/syscalls.cc.

For people looking for a way to help the project, if someone would like to
make appropriate changes to the textutils as shipped in 17.1 (or other
programs shipped as part of the standard gnu-win32 distribution) and send
me the diffs, that would be very much appreciated.  Note that testing must
include successfully configuring the gnu-win32 sources!  Please let me
know first if you want to do this so efforts aren't needlessly duplicated.

-- 
Geoffrey Noer
[email-masked]
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".