Issue #498 - read-line can read 1022+ byte lines

Previously the function would only read up to the first 1022 bytes. We now remove that restriction
This commit is contained in:
Justin Ethier 2022-12-20 21:44:27 -05:00
parent 2ac949b187
commit f728618336
2 changed files with 21 additions and 3 deletions

View file

@ -4,6 +4,7 @@
Bug Fixes
- Fix `read-line` to read entire lines that consist of more than 1022 bytes. Previously the function would only return partial data up to this limit. Thanks to Robby Zambito for the bug report.
- `(include "body.scm")` inside a file `path/to/lib.sld` will look for `path/to/body.scm`, then fallback to the legacy behavior, and look for `$(pwd)/body.scm`.
- Pass append and prepend directories when compiling dependent libraries of a program. This prevents issues where the directories are not made available to any `include` directives within such libraries.

View file

@ -695,9 +695,26 @@
(Cyc-read-char (current-input-port))
(Cyc-read-char (car port))))
(define (read-line . port)
(if (null? port)
(Cyc-read-line (current-input-port))
(Cyc-read-line (car port))))
(let* ((p (if (null? port)
(current-input-port)
(car port)))
(str (Cyc-read-line p)))
(cond
((eof-object? str) str)
((< (string-length str) 1022) str)
(else (_read-line str p)))))
;; Helper function to handle case where a line is too
;; long to be read by a single runtime I/O call
(define (_read-line str port)
(let loop ((lis (list str))
(str (Cyc-read-line port)))
(cond
((eof-object? str)
(apply string-append (reverse lis)))
((< (string-length str) 1022)
(apply string-append (reverse (cons str lis))))
(else
(loop (cons str lis) (Cyc-read-line port))))))
(define (read-string k . opts)
(let ((port (if (null? opts)
(current-input-port)