sqaush! rdelim

* mes/module/mes/guile.mes (read-line): Move to ...
* mes/module/ice-9/rdelim.scm (read-line): ...here.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2021-05-16 12:58:49 +02:00
parent 842d9b7978
commit bc1a687703
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
2 changed files with 15 additions and 14 deletions

View File

@ -16,4 +16,18 @@
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
(define-module (ice-9 rdelim))
(define-module (ice-9 rdelim)
#:export (read-line))
(define (read-line . rest)
(let* ((port (if (pair? rest) (car rest) (current-input-port)))
(handle-delim (if (and (pair? rest) (pair? (cdr rest))) (cadr rest) 'trim))
(c (read-char port)))
(if (eof-object? c) c
(list->string
(let loop ((c c))
(if (or (eof-object? c) (eq? c #\newline)) (case handle-delim
((trim) '())
((concat) '(#\newline))
(else (error (format #f "not supported: handle-delim=~a" handle-delim))))
(cons c (loop (read-char port)))))))))

View File

@ -66,19 +66,6 @@
(define (drain-input port) (read-string))
(define (read-line . rest)
(let* ((port (if (pair? rest) (car rest) (current-input-port)))
(handle-delim (if (and (pair? rest) (pair? (cdr rest))) (cadr rest) 'trim))
(c (read-char port)))
(if (eof-object? c) c
(list->string
(let loop ((c c))
(if (or (eof-object? c) (eq? c #\newline)) (case handle-delim
((trim) '())
((concat) '(#\newline))
(else (error (format #f "not supported: handle-delim=~a" handle-delim))))
(cons c (loop (read-char port)))))))))
(define (object->string x . rest)
(with-output-to-string
(lambda () ((if (pair? rest) (car rest) write) x))))