@@ -59,42 +59,42 @@ end # os test
5959# # ENV: hash interface ##
6060
6161"""
62- EnvHash () -> EnvHash
62+ EnvDict () -> EnvDict
6363
6464A singleton of this type provides a hash table interface to environment variables.
6565"""
66- mutable struct EnvHash <: Associative{String,String} ; end
66+ struct EnvDict <: Associative{String,String} ; end
6767
6868"""
6969 ENV
7070
71- Reference to the singleton `EnvHash `, providing a dictionary interface to system environment
71+ Reference to the singleton `EnvDict `, providing a dictionary interface to system environment
7272variables.
7373"""
74- const ENV = EnvHash ()
74+ const ENV = EnvDict ()
7575
76- similar (:: EnvHash ) = Dict {String,String} ()
76+ similar (:: EnvDict ) = Dict {String,String} ()
7777
78- getindex (:: EnvHash , k:: AbstractString ) = access_env (k-> throw (KeyError (k)), k)
79- get (:: EnvHash , k:: AbstractString , def) = access_env (k-> def, k)
80- get (f:: Callable , :: EnvHash , k:: AbstractString ) = access_env (k-> f (), k)
81- in (k:: AbstractString , :: KeyIterator{EnvHash } ) = _hasenv (k)
82- pop! (:: EnvHash , k:: AbstractString ) = (v = ENV [k]; _unsetenv (k); v)
83- pop! (:: EnvHash , k:: AbstractString , def) = haskey (ENV ,k) ? pop! (ENV ,k) : def
84- delete! (:: EnvHash , k:: AbstractString ) = (_unsetenv (k); ENV )
85- setindex! (:: EnvHash , v, k:: AbstractString ) = _setenv (k,string (v))
86- push! (:: EnvHash , k:: AbstractString , v) = setindex! (ENV , v, k)
78+ getindex (:: EnvDict , k:: AbstractString ) = access_env (k-> throw (KeyError (k)), k)
79+ get (:: EnvDict , k:: AbstractString , def) = access_env (k-> def, k)
80+ get (f:: Callable , :: EnvDict , k:: AbstractString ) = access_env (k-> f (), k)
81+ in (k:: AbstractString , :: KeyIterator{EnvDict } ) = _hasenv (k)
82+ pop! (:: EnvDict , k:: AbstractString ) = (v = ENV [k]; _unsetenv (k); v)
83+ pop! (:: EnvDict , k:: AbstractString , def) = haskey (ENV ,k) ? pop! (ENV ,k) : def
84+ delete! (:: EnvDict , k:: AbstractString ) = (_unsetenv (k); ENV )
85+ setindex! (:: EnvDict , v, k:: AbstractString ) = _setenv (k,string (v))
86+ push! (:: EnvDict , k:: AbstractString , v) = setindex! (ENV , v, k)
8787
8888if Sys. iswindows ()
89- start (hash:: EnvHash ) = (pos = ccall (:GetEnvironmentStringsW ,stdcall,Ptr{UInt16},()); (pos,pos))
90- function done (hash:: EnvHash , block:: Tuple{Ptr{UInt16},Ptr{UInt16}} )
89+ start (hash:: EnvDict ) = (pos = ccall (:GetEnvironmentStringsW ,stdcall,Ptr{UInt16},()); (pos,pos))
90+ function done (hash:: EnvDict , block:: Tuple{Ptr{UInt16},Ptr{UInt16}} )
9191 if unsafe_load (block[1 ]) == 0
9292 ccall (:FreeEnvironmentStringsW , stdcall, Int32, (Ptr{UInt16},), block[2 ])
9393 return true
9494 end
9595 return false
9696 end
97- function next (hash:: EnvHash , block:: Tuple{Ptr{UInt16},Ptr{UInt16}} )
97+ function next (hash:: EnvDict , block:: Tuple{Ptr{UInt16},Ptr{UInt16}} )
9898 pos = block[1 ]
9999 blk = block[2 ]
100100 len = ccall (:wcslen , UInt, (Ptr{UInt16},), pos)
@@ -108,10 +108,10 @@ if Sys.iswindows()
108108 return (Pair {String,String} (m. captures[1 ], m. captures[2 ]), (pos+ (len+ 1 )* 2 , blk))
109109 end
110110else # !windows
111- start (:: EnvHash ) = 0
112- done (:: EnvHash , i) = (ccall (:jl_environ , Any, (Int32,), i) === nothing )
111+ start (:: EnvDict ) = 0
112+ done (:: EnvDict , i) = (ccall (:jl_environ , Any, (Int32,), i) === nothing )
113113
114- function next (:: EnvHash , i)
114+ function next (:: EnvDict , i)
115115 env = ccall (:jl_environ , Any, (Int32,), i)
116116 if env === nothing
117117 throw (BoundsError ())
@@ -126,15 +126,15 @@ else # !windows
126126end # os-test
127127
128128# TODO : Make these more efficent
129- function length (:: EnvHash )
129+ function length (:: EnvDict )
130130 i = 0
131131 for (k,v) in ENV
132132 i += 1
133133 end
134134 return i
135135end
136136
137- function show (io:: IO , :: EnvHash )
137+ function show (io:: IO , :: EnvDict )
138138 for (k,v) = ENV
139139 println (io, " $k =$v " )
140140 end
0 commit comments