Uncook newlines into CRLFs on the way out.

This commit is contained in:
Tony Garnock-Jones 2011-10-26 19:11:41 -04:00
parent 6db845eda5
commit c42934d07b
1 changed files with 16 additions and 1 deletions

View File

@ -64,4 +64,19 @@
(lambda (new-b feedback)
(write-string feedback raw-out)
(loop new-b))))))))))
(values cooked-in raw-out))
(values cooked-in (cook-output raw-out)))
(define (cook-output raw-out)
(define-values (cooked-in cooked-out) (make-pipe))
(thread
(lambda ()
(define buffer (make-bytes 4096))
(let loop ()
(define count (read-bytes-avail! buffer cooked-in))
(if (eof-object? count)
(begin (close-input-port cooked-in)
(close-output-port raw-out))
(let ((raw-data (regexp-replace* #"\n" (subbytes buffer 0 count) #"\r\n")))
(write-bytes raw-data raw-out)
(loop))))))
cooked-out)