GNU bug report logs - #20302
peek-char messes up file position on binary string ports

Previous Next

Package: guile;

Reported by: David Kastrup <dak <at> gnu.org>

Date: Sat, 11 Apr 2015 11:49:02 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Mark H Weaver <mhw <at> netris.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#20302: closed (peek-char messes up file position on binary
 string ports)
Date: Wed, 04 Nov 2015 21:14:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 04 Nov 2015 16:12:38 -0500
with message-id <87k2pxzcxl.fsf <at> netris.org>
and subject line Re: bug#20302: peek-char messes up file position on binary string ports
has caused the debbugs.gnu.org bug report #20302,
regarding peek-char messes up file position on binary string ports
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
20302: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20302
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: David Kastrup <dak <at> gnu.org>
To: bug-guile <at> gnu.org
Subject: peek-char messes up file position on binary string ports
Date: Sat, 11 Apr 2015 13:48:14 +0200
[Message part 3 (text/plain, inline)]
Any idea how to work around _this_ one?

[gaga.scm (text/plain, inline)]
(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
[Message part 5 (text/plain, inline)]
This is using
guile (GNU Guile) 2.0.11
Packaged by Debian (2.0.11-deb+1-1)

-- 
David Kastrup
[Message part 6 (message/rfc822, inline)]
From: Mark H Weaver <mhw <at> netris.org>
To: David Kastrup <dak <at> gnu.org>
Cc: 20302-done <at> debbugs.gnu.org
Subject: Re: bug#20302: peek-char messes up file position on binary string
 ports
Date: Wed, 04 Nov 2015 16:12:38 -0500
Mark H Weaver <mhw <at> netris.org> writes:

> Mark H Weaver <mhw <at> netris.org> writes:
>
>> David Kastrup <dak <at> gnu.org> 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).
>
> I've attached a preliminary patch set to fix this bug and some others.

I believe this is now fixed on the stable-2.0 branch, commit
448eb30e3d9e998e97a5d51875f861c9f6c1101c.  I'm closing this bug now.

     Thanks,
       Mark


This bug report was last modified 9 years and 261 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.