[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] read-line
From: |
Joerg F. Wittenberger |
Subject: |
[Chicken-users] read-line |
Date: |
10 Dec 2002 01:39:32 +0100 |
Hi,
I found read-line working somewhat unexpected on network streams
(where the ^M^J or the "apple" line feed rule applies): it inserts
empty lines in between the line feed.
Anybody who objects this change, which understands any of:
#\newline #\return
#\return #\newline
#\newline
#\return
as line delimiter. Sequences, though, should result in empty lines.
regards
/Jörg
--
The worst of harm may often result from the best of intentions.
*** extras.scm.orig Mon Dec 9 11:05:20 2002
--- extras.scm Tue Dec 10 01:33:24 2002
***************
*** 233,238 ****
--- 233,239 ----
(define read-line
(let ((read-char read-char)
+ (peek-char peek-char)
(substring substring)
(string-append string-append)
(make-string make-string) )
***************
*** 252,258 ****
(substring buffer 0 i) ) )
(if (or (##core#inline "C_eqp" c #\newline)
(##core#inline "C_eqp" c #\return) )
! (return (substring buffer 0 i)) )
(if (##core#inline "C_fixnum_greater_or_equal_p" i len)
(begin
(set! buffer (string-append buffer (make-string 256)))
--- 253,265 ----
(substring buffer 0 i) ) )
(if (or (##core#inline "C_eqp" c #\newline)
(##core#inline "C_eqp" c #\return) )
! (begin
! (let ((c2 (peek-char p)))
! (if (and (not (##core#inline "C_eqp" c2 c))
! (or (##core#inline "C_eqp" c2 #\newline)
! (##core#inline "C_eqp" c2 #\return) ))
! (read-char p)))
! (return (substring buffer 0 i))) )
(if (##core#inline "C_fixnum_greater_or_equal_p" i len)
(begin
(set! buffer (string-append buffer (make-string 256)))
- [Chicken-users] read-line,
Joerg F. Wittenberger <=