[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 07:27:21PM +0100, Vincent Rivi?re wrote:
> Alan Hourihane a ?crit :
>> Can people review ?
>
> I see with this patch, a stream turns into binmode if it is not S_ISCHR() 
> (character device : tty, serial...)
> I think it would be better to use binmode when not S_ISREG() (regular 
> file).
> Maybe it would be better to use binmode by default, and switch to textmode 
> only if S_ISREG() and UNIXMODE != b.

Well,

It seems we're partially the way there, but mintlib doesn't respect
UNIXMODE's settings at libc startup.

Here's a patch (delete the other one - so don't use it), and use this.

Now we default to binary if UNIXMODE specifies it for stdin, stdout and
stderr. If UNIXMODE doesn't specify 'b', then it's only when isatty(x)
is true that we're in binary mode & under FreeMiNT - see further down
the file for this. Should these change too ??

Alan.
Index: mintlib/main.c
===================================================================
RCS file: /mint/mintlib/mintlib/main.c,v
retrieving revision 1.9
diff -u -r1.9 main.c
--- mintlib/main.c	8 Oct 2003 15:23:14 -0000	1.9
+++ mintlib/main.c	30 Dec 2007 23:28:56 -0000
@@ -165,6 +165,11 @@
 	setvbuf (stdout, NULL, _IOLBF, 0);
 	setvbuf (stderr, NULL, _IONBF, 0);
 
+	/* default the streams */
+	stdin->__mode.__binary = __default_mode__.__binary;
+	stdout->__mode.__binary = __default_mode__.__binary;
+	stderr->__mode.__binary = __default_mode__.__binary;
+
 	/* Flag device streams.  */
 	if (isatty (0)) {
 		if (__mint) stdin->__mode.__binary = 1;