perl/perl-5.8.7-172396.patch

112 lines
3.3 KiB
Diff
Raw Normal View History

2005-11-03 19:14:29 +00:00
--- perl-5.8.7/reentr.inc.161305 2005-11-03 12:56:58.000000000 -0500
+++ perl-5.8.7/reentr.inc 2005-11-03 12:58:16.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.161305 2005-04-30 10:34:20.000000000 -0400
+++ perl-5.8.7/config_h.SH 2005-11-03 12:58:16.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.161305 2005-11-03 12:56:58.000000000 -0500
+++ perl-5.8.7/Configure 2005-11-03 13:13:54.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,55 @@
*) 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
@@ -20769,6 +20818,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'