From 1068147b704a4863ccec95d5b53b390027a2cc2c Mon Sep 17 00:00:00 2001
From: Ben Smith-Mannschott <bsmith.occs@gmail.com>
Date: Wed, 25 Aug 2010 22:02:07 +0200
Subject: [PATCH 2/2] t90 default reader implementation special cases for *append*

This prevents the machinery in io, which is designed to prevent this:

  (with-open [os (output-stream FOO)]
    (append-writer [w os]  ;; can't work since os wasn't opened
      (write-to w)))       ;; in append mode.

From also preventing this:

  (append-writer [w FOO]   ;; this could work, provided FOO can
    (write-to w))          ;; be made into a FileOutputStream
---
 src/main/clojure/clojure/contrib/io.clj |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/main/clojure/clojure/contrib/io.clj b/src/main/clojure/clojure/contrib/io.clj
index 4d79318..08a3495 100644
--- a/src/main/clojure/clojure/contrib/io.clj
+++ b/src/main/clojure/clojure/contrib/io.clj
@@ -182,7 +182,11 @@
 
 (def default-streams-impl
   {:reader #(reader (input-stream %))
-   :writer #(writer (output-stream %))
+   :writer #(if (not *append*)
+              (writer (output-stream %))
+              (BufferedWriter.
+               (OutputStreamWriter.
+                (output-stream %) *default-encoding*)))
    :input-stream #(throw (Exception. (str "Cannot open <" (pr-str %) "> as an InputStream.")))
    :output-stream #(throw (Exception. (str "Cannot open <" (pr-str %) "> as an OutputStream.")))})
 
-- 
1.7.1


