зеркало из https://github.com/github/ruby.git
hash.c: call w32_getenv pointer
* hash.c (w32_getenv): call rb_w32_getenv and rb_w32_ugetenv via this pointer without further comparisons. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
dd96e0c76a
Коммит
cb0cde7f24
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Aug 5 17:04:02 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* hash.c (w32_getenv): call rb_w32_getenv and rb_w32_ugetenv via
|
||||||
|
this pointer without further comparisons.
|
||||||
|
|
||||||
Thu Aug 4 11:54:30 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Aug 4 11:54:30 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* hash.c (env_assoc): the encoding of the value should be the
|
* hash.c (env_assoc): the encoding of the value should be the
|
||||||
|
|
20
hash.c
20
hash.c
|
@ -2896,17 +2896,21 @@ static char **my_environ;
|
||||||
#undef environ
|
#undef environ
|
||||||
#define environ my_environ
|
#define environ my_environ
|
||||||
#undef getenv
|
#undef getenv
|
||||||
static inline char *
|
static char *(*w32_getenv)(const char*);
|
||||||
w32_getenv(const char *name)
|
static char *
|
||||||
|
w32_getenv_unknown(const char *name)
|
||||||
{
|
{
|
||||||
static int binary = -1;
|
char *(*func)(const char*);
|
||||||
static int locale = -1;
|
if (rb_locale_encindex() == rb_ascii8bit_encindex()) {
|
||||||
if (binary < 0) {
|
func = rb_w32_getenv;
|
||||||
binary = rb_ascii8bit_encindex();
|
|
||||||
locale = rb_locale_encindex();
|
|
||||||
}
|
}
|
||||||
return locale == binary ? rb_w32_getenv(name) : rb_w32_ugetenv(name);
|
else {
|
||||||
|
func = rb_w32_ugetenv;
|
||||||
|
}
|
||||||
|
/* atomic assignment in flat memory model */
|
||||||
|
return (w32_getenv = func)(name);
|
||||||
}
|
}
|
||||||
|
static char *(*w32_getenv)(const char*) = w32_getenv_unknown;
|
||||||
#define getenv(n) w32_getenv(n)
|
#define getenv(n) w32_getenv(n)
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#undef environ
|
#undef environ
|
||||||
|
|
Загрузка…
Ссылка в новой задаче