mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* strftime.c: don't call tzset. strftime.c doesn't depend on
the global timezone. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
00f97ed41a
commit
6f1c1b496e
2 changed files with 5 additions and 44 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jul 9 21:04:10 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* strftime.c: don't call tzset. strftime.c doesn't depend on
|
||||
the global timezone.
|
||||
|
||||
Fri Jul 9 20:30:26 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* time.c (find_time_t): 24:00 should be the beginning of the next
|
||||
|
|
44
strftime.c
44
strftime.c
|
@ -73,9 +73,6 @@
|
|||
#define VMS_EXT 1 /* include %v for VMS date format */
|
||||
#define MAILHEADER_EXT 1 /* add %z for HHMM format */
|
||||
#define ISO_DATE_EXT 1 /* %G and %g for year of ISO week */
|
||||
#ifndef GAWK
|
||||
#define POSIX_SEMANTICS 1 /* call tzset() if TZ changes */
|
||||
#endif
|
||||
|
||||
#if defined(ISO_DATE_EXT)
|
||||
#if ! defined(POSIX2_DATE)
|
||||
|
@ -200,12 +197,6 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
|
|||
ptrdiff_t i;
|
||||
int w;
|
||||
long y;
|
||||
static short first = 1;
|
||||
#ifdef POSIX_SEMANTICS
|
||||
static char *savetz = NULL;
|
||||
static size_t savetzlen = 0;
|
||||
char *tz;
|
||||
#endif /* POSIX_SEMANTICS */
|
||||
#ifndef HAVE_TM_ZONE
|
||||
#ifndef HAVE_TM_NAME
|
||||
#if ((defined(MAILHEADER_EXT) && !HAVE_VAR_TIMEZONE && HAVE_GETTIMEOFDAY) || \
|
||||
|
@ -242,41 +233,6 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef POSIX_SEMANTICS
|
||||
if (first) {
|
||||
tzset();
|
||||
first = 0;
|
||||
}
|
||||
#else /* POSIX_SEMANTICS */
|
||||
tz = getenv("TZ");
|
||||
if (first) {
|
||||
if (tz != NULL) {
|
||||
size_t tzlen = strlen(tz);
|
||||
|
||||
savetz = (char *) malloc(tzlen + 1);
|
||||
if (savetz != NULL) {
|
||||
savetzlen = tzlen + 1;
|
||||
memcpy(savetz, tz, savetzlen);
|
||||
}
|
||||
}
|
||||
tzset();
|
||||
first = 0;
|
||||
}
|
||||
/* if we have a saved TZ, and it is different, recapture and reset */
|
||||
if (tz && savetz && (tz[0] != savetz[0] || strcmp(tz, savetz) != 0)) {
|
||||
size_t i = strlen(tz) + 1;
|
||||
if (i > savetzlen) {
|
||||
savetz = (char *) realloc(savetz, i);
|
||||
if (savetz) {
|
||||
savetzlen = i;
|
||||
memcpy(savetz, tz, i);
|
||||
}
|
||||
} else
|
||||
memcpy(savetz, tz, i);
|
||||
tzset();
|
||||
}
|
||||
#endif /* POSIX_SEMANTICS */
|
||||
|
||||
for (; *format && s < endp - 1; format++) {
|
||||
#define FLAG_FOUND() do { \
|
||||
if (precision > 0 || flags & (BIT_OF(LOCALE_E)|BIT_OF(LOCALE_O))) \
|
||||
|
|
Loading…
Reference in a new issue