From mint-bounce@lists.fishpool.fi Tue Jan 22 17:30:34 2008 X-Original-To: fnaumann@mail.boerde.de Delivered-To: fnaumann@mail.boerde.de Subject: [MiNT] fflush patch for mintlib From: Alan Hourihane To: mint Content-Type: multipart/mixed; boundary="=-ouJwn0xAZaj375pP+AjO" Date: Fri, 14 Dec 2007 10:10:44 +0000 Message-Id: <1197627044.16934.39.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 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: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: 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: --=-ouJwn0xAZaj375pP+AjO Content-Type: text/plain Content-Transfer-Encoding: 7bit In mintlib CVS we check for a write operation on the FILE stream for fflush(). The problem is that some programs try to do a fflush() operation on a read-only file, and the information I've found is that operation is undefined, but certainly on Linux (and I think there's patches for FreeBSD if they haven't made it already) to return no error when trying to fflush() on a read only file. The patch below does that. It also removes a duplicate check which __flshfp() does anyway. Frank - any problems with this ? Alan. --=-ouJwn0xAZaj375pP+AjO Content-Disposition: attachment; filename=fflush.patch Content-Type: text/x-patch; name=fflush.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: stdio/fflush.c =================================================================== RCS file: /mint/mintlib/stdio/fflush.c,v retrieving revision 1.2 diff -u -r1.2 fflush.c --- stdio/fflush.c 19 Jul 2001 21:01:01 -0000 1.2 +++ stdio/fflush.c 14 Dec 2007 10:08:12 -0000 @@ -26,6 +26,11 @@ fflush (stream) register FILE *stream; { + if (stream->__mode.__read && !stream->__mode.__write) + { + return 0; /* no error on read only file */ + } + if (stream == NULL) { int lossage = 0; @@ -35,12 +40,6 @@ return lossage ? EOF : 0; } - if (!__validfp (stream) || !stream->__mode.__write) - { - __set_errno (EINVAL); - return EOF; - } - return __flshfp (stream, EOF); } weak_alias(fflush, fflush_unlocked) --=-ouJwn0xAZaj375pP+AjO--