diff options
-rw-r--r-- | src/clj/clojure/pprint/cl_format.clj | 9 | ||||
-rw-r--r-- | test/clojure/test_clojure/pprint/test_cl_format.clj | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/clj/clojure/pprint/cl_format.clj b/src/clj/clojure/pprint/cl_format.clj index 0a74bbd5..ef5c9810 100644 --- a/src/clj/clojure/pprint/cl_format.clj +++ b/src/clj/clojure/pprint/cl_format.clj @@ -1088,10 +1088,11 @@ Note this should only be used for the last one in the sequence" (let [s ^String x] (.write writer ^String (capitalize-string (.toLowerCase s) @last-was-whitespace?)) - (dosync - (ref-set last-was-whitespace? - (Character/isWhitespace - ^Character (nth s (dec (count s))))))) + (when (pos? (.length s)) + (dosync + (ref-set last-was-whitespace? + (Character/isWhitespace + ^Character (nth s (dec (count s)))))))) Integer (let [c (char x)] diff --git a/test/clojure/test_clojure/pprint/test_cl_format.clj b/test/clojure/test_clojure/pprint/test_cl_format.clj index 95b324d1..8a951040 100644 --- a/test/clojure/test_clojure/pprint/test_cl_format.clj +++ b/test/clojure/test_clojure/pprint/test_cl_format.clj @@ -253,6 +253,8 @@ (cl-format nil "~:(~A~)" 'kludgy-hash-search) "Kludgy-Hash-Search" (cl-format nil "~:(~A~)" "DON'T!") "Don'T!" ;not "Don't!" (cl-format nil "~:(~A~)" "pipe 13a, foo16c") "Pipe 13a, Foo16c" + (cl-format nil "~:(~A~)" nil) "Nil" + (cl-format nil "~:(~A~)" "") "" ) (simple-tests square-bracket-tests |