Mail Archives: cygwin/1997/01/31/00:29:42
> 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.
It would be easier for some types of programs if there were some basic
mechanisms in the header files/libraries for automating some of it (see my
comment below)..
> 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.
Might I make a suggestion here? The issue of modes on pipes would be much less
of a problem if the mechanism for converting between DOS/Win text and C native
text were a 1:1 mapping (i.e. NL->CRLF, CRLF->NL, CR->CR(always), (and LF->NL,
but that's a side-issue)). This way, if I want to pipe "gzip -dc file | tar
xvf -" (as I often do), it wouldn't matter what mode the pipe was created in as
long as it was the same mode on both ends, because any changes introduced in a
C->text conversion would be exactly reversed in the text->C conversion on the
other end of the pipe.
Of course this doesn't help as much with redirection to files (thought it would
under a few circumstances).. it would also be nice if there was a way to
specify on the compiler command line (with a define or something) whether file
IO should assume text or binary mode.. this would make it easy to fix with a
single command-line switch many programs (such as gzip) which should always do
binary IO anyway. It would probably be a good idea for any program which works
with binary files in general to call setmode on its stdin/stdout handles itself
(I'm assuming Cygwin32 allows this.. if it doesn't it certainly should) anyway.
-alex
-------------------------------------------------------------------------------
Alex Stewart - riche AT crl DOT com - Richelieu @ Diversity University MOO
http://www.crl.com/~riche
"For the world is hollow, and I have touched the sky."
-
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 -