~ chicken-core (chicken-5) 6b433ea1eae6f0b698b6c4c10eeae579d7f9c9cb


commit 6b433ea1eae6f0b698b6c4c10eeae579d7f9c9cb
Author:     Moritz Heidkamp <moritz.heidkamp@bevuta.com>
AuthorDate: Fri Apr 14 16:22:39 2017 +0200
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Fri Apr 14 19:31:37 2017 +0200

    Fix char-ready? on EOF for string input ports
    
    char-ready? on string input ports would return #f when they've reached
    the end of their underlying string. However, char-ready? is supposed
    to return #t in this case.
    
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/NEWS b/NEWS
index 1d59f4d5..a107ebb0 100644
--- a/NEWS
+++ b/NEWS
@@ -71,6 +71,8 @@
 - Core Libraries
   - Unit "posix": If file-lock, file-lock/blocking or file-unlock are
     interrupted by a signal, we now retry (thanks to Joerg Wittenberger).
+  - char-ready? on string ports now also returns #t at EOF, as per R5RS;
+    in other words, it always returns #t (thanks to Moritz Heidkamp)
 
 - Build system
   - Fixed broken compilation on NetBSD, due to missing _NETBSD_SOURCE.
diff --git a/library.scm b/library.scm
index 3caba429..51d6793b 100644
--- a/library.scm
+++ b/library.scm
@@ -4255,8 +4255,7 @@ EOF
 	   (##sys#setislot p 10 (fx+ position len)) ) ) )
      void ; close
      (lambda (p) #f)			; flush-output
-     (lambda (p)			; char-ready?
-       (fx< (##sys#slot p 10) (##sys#slot p 11)) )
+     (lambda (p) #t)			; char-ready?
      (lambda (p n dest start)		; read-string!
        (let* ((pos (##sys#slot p 10))
 	      (n2 (fx- (##sys#slot p 11) pos) ) )
diff --git a/tests/port-tests.scm b/tests/port-tests.scm
index ec6a323b..463e31e6 100644
--- a/tests/port-tests.scm
+++ b/tests/port-tests.scm
@@ -42,6 +42,8 @@ EOF
   (read-line p)))
 (assert (= 20 (length (read-lines (open-input-string *text*)))))
 
+(assert (char-ready? (open-input-string "")))
+
 (let ((out (open-output-string)))
   (test-equal "Initially, output string is empty"
               (get-output-string out) "")
Trap