diff --git a/pkgs/racket-test-core/tests/racket/port.rktl b/pkgs/racket-test-core/tests/racket/port.rktl index 6b55a1c255..cf1802e26e 100644 --- a/pkgs/racket-test-core/tests/racket/port.rktl +++ b/pkgs/racket-test-core/tests/racket/port.rktl @@ -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 diff --git a/racket/src/racket/src/port.c b/racket/src/racket/src/port.c index 583e280c20..1c30ca2a66 100644 --- a/racket/src/racket/src/port.c +++ b/racket/src/racket/src/port.c @@ -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