Fix bug: would-block value only returned if nothing has been read.
authorChris Hanson <org/chris-hanson/cph>
Sun, 29 Jan 2017 06:00:21 +0000 (22:00 -0800)
committerChris Hanson <org/chris-hanson/cph>
Sun, 29 Jan 2017 06:00:21 +0000 (22:00 -0800)
src/runtime/genio.scm

index 8669b9b59ac0bc00d169b38ed3ac7c96303a7657..4f9e78fbc25358c2852ee9e5c4fd20340c8a7900 100644 (file)
@@ -236,8 +236,12 @@ USA.
   (let loop ((index start))
     (if (fix:< index end)
        (let ((char (generic-io/read-char port)))
-         (cond ((not char) #f)
-               ((eof-object? char) (fix:- index start))
+         (cond ((not char)
+                (if (fix:< start index)
+                    (fix:- index start)
+                    #f))
+               ((eof-object? char)
+                (fix:- index start))
                (else
                 (ustring-set! string index char)
                 (loop (fix:+ index 1)))))