From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.bugs Subject: bug#20302: peek-char messes up file position on binary string ports Date: Fri, 17 Apr 2015 01:29:08 -0400 Message-ID: <87383z5nmj.fsf@netris.org> References: <87y4lylwch.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429248561 29497 80.91.229.3 (17 Apr 2015 05:29:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Apr 2015 05:29:21 +0000 (UTC) Cc: 20302@debbugs.gnu.org To: David Kastrup Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Fri Apr 17 07:29:11 2015 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Yiypy-0002l9-8t for guile-bugs@m.gmane.org; Fri, 17 Apr 2015 07:29:10 +0200 Original-Received: from localhost ([::1]:39538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yiypx-0000SI-B0 for guile-bugs@m.gmane.org; Fri, 17 Apr 2015 01:29:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yiypt-0000SC-Rq for bug-guile@gnu.org; Fri, 17 Apr 2015 01:29:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yiypq-00026E-Md for bug-guile@gnu.org; Fri, 17 Apr 2015 01:29:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40482) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yiypq-000269-J6 for bug-guile@gnu.org; Fri, 17 Apr 2015 01:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Yiypq-0002u6-AN for bug-guile@gnu.org; Fri, 17 Apr 2015 01:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mark H Weaver Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 17 Apr 2015 05:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20302 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 20302-submit@debbugs.gnu.org id=B20302.142924851811131 (code B ref 20302); Fri, 17 Apr 2015 05:29:02 +0000 Original-Received: (at 20302) by debbugs.gnu.org; 17 Apr 2015 05:28:38 +0000 Original-Received: from localhost ([127.0.0.1]:58491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YiypS-0002tS-1h for submit@debbugs.gnu.org; Fri, 17 Apr 2015 01:28:38 -0400 Original-Received: from world.peace.net ([50.252.239.5]:53919 ident=hope5) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YiypQ-0002tL-KJ for 20302@debbugs.gnu.org; Fri, 17 Apr 2015 01:28:37 -0400 Original-Received: from [10.1.10.78] (helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1YiypJ-0008FI-QT; Fri, 17 Apr 2015 01:28:29 -0400 In-Reply-To: <87y4lylwch.fsf@fencepost.gnu.org> (David Kastrup's message of "Sat, 11 Apr 2015 13:48:14 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7769 Archived-At: David Kastrup writes: > (use-modules (rnrs bytevectors) (rnrs io ports)) > (let ((port (open-bytevector-input-port > (string->utf8 "Blablabla\nBlablabla\n")))) > (seek port 13 SEEK_SET) > (format #t "~c ~d\n" (peek-char port) > (ftell port))) > ;; Outputs b 3 but should output b 13 > > This is using > guile (GNU Guile) 2.0.11 > Packaged by Debian (2.0.11-deb+1-1) Ouch :-( The problem is that r6rs-ports.c:bip_seek assumes that c_port->read_{buf,pos,end} point to the original bytevector, and fail to handle the case where it points to a "putback" buffer. Note that (ftell port) is equivalent to (seek port 0 SEEK_CUR). > Any idea how to work around _this_ one? While investigating possible workarounds, I noticed that, afaict, we did _not_ make the incompatible change in 2.0.11 that you claim we made in . That change was only made on our master branch, which will become 2.2. In response to that bug report, I suggested that you use bytevector input ports instead of string ports, and that's what led you to hit this problem. Now my suggestion is that you continue using string ports in 2.0.11 or earlier, and use bytevector inputs ports in 2.0.12 or later. I'll make sure this bug is fixed in 2.0.12. Please let me know if you think I'm mistaken in any of this. If so, I have some other possible workarounds to offer, but I think they will not be needed. Mark