mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Remove unused PHP_AC_BROKEN_SPRINTF and AC_ZEND_BROKEN_SPRINTF
The sprintf function has been normalized to php_sprintf via
61364b5bb1
.
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.
This commit is contained in:
parent
6926cf356e
commit
b33fa18eab
@ -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>]])
|
||||
|
||||
|
@ -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],[
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -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
|
22
acinclude.m4
22
acinclude.m4
@ -1446,28 +1446,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
|
||||
|
11
configure.ac
11
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 \
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user