From accb677f0e1de58aaa4a0a2fed1b473051523886 Mon Sep 17 00:00:00 2001 From: Matthias Felleisen Date: Fri, 19 Aug 2011 21:50:17 -0400 Subject: [PATCH] write and read files in 'text' mode; Closes PR12120 --- collects/2htdp/batch-io.rkt | 7 +++++-- collects/2htdp/tests/batch-io.rkt | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/collects/2htdp/batch-io.rkt b/collects/2htdp/batch-io.rkt index c44a1ff5ca..e55a9f59d4 100644 --- a/collects/2htdp/batch-io.rkt +++ b/collects/2htdp/batch-io.rkt @@ -1,4 +1,4 @@ -#lang scheme +#lang racket (require (for-syntax syntax/parse) srfi/13 htdp/error @@ -109,7 +109,9 @@ (dynamic-wind (lambda () (with-output-to-file t - (lambda () (for-each displayln los)) #:exists 'replace)) + (lambda () (for-each displayln los)) + #:mode 'text + #:exists 'replace)) (lambda () (reader (path->string t))) (lambda () @@ -142,6 +144,7 @@ ;; read a file as a list of X where process-accu is applied to accu when eof (define (read-chunks f read-chunk process-accu) (with-input-from-file f + #:mode 'text (lambda () (let loop ([accu '()]) (define nxt (read-chunk)) diff --git a/collects/2htdp/tests/batch-io.rkt b/collects/2htdp/tests/batch-io.rkt index a4fc8a930a..6a7fa1148c 100644 --- a/collects/2htdp/tests/batch-io.rkt +++ b/collects/2htdp/tests/batch-io.rkt @@ -48,10 +48,10 @@ eos (string #\newline) (second test2-as-list)))) -;(write-file file test1) +(write-file file test1) (check-true (string=? (simulate-file read-file test1) test1) "read-file 1") -;(write-file file test2) +(write-file file test2) (check-true (string=? (simulate-file read-file test2) test2) "read-file 2") (write-file file test1)