diff options
author | Peter Kokot <peterkokot@gmail.com> | 2019-02-20 23:17:15 +0100 |
---|---|---|
committer | Peter Kokot <peterkokot@gmail.com> | 2019-02-23 22:26:47 +0100 |
commit | b33fa18eabf22d79a21aa95e7fa099fad2574142 (patch) | |
tree | e3bb24be779bfe6bd6e03bbde95e37dd54f82574 | |
parent | 6926cf356e4aaa73dab4bcab1f703edb72b1b37c (diff) | |
download | php-git-b33fa18eabf22d79a21aa95e7fa099fad2574142.tar.gz |
Remove unused PHP_AC_BROKEN_SPRINTF and AC_ZEND_BROKEN_SPRINTF
The sprintf function has been normalized to php_sprintf via
61364b5bb172fa512c871b795c2613b1b587e4cd.
This patch removes the checks to make a custom sprintf function
The ZEND_BROKEN_SPRINTF has been removed and the
hardcoded #define zend_sprintf sprintf is used.
The php_sprintf and zend_sprintf are now symbols to sprintf.
This patch now removes the custom PHP definitions of the php_sprintf and
zend_sprintf functions in favor of the C99 sprintf which is also
standardized in C89 already. Once, on some systems sprintf didn't behave
in same way.
-rw-r--r-- | Zend/Zend.m4 | 1 | ||||
-rw-r--r-- | Zend/acinclude.m4 | 21 | ||||
-rw-r--r-- | Zend/zend.h | 2 | ||||
-rw-r--r-- | Zend/zend_compile.c | 4 | ||||
-rw-r--r-- | Zend/zend_config.w32.h | 2 | ||||
-rw-r--r-- | Zend/zend_ini_parser.y | 2 | ||||
-rw-r--r-- | Zend/zend_sprintf.c | 38 | ||||
-rw-r--r-- | acinclude.m4 | 22 | ||||
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | ext/mysqlnd/mysql_float_to_double.h | 2 | ||||
-rw-r--r-- | ext/standard/basic_functions.c | 2 | ||||
-rw-r--r-- | main/php.h | 3 | ||||
-rw-r--r-- | main/php_sprintf.c | 39 | ||||
-rw-r--r-- | main/snprintf.h | 6 | ||||
-rw-r--r-- | win32/build/config.w32 | 4 |
15 files changed, 11 insertions, 148 deletions
diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index eff255f7fb..2a5fecd1f8 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -80,7 +80,6 @@ LIBZEND_CHECK_INT_TYPE(uint32_t) dnl Checks for library functions. AC_FUNC_ALLOCA AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp) -AC_ZEND_BROKEN_SPRINTF AC_CHECK_DECLS([isfinite, isnan, isinf], [], [], [[#include <math.h>]]) diff --git a/Zend/acinclude.m4 b/Zend/acinclude.m4 index ad3c19c4f9..3c26431db3 100644 --- a/Zend/acinclude.m4 +++ b/Zend/acinclude.m4 @@ -58,27 +58,6 @@ fp_except x = (fp_except) 0; fi ]) -dnl -dnl Check for broken sprintf() -dnl -AC_DEFUN([AC_ZEND_BROKEN_SPRINTF],[ - AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }]])],[ - ac_cv_broken_sprintf=no - ],[ - ac_cv_broken_sprintf=yes - ],[ - ac_cv_broken_sprintf=no - ]) - ]) - if test "$ac_cv_broken_sprintf" = "yes"; then - ac_result=1 - else - ac_result=0 - fi - AC_DEFINE_UNQUOTED(ZEND_BROKEN_SPRINTF, $ac_result, [Whether sprintf is broken]) -]) - dnl x87 floating point internal precision control checks dnl See: http://wiki.php.net/rfc/rounding AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ diff --git a/Zend/zend.h b/Zend/zend.h index 7228541b66..76d1bb2bb5 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -40,6 +40,8 @@ #include "zend_smart_string_public.h" #include "zend_signal.h" +#define zend_sprintf sprintf + #define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPTIONS() #define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index bd7139eb5d..7c5c027a54 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -131,7 +131,7 @@ static zend_string *zend_build_runtime_definition_key(zend_string *name, unsigne { zend_string *result; char char_pos_buf[32]; - size_t char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos); + size_t char_pos_len = sprintf(char_pos_buf, "%p", lex_pos); zend_string *filename = CG(active_op_array)->filename; /* NULL, name length, filename length, last accepting char position length */ @@ -6166,7 +6166,7 @@ static zend_string *zend_generate_anon_class_name(unsigned char *lex_pos) /* {{{ { zend_string *result; char char_pos_buf[32]; - size_t char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos); + size_t char_pos_len = sprintf(char_pos_buf, "%p", lex_pos); zend_string *filename = CG(active_op_array)->filename; /* NULL, name length, filename length, last accepting char position length */ diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h index 85384f0b0e..d61ba27b9d 100644 --- a/Zend/zend_config.w32.h +++ b/Zend/zend_config.w32.h @@ -63,8 +63,6 @@ extern "C++" { #define zend_isnan(x) _isnan(x) #endif -#define zend_sprintf sprintf - #ifndef __cplusplus /* This will cause the compilation process to be MUCH longer, but will generate * a much quicker PHP binary diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 6245dc5e0a..43f8cc8808 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -93,7 +93,7 @@ static void zend_ini_do_op(char type, zval *result, zval *op1, zval *op2) break; } - str_len = zend_sprintf(str_result, "%d", i_result); + str_len = sprintf(str_result, "%d", i_result); ZVAL_NEW_STR(result, zend_string_init(str_result, str_len, ZEND_SYSTEM_INI)); } /* }}} */ diff --git a/Zend/zend_sprintf.c b/Zend/zend_sprintf.c deleted file mode 100644 index 8259a52830..0000000000 --- a/Zend/zend_sprintf.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | Zend Engine | - +----------------------------------------------------------------------+ - | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.00 of the Zend license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.zend.com/license/2_00.txt. | - | If you did not receive a copy of the Zend license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@zend.com so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: Andi Gutmans <andi@php.net> | - | Zeev Suraski <zeev@php.net> | - +----------------------------------------------------------------------+ -*/ - -#include <stdio.h> - -#include "zend.h" - -#include <stdarg.h> - -#if ZEND_BROKEN_SPRINTF -int zend_sprintf(char *buffer, const char *format, ...) -{ - int len; - va_list args; - - va_start(args, format); - len = vsprintf(buffer, format, args); - va_end(args); - - return len; -} -#endif diff --git a/acinclude.m4 b/acinclude.m4 index 675899d055..75b61672cd 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1447,28 +1447,6 @@ AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[ ]) dnl -dnl PHP_AC_BROKEN_SPRINTF -dnl -dnl Check for broken sprintf(), C99 conformance -dnl -AC_DEFUN([PHP_AC_BROKEN_SPRINTF],[ - AC_CACHE_CHECK(whether sprintf is broken, ac_cv_broken_sprintf,[ - AC_RUN_IFELSE([AC_LANG_SOURCE([[main() {char buf[20];exit(sprintf(buf,"testing 123")!=11); }]])],[ - ac_cv_broken_sprintf=no - ],[ - ac_cv_broken_sprintf=yes - ],[ - ac_cv_broken_sprintf=no - ]) - ]) - if test "$ac_cv_broken_sprintf" = "yes"; then - AC_DEFINE(PHP_BROKEN_SPRINTF, 1, [Whether sprintf is C99 conform]) - else - AC_DEFINE(PHP_BROKEN_SPRINTF, 0, [Whether sprintf is C99 conform]) - fi -]) - -dnl dnl PHP_AC_BROKEN_SNPRINTF dnl dnl Check for broken snprintf(), C99 conformance diff --git a/configure.ac b/configure.ac index ad110b2213..697d9b789c 100644 --- a/configure.ac +++ b/configure.ac @@ -54,12 +54,6 @@ AH_BOTTOM([ #include <string.h> -#if ZEND_BROKEN_SPRINTF -int zend_sprintf(char *buffer, const char *format, ...); -#else -# define zend_sprintf sprintf -#endif - #if defined(__cplusplus) && __cplusplus >= 201103L extern "C++" { #include <cmath> @@ -743,7 +737,6 @@ fi AC_REPLACE_FUNCS(strlcat strlcpy explicit_bzero getopt) AC_FUNC_ALLOCA -dnl PHP_AC_BROKEN_SPRINTF dnl PHP_AC_BROKEN_SNPRINTF PHP_DECLARED_TIMEZONE PHP_TIME_R_TYPE @@ -1495,7 +1488,7 @@ PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/]) PHP_ADD_SOURCES(TSRM, TSRM.c tsrm_strtok_r.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) -PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \ +PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c \ fopen_wrappers.c alloca.c php_scandir.c \ php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ strlcat.c explicit_bzero.c mergesort.c reentrancy.c php_variables.c php_ticks.c \ @@ -1518,7 +1511,7 @@ PHP_ADD_SOURCES(Zend, \ zend_execute_API.c zend_highlight.c zend_llist.c \ zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c zend_stack.c \ zend_variables.c zend.c zend_API.c zend_extensions.c zend_hash.c \ - zend_list.c zend_builtin_functions.c zend_sprintf.c \ + zend_list.c zend_builtin_functions.c \ zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c zend_stream.c \ zend_iterators.c zend_interfaces.c zend_exceptions.c zend_strtod.c zend_gc.c \ zend_closures.c zend_float.c zend_string.c zend_signal.c zend_generators.c \ diff --git a/ext/mysqlnd/mysql_float_to_double.h b/ext/mysqlnd/mysql_float_to_double.h index dda65017f3..0690a4c498 100644 --- a/ext/mysqlnd/mysql_float_to_double.h +++ b/ext/mysqlnd/mysql_float_to_double.h @@ -42,7 +42,7 @@ static inline double mysql_float_to_double(float fp4, int decimals) { if (decimals < 0) { php_gcvt(fp4, FLT_DIG, '.', 'e', num_buf); } else { - php_sprintf(num_buf, "%.*f", decimals, fp4); + sprintf(num_buf, "%.*f", decimals, fp4); } return zend_strtod(num_buf, NULL); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 64c40b55e5..646907ba6b 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -123,8 +123,6 @@ typedef struct _user_tick_function_entry { static void user_shutdown_function_dtor(zval *zv); static void user_tick_function_dtor(user_tick_function_entry *tick_function_entry); -#undef sprintf - /* {{{ arginfo */ /* {{{ main/main.c */ ZEND_BEGIN_ARG_INFO(arginfo_set_time_limit, 0) diff --git a/main/php.h b/main/php.h index f182bb8932..161f955303 100644 --- a/main/php.h +++ b/main/php.h @@ -36,8 +36,7 @@ #include "zend_API.h" -#undef sprintf -#define sprintf php_sprintf +#define php_sprintf sprintf /* Operating system family definition */ #ifdef PHP_WIN32 diff --git a/main/php_sprintf.c b/main/php_sprintf.c deleted file mode 100644 index 41e632102d..0000000000 --- a/main/php_sprintf.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 7 | - +----------------------------------------------------------------------+ - | Copyright (c) The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Jaakko Hyvätti <jaakko.hyvatti@iki.fi> | - +----------------------------------------------------------------------+ - */ - -#include <stdio.h> -#include <stdarg.h> -#include "php.h" -#ifdef PHP_WIN32 -#include "config.w32.h" -#else -#include <php_config.h> -#endif - -PHPAPI int -php_sprintf (char*s, const char* format, ...) -{ - va_list args; - int ret; - - va_start (args, format); - s[0] = '\0'; - ret = vsprintf (s, format, args); - va_end (args); - return (ret < 0) ? -1 : ret; -} diff --git a/main/snprintf.h b/main/snprintf.h index 39284aeaa4..56efe5625c 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -82,7 +82,6 @@ PHPAPI int ap_php_snprintf(char *, size_t, const char *, ...) ZEND_ATTRIBUTE_FOR PHPAPI int ap_php_vsnprintf(char *, size_t, const char *, va_list ap); PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap); PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3); -PHPAPI int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf); PHPAPI char * php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf); PHPAPI char * php_conv_fp(char format, double num, @@ -118,11 +117,6 @@ END_EXTERN_C() #define asprintf ap_php_asprintf #endif -#ifdef sprintf -#undef sprintf -#endif -#define sprintf php_sprintf - typedef enum { LM_STD = 0, #if SIZEOF_INTMAX_T diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 8c281d4667..10478b41fa 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -231,7 +231,7 @@ ADD_SOURCES("Zend", "zend_language_parser.c zend_language_scanner.c \ zend_llist.c zend_vm_opcodes.c zend_opcode.c zend_operators.c zend_ptr_stack.c \ zend_stack.c zend_variables.c zend.c zend_API.c zend_extensions.c \ zend_hash.c zend_list.c zend_builtin_functions.c \ - zend_sprintf.c zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c \ + zend_ini.c zend_sort.c zend_multibyte.c zend_ts_hash.c \ zend_stream.c zend_iterators.c zend_interfaces.c zend_objects.c \ zend_object_handlers.c zend_objects_API.c \ zend_default_classes.c zend_execute.c zend_strtod.c zend_gc.c zend_closures.c \ @@ -249,7 +249,7 @@ if (VS_TOOLSET && VCVERS >= 1914) { ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \ php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \ strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \ - php_open_temporary_file.c output.c internal_functions.c php_sprintf.c \ + php_open_temporary_file.c output.c internal_functions.c \ php_syslog.c"); ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); if (VS_TOOLSET && VCVERS >= 1914) { |