[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: yesno module consumes too much input
From: |
Bruno Haible |
Subject: |
Re: yesno module consumes too much input |
Date: |
Sat, 18 Aug 2007 19:53:39 +0200 |
User-agent: |
KMail/1.5.4 |
Paul Eggert replied to Eric Blake:
> > is it reasonable to have yesno install an atexit
> > handler on first invocation? If the handler is not present,
> > then stdin was never used (at least not by yesno).
>
> Yes, that sounds reasonable to me.
Still, I haven't understood what is so special about the 'yesno' function.
The code in close_stdin() is needed if _any_ input has been done on stdin,
no?
In that case, rather than modifying 'yesno', 'readline', 'getline', 'getpass'
etc., wouldn't it be more reliable to call close_stdin() always, and optimize
close_stdin() to do nothing if stdin is still in the initial state (i.e.
has no in-memory buffer). This can be done through in-memory tests, such as
essentially (cf. lib/fseeko.c):
#if defined _IO_ferror_unlocked /* GNU libc, BeOS */
if (fp->_IO_read_end == fp->_IO_read_ptr)
#elif defined __sferror /* FreeBSD, NetBSD, OpenBSD, MacOS X,
Cygwin */
if (fp->_r == 0)
#elif defined _IOERR /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw
*/
if (fp->_ptr == NULL || fp->_cnt == 0)
#endif
return;
Bruno
- Re: yesno module consumes too much input, (continued)
- Re: yesno module consumes too much input, Bruno Haible, 2007/08/18
- Re: yesno module consumes too much input, Eric Blake, 2007/08/18
- Re: yesno module consumes too much input, James Youngman, 2007/08/18
- Re: yesno module consumes too much input, Bruno Haible, 2007/08/18
- Re: yesno module consumes too much input, Eric Blake, 2007/08/18
- Re: yesno module consumes too much input, Jim Meyering, 2007/08/19
- Re: yesno module consumes too much input, Eric Blake, 2007/08/19
- Re: yesno module consumes too much input, Jim Meyering, 2007/08/20
- Re: yesno module consumes too much input, Eric Blake, 2007/08/19
- Re: yesno module consumes too much input, Eric Blake, 2007/08/18
- Re: yesno module consumes too much input,
Bruno Haible <=
- Re: yesno module consumes too much input, Eric Blake, 2007/08/18
- new module finpending (was: Re: yesno module consumes too much input), Bruno Haible, 2007/08/18
- Re: new module finpending, Jim Meyering, 2007/08/19
- Re: new module finpending, Bruno Haible, 2007/08/19
- Re: new module finpending, Eric Blake, 2007/08/19
- Re: new module finpending, Bruno Haible, 2007/08/19
- Re: yesno module consumes too much input, Bruno Haible, 2007/08/19
- closein using freadahead [was: yesno module consumes too much input], Eric Blake, 2007/08/20