Skip to content

Commit 5cf570c

Browse files
committed
Remove unused PHP_AC_BROKEN_SNPRINTF m4 macro
The snprintf function is part of the C99 standard and newer systems in most cases all support it as defined in the standard. However, some old Windows and HP-UX systems the function behaves differently. These checks were also removed and PHP now uses a replacement for the snprintf function. With gradual transition to C99 usage as a minimum requirement, it will also be able to be replaced to system's snprintf function directly. Additionally in this context the unused HAVE_VSNPRINTF and check for vsnprintf have been removed. PHP uses its own vsnprintf implementation for now until more reliable C99 compliant function can be used from the C libraries.
1 parent 3aeb7b0 commit 5cf570c

File tree

4 files changed

+1
-43
lines changed

4 files changed

+1
-43
lines changed

acinclude.m4

-37
Original file line numberDiff line numberDiff line change
@@ -1435,43 +1435,6 @@ AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
14351435
])
14361436
])
14371437

1438-
dnl
1439-
dnl PHP_AC_BROKEN_SNPRINTF
1440-
dnl
1441-
dnl Check for broken snprintf(), C99 conformance
1442-
dnl
1443-
AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
1444-
AC_CACHE_CHECK(whether snprintf is broken, ac_cv_broken_snprintf,[
1445-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
1446-
#define NULL (0L)
1447-
main() {
1448-
char buf[20];
1449-
int res = 0;
1450-
res = res || (snprintf(buf, 2, "marcus") != 6);
1451-
res = res || (buf[1] != '\0');
1452-
/* Implementations may consider this as an encoding error */
1453-
snprintf(buf, 0, "boerger");
1454-
/* However, they MUST ignore the pointer */
1455-
res = res || (buf[0] != 'm');
1456-
res = res || (snprintf(NULL, 0, "boerger") != 7);
1457-
res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
1458-
exit(res);
1459-
}
1460-
]])],[
1461-
ac_cv_broken_snprintf=no
1462-
],[
1463-
ac_cv_broken_snprintf=yes
1464-
],[
1465-
ac_cv_broken_snprintf=no
1466-
])
1467-
])
1468-
if test "$ac_cv_broken_snprintf" = "yes"; then
1469-
AC_DEFINE(PHP_BROKEN_SNPRINTF, 1, [Whether snprintf is C99 conform])
1470-
else
1471-
AC_DEFINE(PHP_BROKEN_SNPRINTF, 0, [Whether snprintf is C99 conform])
1472-
fi
1473-
])
1474-
14751438
dnl
14761439
dnl PHP_SOCKADDR_CHECKS
14771440
dnl

configure.ac

-3
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ setsockopt \
651651
setvbuf \
652652
shutdown \
653653
sin \
654-
snprintf \
655654
srand48 \
656655
srandom \
657656
statfs \
@@ -673,7 +672,6 @@ unlockpt \
673672
unsetenv \
674673
usleep \
675674
utime \
676-
vsnprintf \
677675
vasprintf \
678676
asprintf \
679677
nanosleep \
@@ -737,7 +735,6 @@ fi
737735

738736
AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt)
739737
AC_FUNC_ALLOCA
740-
dnl PHP_AC_BROKEN_SNPRINTF
741738
PHP_DECLARED_TIMEZONE
742739
PHP_TIME_R_TYPE
743740
PHP_READDIR_R_TYPE

main/spprintf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ END_EXTERN_C()
3333
#define vspprintf zend_vspprintf
3434
#define vstrpprintf zend_vstrpprintf
3535

36-
#endif /* SNPRINTF_H */
36+
#endif /* SPPRINTF_H */

win32/build/config.w32.h.in

-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@
8686
# define HAVE_SETVBUF 1
8787
#endif
8888
#define HAVE_SHUTDOWN 1
89-
#define HAVE_SNPRINTF 1
90-
#define HAVE_VSNPRINTF 1
9189
#define HAVE_STRCASECMP 1
9290
#define HAVE_STRDUP 1
9391
#define HAVE_STRERROR 1

0 commit comments

Comments
 (0)