pike.git/
lib/
master.pike.in
Branch:
Tag:
Non-build tags
All tags
No tags
2001-11-13
2001-11-13 15:46:22 by Tomas Nilsson <tomas@roxen.com>
a71f83a350d8f5839167a3e4c447ffe4c7cb9e4f (
29
lines) (+
21
/-
8
)
[
Show
|
Annotate
]
Branch:
7.9
Made getenv/putenv case insensitive on NT.
Rev: lib/master.pike.in:1.178
1:
/* -*- Pike -*- *
-
* $Id: master.pike.in,v 1.
177
2001/11/
12
13:
38
:
04
mast
Exp $
+
* $Id: master.pike.in,v 1.
178
2001/11/
13
15
:
46
:
22
tomas
Exp $
* * Master-file for Pike. *
297:
#define master_file_stat file_stat #endif
-
mapping (string:string) environment=([]);
+
mapping (string:
array(
string)
)
environment=([]);
-
+
//! @decl string getenv(string varname) //! @decl mapping(string:string) getenv() //! @appears getenv //!
-
//! When called with no arguments, a mapping with all current
envrionment
+
//! When called with no arguments, a mapping with all current
environment
//! variables will be returned. //! //! If the @[varname] argument has been given, the value of the environment //! variable with the name @[varname] will be returned. If no such //! environment variable exists, @tt{0@} (zero) will be returned. //!
-
+
//! On NT the environment variable name is case insensitive.
+
//!
string|mapping(string:string) getenv(string|void s) {
-
if(!s) return environment
+
(
[]
);
-
return environment[s];
+
if(!s) return
aggregate_mapping( @(values(
environment
)*({})
)
);
+
#ifdef __NT__
+
s = lower_case
(
s
);
+
#endif
+
return environment[s]
&& environment[s][1]
;
}
378:
//! @appears putenv //! Sets the environment variable @[varname] to @[value]. //!
+
//! On NT the environment variable name is case insensitive.
+
//!
//! @seealso //! @[getenv()] //! void putenv(string varname, string value) {
-
environment[varname] = value;
+
string index = varname;
+
#ifdef __NT__
+
index = lower_case(varname);
+
if (
environment[
index] && environment[index][0])
+
varname
= environment[index
]
[0];
+
#endif
+
environment[index]
=
({ varname,
value
})
;
} //! @appears normalize_path
1461:
sscanf(b,"%s=%s",a,b); a="="+a; }
-
environment[
a
]=
b;
+
putenv(
a
,
b
)
;
}else{ werror("Broken environment var %s\n",a); }