From unknown Fri Jun 20 07:16:06 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#12216 <12216@debbugs.gnu.org> To: bug#12216 <12216@debbugs.gnu.org> Subject: Status: peek-char incorrectly *CONSUMES* eof Reply-To: bug#12216 <12216@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:16:06 +0000 retitle 12216 peek-char incorrectly *CONSUMES* eof reassign 12216 guile submitter 12216 dwheeler@dwheeler.com severity 12216 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 16 22:02:26 2012 Received: (at submit) by debbugs.gnu.org; 17 Aug 2012 02:02:26 +0000 Received: from localhost ([127.0.0.1]:34394 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2BtJ-0000om-IE for submit@debbugs.gnu.org; Thu, 16 Aug 2012 22:02:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37687) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T2BtF-0000oc-T6 for submit@debbugs.gnu.org; Thu, 16 Aug 2012 22:02:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2Bke-0001u0-D4 for submit@debbugs.gnu.org; Thu, 16 Aug 2012 21:53:29 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:60885) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2Bke-0001tw-AF for submit@debbugs.gnu.org; Thu, 16 Aug 2012 21:53:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2Bkd-0006ic-55 for bug-guile@gnu.org; Thu, 16 Aug 2012 21:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2Bkb-0001tO-QK for bug-guile@gnu.org; Thu, 16 Aug 2012 21:53:27 -0400 Received: from aibo.runbox.com ([91.220.196.211]:36918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2Bkb-0001sx-KF for bug-guile@gnu.org; Thu, 16 Aug 2012 21:53:25 -0400 Received: from [10.9.9.130] (helo=fenris.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1T2BkZ-0001jS-Ik; Fri, 17 Aug 2012 03:53:23 +0200 Received: from mail by fenris.runbox.com with local (Exim 4.50) id 1T2BkZ-0000eD-Hg; Fri, 17 Aug 2012 03:53:23 +0200 Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [74.96.178.110] by secure.runbox.com with http (uid:258406) (RMM 4.0); Fri, 17 Aug 2012 01:53:23 GMT From: "David A. Wheeler" To: bug-guile@gnu.org Subject: peek-char incorrectly *CONSUMES* eof Date: Thu, 16 Aug 2012 21:53:23 -0400 (EDT) X-Mailer: RMM References: In-Reply-To: Message-Id: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit Cc: almkglor@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) All: Guile's peek-char has a bug; it incorrectly *consumes* eof instead of just = reporting it. According to R5RS, "The value returned by a call to peek-char is the same a= s the value that would have been returned by a call to read-char with the s= ame port. The only difference is that the very next call to read-char or pe= ek-char on that port will return the value returned by the preceding call t= o peek-char." However, if the value returned is #eof, guile does *not* meet the spec; you= *can* get two successive peek-chars with different results. This doesn't matter for files, but it *does* matter for interactive use. I= t means that successive peek-char calls will actually *READ* characters, an= d they can even different in results. Which means that code that does seve= ral peek-chars can act oddly when someone tries to end it with control-D. We've confirmed this bug is true for guile 2.0, 1.8, and 1.6. You can confirm this by placing this in "bug-demo": =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (write (peek-char)) (write (peek-char)) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Then run "guile bug-demo". Press control-D, then newline. You can see tha= t two successive calls to peek-char are reporting different results (eof, t= hen newline), which is NEVER supposed to happen! I just had to write some code to work around this, but it'd be nice for thi= s to work "correctly" in the future for interactive use. (This was code fo= r the "readable" project, http://readable.sourceforge.net, where we do a lo= t with guile.) Thanks for your time... and thanks for guile! --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 05 13:54:42 2013 Received: (at 12216) by debbugs.gnu.org; 5 Mar 2013 18:54:42 +0000 Received: from localhost ([127.0.0.1]:32846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCx0a-0000YP-88 for submit@debbugs.gnu.org; Tue, 05 Mar 2013 13:54:41 -0500 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:39932 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCx0Y-0000YJ-Li for 12216@debbugs.gnu.org; Tue, 05 Mar 2013 13:54:39 -0500 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E8681BFB3; Tue, 5 Mar 2013 13:54:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=ZJtl6QCik3pj0oTE6EnauIXhaOk=; b=Vds0SX hIlMyXGsIokROkJmyI2VgknT/lMsIJLb/isZHIBiQeO5asM6Tyt73aDsDyvSxv6R cLkWFeJLgsAwOyp/stRHYLQnnk2YQZrQH5e7fUUetC+rIXpGTxRt4hDiXWFzwWEZ Ht+ImEgMFtnQm2EFAyc1AD4rPYb1i0O+j/tSQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=W85C2Q3FtK+J1v3ineAGVVkvx+HCAtTX 5vonKBwn7gZWFaleA07cEfMzTKAlCZEE6yp5khPjdpBaBoAcx+1dhFyvA/KsWG5e 8Dm45HY/k/9BFhW+YyXJ0z0zHD8yoC6dlJXslmeL908Z/t7B4aMQqhXSituvxbDX N+XXtJo9LFU= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E1539BFB2; Tue, 5 Mar 2013 13:54:16 -0500 (EST) Received: from badger (unknown [217.91.84.86]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 49266BFB1; Tue, 5 Mar 2013 13:54:16 -0500 (EST) From: Andy Wingo To: dwheeler@dwheeler.com Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: Date: Tue, 05 Mar 2013 17:53:45 +0100 In-Reply-To: (David A. Wheeler's message of "Thu, 16 Aug 2012 21:53:23 -0400 (EDT)") Message-ID: <87sj49vld2.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 1440C0EC-85C6-11E2-ACCF-59240E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor@gmail.com, 12216@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) Hi, On Fri 17 Aug 2012 03:53, "David A. Wheeler" writes: > Guile's peek-char has a bug; it incorrectly *consumes* eof instead of > just reporting it. I'm not sure there is a sane way to deal with this. Guile's ports are fundamentally binary, underneath. The backing store is a byte buffer that is decoded and encoded to Scheme characters at need, along with vtable to fill and flush that buffer. You can do strange things like unread characters, switch the encoding, and read them back out in a different encoding. There is no way to represent EOF in that buffer. I have the feeling that for interactive use, if you expect to read a EOF from a port and then continue, you have to not use peek-char. You need to handle your own lookahead buffer. I know it's not a great answer, but I can't think of anything else that makes sense. What do you think? Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 05 14:17:57 2013 Received: (at 12216) by debbugs.gnu.org; 5 Mar 2013 19:17:57 +0000 Received: from localhost ([127.0.0.1]:32927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCxN7-00019P-2N for submit@debbugs.gnu.org; Tue, 05 Mar 2013 14:17:57 -0500 Received: from aibo.runbox.com ([91.220.196.211]:42162) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UCxN4-00019G-GR for 12216@debbugs.gnu.org; Tue, 05 Mar 2013 14:17:55 -0500 Received: from [10.9.9.135] (helo=taishi.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UCxMh-0001HU-63; Tue, 05 Mar 2013 20:17:31 +0100 Received: from mail by taishi.runbox.com with local (Exim 4.69) id 1UCxMh-0001Fd-58; Tue, 05 Mar 2013 20:17:31 +0100 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [129.6.253.26] by secure.runbox.com with http (uid:258406) (RMM 4.0); Tue, 05 Mar 2013 19:17:31 GMT From: "David A. Wheeler" To: "wingo" Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Tue, 05 Mar 2013 14:17:31 -0500 (EST) X-Mailer: RMM5 References: <87sj49vld2.fsf@pobox.com> In-Reply-To: <87sj49vld2.fsf@pobox.com> Message-Id: X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) I reported: > > Guile's peek-char has a bug; it incorrectly *consumes* eof instead of > > just reporting it. Andy Wingo replied: > I have the feeling that for interactive use, if you expect to read a EOF > from a port and then continue, you have to not use peek-char. You need > to handle your own lookahead buffer. I know it's not a great answer, > but I can't think of anything else that makes sense. We don't want to read an EOF and then continue. We peek-char to not *CONSUME* an interactive EOF. Once peek-char returns EOF, every following peek-char should *also* return EOF until the EOF is read. That isn't what currently happens. E.G.: (define (demo) (write (peek-char)) (write (peek-char))) (demo) ; Now type control-D ENTER. ; It SHOULD produce # twice, after peeking EOF, ; but instead it produces # #\newline ##guile> (demo) --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 07 16:33:18 2013 Received: (at 12216) by debbugs.gnu.org; 7 Mar 2013 21:33:18 +0000 Received: from localhost ([127.0.0.1]:37178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UDiRB-0003Mg-DL for submit@debbugs.gnu.org; Thu, 07 Mar 2013 16:33:17 -0500 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:44629 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UDiR9-0003MZ-UO for 12216@debbugs.gnu.org; Thu, 07 Mar 2013 16:33:16 -0500 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 5FBEDB0D3; Thu, 7 Mar 2013 16:32:41 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=eqd0URu1G1DW4s4/AEsuHxa8C6Q=; b=HtfBiO LYhGb7DIheMzFTg4YsET2LT6AZQhnofZzDmAogrbg8ckQCmr5gDauhfIamIvIewj KdAzmBTVg2ZRYcYPCPQHx1gQ9syCI1oQrQH87l963liOLx4kRBNbgp1yFQDKBWUH NJ8zIeErNj8X3yiLrfB/S1lLKAHV+7TB8CPtI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=wd2B+r8IbUdv2kKQkH2f6590Lz0PRvUf WMfMddzV/rc+0GyTxdhBfqcJEhjiETYnDbSPX0fybYarlx3+6fWgF8eTMQcxwm9E XGTZUkq0dXh+7WrXNNL2Dm6RVxbKZEMglI3kL2ryW5/lIWDqPCrrqTgw/O1TPUnN y7lXJREglJI= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 57846B0D2; Thu, 7 Mar 2013 16:32:41 -0500 (EST) Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id C8191B0D1; Thu, 7 Mar 2013 16:32:40 -0500 (EST) From: Andy Wingo To: dwheeler@dwheeler.com Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> Date: Thu, 07 Mar 2013 22:32:38 +0100 In-Reply-To: (David A. Wheeler's message of "Tue, 05 Mar 2013 14:17:31 -0500 (EST)") Message-ID: <87ip52ew09.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 8A35FB7E-876E-11E2-B4C6-59240E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.5 (--) On Tue 05 Mar 2013 20:17, "David A. Wheeler" writes: > I reported: >> > Guile's peek-char has a bug; it incorrectly *consumes* eof instead of >> > just reporting it. > > Andy Wingo replied: >> I have the feeling that for interactive use, if you expect to read a EOF >> from a port and then continue, you have to not use peek-char. You need >> to handle your own lookahead buffer. I know it's not a great answer, >> but I can't think of anything else that makes sense. > > We don't want to read an EOF and then continue. > We peek-char to not *CONSUME* an interactive EOF. I understand what it is you want. But I don't know of any sane way to implement it. Given that it is an edge case -- peek-char on an interactive port -- I think the thing to do is to document this inconsistency, and for you (in your code) to implement some sort of abstraction that does not use peek-char. That is to say, use read-char, and do unread-char as necessary. Or keep your own buffer around. I know it isn't nice, but I don't know how to do anything better. Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 08 21:26:20 2013 Received: (at 12216) by debbugs.gnu.org; 9 Mar 2013 02:26:20 +0000 Received: from localhost ([127.0.0.1]:40396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UE9UJ-00020C-DA for submit@debbugs.gnu.org; Fri, 08 Mar 2013 21:26:19 -0500 Received: from mail-ia0-f172.google.com ([209.85.210.172]:61526) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UE9UG-0001zz-2i for 12216@debbugs.gnu.org; Fri, 08 Mar 2013 21:26:17 -0500 Received: by mail-ia0-f172.google.com with SMTP id l29so2085718iag.3 for <12216@debbugs.gnu.org>; Fri, 08 Mar 2013 18:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=t3R+6Ru1svQ5qbZLAblmpg7sPT1bqUInn6+W4+vaHsI=; b=Z75K2lYWuB6o64QZ6Db1Bf51BDPNIqV6jFddfKA7rTajg+fCKWdj4q6WD2vutY/3Ca vqggYyZJiT08geWgoJmqAoReAPrkwq3mvvJHXBR6NAz4IJwJnSEZ8FqU/DtHVlVzH8AZ R5bMX1D5kXXPlkKU5Tt7zuO1KoR4UVieeOYxLWm7x4BP+7qLwlsOkmlJhyhRdwwjqXL3 j/wXu8w0nS/+GnVo2ZMZnUefQLXrSV+X39z9Q1j7iyilRmjUR6saiF1/rwBqj4IBNXMn KhA4NJMO1DoMmlte/F9G/SF+JDOJLNDatdpHe8Clia+laEmY7aqq6w4hUO9DCLval7bf n9Rw== MIME-Version: 1.0 X-Received: by 10.50.135.105 with SMTP id pr9mr1142846igb.6.1362795930147; Fri, 08 Mar 2013 18:25:30 -0800 (PST) Received: by 10.64.26.168 with HTTP; Fri, 8 Mar 2013 18:25:30 -0800 (PST) In-Reply-To: <87ip52ew09.fsf@pobox.com> References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> Date: Sat, 9 Mar 2013 10:25:30 +0800 Message-ID: Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof From: Daniel Hartwig To: Andy Wingo Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 8 March 2013 05:32, Andy Wingo wrote: > On Tue 05 Mar 2013 20:17, "David A. Wheeler" writes: > >> I reported: >>> > Guile's peek-char has a bug; it incorrectly *consumes* eof instead of >>> > just reporting it. >> >> Andy Wingo replied: >>> I have the feeling that for interactive use, if you expect to read a EOF >>> from a port and then continue, you have to not use peek-char. You need >>> to handle your own lookahead buffer. I know it's not a great answer, >>> but I can't think of anything else that makes sense. >> >> We don't want to read an EOF and then continue. >> We peek-char to not *CONSUME* an interactive EOF. > > I understand what it is you want. But I don't know of any sane way to > implement it. Indeed. There is a distinction between the end-of-file _object_ (Scheme) and end-of-transmission _character_ (ASCII ^D). The two are not equivalent, and when read-char and peek-char return the former value it is only to signal a _current_ lack of characters and should not be considered part of the character stream read from the port. This is the same reason why, e.g. the end-of-file object can not be passed to unread-char: it is not a character. IIRC some other Schemes do handle the test case from OP, but I do not agree that those semantics are sane. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 09 12:12:02 2013 Received: (at 12216) by debbugs.gnu.org; 9 Mar 2013 17:12:02 +0000 Received: from localhost ([127.0.0.1]:42058 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UENJR-0007La-1x for submit@debbugs.gnu.org; Sat, 09 Mar 2013 12:12:02 -0500 Received: from aibo.runbox.com ([91.220.196.211]:52170) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UENJO-0007LT-Rg for 12216@debbugs.gnu.org; Sat, 09 Mar 2013 12:11:59 -0500 Received: from [10.9.9.135] (helo=taishi.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UENIe-0003r3-JE; Sat, 09 Mar 2013 18:11:12 +0100 Received: from mail by taishi.runbox.com with local (Exim 4.69) id 1UENIe-0007sf-IU; Sat, 09 Mar 2013 18:11:12 +0100 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [108.45.113.66] by secure.runbox.com with http (uid:258406) (RMM 4.0); Sat, 09 Mar 2013 17:11:12 GMT From: "David A. Wheeler" To: "mandyke" Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Sat, 09 Mar 2013 12:11:12 -0500 (EST) X-Mailer: RMM5 References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> In-Reply-To: Message-Id: X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: wingo , almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.2 (-) Daniel Hartwig: > Indeed. There is a distinction between the end-of-file _object_ > (Scheme) and end-of-transmission _character_ (ASCII ^D). The two are > not equivalent, ... Sure. > and when read-char and peek-char return the former > value it is only to signal a _current_ lack of characters and should > not be considered part of the character stream read from the port. If I understand you correctly, that sounds more like "char-ready?". In any case, I believe guile fails to meet the semantics of R5RS, and I believe other versions of the Scheme spec, in this area. R5RS says: > (peek-char) procedure > (peek-char port) procedure > Returns the next character available from the input port, > without updating the port to point to the following character. > If no more characters are available, an end of =0Cle > object is returned. Port may be omitted, in which case it > defaults to the value returned by current-input-port. > Note: The value returned by a call to peek-char is the same as > the value that would have been returned by a call to read-char > with the same port. The only diff=0Berence is that the very next call > to read-char or peek-char on that port will return the value > returned by the preceding call to peek-char. In particular, a > call to peek-char on an interactive port will hang waiting for > input whenever a call to read-char would have hung. Note that the spec says that the very next call "to read-char or peek-char on that port will return the value returned by the preceding call to peek-char." It does not say the same *CHARACTER*, it says the same *VALUE*, and the eof object is a possible value from peek-char and read-char. I'd be okay if, after a read-char of EOF, it could return something else as some sort of extension. But (peek-char) (peek-char) (peek-char) should return the same values 3 times, no matter what... even if it's EOF. --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 09 19:24:36 2013 Received: (at 12216) by debbugs.gnu.org; 10 Mar 2013 00:24:36 +0000 Received: from localhost ([127.0.0.1]:42493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UEU43-00027d-Dg for submit@debbugs.gnu.org; Sat, 09 Mar 2013 19:24:36 -0500 Received: from mail-ia0-f171.google.com ([209.85.210.171]:39633) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UEU40-00027P-BB for 12216@debbugs.gnu.org; Sat, 09 Mar 2013 19:24:33 -0500 Received: by mail-ia0-f171.google.com with SMTP id z13so2584910iaz.2 for <12216@debbugs.gnu.org>; Sat, 09 Mar 2013 16:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=2XPm2nilMWnr0m5011kEkruKXN+raDjI6SmUB/09kvo=; b=fKZVjruuxKpd892+lGzKCWH+gpdxCIY+oySuRU47+qwrGIIH16Sq97UR9t3sXmqEGl OpZg2I/+ITRMrTdFNdVTF20st1xkfSSMFgHjuOStTUhv0UL2hEwnVjUV3AfF8E11bUyT tvXHvKq4RtOAqmVaNdwEDfzw5TTi7d+NiStt87dmolMkTYzdzbtQKjuaPsskY1UIj90h IW25mLh9Hm7DH66hVRdzWgcKDyGDY+Nq57xIJ8hoOHx0h109tc7kAkZGNMu4nu/szHkH aYOUrbOf73NP6+bf8aZNPSInR9vMMnTYiQsbHuXpQjXzdwEJZlU3sVQRPRol4Lijl6iX +xdQ== MIME-Version: 1.0 X-Received: by 10.42.149.135 with SMTP id w7mr2453908icv.25.1362875021256; Sat, 09 Mar 2013 16:23:41 -0800 (PST) Received: by 10.64.26.168 with HTTP; Sat, 9 Mar 2013 16:23:41 -0800 (PST) In-Reply-To: References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> Date: Sun, 10 Mar 2013 08:23:41 +0800 Message-ID: Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof From: Daniel Hartwig To: dwheeler@dwheeler.com Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: wingo , almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 10 March 2013 01:11, David A. Wheeler wrote: > Daniel Hartwig: >> and when read-char and peek-char return the former >> value it is only to signal a _current_ lack of characters and should >> not be considered part of the character stream read from the port. > > If I understand you correctly, that sounds more like "char-ready?". Erm yes, my mistake. From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 07:03:58 2013 Received: (at 12216) by debbugs.gnu.org; 13 Mar 2013 11:03:58 +0000 Received: from localhost ([127.0.0.1]:50421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFjTR-0002kQ-R7 for submit@debbugs.gnu.org; Wed, 13 Mar 2013 07:03:58 -0400 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:32860 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFjTQ-0002kI-8Y for 12216@debbugs.gnu.org; Wed, 13 Mar 2013 07:03:57 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 08CD3AF79; Wed, 13 Mar 2013 07:02:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=/nhRt2/b6rp9217aUDkd/95nJAE=; b=cJhB07 u7m1Ot4qPojECJntdBmc30jCN3JBP9/vmJtOFFzqLLIb/+STysZPdHLqHX5RvZP+ hd0SOj8cxunScOnfahOWOVlQTGzW4W9Biw/U8H0RAyOGTNUo7X1lHo6E1xMl98JU UE0wocntGxb2voweHb17Z9RNlZAMeQEPSS0vQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Y56gkMZMXRGk1lu5Tr4S5KvhlExwohZQ B9XsABlHnAAU4Xsq/hj8DNI7qyzb0iyg5F7OcBu1scCNcJmvUjRvO8WqoTsV4kdu D77m7nCf+OcSriDjtt970Hd96HWDxuponQ1SUqecVUpldXmDiqOKoNIKLqcjm0hD NPj9wBtfPyc= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id F3FE0AF78; Wed, 13 Mar 2013 07:02:50 -0400 (EDT) Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 7231CAF77; Wed, 13 Mar 2013 07:02:50 -0400 (EDT) From: Andy Wingo To: dwheeler@dwheeler.com Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> Date: Wed, 13 Mar 2013 12:02:47 +0100 In-Reply-To: (David A. Wheeler's message of "Sat, 09 Mar 2013 12:11:12 -0500 (EST)") Message-ID: <87ehfjimug.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 8BE215F8-8BCD-11E2-A926-59240E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 12216 Cc: 12216@debbugs.gnu.org, almkglor , mandyke X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.3 (----) On Sat 09 Mar 2013 18:11, "David A. Wheeler" writes: > (peek-char) (peek-char) (peek-char) should return the same values 3 > times, no matter what... even if it's EOF. So, we are repeating ourselves here :) I agree with you but I can't see a good way of implementing this. For that reason I am inclined to document this inconsistency and close as a wontfix. Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 09:10:35 2013 Received: (at 12216) by debbugs.gnu.org; 13 Mar 2013 13:10:35 +0000 Received: from localhost ([127.0.0.1]:50588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFlRy-0006Yp-1h for submit@debbugs.gnu.org; Wed, 13 Mar 2013 09:10:35 -0400 Received: from aibo.runbox.com ([91.220.196.211]:53182) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFlRu-0006Yg-Pw for 12216@debbugs.gnu.org; Wed, 13 Mar 2013 09:10:32 -0400 Received: from [10.9.9.241] (helo=rmm6prod02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UFlQp-0002eI-5v; Wed, 13 Mar 2013 14:09:23 +0100 Received: from mail by rmm6prod02.runbox.com with local (Exim 4.76) (envelope-from ) id 1UFlQp-0007N8-5R; Wed, 13 Mar 2013 14:09:23 +0100 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [108.45.113.66] by rmm6.runbox.com with http (uid:258406) (RMM6); Wed, 13 Mar 2013 13:09:23 GMT From: "David A. Wheeler" To: "wingo" Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Wed, 13 Mar 2013 09:09:23 -0400 (EDT) X-Mailer: RMM6 References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> In-Reply-To: <87ehfjimug.fsf@pobox.com> Message-Id: X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: 12216 <12216@debbugs.gnu.org>, almkglor , mandyke X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.7 (/) Andy Wingo: > So, we are repeating ourselves here :) I agree with you but I can't see > a good way of implementing this. Would the per-port reader options be reasonable place to store the info about EOF? --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 10:34:51 2013 Received: (at 12216) by debbugs.gnu.org; 13 Mar 2013 14:34:51 +0000 Received: from localhost ([127.0.0.1]:51372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFmlW-00009j-OT for submit@debbugs.gnu.org; Wed, 13 Mar 2013 10:34:51 -0400 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:52327 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFmlU-00009a-Hz for 12216@debbugs.gnu.org; Wed, 13 Mar 2013 10:34:49 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 7A4E2BCD8; Wed, 13 Mar 2013 10:33:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=NJG8Ww9EYsRHDPFvgdKSmfXCkJE=; b=Lt+Zgq lTiWC8cNw1DgZ1um8d/lcnN535hQlNoV3kMJtFA4MQZc1QmZnEpr/oj8pggKDV38 nCFG61sEE4f0RFowRZqhA8LHCvxh3Wzwvj9+7ayEjzFdFz5IiPmVPGxXRRgyoDOB F6rjSNhkdyst/5ysG8FfSC4SgGSoFQ9cojXs8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=c6NuMaOgwQCii1JV8PswWR+zQM0HVR/2 CJmOsXeQLaEjxNzlsB5KothVcKBTIDxx67kihcR47cyNYVOfis9KdOnoVAXczbI9 wdu6A97pABqMGB7ktuKzuH+E2kdqVUPZ2FygfSySXFpwGthcVFslsCrOS/3EUFIy emYBd/5v35o= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 72D75BCD7; Wed, 13 Mar 2013 10:33:41 -0400 (EDT) Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id C3A09BCD6; Wed, 13 Mar 2013 10:33:40 -0400 (EDT) From: Andy Wingo To: dwheeler@dwheeler.com Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> Date: Wed, 13 Mar 2013 15:33:33 +0100 In-Reply-To: (David A. Wheeler's message of "Wed, 13 Mar 2013 09:09:23 -0400 (EDT)") Message-ID: <87r4jjfjya.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 001DD55C-8BEB-11E2-A234-59240E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 12216 Cc: 12216 <12216@debbugs.gnu.org>, almkglor , mandyke X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.3 (----) On Wed 13 Mar 2013 14:09, "David A. Wheeler" writes: > Andy Wingo: > >> So, we are repeating ourselves here :) I agree with you but I can't see >> a good way of implementing this. > > Would the per-port reader options be reasonable place to store the info > about EOF? For your own purposes that would be fine. But it cannot affect read-char / peek-char / etc for everyone, because it would have bad global effects on performance and correctness. That's why I'm pushing back on fixing this in Guile itself. Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 14:11:47 2013 Received: (at 12216) by debbugs.gnu.org; 13 Mar 2013 18:11:47 +0000 Received: from localhost ([127.0.0.1]:51747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFq9S-0006BS-Ds for submit@debbugs.gnu.org; Wed, 13 Mar 2013 14:11:47 -0400 Received: from world.peace.net ([96.39.62.75]:59215 ident=hope9) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFq9O-0006BI-Sw for 12216@debbugs.gnu.org; Wed, 13 Mar 2013 14:11:45 -0400 Received: from 209-6-96-61.c3-0.smr-ubr2.sbo-smr.ma.cable.rcn.com ([209.6.96.61] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UFq8D-00014s-8M; Wed, 13 Mar 2013 14:10:29 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> Date: Wed, 13 Mar 2013 14:10:15 -0400 In-Reply-To: <87r4jjfjya.fsf@pobox.com> (Andy Wingo's message of "Wed, 13 Mar 2013 15:33:33 +0100") Message-ID: <87r4jj188o.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Andy Wingo writes: > On Wed 13 Mar 2013 14:09, "David A. Wheeler" writes: > >> Andy Wingo: >> >>> So, we are repeating ourselves here :) I agree with you but I can't see >>> a good way of implementing this. >> >> Would the per-port reader options be reasonable place to store the info >> about EOF? > > For your own purposes that would be fine. But it cannot affect > read-char / peek-char / etc for everyone, because it would have bad > global effects on performance and correctness. That's why I'm pushing > back on fixing this in Guile itself. I don't know, it might not be that bad, now that we've agreed on a way to extend the port structure in 2.0. Maybe we could just have a "last peek-char returned EOF" flag that would be consulted by the other read primitives. I agree that we should not allow EOF to be unread. What do you think? Mark From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 13 14:23:55 2013 Received: (at 12216) by debbugs.gnu.org; 13 Mar 2013 18:23:55 +0000 Received: from localhost ([127.0.0.1]:51772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFqLD-0006T6-7G for submit@debbugs.gnu.org; Wed, 13 Mar 2013 14:23:55 -0400 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:49160 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UFqLA-0006Sy-Bj for 12216@debbugs.gnu.org; Wed, 13 Mar 2013 14:23:53 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 27A4DAEE6; Wed, 13 Mar 2013 14:22:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=aMLIeDMFW2WWnI44ULYmEHOnnTk=; b=m0nFw6 hEKrGwnKITfrEDENa3b5NlN0bXLIQG4DtCb7xFsIHv9XN+a3GMwWIOdqwKU2mTJI gSadJggvXkjqZ0J8Y3qDNe2uVk0rBdSINqlKFQNDd9UHcWL1w7tbP5Xxk7vqM4F5 XzmS4OnfnAhO1NsNJ2f+3eB5vAQTnfv+4NvaM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=xmUQUjxXMZrC2jCrQUpzdPG4X4B7k+Kq 0kanF4b3gTuXvCJ/BdFfjApKLDliil9Mb5RjaI9wpCxrY+sBmzZS9OZ+YBXbueVa TG7X2ZFql9LsaHWgVw2IvBc+l+eJrMs9tkkRBZOfR8BeyNiiq+MEIDRw4DuNIzzF k8khIYSCs10= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 1D601AEE5; Wed, 13 Mar 2013 14:22:45 -0400 (EDT) Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 6CCBEAEE4; Wed, 13 Mar 2013 14:22:44 -0400 (EDT) From: Andy Wingo To: Mark H Weaver Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> Date: Wed, 13 Mar 2013 19:22:41 +0100 In-Reply-To: <87r4jj188o.fsf@tines.lan> (Mark H. Weaver's message of "Wed, 13 Mar 2013 14:10:15 -0400") Message-ID: <87sj3zdury.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: FFEBCE48-8C0A-11E2-9F1F-0B750E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.3 (----) On Wed 13 Mar 2013 19:10, Mark H Weaver writes: > Andy Wingo writes: > >> On Wed 13 Mar 2013 14:09, "David A. Wheeler" writes: >> >>> Andy Wingo: >>> >>>> So, we are repeating ourselves here :) I agree with you but I can't see >>>> a good way of implementing this. >>> >>> Would the per-port reader options be reasonable place to store the info >>> about EOF? >> >> For your own purposes that would be fine. But it cannot affect >> read-char / peek-char / etc for everyone, because it would have bad >> global effects on performance and correctness. That's why I'm pushing >> back on fixing this in Guile itself. > > I don't know, it might not be that bad, now that we've agreed on a way > to extend the port structure in 2.0. Maybe we could just have a "last > peek-char returned EOF" flag that would be consulted by the other read > primitives. > > I agree that we should not allow EOF to be unread. > > What do you think? I really doubt our ability to get it right. Consider that we have code that accesses the buffer directly, binary and textual ports, etc etc... I don't think we're going to get this right. Fixing this would also have complexity and performance costs as well. Maybe if it is somehow confined to scm_peek_char and scm_fill_input it could be doable. Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 14 13:15:22 2013 Received: (at 12216) by debbugs.gnu.org; 14 Mar 2013 17:15:22 +0000 Received: from localhost ([127.0.0.1]:54442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UGBkL-00083t-Ts for submit@debbugs.gnu.org; Thu, 14 Mar 2013 13:15:22 -0400 Received: from world.peace.net ([96.39.62.75]:60387 ident=hope5) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UGBkG-00083g-7t for 12216@debbugs.gnu.org; Thu, 14 Mar 2013 13:15:16 -0400 Received: from 209-6-96-61.c3-0.smr-ubr2.sbo-smr.ma.cable.rcn.com ([209.6.96.61] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UGBiz-0004id-6Q; Thu, 14 Mar 2013 13:13:53 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> Date: Thu, 14 Mar 2013 13:13:39 -0400 In-Reply-To: <87sj3zdury.fsf@pobox.com> (Andy Wingo's message of "Wed, 13 Mar 2013 19:22:41 +0100") Message-ID: <87fvzx29bw.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Andy Wingo writes: > On Wed 13 Mar 2013 19:10, Mark H Weaver writes: > >> I don't know, it might not be that bad, now that we've agreed on a way >> to extend the port structure in 2.0. Maybe we could just have a "last >> peek-char returned EOF" flag that would be consulted by the other read >> primitives. >> >> I agree that we should not allow EOF to be unread. >> >> What do you think? > > I really doubt our ability to get it right. Consider that we have code > that accesses the buffer directly, binary and textual ports, etc > etc... I don't think we're going to get this right. I think you're being overly pessimistic, but for the sake of argument, suppose you're right. Then we do the best we can and fix any remaining problems as they're discovered later. It's better to aim for correctness and fail in our first attempt than to give up without trying. IMO, this is a bug, pure and simple. I think we can do better than "it's too hard, let's just punt on this". We are implementors of Scheme, which has lots of details that are hard to get right, yet we rise to the challenge, do we not? > Fixing this would also have complexity and performance costs as well. One extra check per read primitive is hardly enough of a cost to consider abandoning correctness, IMO. Mark From debbugs-submit-bounces@debbugs.gnu.org Thu Mar 14 13:44:26 2013 Received: (at 12216) by debbugs.gnu.org; 14 Mar 2013 17:44:26 +0000 Received: from localhost ([127.0.0.1]:54479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UGCCT-0000Mh-Nc for submit@debbugs.gnu.org; Thu, 14 Mar 2013 13:44:25 -0400 Received: from aibo.runbox.com ([91.220.196.211]:33737) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UGCCN-0000MG-PM for 12216@debbugs.gnu.org; Thu, 14 Mar 2013 13:44:20 -0400 Received: from [10.9.9.241] (helo=rmm6prod02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UGCBB-0000xI-1B; Thu, 14 Mar 2013 18:43:01 +0100 Received: from mail by rmm6prod02.runbox.com with local (Exim 4.76) (envelope-from ) id 1UGCBB-0002Kz-0o; Thu, 14 Mar 2013 18:43:01 +0100 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [129.246.254.97] by rmm6.runbox.com with http (uid:258406) (RMM6); Thu, 14 Mar 2013 17:43:01 GMT From: "David A. Wheeler" To: "mhw" Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Thu, 14 Mar 2013 13:43:01 -0400 (EDT) X-Mailer: RMM6 References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87fvzx29bw.fsf@tines.lan> In-Reply-To: <87fvzx29bw.fsf@tines.lan> Message-Id: X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: wingo , almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On Thu, 14 Mar 2013 13:13:39 -0400, Mark H Weaver wrote: > One extra check per read primitive is hardly enough of a cost to > consider abandoning correctness, IMO. Though I've not reviewed this code, I *think* you'd only need to check when= the buffer is empty. When the buffer is empty, it'll take a while for the= OS to fill it anyway, far more than checking a boolean value. --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 17 19:49:27 2013 Received: (at 12216-done) by debbugs.gnu.org; 17 Mar 2013 23:49:27 +0000 Received: from localhost ([127.0.0.1]:60460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UHNKP-0007nw-Bh for submit@debbugs.gnu.org; Sun, 17 Mar 2013 19:49:26 -0400 Received: from world.peace.net ([96.39.62.75]:35371 ident=hope4) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UHNKM-0007nl-Ko for 12216-done@debbugs.gnu.org; Sun, 17 Mar 2013 19:49:23 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UHNIn-0006Yj-5C; Sun, 17 Mar 2013 19:47:45 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: Problems with Guile's number printer References: <0F432FA1-CFF8-4A22-A477-5291A1B9925D@bluewin.ch> <87ip9mgzp4.fsf@gnu.org> <878v7m5xdh.fsf@pobox.com> <2E5FFE0D-9001-409C-BCD4-9EE3BF9883F0@bluewin.ch> <87mww0nu8l.fsf@pobox.com> <2D31D517-08F8-4D07-84DB-098E335AE0AD@bluewin.ch> <874nh9boqe.fsf@pobox.com> <87txp9nrmc.fsf_-_@tines.lan> <87621o90ow.fsf_-_@pobox.com> Date: Sun, 17 Mar 2013 19:47:35 -0400 In-Reply-To: <87621o90ow.fsf_-_@pobox.com> (Andy Wingo's message of "Tue, 19 Feb 2013 09:18:07 +0100") Message-ID: <87ehfdh9m0.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 12216-done Cc: 12216-done@debbugs.gnu.org, Daniel Llorens X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) I've pushed 1ea37620c2c1794f7685b312d2530676a078ada7 to stable-2.0, which fixes our number printer. Closing this bug. Thanks, Mark From unknown Fri Jun 20 07:16:06 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: Did not alter fixed versions and reopened. Date: Mon, 18 Mar 2013 01:17:01 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # Did not alter fixed versions and reopened. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 17 21:30:03 2013 Received: (at 12216) by debbugs.gnu.org; 18 Mar 2013 01:30:03 +0000 Received: from localhost ([127.0.0.1]:60494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UHOtm-0002jW-MJ for submit@debbugs.gnu.org; Sun, 17 Mar 2013 21:30:03 -0400 Received: from world.peace.net ([96.39.62.75]:35457 ident=hope5) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UHOtl-0002i5-Cd for 12216@debbugs.gnu.org; Sun, 17 Mar 2013 21:30:01 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UHOsC-0006mq-DF; Sun, 17 Mar 2013 21:28:24 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: Problems with Guile's number printer References: <0F432FA1-CFF8-4A22-A477-5291A1B9925D@bluewin.ch> <87ip9mgzp4.fsf@gnu.org> <878v7m5xdh.fsf@pobox.com> <2E5FFE0D-9001-409C-BCD4-9EE3BF9883F0@bluewin.ch> <87mww0nu8l.fsf@pobox.com> <2D31D517-08F8-4D07-84DB-098E335AE0AD@bluewin.ch> <874nh9boqe.fsf@pobox.com> <87txp9nrmc.fsf_-_@tines.lan> <87621o90ow.fsf_-_@pobox.com> <87ehfdh9m0.fsf@tines.lan> Date: Sun, 17 Mar 2013 21:28:15 -0400 In-Reply-To: <87ehfdh9m0.fsf@tines.lan> (Mark H. Weaver's message of "Sun, 17 Mar 2013 19:47:35 -0400") Message-ID: <87wqt5fqds.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 12216 Cc: Daniel Llorens , 12216@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) I wrote: > I've pushed 1ea37620c2c1794f7685b312d2530676a078ada7 to stable-2.0, > which fixes our number printer. Closing this bug. Sorry, I sent this to the wrong bug. Oops :) Mark From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 30 18:40:29 2013 Received: (at 12216) by debbugs.gnu.org; 30 Mar 2013 22:40:29 +0000 Received: from localhost ([127.0.0.1]:53242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UM4Ro-0006i5-6A for submit@debbugs.gnu.org; Sat, 30 Mar 2013 18:40:28 -0400 Received: from world.peace.net ([96.39.62.75]:53188) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UM4Rf-0006hp-Ci for 12216@debbugs.gnu.org; Sat, 30 Mar 2013 18:40:21 -0400 Received: from 74-94-165-125-newengland.hfc.comcastbusiness.net ([74.94.165.125] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UM4Ot-0006NK-N8; Sat, 30 Mar 2013 18:37:27 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> Date: Sat, 30 Mar 2013 18:37:06 -0400 In-Reply-To: <87sj3zdury.fsf@pobox.com> (Andy Wingo's message of "Wed, 13 Mar 2013 19:22:41 +0100") Message-ID: <87obe07bvx.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Andy Wingo 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 From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 30 19:05:21 2013 Received: (at 12216) by debbugs.gnu.org; 30 Mar 2013 23:05:21 +0000 Received: from localhost ([127.0.0.1]:53266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UM4ps-0008H7-RM for submit@debbugs.gnu.org; Sat, 30 Mar 2013 19:05:21 -0400 Received: from aibo.runbox.com ([91.220.196.211]:54272) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UM4pp-0008Gw-BL for 12216@debbugs.gnu.org; Sat, 30 Mar 2013 19:05:18 -0400 Received: from [10.9.9.241] (helo=rmm6prod02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UM4n9-0008On-9t; Sun, 31 Mar 2013 00:02:31 +0100 Received: from mail by rmm6prod02.runbox.com with local (Exim 4.76) (envelope-from ) id 1UM4n9-0006Sl-92; Sun, 31 Mar 2013 00:02:31 +0100 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [108.45.113.66] by rmm6.runbox.com with http (uid:258406) (RMM6); Sat, 30 Mar 2013 23:02:31 GMT From: "David A. Wheeler" To: "mhw" Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Sat, 30 Mar 2013 19:02:31 -0400 (EDT) X-Mailer: RMM6 References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> In-Reply-To: <87obe07bvx.fsf@tines.lan> Message-Id: X-Spam-Score: 0.1 (/) X-Debbugs-Envelope-To: 12216 Cc: wingo , almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Mark H Weaver: > 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... That's awesome, and it sounds like it'd work well. Thanks for looking into this. --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 31 22:09:13 2013 Received: (at 12216) by debbugs.gnu.org; 1 Apr 2013 02:09:13 +0000 Received: from localhost ([127.0.0.1]:55020 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMUBN-0002QP-AB for submit@debbugs.gnu.org; Sun, 31 Mar 2013 22:09:13 -0400 Received: from world.peace.net ([96.39.62.75]:54237) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMUBL-0002QE-1p for 12216@debbugs.gnu.org; Sun, 31 Mar 2013 22:09:12 -0400 Received: from 74-94-165-125-newengland.hfc.comcastbusiness.net ([74.94.165.125] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UMU8M-0001n3-DO; Sun, 31 Mar 2013 22:06:06 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> Date: Sun, 31 Mar 2013 22:05:45 -0400 In-Reply-To: <87obe07bvx.fsf@tines.lan> (Mark H. Weaver's message of "Sat, 30 Mar 2013 18:37:06 -0400") Message-ID: <87bo9z3szq.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) --=-=-= Content-Type: text/plain Mark H Weaver writes: > Andy Wingo 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. Upon further thought, I decided that we shouldn't clear it on writes. If 'rw_random' is set, then 'scm_end_input' will be called anyway. If 'rw_random' is not set, then we should *not* clear the flag on writes, because it indicates that the read and write streams are independent, e.g. a terminal or socket. On the other hand, the 'pending_eof' flag should of course be cleared when putting characters back (unget). I've attached a proposed patch. It depends on the three preliminary patches posted here: http://lists.gnu.org/archive/html/guile-devel/2013-03/msg00221.html Thoughts? Regards, Mark --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0004-Peeks-do-not-consume-EOFs.patch Content-Description: [PATCH] Peeks do not consume EOFs >From e732d035b86a990ea0cfb56a710ee9224d8dbd31 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 31 Mar 2013 19:06:51 -0400 Subject: [PATCH 4/5] Peeks do not consume EOFs. * libguile/ports-internal.h (struct scm_port_internal): Add 'pending_eof' flag. * libguile/inline.h (scm_peek_byte_or_eof): Set 'pending_eof' flag before returning EOF. * libguile/ports.c (scm_i_set_pending_eof): New function. (scm_i_clear_pending_eof): New static function. (scm_new_port_table_entry): Initialize 'pending_eof'. (scm_fill_input): Check for 'pending_eof'. (scm_end_input, scm_unget_byte, scm_seek): Clear 'pending_eof'. (scm_peek_char): Set 'pending_eof' flag before returning EOF. * libguile/ports.h (scm_i_set_pending_eof): Add prototype. --- libguile/inline.h | 5 ++++- libguile/ports-internal.h | 1 + libguile/ports.c | 33 +++++++++++++++++++++++++++++++-- libguile/ports.h | 1 + 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/libguile/inline.h b/libguile/inline.h index 88ba7f7..fffe101 100644 --- a/libguile/inline.h +++ b/libguile/inline.h @@ -134,7 +134,10 @@ scm_peek_byte_or_eof (SCM port) if (pt->read_pos >= pt->read_end) { if (SCM_UNLIKELY (scm_fill_input (port) == EOF)) - return EOF; + { + scm_i_set_pending_eof (port); + return EOF; + } } c = *pt->read_pos; diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h index d52eab2..5bde9d0 100644 --- a/libguile/ports-internal.h +++ b/libguile/ports-internal.h @@ -48,6 +48,7 @@ struct scm_port_internal { scm_t_port_encoding_mode encoding_mode; scm_t_iconv_descriptors *iconv_descriptors; + int pending_eof; }; typedef struct scm_port_internal scm_t_port_internal; diff --git a/libguile/ports.c b/libguile/ports.c index 1ac9106..89e1714 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -241,6 +241,18 @@ scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM)) scm_ptobs[SCM_TC2PTOBNUM (tc)].input_waiting = input_waiting; } +void +scm_i_set_pending_eof (SCM port) +{ + SCM_INTERNAL_PTAB_ENTRY (port)->pending_eof = 1; +} + +static void +scm_i_clear_pending_eof (SCM port) +{ + SCM_INTERNAL_PTAB_ENTRY (port)->pending_eof = 0; +} + SCM_DEFINE (scm_char_ready_p, "char-ready?", 0, 1, 0, @@ -634,6 +646,8 @@ scm_new_port_table_entry (scm_t_bits tag) entry->input_cd = pti; /* XXX pointer to the internal port structure */ entry->output_cd = NULL; /* XXX unused */ + pti->pending_eof = 0; + SCM_SET_CELL_TYPE (z, tag); SCM_SETPTAB_ENTRY (z, entry); @@ -1410,9 +1424,16 @@ int scm_fill_input (SCM port) { scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_t_port_internal *pti = SCM_INTERNAL_PTAB_ENTRY (port); assert (pt->read_pos == pt->read_end); + if (pti->pending_eof) + { + pti->pending_eof = 0; + return EOF; + } + if (pt->read_buf == pt->putback_buf) { /* finished reading put-back chars. */ @@ -1652,6 +1673,7 @@ scm_end_input (SCM port) long offset; scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_i_clear_pending_eof (port); if (pt->read_buf == pt->putback_buf) { offset = pt->read_end - pt->read_pos; @@ -1675,6 +1697,7 @@ scm_unget_byte (int c, SCM port) { scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_i_clear_pending_eof (port); if (pt->read_buf == pt->putback_buf) /* already using the put-back buffer. */ { @@ -1846,7 +1869,10 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0, result = SCM_BOOL_F; } else if (c == EOF) - result = SCM_EOF_VAL; + { + scm_i_set_pending_eof (port); + result = SCM_EOF_VAL; + } else result = SCM_MAKE_CHAR (c); @@ -1945,7 +1971,10 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0, SCM_MISC_ERROR ("port is not seekable", scm_cons (fd_port, SCM_EOL)); else - rv = ptob->seek (fd_port, off, how); + { + scm_i_clear_pending_eof (fd_port); + rv = ptob->seek (fd_port, off, how); + } return scm_from_off_t_or_off64_t (rv); } else /* file descriptor?. */ diff --git a/libguile/ports.h b/libguile/ports.h index 95545cd..5aca26d 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -319,6 +319,7 @@ SCM_API SCM scm_set_port_filename_x (SCM port, SCM filename); SCM_INTERNAL const char *scm_i_default_port_encoding (void); SCM_INTERNAL void scm_i_set_default_port_encoding (const char *); SCM_INTERNAL void scm_i_set_port_encoding_x (SCM port, const char *str); +SCM_INTERNAL void scm_i_set_pending_eof (SCM port); SCM_API SCM scm_port_encoding (SCM port); SCM_API SCM scm_set_port_encoding_x (SCM port, SCM encoding); SCM_INTERNAL scm_t_string_failed_conversion_handler -- 1.7.10.4 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 01 17:30:41 2013 Received: (at 12216) by debbugs.gnu.org; 1 Apr 2013 21:30:41 +0000 Received: from localhost ([127.0.0.1]:56601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMmJN-0000Zf-4X for submit@debbugs.gnu.org; Mon, 01 Apr 2013 17:30:41 -0400 Received: from world.peace.net ([96.39.62.75]:55223) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMmJK-0000ZX-Hx for 12216@debbugs.gnu.org; Mon, 01 Apr 2013 17:30:39 -0400 Received: from 74-94-165-125-newengland.hfc.comcastbusiness.net ([74.94.165.125] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UMmGN-0004yh-Ib; Mon, 01 Apr 2013 17:27:35 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> <87bo9z3szq.fsf@tines.lan> Date: Mon, 01 Apr 2013 17:27:14 -0400 In-Reply-To: <87bo9z3szq.fsf@tines.lan> (Mark H. Weaver's message of "Sun, 31 Mar 2013 22:05:45 -0400") Message-ID: <87li920wnh.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) --=-=-= Content-Type: text/plain The prerequisite patches are now in stable-2.0. Here's an updated patch that applies against current stable-2.0. Otherwise it has not changed. Mark --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Peeks-do-not-consume-EOFs.patch Content-Description: [PATCH] Peeks do not consume EOFs >From 7d9ebc691519af7236e1fec8dfefd5fc8784f875 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 31 Mar 2013 19:06:51 -0400 Subject: [PATCH] Peeks do not consume EOFs. Fixes . * libguile/ports-internal.h (struct scm_port_internal): Add 'pending_eof' flag. * libguile/inline.h (scm_peek_byte_or_eof): Set 'pending_eof' flag before returning EOF. * libguile/ports.c (scm_i_set_pending_eof): New function. (scm_i_clear_pending_eof): New static function. (scm_new_port_table_entry): Initialize 'pending_eof'. (scm_fill_input): Check for 'pending_eof'. (scm_end_input, scm_unget_byte, scm_seek): Clear 'pending_eof'. (scm_peek_char): Set 'pending_eof' flag before returning EOF. * libguile/ports.h (scm_i_set_pending_eof): Add prototype. --- libguile/inline.h | 5 ++++- libguile/ports-internal.h | 1 + libguile/ports.c | 32 ++++++++++++++++++++++++++++++-- libguile/ports.h | 1 + 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/libguile/inline.h b/libguile/inline.h index 88ba7f7..fffe101 100644 --- a/libguile/inline.h +++ b/libguile/inline.h @@ -134,7 +134,10 @@ scm_peek_byte_or_eof (SCM port) if (pt->read_pos >= pt->read_end) { if (SCM_UNLIKELY (scm_fill_input (port) == EOF)) - return EOF; + { + scm_i_set_pending_eof (port); + return EOF; + } } c = *pt->read_pos; diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h index 73a788f..333d4fb 100644 --- a/libguile/ports-internal.h +++ b/libguile/ports-internal.h @@ -48,6 +48,7 @@ struct scm_port_internal { scm_t_port_encoding_mode encoding_mode; scm_t_iconv_descriptors *iconv_descriptors; + int pending_eof; SCM alist; }; diff --git a/libguile/ports.c b/libguile/ports.c index becdbed..65e2e6f 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -241,6 +241,18 @@ scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM)) scm_ptobs[SCM_TC2PTOBNUM (tc)].input_waiting = input_waiting; } +void +scm_i_set_pending_eof (SCM port) +{ + SCM_PORT_GET_INTERNAL (port)->pending_eof = 1; +} + +static void +scm_i_clear_pending_eof (SCM port) +{ + SCM_PORT_GET_INTERNAL (port)->pending_eof = 0; +} + SCM scm_i_port_alist (SCM port) { @@ -645,6 +657,7 @@ scm_new_port_table_entry (scm_t_bits tag) entry->input_cd = pti; /* XXX pointer to the internal port structure */ entry->output_cd = NULL; /* XXX unused */ + pti->pending_eof = 0; pti->alist = SCM_EOL; SCM_SET_CELL_TYPE (z, tag); @@ -1423,9 +1436,16 @@ int scm_fill_input (SCM port) { scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port); assert (pt->read_pos == pt->read_end); + if (pti->pending_eof) + { + pti->pending_eof = 0; + return EOF; + } + if (pt->read_buf == pt->putback_buf) { /* finished reading put-back chars. */ @@ -1665,6 +1685,7 @@ scm_end_input (SCM port) long offset; scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_i_clear_pending_eof (port); if (pt->read_buf == pt->putback_buf) { offset = pt->read_end - pt->read_pos; @@ -1688,6 +1709,7 @@ scm_unget_byte (int c, SCM port) { scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_i_clear_pending_eof (port); if (pt->read_buf == pt->putback_buf) /* already using the put-back buffer. */ { @@ -1859,7 +1881,10 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0, result = SCM_BOOL_F; } else if (c == EOF) - result = SCM_EOF_VAL; + { + scm_i_set_pending_eof (port); + result = SCM_EOF_VAL; + } else result = SCM_MAKE_CHAR (c); @@ -1958,7 +1983,10 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0, SCM_MISC_ERROR ("port is not seekable", scm_cons (fd_port, SCM_EOL)); else - rv = ptob->seek (fd_port, off, how); + { + scm_i_clear_pending_eof (fd_port); + rv = ptob->seek (fd_port, off, how); + } return scm_from_off_t_or_off64_t (rv); } else /* file descriptor?. */ diff --git a/libguile/ports.h b/libguile/ports.h index 53d5081..5c9334a 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -316,6 +316,7 @@ SCM_API SCM scm_port_column (SCM port); SCM_API SCM scm_set_port_column_x (SCM port, SCM line); SCM_API SCM scm_port_filename (SCM port); SCM_API SCM scm_set_port_filename_x (SCM port, SCM filename); +SCM_INTERNAL void scm_i_set_pending_eof (SCM port); SCM_INTERNAL SCM scm_i_port_alist (SCM port); SCM_INTERNAL void scm_i_set_port_alist_x (SCM port, SCM alist); SCM_INTERNAL const char *scm_i_default_port_encoding (void); -- 1.7.10.4 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 01 17:36:51 2013 Received: (at 12216) by debbugs.gnu.org; 1 Apr 2013 21:36:51 +0000 Received: from localhost ([127.0.0.1]:56611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMmPL-0000jF-3S for submit@debbugs.gnu.org; Mon, 01 Apr 2013 17:36:51 -0400 Received: from aibo.runbox.com ([91.220.196.211]:46192) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMmPH-0000j6-Nq for 12216@debbugs.gnu.org; Mon, 01 Apr 2013 17:36:49 -0400 Received: from [10.9.9.241] (helo=rmm6prod02.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1UMmMQ-0000EN-SP; Mon, 01 Apr 2013 23:33:50 +0200 Received: from mail by rmm6prod02.runbox.com with local (Exim 4.76) (envelope-from ) id 1UMmMQ-0002vJ-Rp; Mon, 01 Apr 2013 23:33:50 +0200 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Received: from [129.246.254.217] by rmm6.runbox.com with http (uid:258406) (RMM6); Mon, 01 Apr 2013 21:33:50 GMT From: "David A. Wheeler" To: "mhw" Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof Date: Mon, 01 Apr 2013 17:33:50 -0400 (EDT) X-Mailer: RMM6 References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> <87bo9z3szq.fsf@tines.lan> <87li920wnh.fsf@tines.lan> In-Reply-To: <87li920wnh.fsf@tines.lan> Message-Id: X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 12216 Cc: wingo , almkglor , 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: dwheeler@dwheeler.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On Mon, 01 Apr 2013 17:27:14 -0400, Mark H Weaver wrote: > The prerequisite patches are now in stable-2.0. Here's an updated patch > that applies against current stable-2.0. Otherwise it has not changed. Awesome!! Thanks for tracking that down and finding a solution. --- David A. Wheeler From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 02 04:01:49 2013 Received: (at 12216) by debbugs.gnu.org; 2 Apr 2013 08:01:49 +0000 Received: from localhost ([127.0.0.1]:57139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMwA6-00008a-Vk for submit@debbugs.gnu.org; Tue, 02 Apr 2013 04:01:48 -0400 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:57419 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UMwA4-00008R-6G for 12216@debbugs.gnu.org; Tue, 02 Apr 2013 04:01:45 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 60E80C90E; Tue, 2 Apr 2013 03:58:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=Ses6VxhDze1zm8ttRe0SB12x/Hs=; b=nDhfuT ZUFj4DN0SVxmaqt9jRhUdKfFXAARCyXTWIt8M3aNKVaDw3i11vVy3MZAHHpht48G Lc9Ljr+N/NShR4W1mgsoZqcuvnimp8k8r29cRju+CZVPZtTt0uRHaWd2yNGZxT6/ Mx9uP5GjB8lJ64Pef0fXQ5bQ8zRbre/PzHqdk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Q2lpFxdYSD5MCqz2otg+xbB1q0jNZZzj solnSnH9oSSO00fShQNvIm6NPvga/+ChN82WcveYsI8DqcJye+hdAAcZDd14aYgH cV5aU0j6TvACx/LaXTmJeISBKVg+72r+2zvnNJqHLyUGTpWYIzXTQRonfNaoy/bY rSFcWigyoy8= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 5648AC90D; Tue, 2 Apr 2013 03:58:46 -0400 (EDT) Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id BCE94C90C; Tue, 2 Apr 2013 03:58:45 -0400 (EDT) From: Andy Wingo To: Mark H Weaver Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> <87bo9z3szq.fsf@tines.lan> <87li920wnh.fsf@tines.lan> Date: Tue, 02 Apr 2013 09:58:43 +0200 In-Reply-To: <87li920wnh.fsf@tines.lan> (Mark H. Weaver's message of "Mon, 01 Apr 2013 17:27:14 -0400") Message-ID: <87r4itbbyk.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 24FE25FE-9B6B-11E2-B8BD-D36F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) Looks like a good start. Two comments: On Mon 01 Apr 2013 23:27, Mark H Weaver writes: > --- a/libguile/inline.h > +++ b/libguile/inline.h > @@ -134,7 +134,10 @@ scm_peek_byte_or_eof (SCM port) > if (pt->read_pos >= pt->read_end) > { > if (SCM_UNLIKELY (scm_fill_input (port) == EOF)) > - return EOF; > + { > + scm_i_set_pending_eof (port); > + return EOF; > + } > } > 1. I don't much like the addition of this call to this inline function. Can we move all the non-fast-path code into some other function? That would include the flush call as well. 2. I think we probably need some tests. Thanks for looking at this :-) Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 02 15:44:48 2013 Received: (at 12216) by debbugs.gnu.org; 2 Apr 2013 19:44:49 +0000 Received: from localhost ([127.0.0.1]:58613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UN78S-0004Fy-5T for submit@debbugs.gnu.org; Tue, 02 Apr 2013 15:44:48 -0400 Received: from world.peace.net ([96.39.62.75]:56303) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UN78O-0004Fn-KS for 12216@debbugs.gnu.org; Tue, 02 Apr 2013 15:44:46 -0400 Received: from 209-6-91-212.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.91.212] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UN75I-0008MR-Oo; Tue, 02 Apr 2013 15:41:33 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> <87bo9z3szq.fsf@tines.lan> <87li920wnh.fsf@tines.lan> <87r4itbbyk.fsf@pobox.com> Date: Tue, 02 Apr 2013 15:41:22 -0400 In-Reply-To: <87r4itbbyk.fsf@pobox.com> (Andy Wingo's message of "Tue, 02 Apr 2013 09:58:43 +0200") Message-ID: <87zjxgzpnh.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) --=-=-= Content-Type: text/plain Hi Andy, Andy Wingo writes: > Looks like a good start. Two comments: > > On Mon 01 Apr 2013 23:27, Mark H Weaver writes: > > 1. I don't much like the addition of this call to this inline function. > Can we move all the non-fast-path code into some other function? That > would include the flush call as well. Good idea! I've posted separate patches to do that here: "[PATCH] Move slow path out of 'scm_get_byte_or_eof' et al" http://lists.gnu.org/archive/html/guile-devel/2013-04/msg00032.html > 2. I think we probably need some tests. I've attached a new patch which adds tests. Note that this patch depends upon the "Move slow path out" patches referenced above. More thoughts? Thanks! Mark --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Peeks-do-not-consume-EOFs.patch Content-Description: [PATCH] Peeks do not consume EOFs >From 688dd519d7be102b9d5ce2193883c33d82f8df7b Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 31 Mar 2013 19:06:51 -0400 Subject: [PATCH] Peeks do not consume EOFs. Fixes . * libguile/ports-internal.h (struct scm_port_internal): Add 'pending_eof' flag. * libguile/ports.c (scm_i_set_pending_eof, scm_i_clear_pending_eof): New static functions. (scm_new_port_table_entry): Initialize 'pending_eof'. (scm_i_fill_input): Check for 'pending_eof'. (scm_i_peek_byte_or_eof): Set 'pending_eof' flag before returning EOF. (scm_end_input, scm_unget_byte, scm_seek): Clear 'pending_eof'. (scm_peek_char): Set 'pending_eof' flag before returning EOF. * test-suite/tests/ports.test ("pending EOF behavior"): Add tests. --- libguile/ports-internal.h | 1 + libguile/ports.c | 37 +++++++++++++++++-- test-suite/tests/ports.test | 84 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+), 3 deletions(-) diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h index 73a788f..333d4fb 100644 --- a/libguile/ports-internal.h +++ b/libguile/ports-internal.h @@ -48,6 +48,7 @@ struct scm_port_internal { scm_t_port_encoding_mode encoding_mode; scm_t_iconv_descriptors *iconv_descriptors; + int pending_eof; SCM alist; }; diff --git a/libguile/ports.c b/libguile/ports.c index ee14ca5..61bfc72 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -241,6 +241,18 @@ scm_set_port_input_waiting (scm_t_bits tc, int (*input_waiting) (SCM)) scm_ptobs[SCM_TC2PTOBNUM (tc)].input_waiting = input_waiting; } +static void +scm_i_set_pending_eof (SCM port) +{ + SCM_PORT_GET_INTERNAL (port)->pending_eof = 1; +} + +static void +scm_i_clear_pending_eof (SCM port) +{ + SCM_PORT_GET_INTERNAL (port)->pending_eof = 0; +} + SCM scm_i_port_alist (SCM port) { @@ -645,6 +657,7 @@ scm_new_port_table_entry (scm_t_bits tag) entry->input_cd = pti; /* XXX pointer to the internal port structure */ entry->output_cd = NULL; /* XXX unused */ + pti->pending_eof = 0; pti->alist = SCM_EOL; SCM_SET_CELL_TYPE (z, tag); @@ -1423,9 +1436,16 @@ static int scm_i_fill_input (SCM port) { scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port); assert (pt->read_pos == pt->read_end); + if (pti->pending_eof) + { + pti->pending_eof = 0; + return EOF; + } + if (pt->read_buf == pt->putback_buf) { /* finished reading put-back chars. */ @@ -1481,7 +1501,10 @@ scm_i_peek_byte_or_eof (SCM port) if (pt->read_pos >= pt->read_end) { if (SCM_UNLIKELY (scm_i_fill_input (port) == EOF)) - return EOF; + { + scm_i_set_pending_eof (port); + return EOF; + } } return *pt->read_pos; @@ -1713,6 +1736,7 @@ scm_end_input (SCM port) long offset; scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_i_clear_pending_eof (port); if (pt->read_buf == pt->putback_buf) { offset = pt->read_end - pt->read_pos; @@ -1736,6 +1760,7 @@ scm_unget_byte (int c, SCM port) { scm_t_port *pt = SCM_PTAB_ENTRY (port); + scm_i_clear_pending_eof (port); if (pt->read_buf == pt->putback_buf) /* already using the put-back buffer. */ { @@ -1907,7 +1932,10 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0, result = SCM_BOOL_F; } else if (c == EOF) - result = SCM_EOF_VAL; + { + scm_i_set_pending_eof (port); + result = SCM_EOF_VAL; + } else result = SCM_MAKE_CHAR (c); @@ -2006,7 +2034,10 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0, SCM_MISC_ERROR ("port is not seekable", scm_cons (fd_port, SCM_EOL)); else - rv = ptob->seek (fd_port, off, how); + { + scm_i_clear_pending_eof (fd_port); + rv = ptob->seek (fd_port, off, how); + } return scm_from_off_t_or_off64_t (rv); } else /* file descriptor?. */ diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index 886ab24..7b6ee22 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -1110,6 +1110,90 @@ (char-ready?)))))) +;;;; pending-eof behavior + +(with-test-prefix "pending EOF behavior" + ;; Make a test port that will produce the given sequence. Each + ;; element of 'lst' may be either a character or #f (which means EOF). + (define (test-soft-port . lst) + (make-soft-port + (vector (lambda (c) #f) ; write char + (lambda (s) #f) ; write string + (lambda () #f) ; flush + (lambda () ; read char + (let ((c (car lst))) + (set! lst (cdr lst)) + c)) + (lambda () #f)) ; close + "rw")) + + (define (call-with-port p proc) + (dynamic-wind + (lambda () #f) + (lambda () (proc p)) + (lambda () (close-port p)))) + + (define (call-with-test-file str proc) + (let ((filename (test-file))) + (dynamic-wind + (lambda () (call-with-output-file filename + (lambda (p) (display str p)))) + (lambda () (call-with-input-file filename proc)) + (lambda () (delete-file (test-file)))))) + + (pass-if "peek-char does not swallow EOF (soft port)" + (call-with-port (test-soft-port #\a #f #\b) + (lambda (p) + (and (char=? #\a (peek-char p)) + (char=? #\a (read-char p)) + (eof-object? (peek-char p)) + (eof-object? (read-char p)) + (char=? #\b (peek-char p)) + (char=? #\b (read-char p)))))) + + (pass-if "unread clears pending EOF (soft port)" + (call-with-port (test-soft-port #\a #f #\b) + (lambda (p) + (and (char=? #\a (read-char p)) + (eof-object? (peek-char p)) + (begin (unread-char #\u p) + (char=? #\u (read-char p))))))) + + (pass-if "unread clears pending EOF (string port)" + (call-with-input-string "a" + (lambda (p) + (and (char=? #\a (read-char p)) + (eof-object? (peek-char p)) + (begin (unread-char #\u p) + (char=? #\u (read-char p))))))) + + (pass-if "unread clears pending EOF (file port)" + (call-with-test-file + "a" + (lambda (p) + (and (char=? #\a (read-char p)) + (eof-object? (peek-char p)) + (begin (unread-char #\u p) + (char=? #\u (read-char p))))))) + + (pass-if "seek clears pending EOF (string port)" + (call-with-input-string "a" + (lambda (p) + (and (char=? #\a (read-char p)) + (eof-object? (peek-char p)) + (begin (seek p 0 SEEK_SET) + (char=? #\a (read-char p))))))) + + (pass-if "seek clears pending EOF (file port)" + (call-with-test-file + "a" + (lambda (p) + (and (char=? #\a (read-char p)) + (eof-object? (peek-char p)) + (begin (seek p 0 SEEK_SET) + (char=? #\a (read-char p)))))))) + + ;;;; Close current-input-port, and make sure everyone can handle it. (with-test-prefix "closing current-input-port" -- 1.7.10.4 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 04 16:03:57 2013 Received: (at 12216) by debbugs.gnu.org; 4 Apr 2013 20:03:57 +0000 Received: from localhost ([127.0.0.1]:34098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UNqO2-0001P6-4d for submit@debbugs.gnu.org; Thu, 04 Apr 2013 16:03:57 -0400 Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:57627 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UNqNy-0001Ox-HL for 12216@debbugs.gnu.org; Thu, 04 Apr 2013 16:03:53 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 9D301B87A; Thu, 4 Apr 2013 16:00:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=1gfYBo5xBBc6+L29rnGYWlIo5rg=; b=T10Q80 QvrYTtlgB5AWd42+QrObey2nhGsG9ou/QB2U0fsiA2LrH0iN3XI1AbiAl0TgjvyD c/mo52P8yBabBY4w3hVzCqh39S1zoDvmBbcg9dVEfSOgoRaqqhl11QQqBhlLLXiL tAAZgKCkRmGZPld3y8xR6KMOctmniVhRXoYl0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=YXwpvO9WkTmgYPIJOgyS2tcP2di+7XH4 Thlk1h/0jEJPjR4E8c11va/HZaeZWoDDv6+NBQkhfwHY2SBk6P7qNhmJTFoIh7ix 8mOZrDFNxI2pjGGOS2TlFSNKevmwfgoS02vgAGxdLow78hEAJfhhLR0U6cFIUHZy RG0uZeX1NtE= Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 8C67CB879; Thu, 4 Apr 2013 16:00:38 -0400 (EDT) Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id E31F9B878; Thu, 4 Apr 2013 16:00:37 -0400 (EDT) From: Andy Wingo To: Mark H Weaver Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> <87bo9z3szq.fsf@tines.lan> <87li920wnh.fsf@tines.lan> <87r4itbbyk.fsf@pobox.com> <87zjxgzpnh.fsf@tines.lan> Date: Thu, 04 Apr 2013 22:00:35 +0200 In-Reply-To: <87zjxgzpnh.fsf@tines.lan> (Mark H. Weaver's message of "Tue, 02 Apr 2013 15:41:22 -0400") Message-ID: <877gki9icc.fsf@pobox.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 51E29660-9D62-11E2-9290-D36F0E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 12216 Cc: almkglor , dwheeler@dwheeler.com, 12216 <12216@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) On Tue 02 Apr 2013 21:41, Mark H Weaver writes: > Good idea! I've posted separate patches to do that here: > > "[PATCH] Move slow path out of 'scm_get_byte_or_eof' et al" > http://lists.gnu.org/archive/html/guile-devel/2013-04/msg00032.html Cool, and thanks to Ludo for review there. Just to note, if you end up doing any more work on these functions in the future, you should move them to ports.h. See 18cd9aff9429c99ffae34448507f9b468e20e06f for an example of what I'm talking about. >> 2. I think we probably need some tests. > > I've attached a new patch which adds tests. Note that this patch > depends upon the "Move slow path out" patches referenced above. Looks great to me. Thanks for following up on this! Andy -- http://wingolog.org/ From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 04 17:57:31 2013 Received: (at 12216-done) by debbugs.gnu.org; 4 Apr 2013 21:57:31 +0000 Received: from localhost ([127.0.0.1]:34272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UNs9y-00056t-Na for submit@debbugs.gnu.org; Thu, 04 Apr 2013 17:57:30 -0400 Received: from world.peace.net ([96.39.62.75]:59015) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UNs9t-00056d-LG for 12216-done@debbugs.gnu.org; Thu, 04 Apr 2013 17:57:28 -0400 Received: from turntable.mit.edu ([18.160.0.29] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UNs6h-00089I-Re; Thu, 04 Apr 2013 17:54:07 -0400 From: Mark H Weaver To: Andy Wingo Subject: Re: bug#12216: peek-char incorrectly *CONSUMES* eof References: <87sj49vld2.fsf@pobox.com> <87ip52ew09.fsf@pobox.com> <87ehfjimug.fsf@pobox.com> <87r4jjfjya.fsf@pobox.com> <87r4jj188o.fsf@tines.lan> <87sj3zdury.fsf@pobox.com> <87obe07bvx.fsf@tines.lan> <87bo9z3szq.fsf@tines.lan> <87li920wnh.fsf@tines.lan> <87r4itbbyk.fsf@pobox.com> <87zjxgzpnh.fsf@tines.lan> <877gki9icc.fsf@pobox.com> Date: Thu, 04 Apr 2013 17:53:50 -0400 In-Reply-To: <877gki9icc.fsf@pobox.com> (Andy Wingo's message of "Thu, 04 Apr 2013 22:00:35 +0200") Message-ID: <87y5cyvu6p.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 12216-done Cc: almkglor , dwheeler@dwheeler.com, 12216-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Andy Wingo writes: > Looks great to me. Thanks for following up on this! Excellent! I pushed this to stable-2.0, so it will be in Guile 2.0.8. Closing this bug now. Thanks! Mark From unknown Fri Jun 20 07:16:06 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 03 May 2013 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator