diff options
author | Tom Faulhaber <git_net@infolace.com> | 2011-03-05 21:58:11 -0800 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2011-04-08 10:00:02 -0400 |
commit | f0a46155ba3b7243477515613573c6217c0291ab (patch) | |
tree | 8cd73ed9846fde45218f24680f4e38b70204276e | |
parent | dd49d07b75c619075156d1b38bae9a364ffb63b1 (diff) |
Fix handling of the ~:(~) directive when the contents are the empty string. Refs #751
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-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 |