This is the mail archive of the
kawa@sourceware.cygnus.com
mailing list for the Kawa project.
Re: read-line and CRLF
- To: kawa at sourceware dot cygnus dot com
- Subject: Re: read-line and CRLF
- From: brlewis at alum dot mit dot edu
- Date: Wed, 7 Jun 2000 14:16:06 -0400
- References: <200006062014.QAA21097@tux.eatonvance.com> <m21z2a1s4v.fsf@kelso.bo\
--text follows this line--
Per Bothner <per@bothner.com> writes:
> Hm. There already is code in kawa/standard/read_line.java to
> handle CRLF. If it doesn't could you try to debug it?
I'll work on it. In the meantime, here's a test case. Seems that
read-line does the right thing with 'split, but otherwise not.
--- testsuite/misc-test.scm 2000/06/07 17:46:17 1.3
+++ testsuite/misc-test.scm 2000/06/07 17:46:29
@@ -1,4 +1,4 @@
-(test-init "Miscellaneous" 86)
+(test-init "Miscellaneous" 88)
;;; DSSSL spec example 11
(test '(3 4 5 6) (lambda x x) 3 4 5 6)
@@ -385,3 +385,24 @@
(test 15 'tail-call (let loop ((a 1) (b 2) (c 3) (d 4) (e 5) (f 6))
(if (> a 10) b (loop b c d e f (+ a b c)))))
+
+;;; read-line should handle CR, LF and CRLF equally
+(section "read-line")
+
+(define (test-read-split port)
+ (call-with-values (lambda () (read-line port 'split))
+ (lambda x (car x))))
+
+(define (test-read-line proc)
+ (call-with-input-string
+ "line\rline\nline\r\nline"
+ (lambda (strport)
+ (list (proc strport) (proc strport) (proc strport) (proc strport)))))
+
+(test '("line" "line" "line" "line")
+ test-read-line
+ read-line)
+
+(test '("line" "line" "line" "line")
+ test-read-line
+ test-read-split)
--
Bruce R. Lewis http://brl.sourceforge.net/