[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] stdio write problem in mintlib
On Sun, Dec 30, 2007 at 05:10:56PM +0100, Vincent Rivi?re wrote:
> Alan Hourihane a ?crit :
>> Yeah, it's o.k. turns out to be the shell.
>> Not to worry.
>
> Unfortunately, you're wrong. The problem is in the MiNTLib.
> The main idea is that the text mode (CR+LF) should only be used with
> regular files (if not disabled by UNIXMODE=b), and never used with pipes.
> The shell statement `command` does exactly what is expected : it runs the
> command to a pipe, then replaces spaces and LF by single spaces. The CR
> characters are treated as normal characters (not removed). It should not be
> a problem, because no end-of-line CR should be present in the pipe.
> I know very well the problem, because some time ago, I had a discussion
> about that with Cygwin people, where the situation is similar.
Fixed.
Attached is a patch.
Can people review ?
Alan.
Index: stdio/internals.c
===================================================================
RCS file: /mint/mintlib/stdio/internals.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 internals.c
--- stdio/internals.c 12 Oct 2000 10:56:54 -0000 1.1.1.1
+++ stdio/internals.c 30 Dec 2007 17:02:36 -0000
@@ -37,9 +37,9 @@
set by this function. */
extern void __stdio_init_stream __P ((FILE *));
fp->__room_funcs = __default_room_functions;
+ __stdio_init_stream (fp);
fp->__io_funcs = fp->__mode.__binary ? __default_io_functions
: __default_text_io_functions;
- __stdio_init_stream (fp);
fp->__seen = 1;
}
}
Index: stdio/stdio_init.c
===================================================================
RCS file: /mint/mintlib/stdio/stdio_init.c,v
retrieving revision 1.2
diff -u -r1.2 stdio_init.c
--- stdio/stdio_init.c 19 Jul 2001 21:01:01 -0000 1.2
+++ stdio/stdio_init.c 30 Dec 2007 17:02:36 -0000
@@ -70,8 +70,13 @@
stream->__io_funcs.__seek = NULL; /* Seeks get ESPIPE. */
}
+ }
+ else
+ {
+ __set_binmode (stream, 1);
}
+
#ifdef _STATBUF_ST_BLKSIZE
/* Use the block-size field to determine
the system's optimal buffering size. */