ruby-changes:52352
From: usa <ko1@a...>
Date: Mon, 27 Aug 2018 22:59:17 +0900 (JST)
Subject: [ruby-changes:52352] usa:r64560 (ruby_2_4): merge revision(s) 63994: [Backport #14920]
usa 2018-08-27 22:59:09 +0900 (Mon, 27 Aug 2018) New Revision: 64560 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64560 Log: merge revision(s) 63994: [Backport #14920] reduce tzset * time.c (rb_localtime_r): call tzset() only after TZ environment variable is changed. Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/hash.c branches/ruby_2_4/time.c branches/ruby_2_4/version.h Index: ruby_2_4/time.c =================================================================== --- ruby_2_4/time.c (revision 64559) +++ ruby_2_4/time.c (revision 64560) @@ -643,12 +643,18 @@ static struct vtm *localtimew(wideval_t https://github.com/ruby/ruby/blob/trunk/ruby_2_4/time.c#L643 static int leap_year_p(long y); #define leap_year_v_p(y) leap_year_p(NUM2LONG(mod((y), INT2FIX(400)))) +int ruby_tz_update; + static struct tm * rb_localtime_r(const time_t *t, struct tm *result) { #if defined __APPLE__ && defined __LP64__ if (*t != (time_t)(int)*t) return NULL; #endif + if (!ruby_tz_update) { + ruby_tz_update = 1; + tzset(); + } #ifdef HAVE_GMTIME_R result = localtime_r(t, result); #else @@ -674,7 +680,7 @@ rb_localtime_r(const time_t *t, struct t https://github.com/ruby/ruby/blob/trunk/ruby_2_4/time.c#L680 #endif 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 static struct tm * Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 64559) +++ ruby_2_4/version.h (revision 64560) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.5" #define RUBY_RELEASE_DATE "2018-08-27" -#define RUBY_PATCHLEVEL 317 +#define RUBY_PATCHLEVEL 318 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_4/hash.c =================================================================== --- ruby_2_4/hash.c (revision 64559) +++ ruby_2_4/hash.c (revision 64560) @@ -3136,6 +3136,9 @@ env_str_new2(const char *ptr) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/hash.c#L3136 static int env_path_tainted(const char *); +static const char TZ_ENV[] = "TZ"; +extern int ruby_tz_update; + static rb_encoding * env_encoding_for(const char *name, const char *ptr) { @@ -3217,6 +3220,9 @@ env_delete(VALUE obj, VALUE name) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/hash.c#L3220 RB_GC_GUARD(name); path_tainted = 0; } + else if (ENVMATCH(nam, TZ_ENV)) { + ruby_tz_update = 0; + } return value; } return Qnil; @@ -3576,6 +3582,9 @@ env_aset(VALUE obj, VALUE nm, VALUE val) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/hash.c#L3582 path_tainted_p(value); } } + else if (ENVMATCH(name, TZ_ENV)) { + ruby_tz_update = 0; + } return val; } Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 64559) +++ ruby_2_4 (revision 64560) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r63994 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/