Hi,

I have found a regression introduced with commit
7fdc4b41b4a7b2a78afd33f73bc5d2ea07e6d60c. The following test code
breaks without this patch:

http://paste.call-cc.org/paste?id=8a48a4ffcd7925732e61995a6656698ef52939bb
(Note you need to run "t2" not "t1" as this paste tells you. That's
t2 the letter, not t2 the number).

This patch seems to fix the issue, thanks to Peter Bex and Jim
Ursetto for being of excellent help.

What do you think?

Kind regards,

Christian
 
-- 
In the world, there is nothing more submissive and weak than
water. Yet for attacking that which is hard and strong, nothing can
surpass it. --- Lao Tzu
>From cb5b1c354e179d4a223489a5e36961c280199c49 Mon Sep 17 00:00:00 2001
From: Christian Kellermann <ck...@pestilenz.org>
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 <ck...@pestilenz.org>
---
 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

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to