fix line counting with mixed CR and LF
A CR by itself could be incorrectly treated as preceding a later LF, which would form a CRLF combination if they had been adjacent. Closes #3033
This commit is contained in:
parent
654f821919
commit
4ed253d66e
|
@ -683,6 +683,21 @@
|
|||
(test 0 syntax-column stx)
|
||||
(test 1026 syntax-position stx))))
|
||||
|
||||
;; Test provided by @wcs4217
|
||||
(let ([p (open-input-bytes #"\rx\ny")])
|
||||
(port-count-lines! p)
|
||||
(test-values '(1 0 1) (lambda () (port-next-location p)))
|
||||
(test #\return read-char p)
|
||||
(test-values '(2 0 2) (lambda () (port-next-location p)))
|
||||
(test #\x read-char p)
|
||||
(test-values '(2 1 3) (lambda () (port-next-location p)))
|
||||
(test #\newline read-char p)
|
||||
(test-values '(3 0 4) (lambda () (port-next-location p)))
|
||||
(test #\y read-char p)
|
||||
(test-values '(3 1 5) (lambda () (port-next-location p)))
|
||||
(test eof read-char p)
|
||||
(test-values '(3 1 5) (lambda () (port-next-location p))))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Check that if the initial commit thread is killed, then
|
||||
;; another commit thread is broken, that the second doesn't
|
||||
|
|
|
@ -1043,6 +1043,7 @@ XFORM_NONGCING static void do_count_lines(Scheme_Port *ip, const char *buffer, i
|
|||
ip->column = 0;
|
||||
} else {
|
||||
ip->charsSinceNewline += c;
|
||||
ip->was_cr = 0;
|
||||
}
|
||||
|
||||
/* Do the last line to get the column count right and to
|
||||
|
|
Loading…
Reference in New Issue
Block a user