Skip to content

Commit c6756a8

Browse files
committed
move read-edn* into clojure.edn namespace
1 parent 21425a6 commit c6756a8

File tree

3 files changed

+50
-37
lines changed

3 files changed

+50
-37
lines changed

build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<arg value="clojure.core.protocols"/>
5656
<arg value="clojure.main"/>
5757
<arg value="clojure.set"/>
58+
<arg value="clojure.edn"/>
5859
<arg value="clojure.xml"/>
5960
<arg value="clojure.zip"/>
6061
<arg value="clojure.inspector"/>

src/clj/clojure/core.clj

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3394,7 +3394,7 @@
33943394
Note that read can execute code (controlled by *read-eval*),
33953395
and as such should be used only with trusted sources.
33963396
3397-
For data structure interop use read-edn"
3397+
For data structure interop use clojure.edn/read"
33983398
{:added "1.0"
33993399
:static true}
34003400
([]
@@ -3421,45 +3421,11 @@
34213421
Note that read-string can execute code (controlled by *read-eval*),
34223422
and as such should be used only with trusted sources.
34233423
3424-
For data structure interop use read-edn-string"
3424+
For data structure interop use clojure.edn/read-string"
34253425
{:added "1.0"
34263426
:static true}
34273427
[s] (clojure.lang.RT/readString s))
34283428

3429-
(defn read-edn
3430-
"Reads the next object from stream, which must be an instance of
3431-
java.io.PushbackReader or some derivee. stream defaults to the
3432-
current value of *in*.
3433-
3434-
Reads data in the edn format (subset of Clojure data):
3435-
http://edn-format.org
3436-
3437-
opts is a map that can include the following keys:
3438-
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
3439-
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
3440-
When not supplied, only the default-data-readers will be used.
3441-
:default - A function of two args, that will, if present and no reader is found for a tag,
3442-
be called with the tag and the value."
3443-
3444-
{:added "1.5"}
3445-
([]
3446-
(read-edn *in*))
3447-
([stream]
3448-
(read-edn {} stream))
3449-
([opts stream]
3450-
(clojure.lang.EdnReader/read stream opts)))
3451-
3452-
(defn read-edn-string
3453-
"Reads one object from the string s. Returns nil when s is nil or empty.
3454-
3455-
Reads data in the edn format (subset of Clojure data):
3456-
http://edn-format.org
3457-
3458-
opts is a map as per read-edn"
3459-
{:added "1.5"}
3460-
([s] (read-edn-string {:eof nil} s))
3461-
([opts s] (when s (clojure.lang.EdnReader/readString s opts))))
3462-
34633429
(defn subvec
34643430
"Returns a persistent vector of the items in vector from
34653431
start (inclusive) to end (exclusive). If end is not supplied,
@@ -5918,7 +5884,7 @@
59185884
"Defaults to true (or value specified by system property, see below)
59195885
***This setting implies that the full power of the reader is in play,
59205886
including syntax that can cause code to execute. It should never be
5921-
used with untrusted sources. See also: read-edn.***
5887+
used with untrusted sources. See also: clojure.edn/read.***
59225888
59235889
When set to logical false in the thread-local binding,
59245890
the eval reader (#=) and record/type literal syntax are disabled in read/load.

src/clj/clojure/edn.clj

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; Copyright (c) Rich Hickey. All rights reserved.
2+
; The use and distribution terms for this software are covered by the
3+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+
; which can be found in the file epl-v10.html at the root of this distribution.
5+
; By using this software in any fashion, you are agreeing to be bound by
6+
; the terms of this license.
7+
; You must not remove this notice, or any other, from this software.
8+
9+
(ns ^{:doc "edn reading."
10+
:author "Rich Hickey"}
11+
clojure.edn
12+
(:refer-clojure :exclude [read read-string]))
13+
14+
(defn read
15+
"Reads the next object from stream, which must be an instance of
16+
java.io.PushbackReader or some derivee. stream defaults to the
17+
current value of *in*.
18+
19+
Reads data in the edn format (subset of Clojure data):
20+
http://edn-format.org
21+
22+
opts is a map that can include the following keys:
23+
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
24+
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
25+
When not supplied, only the default-data-readers will be used.
26+
:default - A function of two args, that will, if present and no reader is found for a tag,
27+
be called with the tag and the value."
28+
29+
{:added "1.5"}
30+
([]
31+
(read *in*))
32+
([stream]
33+
(read {} stream))
34+
([opts stream]
35+
(clojure.lang.EdnReader/read stream opts)))
36+
37+
(defn read-string
38+
"Reads one object from the string s. Returns nil when s is nil or empty.
39+
40+
Reads data in the edn format (subset of Clojure data):
41+
http://edn-format.org
42+
43+
opts is a map as per clojure.edn/read"
44+
{:added "1.5"}
45+
([s] (read-string {:eof nil} s))
46+
([opts s] (when s (clojure.lang.EdnReader/readString s opts))))

0 commit comments

Comments
 (0)