delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/01/27/22:32:59

From: noer AT cygnus DOT com (Geoffrey Noer)
Subject: Re: ASCII and BINARY files. Why?
27 Jan 1997 22:32:59 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199701280532.VAA16452.cygnus.gnu-win32@rtl.cygnus.com>
Original-To: smueller AT microsoft DOT com (Stephan Mueller)
Original-Cc: Paul AT chocolat DOT foobar DOT co DOT uk, dahms AT ifk20 DOT mach DOT uni-karlsruhe DOT de,
aurel AT xylo DOT owl DOT de, gnu-win32 AT cygnus DOT com,
noer AT cygnus DOT com (Geoffrey Noer)
In-Reply-To: <c=US%a=_%p=msft%l=RED-67-MSG-970127183114Z-12470@INET-04-IMC.microsoft.com> from "Stephan Mueller" at Jan 27, 97 10:31:14 am
X-Mailer: ELM [version 2.4 PL23]
Original-Sender: owner-gnu-win32 AT cygnus DOT com

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
noer AT cygnus DOT com
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019