[racket] problem with Port Events and make-limited-input-port
The port created by `make-limited-input-port' didn't correctly count
bytes that were consumed via `port-commit-peeked' (which is used by
`read-bytes-line-evt').
The bug is now fixed in the git repo, so it will be fixed in the next
nightly build.
Thanks for the report and test case!
At Fri, 17 Jun 2011 17:33:56 +0100, milo arvidsson wrote:
> (I'm using the latest build: mz-bin-i386-win32; version 5.1.1.6,
> updated Friday, June 17 2011, 03:50 EDT)
>
> I've written versions of the following program using limited file,
> string, and pipe ports with read-bytes-line-evt, read-char-evt,
> read-line-evt, read-bytes-evt, read-string-evt, and regexp-match-evt.
> None of the port events returned #<eof> after 4 bytes were read.
>
>
> #lang racket/base
>
> (require racket/port)
>
> ;The input port is limited to 4 bytes, or just 2 lines.
> (parameterize ((current-input-port (make-limited-input-port
> (open-input-string "A\nB\nC\nD\n") 4)))
> (list
> (list (sync (read-bytes-line-evt (current-input-port)))
> (file-position (current-input-port)))
> (list (sync (read-bytes-line-evt (current-input-port)))
> (file-position (current-input-port)))
> (list (sync (read-bytes-line-evt (current-input-port)))
> (file-position (current-input-port)))
> (list (sync (read-bytes-line-evt (current-input-port)))
> (file-position (current-input-port)))))
>
> ;returns with: '((#"A" 2) (#"B" 4) (#"C" 6) (#"D" 8))
>
>
> The following version uses 'read-bytes-line' and works as expected:
>
> #lang racket/base
>
> (require racket/port)
>
> (parameterize ((current-input-port (make-limited-input-port
> (open-input-string "A\nB\nC\nD\n") 4)))
> (list
> (list (read-bytes-line) (file-position (current-input-port)))
> (list (read-bytes-line) (file-position (current-input-port)))
> (list (read-bytes-line) (file-position (current-input-port)))
> (list (read-bytes-line) (file-position (current-input-port)))))
>
> ;returns: '((#"A" 2) (#"B" 4) (#<eof> 4) (#<eof> 4))
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users