~ chicken-core (chicken-5) 298c932c16c9187551e579d7ac74511a1f95786a
commit 298c932c16c9187551e579d7ac74511a1f95786a
Author: Christian Kellermann <ckeen@pestilenz.org>
AuthorDate: Wed Apr 10 21:14:27 2013 +0200
Commit: Peter Bex <peter.bex@xs4all.nl>
CommitDate: Wed Apr 10 21:28:39 2013 +0200
Fetch a new char before peeking it on custom input ports.
This fixes a regression introduced by commit
7fdc4b41b4a7b2a78afd33f73bc5d2ea07e6d60c which returns eof chars upon
broken up strings. This patch tries to fetch a new character before
calling peek. Also the buffer position must not advance on a real eof
condition.
Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>
Signed-off-by: Peter Bex <peter.bex@xs4all.nl>
diff --git a/posixunix.scm b/posixunix.scm
index 6d1fe512..15cb5353 100644
--- a/posixunix.scm
+++ b/posixunix.scm
@@ -1350,10 +1350,10 @@ EOF
(letrec ([this-port
(make-input-port
(lambda () ; read-char
+ (when (fx>= bufpos buflen)
+ (fetch))
(let ([ch (peek)])
- #; ; Allow increment since overflow is far, far away
(unless (eof-object? ch) (set! bufpos (fx+ bufpos 1)))
- (set! bufpos (fx+ bufpos 1))
ch ) )
(lambda () ; char-ready?
(or (fx< bufpos buflen)
Trap