|
9 | 9 | (ns clojure.string |
10 | 10 | (:refer-clojure :exclude (replace reverse)) |
11 | 11 | (:import (regexp *Regexp) |
12 | | - (github.com:glojurelang:glojure:pkg:lang ToString NewIllegalArgumentError Char CharAt))) |
| 12 | + #_(github.com:glojurelang:glojure:pkg:lang ToString NewIllegalArgumentError Char CharAt) |
| 13 | + (github.com:glojurelang:glojure:pkg:lang))) |
13 | 14 |
|
14 | 15 | (set! *warn-on-reflection* true) |
15 | 16 |
|
16 | 17 | (defn- check-string |
17 | 18 | [maybe-s] |
18 | 19 | (if (nil? maybe-s) |
19 | | - (throw (NewIllegalArgumentError "cannot call clojure.string function on nil")) |
| 20 | + (throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError "cannot call clojure.string function on nil")) |
20 | 21 | maybe-s)) |
21 | 22 |
|
22 | 23 | (defn ^go/string reverse |
|
45 | 46 | (do (.appendReplacement m buffer (re-quote-replacement (f (re-groups m)))) |
46 | 47 | (recur (.find m))) |
47 | 48 | (do (.appendTail m buffer) |
48 | | - (ToString buffer))))) |
| 49 | + (github.com:glojurelang:glojure:pkg:lang.ToString buffer))))) |
49 | 50 | s))) |
50 | 51 |
|
51 | 52 | (defn ^go/string replace |
|
76 | 77 | [^go/string s match replacement] |
77 | 78 | (let [s (check-string s)] |
78 | 79 | (cond |
79 | | - (instance? Char match) (strings.ReplaceAll s match replacement) |
| 80 | + (instance? github.com:glojurelang:glojure:pkg:lang.Char match) (strings.ReplaceAll s match replacement) |
80 | 81 | (instance? go/string match) (strings.ReplaceAll s match replacement) |
81 | 82 | (instance? *Regexp match) (if (instance? go/string replacement) |
82 | 83 | (.replaceAllString ^*Regexp match s replacement) |
83 | 84 | (replace-by s match replacement)) |
84 | | - :else (throw (NewIllegalArgumentError (str "Invalid match arg: " match)))))) |
| 85 | + :else (throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError (str "Invalid match arg: " match)))))) |
85 | 86 |
|
86 | 87 | (defn- replace-first-by |
87 | 88 | [^go/string s ^*Regexp re f] |
|
95 | 96 | s))) |
96 | 97 |
|
97 | 98 | (defn- replace-first-char |
98 | | - [^go/string s ^Char match replace] |
99 | | - (let [s (ToString s) |
| 99 | + [^go/string s ^github.com:glojurelang:glojure:pkg:lang.Char match replace] |
| 100 | + (let [s (github.com:glojurelang:glojure:pkg:lang.ToString s) |
100 | 101 | i (strings.Index s (int match))] |
101 | 102 | (if (= -1 i) |
102 | 103 | s |
103 | 104 | (str (subs s 0 i) replace (subs s (inc i)))))) |
104 | 105 |
|
105 | 106 | (defn- replace-first-str |
106 | 107 | [^go/string s ^go/string match ^go/string replace] |
107 | | - (let [^go/string s (ToString s) |
| 108 | + (let [^go/string s (github.com:glojurelang:glojure:pkg:lang.ToString s) |
108 | 109 | i (strings.Index s match)] |
109 | 110 | (if (= -1 i) |
110 | 111 | s |
|
139 | 140 | [^go/string s match replacement] |
140 | 141 | (let [s (check-string s)] |
141 | 142 | (cond |
142 | | - (instance? Char match) |
| 143 | + (instance? github.com:glojurelang:glojure:pkg:lang.Char match) |
143 | 144 | (replace-first-char s match replacement) |
144 | 145 | (instance? go/string match) |
145 | | - (replace-first-str s (ToString ^go/string match) |
146 | | - (ToString ^go/string replacement)) |
| 146 | + (replace-first-str s (github.com:glojurelang:glojure:pkg:lang.ToString ^go/string match) |
| 147 | + (github.com:glojurelang:glojure:pkg:lang.ToString ^go/string replacement)) |
147 | 148 | (instance? *Regexp match) |
148 | 149 | (if (instance? go/string replacement) |
149 | 150 | (let [done (atom false)] |
|
155 | 156 | (reset! done true) |
156 | 157 | (.ReplaceAllString ^*Regexp match m replacement)))))) |
157 | 158 | (replace-first-by s match replacement)) |
158 | | - :else (throw (NewIllegalArgumentError (str "Invalid match arg: " match)))))) |
| 159 | + :else (throw (github.com:glojurelang:glojure:pkg:lang.NewIllegalArgumentError (str "Invalid match arg: " match)))))) |
159 | 160 |
|
160 | 161 |
|
161 | 162 | (defn ^go/string join |
|
195 | 196 | the maximum number of parts. Not lazy. Returns vector of the parts. |
196 | 197 | Trailing empty strings are not returned - pass limit of -1 to return all." |
197 | 198 | {:added "1.2"} |
198 | | - ([^go/string s ^*Regexp re] |
| 199 | + ([^go/string s ^regexp.*Regexp re] |
199 | 200 | (github.com:glojurelang:glojure:pkg:lang.CreateOwningLazilyPersistentVector (.split re s -1))) |
200 | | - ([ ^go/string s ^*Regexp re limit] |
| 201 | + ([ ^go/string s ^regexp.*Regexp re limit] |
201 | 202 | (github.com:glojurelang:glojure:pkg:lang.CreateOwningLazilyPersistentVector (.split re s limit)))) |
202 | 203 |
|
203 | 204 | (defn split-lines |
204 | 205 | "Splits s on \\n or \\r\\n. Trailing empty lines are not returned." |
205 | 206 | {:added "1.2"} |
206 | 207 | [^go/string s] |
207 | | - (split s #"\r?\n")) |
| 208 | + #_(split s #"\r?\n") |
| 209 | + (split s (re-pattern "\\r?\\n"))) |
208 | 210 |
|
209 | 211 | (defn ^go/string trim |
210 | 212 | "Removes whitespace from both ends of string." |
|
239 | 241 | (loop [index (int 0)] |
240 | 242 | (if (= (count s) index) |
241 | 243 | true |
242 | | - (if (unicode.IsSpace (CharAt s index)) |
| 244 | + (if (unicode.IsSpace (github.com:glojurelang:glojure:pkg:lang.CharAt s index)) |
243 | 245 | (recur (inc index)) |
244 | 246 | false))) |
245 | 247 | true)) |
|
263 | 265 | ([^go/string s value] |
264 | 266 | (let [s (check-string s) |
265 | 267 | result ^long |
266 | | - (if (instance? Char value) |
267 | | - (strings.IndexRune s ^go/rune (go/rune ^Char value)) |
| 268 | + (if (instance? github.com:glojurelang:glojure:pkg:lang.Char value) |
| 269 | + (strings.IndexRune s ^go/rune (go/rune ^github.com:glojurelang:glojure:pkg:lang.Char value)) |
268 | 270 | (strings.Index s ^go/string value))] |
269 | 271 | (if (= result -1) |
270 | 272 | nil |
|
273 | 275 | (let [from-index (min (count s) (max 0 (unchecked-int from-index))) |
274 | 276 | s (subs (check-string s) from-index) |
275 | 277 | result ^long |
276 | | - (if (instance? Char value) |
277 | | - (strings.IndexRune s ^go/rune (go/rune ^Char value)) |
| 278 | + (if (instance? github.com:glojurelang:glojure:pkg:lang.Char value) |
| 279 | + (strings.IndexRune s ^go/rune (go/rune ^github.com:glojurelang:glojure:pkg:lang.Char value)) |
278 | 280 | (strings.Index s ^go/string value))] |
279 | 281 | (if (= result -1) |
280 | 282 | nil |
|
302 | 304 | "True if s starts with substr." |
303 | 305 | {:added "1.8"} |
304 | 306 | [^go/string s ^go/string substr] |
305 | | - (strings.HasPrefix (ToString s) substr)) |
| 307 | + (strings.HasPrefix (github.com:glojurelang:glojure:pkg:lang.ToString s) substr)) |
306 | 308 |
|
307 | 309 | (defn ends-with? |
308 | 310 | "True if s ends with substr." |
309 | 311 | {:added "1.8"} |
310 | 312 | [^go/string s ^go/string substr] |
311 | | - (strings.HasSuffix (ToString s) substr)) |
| 313 | + (strings.HasSuffix (github.com:glojurelang:glojure:pkg:lang.ToString s) substr)) |
312 | 314 |
|
313 | 315 | (defn includes? |
314 | 316 | "True if s includes substr." |
315 | 317 | {:added "1.8"} |
316 | 318 | [^go/string s ^go/string substr] |
317 | | - (strings.Contains (ToString s) substr)) |
| 319 | + (strings.Contains (github.com:glojurelang:glojure:pkg:lang.ToString s) substr)) |
0 commit comments