On 06/12/2012 04:21 AM, Paolo Bonzini wrote: > perhaps we can follow the suggestion and > replace "if (freadahead (f))" with "if (freading(f) && !feof(f))" in > closein.c.
Yes, thanks, I like this idea the best of those suggested so far. Here's a proposed patch to gnulib. >From 43f704124bc3a96dc19146408285747fecf057bb Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Tue, 12 Jun 2012 08:28:29 -0700 Subject: [PATCH] closein: port to musl, which lacks freadahead Suggested by Paolo Bonzini in <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00103.html>. * lib/closein.c: Include freading.h rather than freadahead.h. (close_stdin): Use freading and feof, not freadhead, to decide whether there is buffered input. * modules/closein (Depends-on): Depend on freading, not freadahead. --- ChangeLog | 10 ++++++++++ lib/closein.c | 4 ++-- modules/closein | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecff180..206178b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2012-06-12 Paul Eggert <egg...@cs.ucla.edu> + + closein: port to musl, which lacks freadahead + Suggested by Paolo Bonzini in + <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00103.html>. + * lib/closein.c: Include freading.h rather than freadahead.h. + (close_stdin): Use freading and feof, not freadhead, to decide + whether there is buffered input. + * modules/closein (Depends-on): Depend on freading, not freadahead. + 2012-06-12 Akim Demaille <a...@lrde.epita.fr> announce-gen: VPATH issues diff --git a/lib/closein.c b/lib/closein.c index 65f2cb9..b910575 100644 --- a/lib/closein.c +++ b/lib/closein.c @@ -31,7 +31,7 @@ #include "closeout.h" #include "error.h" #include "exitfail.h" -#include "freadahead.h" +#include "freading.h" #include "quotearg.h" static const char *file_name; @@ -84,7 +84,7 @@ close_stdin (void) input buffer is empty; in this case we know that if stdin is seekable, (fseeko (stdin, 0, SEEK_CUR), ftello (stdin)) == lseek (0, 0, SEEK_CUR). */ - if (freadahead (stdin) > 0) + if (freading (stdin) && !feof (stdin)) { /* Only attempt flush if stdin is seekable, as fflush is entitled to fail on non-seekable streams. */ diff --git a/modules/closein b/modules/closein index 5f6e7d7..0905f5b 100644 --- a/modules/closein +++ b/modules/closein @@ -8,7 +8,7 @@ m4/closein.m4 Depends-on: closeout -freadahead +freading fflush stdbool -- 1.7.6.5