]> granicus.if.org Git - php/commitdiff
this fixes segfault in strptime() on 64bit Linuxes, caused by the missing declaration
authorAntony Dovgal <tony2001@php.net>
Thu, 24 Aug 2006 11:05:38 +0000 (11:05 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 24 Aug 2006 11:05:38 +0000 (11:05 +0000)
unfortunately defining _XOPEN_SOURCE breaks the build (some odd dependencies in glibc headers) and this seems to be the best solution

ext/standard/config.m4
ext/standard/datetime.c

index cc1f95f3132783e62729958cd958b1b9c61800b4..d9961131c522fd0c78fc41e609db2767dbf5e21d 100644 (file)
@@ -477,6 +477,26 @@ if test "$ac_cv_huge_val_nan" = "yes"; then
   AC_DEFINE([HAVE_HUGE_VAL_NAN], 1, [whether HUGE_VAL + -HUGEVAL == NAN])
 fi
 
+AC_CACHE_CHECK(whether strptime() declaration fails, ac_cv_strptime_decl_fails,[
+  AC_TRY_COMPILE([
+#include <time.h>
+  ],[
+#ifndef HAVE_STRPTIME
+#error no strptime() on this platform
+#else
+/* use invalid strptime() declaration to see if it fails to compile */
+int strptime(const char *s, const char *format, struct tm *tm);
+#endif
+  ],[
+      ac_cv_strptime_decl_fails=no
+  ],[
+      ac_cv_strptime_decl_fails=yes
+  ])
+])
+if test "$ac_cv_strptime_decl_fails" = "yes"; then
+  AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails])
+fi
+
 PHP_CHECK_I18N_FUNCS
 
 PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \
index 7e2a5b44347eb648a0c4d33d11e9e5b3c42bc16c..ddb7249b35ef1318006de92f0e74bafd9307b83e 100644 (file)
 
 /* $Id$ */
 
-#if HAVE_STRPTIME
-#define _XOPEN_SOURCE
-#endif
-
 #include "php.h"
 #include "zend_operators.h"
 #include "datetime.h"
@@ -85,6 +81,10 @@ PHPAPI char *php_std_date(time_t t TSRMLS_DC)
 
 
 #if HAVE_STRPTIME
+#ifndef HAVE_STRPTIME_DECL_FAILS
+char *strptime(const char *s, const char *format, struct tm *tm);
+#endif
+
 /* {{{ proto string strptime(string timestamp, string format)
    Parse a time/date generated with strftime() */
 PHP_FUNCTION(strptime)