From mint-bounce@lists.fishpool.fi  Tue Jan 22 17:31:49 2008
X-Original-To: fnaumann@mail.boerde.de
Delivered-To: fnaumann@mail.boerde.de
Date: Sun, 30 Dec 2007 23:34:28 +0000
From: Alan Hourihane <alanh@fairlite.demon.co.uk>
To: Vincent Rivi?re <vincent.riviere@freesbee.fr>
Cc: mint@fishpool.com
Subject: Re: [MiNT] stdio write problem in mintlib
Message-ID: <20071230233428.GA10231@fairlite.demon.co.uk>
References: <20071230010610.GA29673@fairlite.demon.co.uk> <47775FEF.5060708@freesbee.fr> <20071230102935.GB32676@fairlite.demon.co.uk> <20071230142950.GA1737@fairlite.demon.co.uk> <4777C310.40504@freesbee.fr> <20071230170400.GA3566@fairlite.demon.co.uk> <
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="OXfL5xGRrasGEqWY"
Content-Disposition: inline
In-Reply-To: <4777E309.8060709@freesbee.fr>
User-Agent: Mutt/1.5.16 (2007-06-09)
X-ecartis-version: Ecartis v1.0.0
Sender: mint-bounce@lists.fishpool.fi
Errors-To: mint-bounce@lists.fishpool.fi
X-original-sender: alanh@fairlite.demon.co.uk
Precedence: bulk
List-help: <mailto:ecartis@lists.fishpool.fi?Subject=help>
List-unsubscribe: <mailto:mint-request@lists.fishpool.fi?Subject=unsubscribe>
List-Id: <mint.lists.fishpool.fi>
X-List-ID: <mint.lists.fishpool.fi>
List-subscribe: <mailto:mint-request@lists.fishpool.fi?Subject=subscribe>
List-owner: <mailto:tjhukkan@fishpool.fi>
List-post: <mailto:mint@lists.fishpool.fi>
X-Virus-Scanned: by amavisd-new at relay.boerde.de
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on relay.boerde.de
X-Spam-Status: No, hits=-1.0 tagged_above=-50.5 required=7.0 tests=BAYES_00
X-Spam-Level: 
Status: 
X-Status: 
X-Keywords:                   


--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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.

--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mintlib.patch"

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;

--OXfL5xGRrasGEqWY--


