mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 14:19:18 +02:00
Acknowledging that I may never be free of the \r evil...
This commit is contained in:
parent
69646a0c94
commit
71afd5d56a
1 changed files with 18 additions and 8 deletions
|
@ -58,9 +58,15 @@
|
||||||
(and (not (equal? res "")) res)))
|
(and (not (equal? res "")) res)))
|
||||||
(else
|
(else
|
||||||
(write-char ch out)
|
(write-char ch out)
|
||||||
(if (eqv? ch #\newline)
|
(cond
|
||||||
(get-output-string out)
|
((eqv? ch #\newline)
|
||||||
(lp))))))))))
|
(get-output-string out))
|
||||||
|
((eqv? ch #\return)
|
||||||
|
(if (eqv? #\newline (peek-char in))
|
||||||
|
(read-char in))
|
||||||
|
(get-output-string out))
|
||||||
|
(else
|
||||||
|
(lp)))))))))))
|
||||||
|
|
||||||
(define (read-line . o)
|
(define (read-line . o)
|
||||||
(let ((in (if (pair? o) (car o) (current-input-port)))
|
(let ((in (if (pair? o) (car o) (current-input-port)))
|
||||||
|
@ -70,11 +76,15 @@
|
||||||
(if (not res)
|
(if (not res)
|
||||||
eof
|
eof
|
||||||
(let ((len (string-length res)))
|
(let ((len (string-length res)))
|
||||||
(if (and (> len 0) (eqv? #\newline (string-ref res (- len 1))))
|
(cond
|
||||||
(if (and (> len 1) (eqv? #\return (string-ref res (- len 2))))
|
((and (> len 0) (eqv? #\newline (string-ref res (- len 1))))
|
||||||
(substring res 0 (- len 2))
|
(if (and (> len 1) (eqv? #\return (string-ref res (- len 2))))
|
||||||
(substring res 0 (- len 1)))
|
(substring res 0 (- len 2))
|
||||||
res))))))
|
(substring res 0 (- len 1))))
|
||||||
|
((and (> len 0) (eqv? #\return (string-ref res (- len 1))))
|
||||||
|
(substring res 0 (- len 1)))
|
||||||
|
(else
|
||||||
|
res)))))))
|
||||||
|
|
||||||
;;> @subsubsubsection{(read-string n [in])}
|
;;> @subsubsubsection{(read-string n [in])}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue