parent
f1f4959b66
commit
77ece3feb0
|
@ -1100,6 +1100,44 @@
|
||||||
(check-srcloc #f 3 #f)
|
(check-srcloc #f 3 #f)
|
||||||
(check-srcloc 1 3 29))
|
(check-srcloc 1 3 29))
|
||||||
|
|
||||||
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Regression test for interaction of `read-line`, "\r\n", and
|
||||||
|
;; input buffering
|
||||||
|
|
||||||
|
(let ()
|
||||||
|
(define f1 (make-temporary-file "line-feed1~a.txt"))
|
||||||
|
(define f2 (make-temporary-file "line-feed2~a.txt"))
|
||||||
|
|
||||||
|
(define p1 (open-output-file f1 #:exists 'truncate))
|
||||||
|
(define p2 (open-output-file f2 #:exists 'truncate))
|
||||||
|
|
||||||
|
(define (write-prefix p)
|
||||||
|
(for ([i 1364])
|
||||||
|
(write-bytes #"x\r\n" p)))
|
||||||
|
|
||||||
|
(write-prefix p1)
|
||||||
|
(write-prefix p2)
|
||||||
|
(write-bytes #"\r\ny\r\ny\r\n" p1)
|
||||||
|
(write-bytes #"y\r\ny\r\ny\r\n" p2)
|
||||||
|
|
||||||
|
(close-output-port p1)
|
||||||
|
(close-output-port p2)
|
||||||
|
|
||||||
|
(define (count f)
|
||||||
|
(call-with-input-file f
|
||||||
|
(lambda (in)
|
||||||
|
(let loop ()
|
||||||
|
(define v (read-line in 'any))
|
||||||
|
(if (eof-object? v)
|
||||||
|
0
|
||||||
|
(add1 (loop)))))))
|
||||||
|
|
||||||
|
(test 1367 count f1)
|
||||||
|
(test 1367 count f2)
|
||||||
|
|
||||||
|
(delete-file f1)
|
||||||
|
(delete-file f2))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(report-errs)
|
(report-errs)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -323,6 +323,13 @@
|
||||||
(eqv? (bytes-ref bstr (fx+ i 1)) (char->integer #\linefeed)))
|
(eqv? (bytes-ref bstr (fx+ i 1)) (char->integer #\linefeed)))
|
||||||
(finish i (fx+ i 2))]
|
(finish i (fx+ i 2))]
|
||||||
[cr?
|
[cr?
|
||||||
(finish i (fx+ i 1))]
|
(cond
|
||||||
|
[(and crlf?
|
||||||
|
((fx+ i 1) . fx= . end))
|
||||||
|
;; needs more input to decide
|
||||||
|
(end-atomic)
|
||||||
|
#f]
|
||||||
|
[else
|
||||||
|
(finish i (fx+ i 1))])]
|
||||||
[else (loop (fx+ i 1))])]
|
[else (loop (fx+ i 1))])]
|
||||||
[else (loop (fx+ i 1))])])))
|
[else (loop (fx+ i 1))])])))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user