From mint-bounce@lists.fishpool.fi  Tue Jan 22 17:31:46 2008
X-Original-To: fnaumann@mail.boerde.de
Delivered-To: fnaumann@mail.boerde.de
Date: Sun, 30 Dec 2007 17:04:00 +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: <20071230170400.GA3566@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>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="0OAP2g/MAC+5xKAE"
Content-Disposition: inline
In-Reply-To: <4777C310.40504@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:                   


--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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.

--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="stdio.patch"

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.  */

--0OAP2g/MAC+5xKAE--


