aboutsummaryrefslogtreecommitdiff
path: root/src/main/clojure/clojure
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2010-07-14 11:30:52 -0400
committerStuart Halloway <stu@thinkrelevance.com>2010-07-14 11:30:52 -0400
commit25e1e10d9a9a61576fe990a05ac1c72d5a02283d (patch)
tree73f08905d21175a55cec62436bf584074e83ae06 /src/main/clojure/clojure
parentd552766eb6153fffc1b384f5fc8055c74bd29247 (diff)
parent29b42bdfec1726976d5c1125d10ee0d811d197ff (diff)
Merge branch '1.2.x' of github.com:richhickey/clojure-contrib into 1.2.x
Diffstat (limited to 'src/main/clojure/clojure')
-rw-r--r--src/main/clojure/clojure/contrib/http/agent.clj8
-rw-r--r--src/main/clojure/clojure/contrib/math.clj2
-rw-r--r--src/main/clojure/clojure/contrib/pprint/cl_format.clj12
-rw-r--r--src/main/clojure/clojure/contrib/pprint/column_writer.clj2
-rw-r--r--src/main/clojure/clojure/contrib/pprint/pretty_writer.clj2
5 files changed, 17 insertions, 9 deletions
diff --git a/src/main/clojure/clojure/contrib/http/agent.clj b/src/main/clojure/clojure/contrib/http/agent.clj
index edae6f96..cd257bb7 100644
--- a/src/main/clojure/clojure/contrib/http/agent.clj
+++ b/src/main/clojure/clojure/contrib/http/agent.clj
@@ -79,6 +79,10 @@
"Sets the instance method, redirect behavior, and request headers of
the HttpURLConnection."
[#^HttpURLConnection conn options]
+ (when-let [t (:connect-timeout options)]
+ (.setConnectTimeout conn t))
+ (when-let [t (:read-timeout options)]
+ (.setReadTimeout conn t))
(.setRequestMethod conn (:method options))
(.setInstanceFollowRedirects conn (:follow-redirects options))
(doseq [[name value] (:headers options)]
@@ -95,7 +99,7 @@
(defn- connection-success? [#^HttpURLConnection conn]
"Returns true if the HttpURLConnection response code is in the 2xx
range."
- (= 2 (unchecked-divide (.getResponseCode conn) 100)))
+ (= 2 (quot (.getResponseCode conn) 100)))
(defn- open-response
"Agent action that opens the response body stream on the HTTP
@@ -133,7 +137,7 @@
"Returns true if the response status of the HTTP agent begins with
digit, an Integer."
[digit http-agnt]
- (= digit (unchecked-divide (.getResponseCode
+ (= digit (quot (.getResponseCode
#^HttpURLConnection (::connection @http-agnt))
100)))
diff --git a/src/main/clojure/clojure/contrib/math.clj b/src/main/clojure/clojure/contrib/math.clj
index cef32bf2..56007c71 100644
--- a/src/main/clojure/clojure/contrib/math.clj
+++ b/src/main/clojure/clojure/contrib/math.clj
@@ -104,7 +104,7 @@ Returns an exact number if the base is an exact number and the power is an integ
expt (fn [x y] [(class x) (class y)]))
(defn- expt-int [base pow]
- (loop [n pow, y 1, z base]
+ (loop [n pow, y (num 1), z base]
(let [t (bit-and n 1), n (bit-shift-right n 1)]
(cond
(zero? t) (recur n y (* z z))
diff --git a/src/main/clojure/clojure/contrib/pprint/cl_format.clj b/src/main/clojure/clojure/contrib/pprint/cl_format.clj
index 292f7f86..b93d535a 100644
--- a/src/main/clojure/clojure/contrib/pprint/cl_format.clj
+++ b/src/main/clojure/clojure/contrib/pprint/cl_format.clj
@@ -245,7 +245,7 @@ http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm
for improved performance"
[base val]
(let [format-str (get java-base-formats base)]
- (if (and format-str (integer? val))
+ (if (and format-str (integer? val) (-> val class .getName (.startsWith "java.")))
(clojure.core/format format-str val)
(base-str base val))))
@@ -423,9 +423,9 @@ Note this should only be used for the last one in the sequence"
not-teens (or (< 11 low-two-digits) (> 19 low-two-digits))
low-digit (rem low-two-digits 10)]
(print (cond
- (and (= low-digit 1) not-teens) "st"
- (and (= low-digit 2) not-teens) "nd"
- (and (= low-digit 3) not-teens) "rd"
+ (and (== low-digit 1) not-teens) "st"
+ (and (== low-digit 2) not-teens) "nd"
+ (and (== low-digit 3) not-teens) "rd"
:else "th")))))))
navigator))
@@ -834,7 +834,7 @@ Note this should only be used for the last one in the sequence"
args (init-navigator arg-list)]
(loop [count 0
args args
- last-pos -1]
+ last-pos (num -1)]
(if (and (not max-count) (= (:pos args) last-pos) (> count 1))
;; TODO get the offset in here and call format exception
(throw (RuntimeException. "%{ construct not consuming any arguments: Infinite loop!")))
@@ -880,7 +880,7 @@ Note this should only be used for the last one in the sequence"
[param-clause navigator])]
(loop [count 0
navigator navigator
- last-pos -1]
+ last-pos (num -1)]
(if (and (not max-count) (= (:pos navigator) last-pos) (> count 1))
;; TODO get the offset in here and call format exception
(throw (RuntimeException. "%@{ construct not consuming any arguments: Infinite loop!")))
diff --git a/src/main/clojure/clojure/contrib/pprint/column_writer.clj b/src/main/clojure/clojure/contrib/pprint/column_writer.clj
index 65b94904..63718e29 100644
--- a/src/main/clojure/clojure/contrib/pprint/column_writer.clj
+++ b/src/main/clojure/clojure/contrib/pprint/column_writer.clj
@@ -75,4 +75,6 @@
(.write #^Writer (get-field this :base) s))
Integer
+ (write-char this x)
+ Long
(write-char this x))))))))
diff --git a/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj b/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj
index ba9c78de..91a1bcca 100644
--- a/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj
+++ b/src/main/clojure/clojure/contrib/pprint/pretty_writer.clj
@@ -402,6 +402,8 @@
(add-to-buffer this (make-buffer-blob s white-space oldpos newpos))))))
Integer
+ (write-char this x)
+ Long
(write-char this x))))
(flush []