rktio: fix bug in 'text mode on Windows
If a #\return lined up in just the wrong way with a file-read request, then the #\return could get mishandled.
This commit is contained in:
parent
b6b9d0d409
commit
e255c737b5
|
@ -371,6 +371,23 @@
|
|||
|
||||
(delete-directory/files dir))
|
||||
|
||||
;; ----------------------------------------
|
||||
;; Check 'text mode conversion
|
||||
;; The content of "text.rktd" once triggered a bug in 'text
|
||||
;; mode conversion on Windows by having line breaks as just
|
||||
;; the right place
|
||||
|
||||
(let ()
|
||||
(define text (call-with-input-file (build-path (current-load-relative-directory)
|
||||
"text.rktd")
|
||||
read))
|
||||
(define tmp (make-temporary-file "tmp-data~a"))
|
||||
(call-with-output-file tmp #:exists 'truncate (lambda (o) (write-string text o)))
|
||||
(define str (file->string tmp #:mode 'text))
|
||||
(test #t values (equal? str (if (eq? (system-type) 'windows)
|
||||
(regexp-replace* #rx"\r\n" text "\n")
|
||||
text))))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
1
pkgs/racket-test-core/tests/racket/text.rktd
Normal file
1
pkgs/racket-test-core/tests/racket/text.rktd
Normal file
File diff suppressed because one or more lines are too long
|
@ -797,6 +797,7 @@ intptr_t rktio_read_converted(rktio_t *rktio, rktio_fd_t *rfd, char *buffer, int
|
|||
}
|
||||
} else {
|
||||
/* read after first byte installed into the buffer */
|
||||
rfd->has_pending_byte = 0;
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user