Skip to content

Commit 1a38098

Browse files
authored
Remove HAVE_STRPTIME_DECL_FAILS (php#14821)
The strptime, where available, needs the _GNU_SOURCE defined or compiler flag -std=gnuXX appended to be declared in time.h. PHP's strptime is also deprecated as of PHP 8.1. This removes the HAVE_STRPTIME_DECL_FAILS in favor of a simpler AC_CHECK_DECL check and HAVE_DECL_STRPTIME CPP macro.
1 parent 94dc2d2 commit 1a38098

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

UPGRADING.INTERNALS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES
140140
- Symbols HAVE_LIBRT and HAVE_TIMER_CREATE removed.
141141
- Symbols PHP_FPM_SYSTEMD, PHP_FPM_USER, and PHP_FPM_GROUP removed.
142142
- Symbol PTHREADS has been removed.
143+
- Symbol HAVE_STRPTIME_DECL_FAILS has been removed (use HAVE_DECL_STRPTIME).
143144
- M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h).
144145
- M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH).
145146
- M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES).

ext/standard/config.m4

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -341,23 +341,14 @@ PHP_CHECK_FUNC(res_search, resolv, socket)
341341
AC_CHECK_FUNCS([posix_spawn_file_actions_addchdir_np])
342342

343343
dnl
344-
dnl Check for strptime()
344+
dnl Obsolete check for strptime() declaration. The strptime, where available,
345+
dnl needs the _GNU_SOURCE defined or compiler flag -std=gnuXX appended to be
346+
dnl declared in time.h. PHP's strptime is also deprecated as of PHP 8.1.
345347
dnl
346-
AC_CACHE_CHECK([whether strptime is declared],
347-
[php_cv_have_decl_strptime],
348-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [
349-
#ifndef HAVE_STRPTIME
350-
#error no strptime() on this platform
351-
#else
352-
/* use invalid strptime() declaration to see if it fails to compile */
353-
int strptime(const char *s, const char *format, struct tm *tm);
354-
#endif
355-
])],
356-
[php_cv_have_decl_strptime=no],
357-
[php_cv_have_decl_strptime=yes])])
358-
AS_VAR_IF([php_cv_have_decl_strptime], [yes],
359-
[AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], [1],
360-
[Define to 1 if 'strptime' has declaration.])])
348+
AC_CHECK_DECL([strptime],
349+
[AC_DEFINE([HAVE_DECL_STRPTIME], [1],
350+
[Define to 1 if you have the declaration of 'strptime'.])],,
351+
[#include <time.h>])
361352

362353
dnl
363354
dnl Check for argon2

ext/standard/datetime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PHPAPI char *php_std_date(time_t t)
6363
/* }}} */
6464

6565
#ifdef HAVE_STRPTIME
66-
#ifndef HAVE_STRPTIME_DECL_FAILS
66+
#ifndef HAVE_DECL_STRPTIME
6767
char *strptime(const char *s, const char *format, struct tm *tm);
6868
#endif
6969

0 commit comments

Comments
 (0)