New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
localtime(3) calls tzset(3), but localtime_r(3) may not. #7092
Comments
From sagawa@sohgoh.netThis is a bug report for perl from sagawa@sohgoh.net, I use cygwin perl package (5.8.2-1) and localtime returns gmtime In cygwin environment (and some other libc), #include <stdio.h> int main(int argc, char *argv[]) { t = time(NULL); printf("call tzset\n"); exit(0); Local timezone is JST:GMT+09, and this short program shows: Local: Sat Feb 7 13:47:25 2004 (wrong -- GMT) Flags: Site configuration information for perl v5.8.2: Configured by Gerrit at Fri Nov 7 12:03:56 2003. Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration: Locally applied patches: @INC for perl v5.8.2: Environment for perl v5.8.2: -- |
From @ysthOn Sat, Feb 07, 2004 at 01:49:23PM -0000, "sagawa@sohgoh.net (via RT)" <perlbug-followup@perl.org> wrote:
Thank you so much for tracking this down.
I'm not sure if this is a perl bug or cygwin/newlib bug. http://cygwin.com/ml/cygwin/2004-02/msg00346.html As a temporary workaround, a tzset() call during startup might be a |
The RT System itself - Status changed from 'new' to 'open' |
From gp@familiehaase.deHallo Akihiro, many thanks for this excellent bug report, I'll see how to integrate Gerrit Am Samstag, 7. Februar 2004 um 14:48 schriebst du:
-- |
From sagawa@sohgoh.netIn "Re: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3)
By the way, I found the same problem on NetBSD's localtime_r(3), and And glibc has a problem when we redefine TZ environment variable.:( Please check this C and its result. #include <stdio.h> int main(int argc, char *argv[]) t = time(NULL); printf("call tzset\n"); localtime_r(&t, &lctime); printf("redefine timezone\n"); localtime_r(&t, &lctime); printf("call tzset\n"); localtime_r(&t, &lctime); exit(0); [ FreeBSD 5.2, SunOS 5.8 (+ Cygwin snapshot?)] [ Linux glibc 2.2.5, 2.1.3 ] [ Cygwin 1.5.7, NetBSD 1.6ZH ] -- |
From @ysthOn Sun, Feb 15, 2004 at 12:12:39AM +0900, Akihiro Sagawa <sagawa@sohgoh.net> wrote:
All CGF's fault, I didn't do anything.
As I said on the cygwin list, the following bits of susv3 lead me to "Local timezone information is used as though localtime() calls tzset(). The relationship between a time in seconds since the Epoch used as The same relationship shall apply for localtime_r(). But it seems as if this isn't clear enough to be the practice. Would |
From sagawa@sohgoh.netIn "Re: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3)
It is good idea that perl's Configure checks localtime_r behavior. Tzset() and localtime_r() might be separated between threads. -- |
From @ysthOn Thu, Feb 26, 2004 at 12:37:06AM +0900, Akihiro Sagawa <sagawa@sohgoh.net> wrote:
localtime_r definitely isn't required to set the global tzname, etc. |
From wia@iglass.netCreated by wia@iglass.netThere seems to be a problem when changing the time zone and using It seems to work correct with perl RH 7.3 and perl 5.6.1 but found it to be I had originally noticed the problem using Date-Handler. Below is a sample script with output: -- start script use POSIX qw(floor strftime mktime setlocale); $ENV{'TZ'} = "US/Eastern"; my $TZ1 = "US/Central"; { { { -- start output DATE4 = Mon 13 Sep 2004 09:59:44 AM EDT DATE7 = Mon 13 Sep 2004 10:59:44 AM CDT thanks, Perl Info
|
From @smpetersFrom what I understand, the output should look like: steve@kirk sandbox $ perl tz.pl DATE4 = Mon Sep 13 19:48:10 2004 DATE7 = Mon Sep 13 18:48:10 2004 If so, I had it work just fine on Perl 5.8.5 on Gentoo Linux 2.4.26 and My guess is that there is something hateful occuring in glibc or Steve Peters |
@smpeters - Status changed from 'new' to 'open' |
From wia@iglass.net
Yes, that is what the output should look like. And thats what I get marc |
From @iabynOn Mon, Sep 13, 2004 at 11:53:53PM -0000, Steve Peters via RT wrote:
It appears to be a problem with the timezone info returned by localtime $summertime = 1095201834; with TZ=GB, DST is supposed to be 1; on threaded builds I get ok 1 On Solaris it succeeds. So it's proably a bug with the Linux localtime_r(3) libarary. -- |
From @ysthOn Tue, Sep 14, 2004 at 11:57:04PM +0100, Dave Mitchell <davem@iabyn.com> wrote:
A configure probe to manually do tzset before calling localtime_r |
From jvdias@redhat.comGreetings - The fact that glibc's localtime_r does not call tzset() #!/usr/bin/perl This program will exit with status 1 on all glibc using Contrary to speculation in bug #26136, this is not due The last post to bug 26126 stated:
So here's an attempt at The patch finds out if the libc's localtime_r calls tzset during Configure, Please review this patch and let me know of any ideas / suggestions / comments Thanks & Regards, ___ BEGIN PATCH : gendiff perl-5.8.7 .orig : Inline Patch--- perl-5.8.7/reentr.inc.orig 2005-11-02 22:19:11.000000000 -0500
+++ perl-5.8.7/reentr.inc 2005-11-02 22:19:27.000000000 -0500
@@ -1368,10 +1368,10 @@
#ifdef HAS_LOCALTIME_R
# undef localtime
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_I_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
#endif /* HAS_LOCALTIME_R */
--- perl-5.8.7/config_h.SH.orig 2005-04-30 10:34:20.000000000 -0400
+++ perl-5.8.7/config_h.SH 2005-11-02 22:19:27.000000000 -0500
@@ -1916,7 +1916,18 @@
*/
#$d_localtime_r HAS_LOCALTIME_R /**/
#define LOCALTIME_R_PROTO $localtime_r_proto /**/
-
+/* LOCALTIME_R_NEEDS_TZSET :
+ * many libc's localtime_r implementations do not call tzset,
+ * making them differ from localtime(), and making timezone
+ * changes using $ENV{TZ} without explicitly calling tzset
+ * impossible. This symbol makes us call tzset before localtime_r:
+ */
+#$d_localtime_r_needs_tzset LOCALTIME_R_NEEDS_TZSET /**/
+#ifdef LOCALTIME_R_NEEDS_TZSET
+#define L_R_TZSET tzset(),
+#else
+#define L_R_TZSET
+#endif
/* HAS_LONG_DOUBLE:
* This symbol will be defined if the C compiler supports long
* doubles.
--- perl-5.8.7/Configure.orig 2005-11-02 22:19:11.000000000 -0500
+++ perl-5.8.7/Configure 2005-11-02 22:19:41.000000000 -0500
@@ -528,6 +528,7 @@
d_libm_lib_version=''
d_link=''
d_localtime_r=''
+d_localtime_r_needs_tzset=''
localtime_r_proto=''
d_locconv=''
d_lockf=''
@@ -14023,7 +14024,51 @@
*) localtime_r_proto=0
;;
esac
+: see if localtime_r calls tzset
+case "$localtime_r_proto" in
+REENTRANT_PROTO*)
+ $cat >try.c <<EOCP
+/* Does our libc's localtime_r call tzset ?
+ * return 0 if so, 1 otherwise.
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <malloc.h>
+int main()
+{
+ time_t t = time(0L);
+ char w_tz[]="TZ=US/Eastern",
+ e_tz[]="TZ=US/Western",
+ *tz_e = (char*)malloc(16),
+ *tz_w = (char*)malloc(16);
+ struct tm tm_e, tm_w;
+
+ strcpy(tz_e,e_tz);
+ strcpy(tz_w,w_tz);
+
+ putenv(tz_e);
+ localtime_r(&t, &tm_e);
+
+ putenv(tz_w);
+ localtime_r(&t, &tm_w);
+ if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
+ return 1;
+ return 0;
+}
+EOCP
+ set try
+ if eval $compile; then
+ if ./try; then
+ d_localtime_r_needs_tzset=undef;
+ else
+ d_localtime_r_needs_tzset=define;
+ fi;
+ fi;
+ ;;
+esac
: see if localeconv exists
set localeconv d_locconv
eval $inlibc
@@ -20769,6 +20814,7 @@
d_libm_lib_version='$d_libm_lib_version'
d_link='$d_link'
d_localtime_r='$d_localtime_r'
+d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
d_locconv='$d_locconv'
d_lockf='$d_lockf'
d_longdbl='$d_longdbl'
___ END PATCH |
From @ysthOn Wed, Nov 02, 2005 at 10:28:41PM -0500, Jason Vas Dias wrote:
Did you actually read the speculation you quote below? I say the localtime_r is however required to return a result "corrected for (If you (RedHat) were able to approach the Open Group about clarifying
So? What difference does that make? The point is whether the globals
Terrific!
Aren't those backwards? Also, I would use non-Olson timezones, since they are by no means required. So: e_tz[]="TZ=EST5EDT"
If the compile failed, set it to undef?
|
From @ysthCareful in responding to this; I just did so and cc'd perlbug inadvertently. On Wed, Nov 02, 2005 at 10:28:41PM -0500, Jason Vas Dias wrote:
|
From bah@longitude.comAlthough a patch for this bug exists in fedora core 5 (bug 172396: Ben |
From bah@longitude.com26136.patchdiff -urp perl-current/config_h.SH perl-patched/config_h.SH
--- perl-current/config_h.SH 2006-06-13 15:28:57.000000000 -0400
+++ perl-patched/config_h.SH 2006-07-14 10:28:02.328011092 -0400
@@ -2284,7 +2284,18 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#und
*/
#$d_localtime_r HAS_LOCALTIME_R /**/
#define LOCALTIME_R_PROTO $localtime_r_proto /**/
-
+/* LOCALTIME_R_NEEDS_TZSET :
+ * many libc's localtime_r implementations do not call tzset,
+ * making them differ from localtime(), and making timezone
+ * changes using $ENV{TZ} without explicitly calling tzset
+ * impossible. This symbol makes us call tzset before localtime_r:
+ */
+#$d_localtime_r_needs_tzset LOCALTIME_R_NEEDS_TZSET /**/
+#ifdef LOCALTIME_R_NEEDS_TZSET
+#define L_R_TZSET tzset(),
+#else
+#define L_R_TZSET
+#endif
/* HAS_LONG_DOUBLE:
* This symbol will be defined if the C compiler supports long
* doubles.
diff -urp perl-current/Configure perl-patched/Configure
--- perl-current/Configure 2006-06-13 15:28:55.000000000 -0400
+++ perl-patched/Configure 2006-07-14 10:28:02.350008665 -0400
@@ -547,6 +547,7 @@ d_ldbl_dig=''
d_libm_lib_version=''
d_link=''
d_localtime_r=''
+d_localtime_r_needs_tzset=''
localtime_r_proto=''
d_locconv=''
d_lockf=''
@@ -14475,7 +14476,55 @@ case "$d_localtime_r" in
*) localtime_r_proto=0
;;
esac
+: see if localtime_r calls tzset
+case "$localtime_r_proto" in
+REENTRANT_PROTO*)
+ $cat >try.c <<EOCP
+/* Does our libc's localtime_r call tzset ?
+ * return 0 if so, 1 otherwise.
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <malloc.h>
+int main()
+{
+ time_t t = time(0L);
+ char w_tz[]="TZ=GMT+5",
+ e_tz[]="TZ=GMT-5",
+ *tz_e = (char*)malloc(16),
+ *tz_w = (char*)malloc(16);
+ struct tm tm_e, tm_w;
+
+ strcpy(tz_e,e_tz);
+ strcpy(tz_w,w_tz);
+
+ putenv(tz_e);
+ localtime_r(&t, &tm_e);
+
+ putenv(tz_w);
+ localtime_r(&t, &tm_w);
+ if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
+ return 1;
+ return 0;
+}
+EOCP
+ set try
+ if eval $compile; then
+ if ./try; then
+ d_localtime_r_needs_tzset=undef;
+ else
+ d_localtime_r_needs_tzset=define;
+ fi;
+ rm -f ./try;
+ else
+ d_localtime_r_needs_tzset=undef;
+ fi;
+ rm -f try.c;
+ ;;
+esac
: see if localeconv exists
set localeconv d_locconv
eval $inlibc
@@ -21465,6 +21514,7 @@ d_ldbl_dig='$d_ldbl_dig'
d_libm_lib_version='$d_libm_lib_version'
d_link='$d_link'
d_localtime_r='$d_localtime_r'
+d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
d_locconv='$d_locconv'
d_lockf='$d_lockf'
d_longdbl='$d_longdbl'
diff -urp perl-current/reentr.h perl-patched/reentr.h
--- perl-current/reentr.h 2006-06-13 15:29:30.000000000 -0400
+++ perl-patched/reentr.h 2006-07-14 10:28:02.325011423 -0400
@@ -1265,10 +1265,10 @@ typedef struct {
#ifdef HAS_LOCALTIME_R
# undef localtime
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_I_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
#endif /* HAS_LOCALTIME_R */
diff -urp perl-current/t/op/time.t perl-patched/t/op/time.t
--- perl-current/t/op/time.t 2006-07-14 10:05:38.752400243 -0400
+++ perl-patched/t/op/time.t 2006-07-14 10:15:28.062278000 -0400
@@ -1,10 +1,10 @@
#!./perl
if ( $does_gmtime = gmtime(time) ) {
- print "1..7\n"
+ print "1..8\n"
}
else {
- print "1..4\n"
+ print "1..5\n"
}
@@ -52,6 +52,13 @@ ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu
'localtime(), scalar context'
);
+# check that localtime respects changes to $ENV{TZ}
+$ENV{TZ} = "GMT-5";
+($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+$ENV{TZ} = "GMT+5";
+($sec,$min,$hour2,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+ok($hour != $hour2, 'changes to $ENV{TZ} respected');
+
exit 0 unless $does_gmtime;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg);
|
From jvdias@redhat.comOn Friday 14 July 2006 10:49, bah@longitude.com wrote:
Here's the latest version of the Fedora patch, which corrects This patch has been applied to perl-5.8.7 in FC-4, perl-5.8.8 in FC-5 and FC-6, It would be great to get this into the next perl-5.8.9 / maint release Regards, Jason Vas Dias<jvdias@redhat.com> |
From jvdias@redhat.comperl-5.8.8-172396.patch--- perl-5.8.8/config_h.SH.bz172396 2005-10-31 13:13:05.000000000 -0500
+++ perl-5.8.8/config_h.SH 2006-05-11 16:20:36.000000000 -0400
@@ -1912,7 +1912,18 @@
*/
#$d_localtime_r HAS_LOCALTIME_R /**/
#define LOCALTIME_R_PROTO $localtime_r_proto /**/
-
+/* LOCALTIME_R_NEEDS_TZSET :
+ * many libc's localtime_r implementations do not call tzset,
+ * making them differ from localtime(), and making timezone
+ * changes using $ENV{TZ} without explicitly calling tzset
+ * impossible. This symbol makes us call tzset before localtime_r:
+ */
+#$d_localtime_r_needs_tzset LOCALTIME_R_NEEDS_TZSET /**/
+#ifdef LOCALTIME_R_NEEDS_TZSET
+#define L_R_TZSET tzset(),
+#else
+#define L_R_TZSET
+#endif
/* HAS_LONG_DOUBLE:
* This symbol will be defined if the C compiler supports long
* doubles.
--- perl-5.8.8/reentr.inc.bz172396 2006-05-11 16:20:36.000000000 -0400
+++ perl-5.8.8/reentr.inc 2006-05-11 16:20:36.000000000 -0400
@@ -1368,10 +1368,10 @@
#ifdef HAS_LOCALTIME_R
# undef localtime
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_I_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
#endif /* HAS_LOCALTIME_R */
--- perl-5.8.8/Configure.bz172396 2006-05-11 16:20:36.000000000 -0400
+++ perl-5.8.8/Configure 2006-05-11 16:21:47.000000000 -0400
@@ -542,6 +542,7 @@
d_libm_lib_version=''
d_link=''
d_localtime_r=''
+d_localtime_r_needs_tzset=''
localtime_r_proto=''
d_locconv=''
d_lockf=''
@@ -14261,7 +14262,59 @@
*) localtime_r_proto=0
;;
esac
+: see if localtime_r calls tzset
+case "$localtime_r_proto" in
+REENTRANT_PROTO*)
+ $cat >try.c <<EOCP
+/* Does our libc's localtime_r call tzset ?
+ * return 0 if so, 1 otherwise.
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <malloc.h>
+int main()
+{
+ time_t t = time(0L);
+ char w_tz[]="TZ=GMT+5",
+ e_tz[]="TZ=GMT-5",
+ *tz_e = (char*)malloc(16),
+ *tz_w = (char*)malloc(16);
+ struct tm tm_e, tm_w;
+ memset(&tm_e,'\0',sizeof(struct tm));
+ memset(&tm_w,'\0',sizeof(struct tm));
+ strcpy(tz_e,e_tz);
+ strcpy(tz_w,w_tz);
+ putenv(tz_e);
+ localtime_r(&t, &tm_e);
+
+ putenv(tz_w);
+ localtime_r(&t, &tm_w);
+
+ if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
+ return 1;
+ return 0;
+}
+EOCP
+ set try
+ if eval $compile; then
+ if ./try; then
+ d_localtime_r_needs_tzset=undef;
+ else
+ d_localtime_r_needs_tzset=define;
+ fi;
+ rm -f ./try;
+ else
+ d_localtime_r_needs_tzset=undef;
+ fi;
+ rm -f try.c;
+ ;;
+ *)
+ d_localtime_r_needs_tzset=undef;
+ ;;
+esac
: see if localeconv exists
set localeconv d_locconv
eval $inlibc
@@ -21220,6 +21273,7 @@
d_libm_lib_version='$d_libm_lib_version'
d_link='$d_link'
d_localtime_r='$d_localtime_r'
+d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
d_locconv='$d_locconv'
d_lockf='$d_lockf'
d_longdbl='$d_longdbl'
|
From bholzman@longitude.com
This patches reentr.inc which is a generated file. I had changed the patch Ben |
From bholzman@longitude.com
I am attaching a combined patch that includes Jason's last version, modified Ben |
From bholzman@longitude.com26136.patchdiff -urp perl-current/config_h.SH perl-patched/config_h.SH
--- perl-current/config_h.SH 2006-06-13 15:28:57.000000000 -0400
+++ perl-patched/config_h.SH 2006-07-14 10:28:02.328011092 -0400
@@ -2284,7 +2284,18 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#und
*/
#$d_localtime_r HAS_LOCALTIME_R /**/
#define LOCALTIME_R_PROTO $localtime_r_proto /**/
-
+/* LOCALTIME_R_NEEDS_TZSET :
+ * many libc's localtime_r implementations do not call tzset,
+ * making them differ from localtime(), and making timezone
+ * changes using $ENV{TZ} without explicitly calling tzset
+ * impossible. This symbol makes us call tzset before localtime_r:
+ */
+#$d_localtime_r_needs_tzset LOCALTIME_R_NEEDS_TZSET /**/
+#ifdef LOCALTIME_R_NEEDS_TZSET
+#define L_R_TZSET tzset(),
+#else
+#define L_R_TZSET
+#endif
/* HAS_LONG_DOUBLE:
* This symbol will be defined if the C compiler supports long
* doubles.
diff -urp perl-current/Configure perl-patched/Configure
--- perl-current/Configure 2006-06-13 15:28:55.000000000 -0400
+++ perl-patched/Configure 2006-07-14 10:28:02.350008665 -0400
@@ -547,6 +547,7 @@ d_ldbl_dig=''
d_libm_lib_version=''
d_link=''
d_localtime_r=''
+d_localtime_r_needs_tzset=''
localtime_r_proto=''
d_locconv=''
d_lockf=''
@@ -14475,7 +14476,59 @@ case "$d_localtime_r" in
*) localtime_r_proto=0
;;
esac
+: see if localtime_r calls tzset
+case "$localtime_r_proto" in
+REENTRANT_PROTO*)
+ $cat >try.c <<EOCP
+/* Does our libc's localtime_r call tzset ?
+ * return 0 if so, 1 otherwise.
+ */
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h>
+#include <string.h>
+#include <malloc.h>
+int main()
+{
+ time_t t = time(0L);
+ char w_tz[]="TZ=GMT+5",
+ e_tz[]="TZ=GMT-5",
+ *tz_e = (char*)malloc(16),
+ *tz_w = (char*)malloc(16);
+ struct tm tm_e, tm_w;
+ memset(&tm_e,'\0',sizeof(struct tm));
+ memset(&tm_w,'\0',sizeof(struct tm));
+ strcpy(tz_e,e_tz);
+ strcpy(tz_w,w_tz);
+
+ putenv(tz_e);
+ localtime_r(&t, &tm_e);
+
+ putenv(tz_w);
+ localtime_r(&t, &tm_w);
+ if( memcmp(&tm_e, &tm_w, sizeof(struct tm)) == 0 )
+ return 1;
+ return 0;
+}
+EOCP
+ set try
+ if eval $compile; then
+ if ./try; then
+ d_localtime_r_needs_tzset=undef;
+ else
+ d_localtime_r_needs_tzset=define;
+ fi;
+ rm -f ./try;
+ else
+ d_localtime_r_needs_tzset=undef;
+ fi;
+ rm -f try.c;
+ ;;
+ *)
+ d_localtime_r_needs_tzset=undef;
+ ;;
+esac
: see if localeconv exists
set localeconv d_locconv
eval $inlibc
@@ -21465,6 +21514,7 @@ d_ldbl_dig='$d_ldbl_dig'
d_libm_lib_version='$d_libm_lib_version'
d_link='$d_link'
d_localtime_r='$d_localtime_r'
+d_localtime_r_needs_tzset='$d_localtime_r_needs_tzset'
d_locconv='$d_locconv'
d_lockf='$d_lockf'
d_longdbl='$d_longdbl'
diff -urp perl-current/reentr.h perl-patched/reentr.h
--- perl-current/reentr.h 2006-06-13 15:29:30.000000000 -0400
+++ perl-patched/reentr.h 2006-07-14 10:28:02.325011423 -0400
@@ -1265,10 +1265,10 @@ typedef struct {
#ifdef HAS_LOCALTIME_R
# undef localtime
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_S_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
# if !defined(localtime) && LOCALTIME_R_PROTO == REENTRANT_PROTO_I_TS
-# define localtime(a) (localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
+# define localtime(a) ( L_R_TZSET localtime_r(a, &PL_reentrant_buffer->_localtime_struct) == 0 ? &PL_reentrant_buffer->_localtime_struct : 0)
# endif
#endif /* HAS_LOCALTIME_R */
diff -urp perl-current/t/op/time.t perl-patched/t/op/time.t
--- perl-current/t/op/time.t 2006-07-14 10:05:38.752400243 -0400
+++ perl-patched/t/op/time.t 2006-07-14 10:15:28.062278000 -0400
@@ -1,10 +1,10 @@
#!./perl
if ( $does_gmtime = gmtime(time) ) {
- print "1..7\n"
+ print "1..8\n"
}
else {
- print "1..4\n"
+ print "1..5\n"
}
@@ -52,6 +52,13 @@ ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu
'localtime(), scalar context'
);
+# check that localtime respects changes to $ENV{TZ}
+$ENV{TZ} = "GMT-5";
+($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+$ENV{TZ} = "GMT+5";
+($sec,$min,$hour2,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg);
+ok($hour != $hour2, 'changes to $ENV{TZ} respected');
+
exit 0 unless $does_gmtime;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg);
|
From bholzman@longitude.comThere have been no comments on this patch. Is there something wrong with it Thanks, Ben
|
From @TuxThis has now been applied to devel in #29207 Change 29209 by merijn@merijn-lt09 on 2006/11/06 09:43:30 RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not. Affected files ... ... //depot/perl/Configure#627 edit -- |
@rgs - Status changed from 'open' to 'resolved' |
From @demerphqOn 11/6/06, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
The new test fails on Win32. Is it supposed to pass or should it be skipped? I'd guess that since Win32 doesnt support the TZ environment var it Yves -- |
From @TuxOn Mon, 6 Nov 2006 12:54:47 +0100, demerphq <demerphq@gmail.com> wrote:
No, it means that even if I /thought/ about it, I forgot to update the Cat you check if windews needs tzset before localtime_r or not? -- |
From @demerphqOn 11/6/06, H.Merijn Brand <h.m.brand@xs4all.nl> wrote:
There is the following comment in win32_putenv. Note the second /* The sane way to deal with the environment. But USE_WIN32_RTL_ENV is no longer supported as it was chainsawed away http://public.activestate.com/cgi-bin/perlbrowse?show_patch=Show+Patch&patch_num=8916 Yves -- |
From BQW10602@nifty.comOn Mon, 6 Nov 2006 13:17:22 +0100, "H.Merijn Brand" <h.m.brand@xs4all.nl> wrote
When I try it with Microsoft Visual C++ (2003), localtime() on Windows As I commented on it at Patch attached: skiptzset.patch Regards, |
From BQW10602@nifty.comOn Mon, 06 Nov 2006 23:27:34 +0900, SADAHIRO Tomoyuki wrote
Sorry, the attached file was empty. Newly attached: skiptzset.patch.gz Regards, |
From @rgarciaOn 06/11/06, SADAHIRO Tomoyuki <bqw10602@nifty.com> wrote:
Thanks, applied as change #29215. |
From @TuxOn Mon, 06 Nov 2006 23:31:50 +0900, SADAHIRO Tomoyuki <bqw10602@nifty.com>
That was applied by rgs in change #29215 I added the defaults for VMS and win32 and on in change #29213 -- |
Migrated from rt.perl.org#26136 (status was 'resolved')
Searchable as RT26136$
The text was updated successfully, but these errors were encountered: