>From cb5b1c354e179d4a223489a5e36961c280199c49 Mon Sep 17 00:00:00 2001 From: Christian Kellermann Date: Wed, 10 Apr 2013 21:14:27 +0200 Subject: [PATCH] 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 --- posixunix.scm | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/posixunix.scm b/posixunix.scm index 6d1fe51..15cb535 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) -- 1.7.6