unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: dwheeler@dwheeler.com, almkglor <almkglor@gmail.com>,
	12216 <12216@debbugs.gnu.org>
Subject: bug#12216: peek-char incorrectly *CONSUMES* eof
Date: Sat, 30 Mar 2013 18:37:06 -0400	[thread overview]
Message-ID: <87obe07bvx.fsf@tines.lan> (raw)
In-Reply-To: <87sj3zdury.fsf@pobox.com> (Andy Wingo's message of "Wed, 13 Mar 2013 19:22:41 +0100")

Andy Wingo <wingo@pobox.com> writes:
> Maybe if it is somehow confined to scm_peek_char and scm_fill_input it
> could be doable.

I think I now see a reasonable way to fix this.

First of all, all interfaces that do something like 'peek' would, when
returning an EOF, set a 'pending_eof' flag in the port structure.  Then
'scm_fill_input' would start by checking this flag; if it is set, then
it would clear the flag and return EOF.

We would also need to clear the 'pending_eof' flag in a few other
places, most notably in 'scm_end_input'.  In theory, that might be
enough, but to be on the safe side we should also clear the flag in any
procedure that writes or seeks.

Note that there is one inlined 'peek' function: 'scm_peek_byte_or_eof'
defined in inline.h.  We can change it to set the 'pending_eof' flag,
but we must consider that some code will be compiled against the old
version.  This is not a serious problem.  It just means that if someone
calls the old 'scm_peek_byte_or_eof' and gets EOF, the EOF will be
swallowed and not properly repeated by the next 'read'.  Oh well.

I plan to cook up a patch along these lines soon, as part of my ports
work for 2.0.8.

   Thoughts?
     Mark





  parent reply	other threads:[~2013-03-30 22:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1T29qG-00049i-Rt@fenris.runbox.com>
     [not found] ` <CAF+kUQVT7BmVaZ-XNFDNpaPFXyWUZv9msC_3m9iNa3yQzKw_1w@mail.gmail.com>
2012-08-17  1:53   ` bug#12216: peek-char incorrectly *CONSUMES* eof David A. Wheeler
2013-03-05 16:53     ` Andy Wingo
2013-03-05 19:17       ` David A. Wheeler
2013-03-07 21:32         ` Andy Wingo
2013-03-09  2:25           ` Daniel Hartwig
2013-03-09 17:11             ` David A. Wheeler
2013-03-10  0:23               ` Daniel Hartwig
2013-03-13 11:02               ` Andy Wingo
2013-03-13 13:09                 ` David A. Wheeler
2013-03-13 14:33                   ` Andy Wingo
2013-03-13 18:10                     ` Mark H Weaver
2013-03-13 18:22                       ` Andy Wingo
2013-03-14 17:13                         ` Mark H Weaver
2013-03-14 17:43                           ` David A. Wheeler
2013-03-30 22:37                         ` Mark H Weaver [this message]
2013-03-30 23:02                           ` David A. Wheeler
2013-04-01  2:05                           ` Mark H Weaver
2013-04-01 21:27                             ` Mark H Weaver
2013-04-01 21:33                               ` David A. Wheeler
2013-04-02  7:58                               ` Andy Wingo
2013-04-02 19:41                                 ` Mark H Weaver
2013-04-04 20:00                                   ` Andy Wingo
2013-04-04 21:53                                     ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obe07bvx.fsf@tines.lan \
    --to=mhw@netris.org \
    --cc=12216@debbugs.gnu.org \
    --cc=almkglor@gmail.com \
    --cc=dwheeler@dwheeler.com \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).