reduce tzset
* time.c (rb_localtime_r): call tzset() only after TZ environment variable is changed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a22232cd93
commit
4bc1669127
9
hash.c
9
hash.c
@ -3315,6 +3315,9 @@ env_str_new2(const char *ptr)
|
|||||||
|
|
||||||
static int env_path_tainted(const char *);
|
static int env_path_tainted(const char *);
|
||||||
|
|
||||||
|
static const char TZ_ENV[] = "TZ";
|
||||||
|
extern int ruby_tz_update;
|
||||||
|
|
||||||
static rb_encoding *
|
static rb_encoding *
|
||||||
env_encoding_for(const char *name, const char *ptr)
|
env_encoding_for(const char *name, const char *ptr)
|
||||||
{
|
{
|
||||||
@ -3396,6 +3399,9 @@ env_delete(VALUE obj, VALUE name)
|
|||||||
RB_GC_GUARD(name);
|
RB_GC_GUARD(name);
|
||||||
path_tainted = 0;
|
path_tainted = 0;
|
||||||
}
|
}
|
||||||
|
else if (ENVMATCH(nam, TZ_ENV)) {
|
||||||
|
ruby_tz_update = 0;
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
@ -3755,6 +3761,9 @@ env_aset(VALUE obj, VALUE nm, VALUE val)
|
|||||||
path_tainted_p(value);
|
path_tainted_p(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ENVMATCH(name, TZ_ENV)) {
|
||||||
|
ruby_tz_update = 0;
|
||||||
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
time.c
8
time.c
@ -647,12 +647,18 @@ static struct vtm *localtimew(wideval_t timew, struct vtm *result);
|
|||||||
static int leap_year_p(long y);
|
static int leap_year_p(long y);
|
||||||
#define leap_year_v_p(y) leap_year_p(NUM2LONG(modv((y), INT2FIX(400))))
|
#define leap_year_v_p(y) leap_year_p(NUM2LONG(modv((y), INT2FIX(400))))
|
||||||
|
|
||||||
|
int ruby_tz_update;
|
||||||
|
|
||||||
static struct tm *
|
static struct tm *
|
||||||
rb_localtime_r(const time_t *t, struct tm *result)
|
rb_localtime_r(const time_t *t, struct tm *result)
|
||||||
{
|
{
|
||||||
#if defined __APPLE__ && defined __LP64__
|
#if defined __APPLE__ && defined __LP64__
|
||||||
if (*t != (time_t)(int)*t) return NULL;
|
if (*t != (time_t)(int)*t) return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
if (!ruby_tz_update) {
|
||||||
|
ruby_tz_update = 1;
|
||||||
|
tzset();
|
||||||
|
}
|
||||||
#ifdef HAVE_GMTIME_R
|
#ifdef HAVE_GMTIME_R
|
||||||
result = localtime_r(t, result);
|
result = localtime_r(t, result);
|
||||||
#else
|
#else
|
||||||
@ -678,7 +684,7 @@ rb_localtime_r(const time_t *t, struct tm *result)
|
|||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#define LOCALTIME(tm, result) (tzset(),rb_localtime_r((tm), &(result)))
|
#define LOCALTIME(tm, result) rb_localtime_r((tm), &(result))
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_TM_TM_GMTOFF
|
#ifndef HAVE_STRUCT_TM_TM_GMTOFF
|
||||||
static struct tm *
|
static struct tm *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user