Re: [PATCH] fclose: don't fail on non-seekable input stream

2011-05-02 Thread Eric Blake
On 05/01/2011 04:38 AM, Bruno Haible wrote: In fact, the dependency on 'fflush' should not be needed, because the fixes of that module are not relevant here: ! Portability problems fixed by Gnulib: ! @itemize ! @item ! @code{fflush} followed by @code{fseek} or @code{fseeko}, applied to an

Re: [PATCH] fclose: don't fail on non-seekable input stream

2011-05-02 Thread Eric Blake
On 05/01/2011 04:21 AM, Bruno Haible wrote: Eric Blake wrote: + /* We only need to flush the file if it is not reading or if it is + seekable. */ + if ((!freading (fp) || fseeko (fp, 0, SEEK_CUR) == 0) fflush (fp)) Would it be equivalent to do if ((!freading (fp) || ftello

Re: [PATCH] fclose: don't fail on non-seekable input stream

2011-05-02 Thread Eric Blake
On 05/02/2011 08:40 AM, Eric Blake wrote: ! @item ! @code{fflush} on an input stream changes the position of the stream to the ! end of the previous buffer, on some platforms: mingw. Likewise not relevant: the position of the stream is irrelevant in fclose(). Yes it is. test-closein has a

Re: [PATCH] fclose: don't fail on non-seekable input stream

2011-05-01 Thread Simon Josefsson
Eric Blake ebl...@redhat.com writes: --- a/modules/fclose +++ b/modules/fclose @@ -8,6 +8,9 @@ m4/fclose.m4 Depends-on: stdio close +fflush +freading +fseeko I'm using the fclose module in a LGPLv2+ library and now I get: /home/jas/bin/gnulib-tool: *** incompatible license on

Re: [PATCH] fclose: don't fail on non-seekable input stream

2011-05-01 Thread Bruno Haible
Eric Blake wrote: +  /* We only need to flush the file if it is not reading or if it is +     seekable.  */ +  if ((!freading (fp) || fseeko (fp, 0, SEEK_CUR) == 0) fflush (fp)) Would it be equivalent to do if ((!freading (fp) || ftello (fp) != -1) fflush (fp)) ? Bruno -- In

Re: [PATCH] fclose: don't fail on non-seekable input stream

2011-05-01 Thread Bruno Haible
Simon Josefsson wrote: Eric Blake ebl...@redhat.com writes: --- a/modules/fclose +++ b/modules/fclose @@ -8,6 +8,9 @@ m4/fclose.m4 Depends-on: stdio close +fflush +freading +fseeko I'm using the fclose module in a LGPLv2+ library and now I get:

[PATCH] fclose: don't fail on non-seekable input stream

2011-04-30 Thread Eric Blake
On mingw, for a project that uses both sockets and streams, then fclose(stdin) when getting input from a terminal or pipe was spuriously failing. * modules/fclose (Depends-on): Add freading, fflush, fseeko. * lib/fclose.c (rpl_fclose): Skip fflush for non-seekable input, since fflush is allowed