summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c29
-rw-r--r--main/SAPI.h23
-rw-r--r--main/build-defs.h.in2
-rw-r--r--main/explicit_bzero.c4
-rw-r--r--main/fastcgi.c2
-rw-r--r--main/fastcgi.h4
-rw-r--r--main/fopen_wrappers.c12
-rw-r--r--main/fopen_wrappers.h2
-rw-r--r--main/getopt.c2
-rw-r--r--main/http_status_codes.h2
-rw-r--r--main/internal_functions.c.in2
-rw-r--r--main/internal_functions_win32.c2
-rw-r--r--main/main.c248
-rw-r--r--main/mergesort.c347
-rw-r--r--main/network.c14
-rw-r--r--main/output.c74
-rw-r--r--main/php.h18
-rw-r--r--main/php_compat.h2
-rw-r--r--main/php_content_types.c2
-rw-r--r--main/php_content_types.h2
-rw-r--r--main/php_getopt.h2
-rw-r--r--main/php_globals.h7
-rw-r--r--main/php_ini.c4
-rw-r--r--main/php_ini.h4
-rw-r--r--main/php_main.h2
-rw-r--r--main/php_memory_streams.h6
-rw-r--r--main/php_network.h6
-rw-r--r--main/php_open_temporary_file.c2
-rw-r--r--main/php_open_temporary_file.h2
-rw-r--r--main/php_output.h2
-rw-r--r--main/php_reentrancy.h8
-rw-r--r--main/php_scandir.c2
-rw-r--r--main/php_scandir.h2
-rw-r--r--main/php_stdint.h31
-rw-r--r--main/php_streams.h6
-rw-r--r--main/php_syslog.c2
-rw-r--r--main/php_syslog.h2
-rw-r--r--main/php_ticks.c2
-rw-r--r--main/php_ticks.h2
-rw-r--r--main/php_variables.c62
-rw-r--r--main/php_variables.h10
-rw-r--r--main/php_version.h10
-rw-r--r--main/reentrancy.c59
-rw-r--r--main/rfc1867.c14
-rw-r--r--main/rfc1867.h2
-rw-r--r--main/snprintf.c25
-rw-r--r--main/snprintf.h2
-rw-r--r--main/spprintf.c24
-rw-r--r--main/spprintf.h2
-rw-r--r--main/streams/cast.c6
-rw-r--r--main/streams/filter.c6
-rw-r--r--main/streams/glob_wrapper.c2
-rw-r--r--main/streams/memory.c14
-rw-r--r--main/streams/mmap.c2
-rw-r--r--main/streams/php_stream_context.h4
-rw-r--r--main/streams/php_stream_filter_api.h2
-rw-r--r--main/streams/php_stream_glob_wrapper.h2
-rw-r--r--main/streams/php_stream_mmap.h2
-rw-r--r--main/streams/php_stream_plain_wrapper.h2
-rw-r--r--main/streams/php_stream_transport.h2
-rw-r--r--main/streams/php_stream_userspace.h2
-rw-r--r--main/streams/php_streams_int.h2
-rw-r--r--main/streams/plain_wrapper.c37
-rw-r--r--main/streams/streams.c27
-rw-r--r--main/streams/transports.c10
-rw-r--r--main/streams/userspace.c12
-rw-r--r--main/streams/xp_socket.c15
-rw-r--r--main/strlcat.c2
-rw-r--r--main/strlcpy.c2
69 files changed, 278 insertions, 972 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index a5a68f8c68..b2840c18e9 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -118,7 +116,7 @@ PHP_FUNCTION(header_register_callback)
zval *callback_func;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback_func) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!zend_is_callable(callback_func, 0, NULL)) {
@@ -612,7 +610,7 @@ static void sapi_remove_header(zend_llist *l, char *name, size_t len) {
}
}
-SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
+SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
{
sapi_header_line ctr = {0};
int r;
@@ -624,7 +622,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_
&ctr);
if (!duplicate)
- efree(header_line);
+ efree((void *) header_line);
return r;
}
@@ -684,7 +682,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
if (!p->line || !p->line_len) {
return FAILURE;
}
- header_line = p->line;
+ header_line = estrndup(p->line, p->line_len);
header_line_len = p->line_len;
http_response_code = p->response_code;
break;
@@ -701,8 +699,6 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
return FAILURE;
}
- header_line = estrndup(header_line, header_line_len);
-
/* cut off trailing spaces, linefeeds and carriage-returns */
if (header_line_len && isspace(header_line[header_line_len-1])) {
do {
@@ -984,7 +980,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva
return SUCCESS;
}
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
{
if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
@@ -1016,7 +1012,7 @@ SAPI_API zend_stat_t *sapi_get_stat(void)
}
}
-SAPI_API char *sapi_getenv(char *name, size_t name_len)
+SAPI_API char *sapi_getenv(const char *name, size_t name_len)
{
if (!strncasecmp(name, "HTTP_PROXY", name_len)) {
/* Ugly fix for HTTP_PROXY issue, see bug #72573 */
@@ -1103,10 +1099,10 @@ SAPI_API void sapi_terminate_process(void) {
}
}
-SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
+SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
{
zval *return_value = (zval*)arg;
- char *str = NULL;
+ char *buf = NULL;
ALLOCA_FLAG(use_heap)
@@ -1117,11 +1113,12 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
var[3] == 'P' &&
var[4] == '_') {
- char *p;
+ const char *p;
+ char *str;
var_len -= 5;
p = var + 5;
- var = str = do_alloca(var_len + 1, use_heap);
+ var = str = buf = do_alloca(var_len + 1, use_heap);
*str++ = *p++;
while (*p) {
if (*p == '_') {
@@ -1147,8 +1144,8 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
return;
}
add_assoc_stringl_ex(return_value, var, var_len, val, val_len);
- if (str) {
- free_alloca(var, use_heap);
+ if (buf) {
+ free_alloca(buf, use_heap);
}
}
/* }}} */
diff --git a/main/SAPI.h b/main/SAPI.h
index fe8bfd6244..b0d2928369 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -24,9 +22,6 @@
#include "zend_API.h"
#include "zend_llist.h"
#include "zend_operators.h"
-#ifdef PHP_WIN32
-#include "win32/php_stdint.h"
-#endif
#include <sys/stat.h>
#define SAPI_OPTION_NO_CHDIR 1
@@ -150,7 +145,7 @@ SAPI_API void sapi_shutdown(void);
SAPI_API void sapi_activate(void);
SAPI_API void sapi_deactivate(void);
SAPI_API void sapi_initialize_empty_request(void);
-SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
+SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
END_EXTERN_C()
/*
@@ -165,7 +160,7 @@ END_EXTERN_C()
*/
typedef struct {
- char *line; /* If you allocated this, you need to free it yourself */
+ const char *line; /* If you allocated this, you need to free it yourself */
size_t line_len;
zend_long response_code; /* long due to zend_parse_parameters compatibility */
} sapi_header_line;
@@ -182,7 +177,7 @@ BEGIN_EXTERN_C()
SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg);
/* Deprecated functions. Use sapi_header_op instead. */
-SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
+SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1)
@@ -195,11 +190,11 @@ SAPI_API int sapi_register_post_entry(const sapi_post_entry *post_entry);
SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void));
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray));
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
SAPI_API int sapi_flush(void);
SAPI_API zend_stat_t *sapi_get_stat(void);
-SAPI_API char *sapi_getenv(char *name, size_t name_len);
+SAPI_API char *sapi_getenv(const char *name, size_t name_len);
SAPI_API char *sapi_get_default_content_type(void);
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header);
@@ -228,7 +223,7 @@ struct _sapi_module_struct {
size_t (*ub_write)(const char *str, size_t str_length);
void (*flush)(void *server_context);
zend_stat_t *(*get_stat)(void);
- char *(*getenv)(char *name, size_t name_len);
+ char *(*getenv)(const char *name, size_t name_len);
void (*sapi_error)(int type, const char *error_msg, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
@@ -240,7 +235,7 @@ struct _sapi_module_struct {
char *(*read_cookies)(void);
void (*register_server_variables)(zval *track_vars_array);
- void (*log_message)(char *message, int syslog_type_int);
+ void (*log_message)(const char *message, int syslog_type_int);
double (*get_request_time)(void);
void (*terminate_process)(void);
@@ -260,7 +255,7 @@ struct _sapi_module_struct {
int (*get_target_uid)(uid_t *);
int (*get_target_gid)(gid_t *);
- unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);
+ unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
@@ -293,7 +288,7 @@ struct _sapi_post_entry {
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg)
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray)
-#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len)
+#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len)
BEGIN_EXTERN_C()
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
diff --git a/main/build-defs.h.in b/main/build-defs.h.in
index f007526846..374996c64a 100644
--- a/main/build-defs.h.in
+++ b/main/build-defs.h.in
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/explicit_bzero.c b/main/explicit_bzero.c
index 57d12080c6..5650932a3c 100644
--- a/main/explicit_bzero.c
+++ b/main/explicit_bzero.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -30,7 +28,7 @@
PHPAPI void php_explicit_bzero(void *dst, size_t siz)
{
-#if HAVE_EXPLICIT_MEMSET
+#ifdef HAVE_EXPLICIT_MEMSET
explicit_memset(dst, 0, siz);
#elif defined(PHP_WIN32)
RtlSecureZeroMemory(dst, siz);
diff --git a/main/fastcgi.c b/main/fastcgi.c
index f8044ffce3..dacb06bcfe 100644
--- a/main/fastcgi.c
+++ b/main/fastcgi.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/fastcgi.h b/main/fastcgi.h
index 95aae11e41..71c8517b11 100644
--- a/main/fastcgi.h
+++ b/main/fastcgi.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -77,7 +75,7 @@ typedef enum _fcgi_protocol_status {
/* FastCGI client API */
-typedef void (*fcgi_apply_func)(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
+typedef void (*fcgi_apply_func)(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
#define FCGI_HASH_TABLE_SIZE 128
#define FCGI_HASH_TABLE_MASK (FCGI_HASH_TABLE_SIZE - 1)
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 11d31366d7..d61a7c6893 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -75,14 +73,8 @@ Allows any change to open_basedir setting in during Startup and Shutdown events,
or a tightening during activation/runtime/deactivation */
PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
{
- char **p, *pathbuf, *ptr, *end;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- p = (char **) (base + (size_t) mh_arg1);
+ char **p = (char **) ZEND_INI_GET_ADDR();
+ char *pathbuf, *ptr, *end;
if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN || stage == PHP_INI_STAGE_ACTIVATE || stage == PHP_INI_STAGE_DEACTIVATE) {
/* We're in a PHP_INI_SYSTEM context, no restrictions */
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
index 17e15b7df0..0f70bb4231 100644
--- a/main/fopen_wrappers.h
+++ b/main/fopen_wrappers.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/getopt.c b/main/getopt.c
index 9123cee0f2..2160a6f4fe 100644
--- a/main/getopt.c
+++ b/main/getopt.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/http_status_codes.h b/main/http_status_codes.h
index 5d5cfb08c3..cf66eabad7 100644
--- a/main/http_status_codes.h
+++ b/main/http_status_codes.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in
index 59557c9651..41458fb366 100644
--- a/main/internal_functions.c.in
+++ b/main/internal_functions.c.in
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c
index 4a3301e49b..bbee5fd0e7 100644
--- a/main/internal_functions_win32.c
+++ b/main/internal_functions_win32.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/main.c b/main/main.c
index 1cb50ce1dd..90fec668dd 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -97,31 +95,6 @@ PHPAPI size_t core_globals_offset;
#define SAFE_FILENAME(f) ((f)?(f):"-")
-static char *get_safe_charset_hint(void) {
- ZEND_TLS char *lastHint = NULL;
- ZEND_TLS char *lastCodeset = NULL;
- char *hint = SG(default_charset);
- size_t len = strlen(hint);
- size_t i = 0;
-
- if (lastHint == SG(default_charset)) {
- return lastCodeset;
- }
-
- lastHint = hint;
- lastCodeset = NULL;
-
- for (i = 0; i < sizeof(charset_map)/sizeof(charset_map[0]); i++) {
- if (len == charset_map[i].codeset_len
- && zend_binary_strcasecmp(hint, len, charset_map[i].codeset, len) == 0) {
- lastCodeset = (char*)charset_map[i].codeset;
- break;
- }
- }
-
- return lastCodeset;
-}
-
/* {{{ PHP_INI_MH
*/
static PHP_INI_MH(OnSetFacility)
@@ -474,9 +447,9 @@ static PHP_INI_MH(OnUpdateTimeout)
/* {{{ php_get_display_errors_mode() helper function
*/
-static int php_get_display_errors_mode(char *value, size_t value_length)
+static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
{
- int mode;
+ zend_uchar mode;
if (!value) {
return PHP_DISPLAY_ERRORS_STDOUT;
@@ -507,7 +480,7 @@ static int php_get_display_errors_mode(char *value, size_t value_length)
*/
static PHP_INI_MH(OnUpdateDisplayErrors)
{
- PG(display_errors) = (zend_bool) php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
+ PG(display_errors) = php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
return SUCCESS;
}
@@ -517,7 +490,8 @@ static PHP_INI_MH(OnUpdateDisplayErrors)
*/
static PHP_INI_DISP(display_errors_mode)
{
- int mode, cgi_or_cli;
+ zend_uchar mode;
+ bool cgi_or_cli;
size_t tmp_value_length;
char *tmp_value;
@@ -564,28 +538,28 @@ static PHP_INI_DISP(display_errors_mode)
PHPAPI const char *php_get_internal_encoding() {
if (PG(internal_encoding) && PG(internal_encoding)[0]) {
return PG(internal_encoding);
- } else if (SG(default_charset)) {
+ } else if (SG(default_charset) && SG(default_charset)[0]) {
return SG(default_charset);
}
- return "";
+ return "UTF-8";
}
PHPAPI const char *php_get_input_encoding() {
if (PG(input_encoding) && PG(input_encoding)[0]) {
return PG(input_encoding);
- } else if (SG(default_charset)) {
+ } else if (SG(default_charset) && SG(default_charset)[0]) {
return SG(default_charset);
}
- return "";
+ return "UTF-8";
}
PHPAPI const char *php_get_output_encoding() {
if (PG(output_encoding) && PG(output_encoding)[0]) {
return PG(output_encoding);
- } else if (SG(default_charset)) {
+ } else if (SG(default_charset) && SG(default_charset)[0]) {
return SG(default_charset);
}
- return "";
+ return "UTF-8";
}
PHPAPI void (*php_internal_encoding_changed)(void) = NULL;
@@ -729,7 +703,7 @@ PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode)
- STD_PHP_INI_BOOLEAN("display_startup_errors", "0", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
@@ -751,7 +725,6 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
- STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("serialize_precision", "-1", PHP_INI_ALL, OnSetSerializePrecision, serialize_precision, php_core_globals, core_globals)
@@ -850,7 +823,7 @@ PHPAPI int php_get_module_initialized(void)
/* {{{ php_log_err_with_severity
*/
-PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int)
+PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int)
{
int fd = -1;
time_t error_time;
@@ -938,6 +911,38 @@ PHPAPI size_t php_printf(const char *format, ...)
}
/* }}} */
+/* {{{ php_printf_unchecked
+ */
+PHPAPI size_t php_printf_unchecked(const char *format, ...)
+{
+ va_list args;
+ size_t ret;
+ char *buffer;
+ size_t size;
+
+ va_start(args, format);
+ size = vspprintf(&buffer, 0, format, args);
+ ret = PHPWRITE(buffer, size);
+ efree(buffer);
+ va_end(args);
+
+ return ret;
+}
+/* }}} */
+
+static zend_string *escape_html(const char *buffer, size_t buffer_len) {
+ zend_string *result = php_escape_html_entities_ex(
+ (const unsigned char *) buffer, buffer_len, 0, ENT_COMPAT,
+ /* charset_hint */ NULL, /* double_encode */ 1, /* quiet */ 1);
+ if (!result || ZSTR_LEN(result) == 0) {
+ /* Retry with substituting invalid chars on fail. */
+ result = php_escape_html_entities_ex(
+ (const unsigned char *) buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS,
+ /* charset_hint */ NULL, /* double_encode */ 1, /* quiet */ 1);
+ }
+ return result;
+}
+
/* {{{ php_verror */
/* php_verror is called from php_error_docref<n> functions.
* Its purpose is to unify error messages and automatically generate clickable
@@ -956,19 +961,14 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
const char *function;
int origin_len;
char *origin;
- char *message;
+ zend_string *message;
int is_function = 0;
/* get error text into buffer and escape for html if necessary */
buffer_len = (int)vspprintf(&buffer, 0, format, args);
if (PG(html_errors)) {
- replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, get_safe_charset_hint());
- /* Retry with substituting invalid chars on fail. */
- if (!replace_buffer || ZSTR_LEN(replace_buffer) < 1) {
- replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, get_safe_charset_hint());
- }
-
+ replace_buffer = escape_html(buffer, buffer_len);
efree(buffer);
if (replace_buffer) {
@@ -1033,7 +1033,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
}
if (PG(html_errors)) {
- replace_origin = php_escape_html_entities((unsigned char*)origin, origin_len, 0, ENT_COMPAT, get_safe_charset_hint());
+ replace_origin = escape_html(origin, origin_len);
efree(origin);
origin = ZSTR_VAL(replace_origin);
}
@@ -1096,15 +1096,15 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
}
/* display html formatted or only show the additional links */
if (PG(html_errors)) {
- spprintf(&message, 0, "%s [<a href='%s%s%s'>%s</a>]: %s", origin, docref_root, docref, docref_target, docref, buffer);
+ message = zend_strpprintf(0, "%s [<a href='%s%s%s'>%s</a>]: %s", origin, docref_root, docref, docref_target, docref, buffer);
} else {
- spprintf(&message, 0, "%s [%s%s%s]: %s", origin, docref_root, docref, docref_target, buffer);
+ message = zend_strpprintf(0, "%s [%s%s%s]: %s", origin, docref_root, docref, docref_target, buffer);
}
if (target) {
efree(target);
}
} else {
- spprintf(&message, 0, "%s: %s", origin, buffer);
+ message = zend_strpprintf(0, "%s: %s", origin, buffer);
}
if (replace_origin) {
zend_string_free(replace_origin);
@@ -1115,26 +1115,14 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
efree(docref_buf);
}
- if (PG(track_errors) && module_initialized && EG(active) &&
- (Z_TYPE(EG(user_error_handler)) == IS_UNDEF || !(EG(user_error_handler_error_reporting) & type))) {
- zval tmp;
- ZVAL_STRINGL(&tmp, buffer, buffer_len);
- if (EG(current_execute_data)) {
- if (zend_set_local_var_str("php_errormsg", sizeof("php_errormsg")-1, &tmp, 0) == FAILURE) {
- zval_ptr_dtor(&tmp);
- }
- } else {
- zend_hash_str_update_ind(&EG(symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp);
- }
- }
if (replace_buffer) {
zend_string_free(replace_buffer);
} else {
efree(buffer);
}
- php_error(type, "%s", message);
- efree(message);
+ zend_error_zstr(type, message);
+ zend_string_release(message);
}
/* }}} */
@@ -1201,20 +1189,29 @@ PHPAPI void php_html_puts(const char *str, size_t size)
}
/* }}} */
+static void clear_last_error() {
+ if (PG(last_error_message)) {
+ zend_string_release(PG(last_error_message));
+ PG(last_error_message) = NULL;
+ }
+ if (PG(last_error_file)) {
+ free(PG(last_error_file));
+ PG(last_error_file) = NULL;
+ }
+}
+
/* {{{ php_error_cb
extended error handling function */
-static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)
+static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message)
{
- char *buffer;
- int buffer_len, display;
-
- buffer_len = (int)vspprintf(&buffer, PG(log_errors_max_len), format, args);
+ zend_bool display;
+ int type = orig_type & E_ALL;
/* check for repeated errors to be ignored */
if (PG(ignore_repeated_errors) && PG(last_error_message)) {
/* no check for PG(last_error_file) is needed since it cannot
* be NULL if PG(last_error_message) is not NULL */
- if (strcmp(PG(last_error_message), buffer)
+ if (zend_string_equals(PG(last_error_message), message)
|| (!PG(ignore_repeated_source)
&& ((PG(last_error_lineno) != (int)error_lineno)
|| strcmp(PG(last_error_file), error_filename)))) {
@@ -1250,36 +1247,26 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
* but DO NOT overwrite a pending exception
*/
if (!EG(exception)) {
- zend_throw_error_exception(EG(exception_class), buffer, 0, type);
+ zend_throw_error_exception(EG(exception_class), message, 0, type);
}
- efree(buffer);
return;
}
}
/* store the error if it has changed */
if (display) {
- if (PG(last_error_message)) {
- char *s = PG(last_error_message);
- PG(last_error_message) = NULL;
- free(s);
- }
- if (PG(last_error_file)) {
- char *s = PG(last_error_file);
- PG(last_error_file) = NULL;
- free(s);
- }
+ clear_last_error();
if (!error_filename) {
error_filename = "Unknown";
}
PG(last_error_type) = type;
- PG(last_error_message) = strdup(buffer);
+ PG(last_error_message) = zend_string_copy(message);
PG(last_error_file) = strdup(error_filename);
PG(last_error_lineno) = error_lineno;
}
/* display/log the error if necessary */
- if (display && (EG(error_reporting) & type || (type & E_CORE))
+ if (display && ((EG(error_reporting) & type) || (type & E_CORE))
&& (PG(log_errors) || PG(display_errors) || (!module_initialized))) {
char *error_type_str;
int syslog_type_int = LOG_NOTICE;
@@ -1330,40 +1317,40 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
char *log_buffer;
#ifdef PHP_WIN32
if (type == E_CORE_ERROR || type == E_CORE_WARNING) {
- syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, buffer, GetCommandLine());
+ syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, ZSTR_VAL(message), GetCommandLine());
}
#endif
- spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %" PRIu32, error_type_str, buffer, error_filename, error_lineno);
+ spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %" PRIu32, error_type_str, ZSTR_VAL(message), error_filename, error_lineno);
php_log_err_with_severity(log_buffer, syslog_type_int);
efree(log_buffer);
}
if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors)))) {
if (PG(xmlrpc_errors)) {
- php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %" PRIu32 "</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno);
+ php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %" PRIu32 "</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, ZSTR_VAL(message), error_filename, error_lineno);
} else {
char *prepend_string = INI_STR("error_prepend_string");
char *append_string = INI_STR("error_append_string");
if (PG(html_errors)) {
if (type == E_ERROR || type == E_PARSE) {
- zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, get_safe_charset_hint());
+ zend_string *buf = escape_html(ZSTR_VAL(message), ZSTR_LEN(message));
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string));
zend_string_free(buf);
} else {
- php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
+ php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(message), error_filename, error_lineno, STR_PRINT(append_string));
}
} else {
/* Write CLI/CGI errors to stderr if display_errors = "stderr" */
if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg")) &&
PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR
) {
- fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, buffer, error_filename, error_lineno);
+ fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, ZSTR_VAL(message), error_filename, error_lineno);
#ifdef PHP_WIN32
fflush(stderr);
#endif
} else {
- php_printf("%s\n%s: %s in %s on line %" PRIu32 "\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
+ php_printf("%s\n%s: %s in %s on line %" PRIu32 "\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(message), error_filename, error_lineno, STR_PRINT(append_string));
}
}
}
@@ -1383,7 +1370,7 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
trigger_break=0;
break;
}
- zend_output_debug_string(trigger_break, "%s(%" PRIu32 ") : %s - %s", error_filename, error_lineno, error_type_str, buffer);
+ zend_output_debug_string(trigger_break, "%s(%" PRIu32 ") : %s - %s", error_filename, error_lineno, error_type_str, ZSTR_VAL(message));
}
#endif
}
@@ -1414,10 +1401,9 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
}
/* the parser would return 1 (failure), we can bail out nicely */
- if (type != E_PARSE) {
+ if (!(orig_type & E_DONT_BAIL)) {
/* restore memory limit */
zend_set_memory_limit(PG(memory_limit));
- efree(buffer);
zend_objects_store_mark_destructed(&EG(objects_store));
zend_bailout();
return;
@@ -1425,27 +1411,6 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
}
break;
}
-
- /* Log if necessary */
- if (!display) {
- efree(buffer);
- return;
- }
-
- if (PG(track_errors) && module_initialized && EG(active)) {
- zval tmp;
-
- ZVAL_STRINGL(&tmp, buffer, buffer_len);
- if (EG(current_execute_data)) {
- if (zend_set_local_var_str("php_errormsg", sizeof("php_errormsg")-1, &tmp, 0) == FAILURE) {
- zval_ptr_dtor(&tmp);
- }
- } else {
- zend_hash_str_update_ind(&EG(symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp);
- }
- }
-
- efree(buffer);
}
/* }}} */
@@ -1528,7 +1493,7 @@ PHP_FUNCTION(set_time_limit)
zend_string *key;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_timeout) == FAILURE) {
- return;
+ RETURN_THROWS();
}
new_timeout_strlen = (int)zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout);
@@ -1625,14 +1590,7 @@ static zval *php_get_configuration_directive_for_zend(zend_string *name)
*/
static void php_free_request_globals(void)
{
- if (PG(last_error_message)) {
- free(PG(last_error_message));
- PG(last_error_message) = NULL;
- }
- if (PG(last_error_file)) {
- free(PG(last_error_file));
- PG(last_error_file) = NULL;
- }
+ clear_last_error();
if (PG(php_sys_temp_dir)) {
efree(PG(php_sys_temp_dir));
PG(php_sys_temp_dir) = NULL;
@@ -1649,7 +1607,7 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void
php_error_docref("function.include", E_WARNING, "Failed opening '%s' for inclusion (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
break;
case ZMSG_FAILED_REQUIRE_FOPEN:
- php_error_docref("function.require", E_COMPILE_ERROR, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
+ zend_throw_error(NULL, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
break;
case ZMSG_FAILED_HIGHLIGHT_FOPEN:
php_error_docref(NULL, E_WARNING, "Failed opening '%s' for highlighting", php_strip_url_passwd((char *) data));
@@ -1859,9 +1817,9 @@ void php_request_shutdown(void *dummy)
php_deactivate_ticks();
/* 1. Call all possible shutdown functions registered with register_shutdown_function() */
- if (PG(modules_activated)) zend_try {
+ if (PG(modules_activated)) {
php_call_shutdown_functions();
- } zend_end_try();
+ }
/* 2. Call all possible __destruct() functions */
zend_try {
@@ -1914,12 +1872,12 @@ void php_request_shutdown(void *dummy)
}
} zend_end_try();
- /* 9. free request-bound globals */
- php_free_request_globals();
-
- /* 10. Shutdown scanner/executor/compiler and restore ini entries */
+ /* 9. Shutdown scanner/executor/compiler and restore ini entries */
zend_deactivate();
+ /* 10. free request-bound globals */
+ php_free_request_globals();
+
/* 11. Call all extensions post-RSHUTDOWN functions */
zend_try {
zend_post_deactivate_modules();
@@ -1991,12 +1949,10 @@ static void core_globals_ctor(php_core_globals *core_globals)
*/
static void core_globals_dtor(php_core_globals *core_globals)
{
- if (core_globals->last_error_message) {
- free(core_globals->last_error_message);
- }
- if (core_globals->last_error_file) {
- free(core_globals->last_error_file);
- }
+ /* These should have been freed earlier. */
+ ZEND_ASSERT(!core_globals->last_error_message);
+ ZEND_ASSERT(!core_globals->last_error_file);
+
if (core_globals->disable_functions) {
free(core_globals->disable_functions);
}
@@ -2164,7 +2120,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
zend_startup(&zuf);
- setlocale(LC_CTYPE, "");
zend_update_current_locale();
#if HAVE_TZSET
@@ -2367,13 +2322,12 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
struct {
const long error_level;
const char *phrase;
- const char *directives[17]; /* Remember to change this if the number of directives change */
+ const char *directives[18]; /* Remember to change this if the number of directives change */
} directives[2] = {
{
E_DEPRECATED,
"Directive '%s' is deprecated",
{
- "track_errors",
"allow_url_include",
NULL
}
@@ -2398,6 +2352,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
"safe_mode_allowed_env_vars",
"safe_mode_protected_env_vars",
"zend.ze1_compatibility_mode",
+ "track_errors",
NULL
}
}
@@ -2430,6 +2385,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
sapi_deactivate();
module_startup = 0;
+ /* Don't leak errors from startup into the per-request phase. */
+ clear_last_error();
shutdown_memory_manager(1, 0);
virtual_cwd_activate();
@@ -2492,6 +2449,7 @@ void php_module_shutdown(void)
/* close down the ini config */
php_shutdown_config();
+ clear_last_error();
#ifndef ZTS
zend_ini_shutdown();
@@ -2536,7 +2494,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
{
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
-#if HAVE_BROKEN_GETCWD
+#ifdef HAVE_BROKEN_GETCWD
volatile int old_cwd_fd = -1;
#else
char *old_cwd;
@@ -2563,7 +2521,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
PG(during_request_startup) = 0;
if (primary_file->filename && !(SG(options) & SAPI_OPTION_NO_CHDIR)) {
-#if HAVE_BROKEN_GETCWD
+#ifdef HAVE_BROKEN_GETCWD
/* this looks nasty to me */
old_cwd_fd = open(".", 0);
#else
@@ -2607,7 +2565,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
}
/*
- If cli primary file has shabang line and there is a prepend file,
+ If cli primary file has shebang line and there is a prepend file,
the `skip_shebang` will be used by prepend file but not primary file,
save it and restore after prepend file been executed.
*/
@@ -2628,7 +2586,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
} zend_end_try();
}
-#if HAVE_BROKEN_GETCWD
+#ifdef HAVE_BROKEN_GETCWD
if (old_cwd_fd != -1) {
fchdir(old_cwd_fd);
close(old_cwd_fd);
diff --git a/main/mergesort.c b/main/mergesort.c
deleted file mode 100644
index da6d8560bf..0000000000
--- a/main/mergesort.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Peter McIlroy.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Hybrid exponential search/linear search merge sort with hybrid
- * natural/pairwise first pass. Requires about .3% more comparisons
- * for random data than LSMS with pairwise first pass alone.
- * It works for objects as small as two bytes.
- */
-
-#define NATURAL
-#define THRESHOLD 16 /* Best choice for natural merge cut-off. */
-
-/* #define NATURAL to get hybrid natural merge.
- * (The default is pairwise merging.)
- */
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "php.h"
-
-#ifdef PHP_WIN32
-#include <winsock2.h> /* Includes definition for u_char */
-#endif
-
-static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *));
-static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *));
-
-#define ISIZE sizeof(int)
-#define PSIZE sizeof(u_char *)
-#define ICOPY_LIST(src, dst, last) \
- do \
- *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \
- while(src < last)
-#define ICOPY_ELT(src, dst, i) \
- do \
- *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \
- while (i -= ISIZE)
-
-#define CCOPY_LIST(src, dst, last) \
- do \
- *dst++ = *src++; \
- while (src < last)
-#define CCOPY_ELT(src, dst, i) \
- do \
- *dst++ = *src++; \
- while (i -= 1)
-
-/*
- * Find the next possible pointer head. (Trickery for forcing an array
- * to do double duty as a linked list when objects do not align with word
- * boundaries.
- */
-/* Assumption: PSIZE is a power of 2. */
-#define EVAL(p) (u_char **) \
- ((u_char *)0 + \
- (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
-
-/* {{{ php_mergesort
- * Arguments are as for qsort.
- */
-PHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *))
-{
- register size_t i;
- register int sense;
- int big, iflag;
- register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
- u_char *list2, *list1, *p2, *p, *last, **p1;
-
- if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */
- errno = EINVAL;
- return (-1);
- }
-
- if (nmemb == 0)
- return (0);
-
- /*
- * XXX
- * Stupid subtraction for the Cray.
- */
- iflag = 0;
- if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
- iflag = 1;
-
- if ((list2 = malloc(nmemb * size + PSIZE)) == NULL)
- return (-1);
-
- list1 = base;
- setup(list1, list2, nmemb, size, cmp);
- last = list2 + nmemb * size;
- i = big = 0;
- while (*EVAL(list2) != last) {
- l2 = list1;
- p1 = EVAL(list1);
- for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
- p2 = *EVAL(p2);
- f1 = l2;
- f2 = l1 = list1 + (p2 - list2);
- if (p2 != last)
- p2 = *EVAL(p2);
- l2 = list1 + (p2 - list2);
- while (f1 < l1 && f2 < l2) {
- if ((*cmp)(f1, f2) <= 0) {
- q = f2;
- b = f1, t = l1;
- sense = -1;
- } else {
- q = f1;
- b = f2, t = l2;
- sense = 0;
- }
- if (!big) { /* here i = 0 */
- while ((b += size) < t && cmp(q, b) >sense)
- if (++i == 6) {
- big = 1;
- goto EXPONENTIAL;
- }
- } else {
-EXPONENTIAL: for (i = size; ; i <<= 1)
- if ((p = (b + i)) >= t) {
- if ((p = t - size) > b &&
- (*cmp)(q, p) <= sense)
- t = p;
- else
- b = p;
- break;
- } else if ((*cmp)(q, p) <= sense) {
- t = p;
- if (i == size)
- big = 0;
- goto FASTCASE;
- } else
- b = p;
- while (t > b+size) {
- i = (((t - b) / size) >> 1) * size;
- if ((*cmp)(q, p = b + i) <= sense)
- t = p;
- else
- b = p;
- }
- goto COPY;
-FASTCASE: while (i > size)
- if ((*cmp)(q,
- p = b + (i >>= 1)) <= sense)
- t = p;
- else
- b = p;
-COPY: b = t;
- }
- i = size;
- if (q == f1) {
- if (iflag) {
- ICOPY_LIST(f2, tp2, b);
- ICOPY_ELT(f1, tp2, i);
- } else {
- CCOPY_LIST(f2, tp2, b);
- CCOPY_ELT(f1, tp2, i);
- }
- } else {
- if (iflag) {
- ICOPY_LIST(f1, tp2, b);
- ICOPY_ELT(f2, tp2, i);
- } else {
- CCOPY_LIST(f1, tp2, b);
- CCOPY_ELT(f2, tp2, i);
- }
- }
- }
- if (f2 < l2) {
- if (iflag)
- ICOPY_LIST(f2, tp2, l2);
- else
- CCOPY_LIST(f2, tp2, l2);
- } else if (f1 < l1) {
- if (iflag)
- ICOPY_LIST(f1, tp2, l1);
- else
- CCOPY_LIST(f1, tp2, l1);
- }
- *p1 = l2;
- }
- tp2 = list1; /* swap list1, list2 */
- list1 = list2;
- list2 = tp2;
- last = list2 + nmemb*size;
- }
- if (base == list2) {
- memmove(list2, list1, nmemb*size);
- list2 = list1;
- }
- free(list2);
- return (0);
-}
-/* }}} */
-
-#define swap(a, b) { \
- s = b; \
- i = size; \
- do { \
- tmp = *a; *a++ = *s; *s++ = tmp; \
- } while (--i); \
- a -= size; \
- }
-#define reverse(bot, top) { \
- s = top; \
- do { \
- i = size; \
- do { \
- tmp = *bot; *bot++ = *s; *s++ = tmp; \
- } while (--i); \
- s -= size2; \
- } while(bot < s); \
-}
-
-/* {{{ setup
- * Optional hybrid natural/pairwise first pass. Eats up list1 in runs of
- * increasing order, list2 in a corresponding linked list. Checks for runs
- * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL
- * is defined. Otherwise simple pairwise merging is used.)
- */
-static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *))
-{
- size_t i, length, size2, sense;
- u_char *f1, *f2, *s, *l2, *last, *p2, tmp;
-
- size2 = size*2;
- if (n <= 5) {
- insertionsort(list1, n, size, cmp);
- *EVAL(list2) = (u_char*) list2 + n*size;
- return;
- }
- /*
- * Avoid running pointers out of bounds; limit n to evens
- * for simplicity.
- */
- i = 4 + (n & 1);
- insertionsort(list1 + (n - i) * size, i, size, cmp);
- last = list1 + size * (n - i);
- *EVAL(list2 + (last - list1)) = list2 + n * size;
-
-#ifdef NATURAL
- p2 = list2;
- f1 = list1;
- sense = (cmp(f1, f1 + size) > 0);
- for (; f1 < last; sense = !sense) {
- length = 2;
- /* Find pairs with same sense. */
- for (f2 = f1 + size2; f2 < last; f2 += size2) {
- if ((cmp(f2, f2+ size) > 0) != sense)
- break;
- length += 2;
- }
- if (length < THRESHOLD) { /* Pairwise merge */
- do {
- p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
- if (sense > 0)
- swap (f1, f1 + size);
- } while ((f1 += size2) < f2);
- } else { /* Natural merge */
- l2 = f2;
- for (f2 = f1 + size2; f2 < l2; f2 += size2) {
- if ((cmp(f2-size, f2) > 0) != sense) {
- p2 = *EVAL(p2) = f2 - list1 + list2;
- if (sense > 0)
- reverse(f1, f2-size);
- f1 = f2;
- }
- }
- if (sense > 0)
- reverse (f1, f2-size);
- f1 = f2;
- if (f2 < last || cmp(f2 - size, f2) > 0)
- p2 = *EVAL(p2) = f2 - list1 + list2;
- else
- p2 = *EVAL(p2) = list2 + n*size;
- }
- }
-#else /* pairwise merge only. */
- for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
- p2 = *EVAL(p2) = p2 + size2;
- if (cmp (f1, f1 + size) > 0)
- swap(f1, f1 + size);
- }
-#endif /* NATURAL */
-}
-/* }}} */
-
-/* {{{ insertionsort
- * This is to avoid out-of-bounds addresses in sorting the
- * last 4 elements.
- */
-static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *))
-{
- u_char *ai, *s, *t, *u, tmp;
- size_t i;
-
- for (ai = a+size; --n >= 1; ai += size)
- for (t = ai; t > a; t -= size) {
- u = t - size;
- if (cmp(u, t) <= 0)
- break;
- swap(u, t);
- }
-}
-/* }}} */
diff --git a/main/network.c b/main/network.c
index f2c54ed3b0..336d311068 100644
--- a/main/network.c
+++ b/main/network.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -770,7 +768,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
/* {{{ php_network_connect_socket_to_host */
php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
- int *error_code, char *bindto, unsigned short bindport, long sockopts
+ int *error_code, const char *bindto, unsigned short bindport, long sockopts
)
{
int num_addrs, n, fatal = 0;
@@ -877,7 +875,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
#endif
if (!local_address || bind(sock, local_address, local_address_len)) {
- php_error_docref(NULL, E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno));
+ php_error_docref(NULL, E_WARNING, "Failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno));
}
skip_bind:
if (local_address) {
@@ -1175,16 +1173,18 @@ PHPAPI void _php_emit_fd_setsize_warning(int max_fd)
PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
{
fd_set rset, wset, eset;
- php_socket_t max_fd = SOCK_ERR;
+ php_socket_t max_fd = SOCK_ERR; /* effectively unused on Windows */
unsigned int i;
int n;
struct timeval tv;
+#ifndef PHP_WIN32
/* check the highest numbered descriptor */
for (i = 0; i < nfds; i++) {
if (ufds[i].fd > max_fd)
max_fd = ufds[i].fd;
}
+#endif
PHP_SAFE_MAX_FD(max_fd, nfds + 1);
@@ -1208,7 +1208,7 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
-/* Reseting/initializing */
+/* Resetting/initializing */
#ifdef PHP_WIN32
WSASetLastError(0);
#else
@@ -1307,7 +1307,7 @@ struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char *
#endif
#endif
-PHPAPI struct hostent* php_network_gethostbyname(char *name) {
+PHPAPI struct hostent* php_network_gethostbyname(const char *name) {
#if !defined(HAVE_GETHOSTBYNAME_R)
return gethostbyname(name);
#else
diff --git a/main/output.c b/main/output.c
index 7751586dbc..4639001dd4 100644
--- a/main/output.c
+++ b/main/output.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -33,7 +31,7 @@
#include "zend_stack.h"
#include "php_output.h"
-PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output);
+PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output)
const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler";
const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler";
@@ -592,9 +590,9 @@ PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_n
{
if (php_output_handler_started(handler_set, handler_set_len)) {
if (handler_new_len != handler_set_len || memcmp(handler_new, handler_set, handler_set_len)) {
- php_error_docref("ref.outcontrol", E_WARNING, "output handler '%s' conflicts with '%s'", handler_new, handler_set);
+ php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' conflicts with '%s'", handler_new, handler_set);
} else {
- php_error_docref("ref.outcontrol", E_WARNING, "output handler '%s' cannot be used twice", handler_new);
+ php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' cannot be used twice", handler_new);
}
return 1;
}
@@ -1199,12 +1197,12 @@ static int php_output_stack_pop(int flags)
if (!orphan) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to %s buffer. No buffer to %s", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to %s buffer. No buffer to %s", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send");
}
return 0;
} else if (!(flags & PHP_OUTPUT_POP_FORCE) && !(orphan->flags & PHP_OUTPUT_HANDLER_REMOVABLE)) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", ZSTR_VAL(orphan->name), orphan->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", ZSTR_VAL(orphan->name), orphan->level);
}
return 0;
} else {
@@ -1301,7 +1299,7 @@ PHP_FUNCTION(ob_start)
zend_long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zll", &output_handler, &chunk_size, &flags) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (chunk_size < 0) {
@@ -1309,7 +1307,7 @@ PHP_FUNCTION(ob_start)
}
if (php_output_start_user(output_handler, chunk_size, flags) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to create buffer");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to create buffer");
RETURN_FALSE;
}
RETURN_TRUE;
@@ -1321,16 +1319,16 @@ PHP_FUNCTION(ob_start)
PHP_FUNCTION(ob_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to flush buffer. No buffer to flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to flush buffer. No buffer to flush");
RETURN_FALSE;
}
if (SUCCESS != php_output_flush()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to flush buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to flush buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
@@ -1342,16 +1340,16 @@ PHP_FUNCTION(ob_flush)
PHP_FUNCTION(ob_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
if (SUCCESS != php_output_clean()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
@@ -1363,11 +1361,11 @@ PHP_FUNCTION(ob_clean)
PHP_FUNCTION(ob_end_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete and flush buffer. No buffer to delete or flush");
RETURN_FALSE;
}
@@ -1380,11 +1378,11 @@ PHP_FUNCTION(ob_end_flush)
PHP_FUNCTION(ob_end_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
@@ -1392,31 +1390,31 @@ PHP_FUNCTION(ob_end_clean)
}
/* }}} */
-/* {{{ proto bool ob_get_flush(void)
+/* {{{ proto string|false ob_get_flush(void)
Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_get_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_contents(return_value) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete and flush buffer. No buffer to delete or flush");
RETURN_FALSE;
}
if (SUCCESS != php_output_end()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
}
}
/* }}} */
-/* {{{ proto bool ob_get_clean(void)
+/* {{{ proto string|false ob_get_clean(void)
Get current buffer contents and delete current output buffer */
PHP_FUNCTION(ob_get_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if(!OG(active)) {
@@ -1424,22 +1422,22 @@ PHP_FUNCTION(ob_get_clean)
}
if (php_output_get_contents(return_value) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
if (SUCCESS != php_output_discard()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
}
}
/* }}} */
-/* {{{ proto string ob_get_contents(void)
+/* {{{ proto string|false ob_get_contents(void)
Return the contents of the output buffer */
PHP_FUNCTION(ob_get_contents)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_contents(return_value) == FAILURE) {
@@ -1453,19 +1451,19 @@ PHP_FUNCTION(ob_get_contents)
PHP_FUNCTION(ob_get_level)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
RETURN_LONG(php_output_get_level());
}
/* }}} */
-/* {{{ proto int ob_get_length(void)
+/* {{{ proto int|false ob_get_length(void)
Return the length of the output buffer */
PHP_FUNCTION(ob_get_length)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_length(return_value) == FAILURE) {
@@ -1474,12 +1472,12 @@ PHP_FUNCTION(ob_get_length)
}
/* }}} */
-/* {{{ proto false|array ob_list_handlers()
+/* {{{ proto null|array ob_list_handlers()
List all output_buffers in an array */
PHP_FUNCTION(ob_list_handlers)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
array_init(return_value);
@@ -1499,7 +1497,7 @@ PHP_FUNCTION(ob_get_status)
zend_bool full_status = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &full_status) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
@@ -1523,7 +1521,7 @@ PHP_FUNCTION(ob_implicit_flush)
zend_long flag = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
- return;
+ RETURN_THROWS();
}
php_output_set_implicit_flush(flag);
@@ -1535,7 +1533,7 @@ PHP_FUNCTION(ob_implicit_flush)
PHP_FUNCTION(output_reset_rewrite_vars)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_url_scanner_reset_vars() == SUCCESS) {
@@ -1554,7 +1552,7 @@ PHP_FUNCTION(output_add_rewrite_var)
size_t name_len, value_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &value, &value_len) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_url_scanner_add_var(name, name_len, value, value_len, 1) == SUCCESS) {
diff --git a/main/php.h b/main/php.h
index dbd7673643..76ced5907e 100644
--- a/main/php.h
+++ b/main/php.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -24,7 +22,7 @@
#include <dmalloc.h>
#endif
-#define PHP_API_VERSION 20190902
+#define PHP_API_VERSION 20190128
#define PHP_HAVE_STREAMS
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
@@ -128,7 +126,7 @@ typedef int pid_t;
#endif
#include <assert.h>
-#if HAVE_UNIX_H
+#ifdef HAVE_UNIX_H
#include <unix.h>
#endif
@@ -295,11 +293,10 @@ END_EXTERN_C()
#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
/* global variables */
-#if !defined(PHP_WIN32)
-#define PHP_SLEEP_NON_VOID
+#ifndef PHP_WIN32
#define php_sleep sleep
extern char **environ;
-#endif /* !defined(PHP_WIN32) */
+#endif /* ifndef PHP_WIN32 */
#ifdef PHP_PWRITE_64
ssize_t pwrite(int, void *, size_t, off64_t);
@@ -312,8 +309,8 @@ ssize_t pread(int, void *, size_t, off64_t);
BEGIN_EXTERN_C()
void phperror(char *error);
PHPAPI size_t php_write(void *buf, size_t size);
-PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
- 2);
+PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
+PHPAPI size_t php_printf_unchecked(const char *format, ...);
PHPAPI int php_get_module_initialized(void);
#ifdef HAVE_SYSLOG_H
#include "php_syslog.h"
@@ -321,7 +318,7 @@ PHPAPI int php_get_module_initialized(void);
#else
#define php_log_err(msg) php_log_err_with_severity(msg, 5)
#endif
-PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int);
+PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int);
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
int cfgparse(void);
END_EXTERN_C()
@@ -363,7 +360,6 @@ END_EXTERN_C()
BEGIN_EXTERN_C()
PHPAPI extern int (*php_register_internal_extensions_func)(void);
PHPAPI int php_register_internal_extensions(void);
-PHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *));
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
PHPAPI void php_com_initialize(void);
PHPAPI char *php_get_current_user(void);
diff --git a/main/php_compat.h b/main/php_compat.h
index 01d3e326c5..4dcf39dc22 100644
--- a/main/php_compat.h
+++ b/main/php_compat.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_content_types.c b/main/php_content_types.c
index b53ee1ab84..d953afcec6 100644
--- a/main/php_content_types.c
+++ b/main/php_content_types.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_content_types.h b/main/php_content_types.h
index 145e8d4c5e..b1bae1dd0c 100644
--- a/main/php_content_types.h
+++ b/main/php_content_types.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_getopt.h b/main/php_getopt.h
index c368aa7fa9..c68d3969c4 100644
--- a/main/php_getopt.h
+++ b/main/php_getopt.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_globals.h b/main/php_globals.h
index 6b31d9eaa6..42337e5b9b 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -67,8 +65,7 @@ struct _php_core_globals {
zend_long memory_limit;
zend_long max_input_time;
- zend_bool track_errors;
- zend_bool display_errors;
+ zend_uchar display_errors;
zend_bool display_startup_errors;
zend_bool log_errors;
zend_long log_errors_max_len;
@@ -136,7 +133,7 @@ struct _php_core_globals {
zend_bool report_zend_debug;
int last_error_type;
- char *last_error_message;
+ zend_string *last_error_message;
char *last_error_file;
int last_error_lineno;
diff --git a/main/php_ini.c b/main/php_ini.c
index cc2cf16cf8..63d3db09b8 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -780,7 +778,7 @@ void php_ini_register_extensions(void)
/* {{{ php_parse_user_ini_file
*/
-PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash)
+PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash)
{
zend_stat_t sb;
char ini_file[MAXPATHLEN];
diff --git a/main/php_ini.h b/main/php_ini.h
index a4fad6c689..7fd7cdd1ce 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -31,7 +29,7 @@ PHPAPI zval *cfg_get_entry(const char *name, size_t name_length);
PHPAPI int cfg_get_long(const char *varname, zend_long *result);
PHPAPI int cfg_get_double(const char *varname, double *result);
PHPAPI int cfg_get_string(const char *varname, char **result);
-PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash);
+PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash);
PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage);
PHPAPI int php_ini_has_per_dir_config(void);
PHPAPI int php_ini_has_per_host_config(void);
diff --git a/main/php_main.h b/main/php_main.h
index 44eeb974d6..ee27209fbe 100644
--- a/main/php_main.h
+++ b/main/php_main.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h
index 7db25dd1dd..5d0b978aad 100644
--- a/main/php_memory_streams.h
+++ b/main/php_memory_streams.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -42,12 +40,12 @@
BEGIN_EXTERN_C()
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC);
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC);
+PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC);
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC);
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC);
+PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC);
PHPAPI int php_stream_mode_from_str(const char *mode);
PHPAPI const char *_php_stream_mode_to_str(int mode);
diff --git a/main/php_network.h b/main/php_network.h
index 241ca94e27..437069b4fc 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -243,7 +241,7 @@ PHPAPI void php_network_freeaddresses(struct sockaddr **sal);
PHPAPI php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
- int *error_code, char *bindto, unsigned short bindport, long sockopts
+ int *error_code, const char *bindto, unsigned short bindport, long sockopts
);
PHPAPI int php_network_connect_socket(php_socket_t sockfd,
@@ -317,7 +315,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
PHPAPI int php_network_parse_network_address_with_port(const char *addr,
zend_long addrlen, struct sockaddr *sa, socklen_t *sl);
-PHPAPI struct hostent* php_network_gethostbyname(char *name);
+PHPAPI struct hostent* php_network_gethostbyname(const char *name);
PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
END_EXTERN_C()
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 6fca7e4cab..a65b91e84e 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h
index 0195056e31..deb8e240e5 100644
--- a/main/php_open_temporary_file.h
+++ b/main/php_open_temporary_file.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_output.h b/main/php_output.h
index f76d61d841..60f389b2b5 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h
index bbc772b5db..62c1ca232f 100644
--- a/main/php_reentrancy.h
+++ b/main/php_reentrancy.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -101,12 +99,6 @@ char *strtok_r(char *s, const char *delim, char **last);
#endif
#endif
-#if !defined(HAVE_RAND_R)
-PHPAPI int php_rand_r(unsigned int *seed);
-#else
-#define php_rand_r rand_r
-#endif
-
END_EXTERN_C()
#if !defined(ZTS)
diff --git a/main/php_scandir.c b/main/php_scandir.c
index 7fdb49b77a..91bfabc73c 100644
--- a/main/php_scandir.c
+++ b/main/php_scandir.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_scandir.h b/main/php_scandir.h
index 04bf29f2c9..834d0b7f1e 100644
--- a/main/php_scandir.h
+++ b/main/php_scandir.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_stdint.h b/main/php_stdint.h
index 3e5fd0016c..42bf9aa316 100644
--- a/main/php_stdint.h
+++ b/main/php_stdint.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -41,25 +39,12 @@
# endif
#endif
+#include <inttypes.h>
+#include <stdint.h>
#if defined(_MSC_VER)
-/* Make sure the regular stdint.h wasn't included already and prevent it to be
- included afterwards. Though if some other library needs some stuff from
- stdint.h included afterwards and misses it, we'd have to extend ours. On
- the other hand, if stdint.h was included before, some conflicts might
- happen so we'd likewise have to fix ours. */
-# if !defined(_STDINT)
-# define _STDINT
-# include "win32/php_stdint.h"
-# include "win32/php_inttypes.h"
+# ifndef u_char
+typedef unsigned __int8 u_char;
# endif
-# define HAVE_INT8_T 1
-# define HAVE_UINT8_T 1
-# define HAVE_INT16_T 1
-# define HAVE_UINT16_T 1
-# define HAVE_INT32_T 1
-# define HAVE_UINT32_T 1
-# define HAVE_INT64_T 1
-# define HAVE_UINT64_T 1
#else
#include "php_config.h"
@@ -68,14 +53,6 @@
# include <sys/types.h>
#endif
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
#ifndef HAVE_INT8_T
# ifdef HAVE_INT8
typedef int8 int8_t;
diff --git a/main/php_streams.h b/main/php_streams.h
index 11e7c2aae7..73740a7a79 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -260,13 +258,13 @@ END_EXTERN_C()
#define php_stream_from_zval(xstr, pzval) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), \
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
} while (0)
#define php_stream_from_res(xstr, res) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2((res), \
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
} while (0)
#define php_stream_from_res_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2((res), "stream", php_file_le_stream(), php_file_le_pstream())
diff --git a/main/php_syslog.c b/main/php_syslog.c
index 987ef9cc0c..37bf5a7fb6 100644
--- a/main/php_syslog.c
+++ b/main/php_syslog.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_syslog.h b/main/php_syslog.h
index 2c499269a4..227baa8b16 100644
--- a/main/php_syslog.h
+++ b/main/php_syslog.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_ticks.c b/main/php_ticks.c
index f5b0dd0c58..0fd0dde6fe 100644
--- a/main/php_ticks.c
+++ b/main/php_ticks.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_ticks.h b/main/php_ticks.h
index 5b2bb057e6..cc92eae8fc 100644
--- a/main/php_ticks.h
+++ b/main/php_ticks.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_variables.c b/main/php_variables.c
index 1a40c2a19f..0a1eb0b4cd 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -27,33 +25,24 @@
#include "php_content_types.h"
#include "SAPI.h"
#include "zend_globals.h"
-#ifdef PHP_WIN32
-# include "win32/php_inttypes.h"
-#endif
/* for systems that need to override reading of environment variables */
void _php_import_environment_variables(zval *array_ptr);
PHPAPI void (*php_import_environment_variables)(zval *array_ptr) = _php_import_environment_variables;
-PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array)
+PHPAPI void php_register_variable(const char *var, const char *strval, zval *track_vars_array)
{
php_register_variable_safe(var, strval, strlen(strval), track_vars_array);
}
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array)
+PHPAPI void php_register_variable_safe(const char *var, const char *strval, size_t str_len, zval *track_vars_array)
{
zval new_entry;
assert(strval != NULL);
- /* Prepare value */
- if (str_len == 0) {
- ZVAL_EMPTY_STRING(&new_entry);
- } else if (str_len == 1) {
- ZVAL_INTERNED_STR(&new_entry, ZSTR_CHAR((zend_uchar)*strval));
- } else {
- ZVAL_NEW_STR(&new_entry, zend_string_init(strval, str_len, 0));
- }
+ ZVAL_STRINGL_FAST(&new_entry, strval, str_len);
+
php_register_variable_ex(var, &new_entry, track_vars_array);
}
@@ -65,7 +54,7 @@ static zend_always_inline void php_register_variable_quick(const char *name, siz
zend_string_release_ex(key, 0);
}
-PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array)
+PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *track_vars_array)
{
char *p = NULL;
char *ip = NULL; /* index pointer */
@@ -557,13 +546,7 @@ static zend_always_inline void import_environment_variable(HashTable *ht, char *
name_len = p - env;
p++;
len = strlen(p);
- if (len == 0) {
- ZVAL_EMPTY_STRING(&val);
- } else if (len == 1) {
- ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
- } else {
- ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
- }
+ ZVAL_STRINGL_FAST(&val, p, len);
if (ZEND_HANDLE_NUMERIC_STR(env, name_len, idx)) {
zend_hash_index_update(ht, idx, &val);
} else {
@@ -573,21 +556,15 @@ static zend_always_inline void import_environment_variable(HashTable *ht, char *
void _php_import_environment_variables(zval *array_ptr)
{
-#ifndef PHP_WIN32
- char **env;
-#else
- char *environment, *env;
-#endif
-
tsrm_env_lock();
#ifndef PHP_WIN32
- for (env = environ; env != NULL && *env != NULL; env++) {
+ for (char **env = environ; env != NULL && *env != NULL; env++) {
import_environment_variable(Z_ARRVAL_P(array_ptr), *env);
}
#else
- environment = GetEnvironmentStringsA();
- for (env = environment; env != NULL && *env; env += strlen(env) + 1) {
+ char *environment = GetEnvironmentStringsA();
+ for (char *env = environment; env != NULL && *env; env += strlen(env) + 1) {
import_environment_variable(Z_ARRVAL_P(array_ptr), env);
}
FreeEnvironmentStringsA(environment);
@@ -604,11 +581,10 @@ zend_bool php_std_auto_global_callback(char *name, uint32_t name_len)
/* {{{ php_build_argv
*/
-PHPAPI void php_build_argv(char *s, zval *track_vars_array)
+PHPAPI void php_build_argv(const char *s, zval *track_vars_array)
{
zval arr, argc, tmp;
int count = 0;
- char *ss, *space;
if (!(SG(request_info).argc || track_vars_array)) {
return;
@@ -626,24 +602,18 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array)
}
}
} else if (s && *s) {
- ss = s;
- while (ss) {
- space = strchr(ss, '+');
- if (space) {
- *space = '\0';
- }
+ while (1) {
+ const char *space = strchr(s, '+');
/* auto-type */
- ZVAL_STRING(&tmp, ss);
+ ZVAL_STRINGL(&tmp, s, space ? space - s : strlen(s));
count++;
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
zend_string_efree(Z_STR(tmp));
}
- if (space) {
- *space = '+';
- ss = space + 1;
- } else {
- ss = space;
+ if (!space) {
+ break;
}
+ s = space + 1;
}
}
diff --git a/main/php_variables.h b/main/php_variables.h
index 7dc33d328a..c6ccbe6a72 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -34,12 +32,12 @@
BEGIN_EXTERN_C()
void php_startup_auto_globals(void);
extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr);
-PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array);
+PHPAPI void php_register_variable(const char *var, const char *val, zval *track_vars_array);
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *val, size_t val_len, zval *track_vars_array);
-PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array);
+PHPAPI void php_register_variable_safe(const char *var, const char *val, size_t val_len, zval *track_vars_array);
+PHPAPI void php_register_variable_ex(const char *var, zval *val, zval *track_vars_array);
-PHPAPI void php_build_argv(char *s, zval *track_vars_array);
+PHPAPI void php_build_argv(const char *s, zval *track_vars_array);
PHPAPI int php_hash_environment(void);
END_EXTERN_C()
diff --git a/main/php_version.h b/main/php_version.h
index 9924d06d19..24765617cb 100644
--- a/main/php_version.h
+++ b/main/php_version.h
@@ -1,8 +1,8 @@
/* automatically generated by configure */
/* edit configure.ac to change version number */
-#define PHP_MAJOR_VERSION 7
-#define PHP_MINOR_VERSION 4
-#define PHP_RELEASE_VERSION 7
+#define PHP_MAJOR_VERSION 8
+#define PHP_MINOR_VERSION 0
+#define PHP_RELEASE_VERSION 0
#define PHP_EXTRA_VERSION "-dev"
-#define PHP_VERSION "7.4.7-dev"
-#define PHP_VERSION_ID 70407
+#define PHP_VERSION "8.0.0-dev"
+#define PHP_VERSION_ID 80000
diff --git a/main/reentrancy.c b/main/reentrancy.c
index e4c378f659..776bcb9f35 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -215,63 +213,6 @@ void reentrancy_shutdown(void)
#endif
-#ifndef HAVE_RAND_R
-
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
- */
-
-#include <sys/types.h>
-#include <stdlib.h>
-
-static int
-do_rand(unsigned long *ctx)
-{
- return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)PHP_RAND_MAX + 1));
-}
-
-
-PHPAPI int
-php_rand_r(unsigned int *ctx)
-{
- u_long val = (u_long) *ctx;
- *ctx = do_rand(&val);
- return (int) *ctx;
-}
-
-#endif
-
#ifndef HAVE_STRTOK_R
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 8bdc409296..9dcd5ad07f 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -1139,11 +1137,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
snprintf(lbuf, llen, "%s_name", param);
}
- /* The \ check should technically be needed for win32 systems only where
- * it is a valid path separator. However, IE in all it's wisdom always sends
- * the full path of the file on the user's filesystem, which means that unless
- * the user does basename() they get a bogus file name. Until IE's user base drops
- * to nill or problem is fixed this code must remain enabled for all systems. */
+ /* Pursuant to RFC 7578, strip any path components in the
+ * user-supplied file name:
+ * > If a "filename" parameter is supplied ... do not use
+ * > directory path information that may be present."
+ */
s = _basename(internal_encoding, filename);
if (!s) {
s = filename;
@@ -1200,7 +1198,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
{
/* store temp_filename as-is (in case upload_tmp_dir
- * contains escapeable characters. escape only the variable name.) */
+ * contains escapable characters. escape only the variable name.) */
zval zfilename;
/* Initialize variables */
diff --git a/main/rfc1867.h b/main/rfc1867.h
index bfb9bb51c6..2fb396b40c 100644
--- a/main/rfc1867.h
+++ b/main/rfc1867.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/snprintf.c b/main/snprintf.c
index 61a5dfffce..581cac1d3b 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -29,10 +27,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
-
-#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#endif
#include <locale.h>
#ifdef ZTS
@@ -714,25 +709,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
fmt++;
modifier = LM_LONG_DOUBLE;
break;
- case 'I':
- fmt++;
-#if SIZEOF_LONG_LONG
- if (*fmt == '6' && *(fmt+1) == '4') {
- fmt += 2;
- modifier = LM_LONG_LONG;
- } else
-#endif
- if (*fmt == '3' && *(fmt+1) == '2') {
- fmt += 2;
- modifier = LM_LONG;
- } else {
-#ifdef _WIN64
- modifier = LM_LONG_LONG;
-#else
- modifier = LM_LONG;
-#endif
- }
- break;
case 'l':
fmt++;
#if SIZEOF_LONG_LONG
@@ -982,7 +958,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
case 's':
- case 'v':
s = va_arg(ap, char *);
if (s != NULL) {
s_len = strlen(s);
diff --git a/main/snprintf.h b/main/snprintf.h
index 93d2034bb6..8a36562127 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/spprintf.c b/main/spprintf.c
index a20705016a..768a27470c 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -85,9 +83,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
-#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#endif
#include <locale.h>
#ifdef ZTS
@@ -314,25 +310,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
fmt++;
modifier = LM_LONG_DOUBLE;
break;
- case 'I':
- fmt++;
-#if SIZEOF_LONG_LONG
- if (*fmt == '6' && *(fmt+1) == '4') {
- fmt += 2;
- modifier = LM_LONG_LONG;
- } else
-#endif
- if (*fmt == '3' && *(fmt+1) == '2') {
- fmt += 2;
- modifier = LM_LONG;
- } else {
-#ifdef _WIN64
- modifier = LM_LONG_LONG;
-#else
- modifier = LM_LONG;
-#endif
- }
- break;
case 'l':
fmt++;
#if SIZEOF_LONG_LONG
@@ -589,7 +566,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
case 's':
- case 'v':
s = va_arg(ap, char *);
if (s != NULL) {
if (!adjust_precision) {
diff --git a/main/spprintf.h b/main/spprintf.h
index bbb7add25c..afb3b505b8 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 262ec5e38f..76d4aa2263 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -295,7 +293,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
}
if (php_stream_is_filtered(stream)) {
- php_error_docref(NULL, E_WARNING, "cannot cast a filtered stream on this system");
+ php_error_docref(NULL, E_WARNING, "Cannot cast a filtered stream on this system");
return FAILURE;
} else if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS) {
goto exit_success;
@@ -310,7 +308,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
"select()able descriptor"
};
- php_error_docref(NULL, E_WARNING, "cannot represent a stream of type %s as a %s", stream->ops->label, cast_names[castas]);
+ php_error_docref(NULL, E_WARNING, "Cannot represent a stream of type %s as a %s", stream->ops->label, cast_names[castas]);
}
return FAILURE;
diff --git a/main/streams/filter.c b/main/streams/filter.c
index f536b92a02..e14925c1d7 100644
--- a/main/streams/filter.c
+++ b/main/streams/filter.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -255,9 +253,9 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
if (filter == NULL) {
/* TODO: these need correct docrefs */
if (factory == NULL)
- php_error_docref(NULL, E_WARNING, "unable to locate filter \"%s\"", filtername);
+ php_error_docref(NULL, E_WARNING, "Unable to locate filter \"%s\"", filtername);
else
- php_error_docref(NULL, E_WARNING, "unable to create or locate filter \"%s\"", filtername);
+ php_error_docref(NULL, E_WARNING, "Unable to create or locate filter \"%s\"", filtername);
}
return filter;
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 0e72558a2a..212d905e16 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/memory.c b/main/streams/memory.c
index 4b92fc2ffd..0def3b1a3d 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -256,9 +254,9 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu
ms->fsize = newsize;
return PHP_STREAM_OPTION_RETURN_OK;
}
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
/* }}} */
@@ -317,7 +315,7 @@ PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC)
/* {{{ */
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC)
+PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_memory_data *ms;
@@ -327,7 +325,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
/* use the buffer directly */
- ms->data = buf;
+ ms->data = (char *) buf;
ms->fsize = length;
} else {
if (length) {
@@ -600,7 +598,7 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
/* }}} */
/* {{{ _php_stream_temp_open */
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC)
+PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_temp_data *ts;
@@ -621,7 +619,7 @@ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char
/* }}} */
PHPAPI const php_stream_ops php_stream_rfc2397_ops = {
- php_stream_temp_write, php_stream_temp_read,
+ NULL, php_stream_temp_read,
php_stream_temp_close, php_stream_temp_flush,
"RFC2397",
php_stream_temp_seek,
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 63bae87505..c99c63f065 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
index c477dda4ac..29c9ae28a6 100644
--- a/main/streams/php_stream_context.h
+++ b/main/streams/php_stream_context.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -102,7 +100,7 @@ END_EXTERN_C()
(context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)
-#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \
+#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && ((context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS)) { \
(context)->notifier->progress += (dsofar); \
(context)->notifier->progress_max += (dmax); \
php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
index 4d5760e2cf..9df312152a 100644
--- a/main/streams/php_stream_filter_api.h
+++ b/main/streams/php_stream_filter_api.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h
index 644e5ab7e4..f4c8e05b7e 100644
--- a/main/streams/php_stream_glob_wrapper.h
+++ b/main/streams/php_stream_glob_wrapper.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index 132f3214c1..aae9097b41 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h
index 4af8b86cdd..44910bf320 100644
--- a/main/streams/php_stream_plain_wrapper.h
+++ b/main/streams/php_stream_plain_wrapper.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index f49d9c787d..69d2b9a774 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h
index 389d591921..4171a0d953 100644
--- a/main/streams/php_stream_userspace.h
+++ b/main/streams/php_stream_userspace.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
index 1bc6fdc89c..ab00549a6e 100644
--- a/main/streams/php_streams_int.h
+++ b/main/streams/php_streams_int.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 8f7774a30e..34d0590f44 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -135,11 +133,11 @@ typedef struct {
int lock_flag; /* stores the lock state */
zend_string *temp_name; /* if non-null, this is the path to a temporary file that
* is to be deleted when the stream is closed */
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
char last_op;
#endif
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
char *last_mapped_addr;
size_t last_mapped_len;
#endif
@@ -233,7 +231,7 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char
}
close(fd);
- php_error_docref(NULL, E_WARNING, "unable to allocate stream");
+ php_error_docref(NULL, E_WARNING, "Unable to allocate stream");
return NULL;
}
@@ -355,12 +353,12 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
/* TODO: Should this be treated as a proper error or not? */
return bytes_written;
}
- php_error_docref(NULL, E_NOTICE, "write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ php_error_docref(NULL, E_NOTICE, "Write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
}
return bytes_written;
} else {
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
if (data->is_seekable && data->last_op == 'r') {
zend_fseek(data->file, 0, SEEK_CUR);
}
@@ -394,7 +392,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
if (!PeekNamedPipe(ph, NULL, 0, NULL, &avail_read, NULL)) {
break;
}
- /* If there's nothing to read, wait in 10ms periods. */
+ /* If there's nothing to read, wait in 10us periods. */
if (0 == avail_read) {
usleep(10);
}
@@ -423,7 +421,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
} else if (errno == EINTR) {
/* TODO: Should this be treated as a proper error or not? */
} else {
- php_error_docref(NULL, E_NOTICE, "read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ php_error_docref(NULL, E_NOTICE, "Read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
/* TODO: Remove this special-case? */
if (errno != EBADF) {
@@ -435,7 +433,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
}
} else {
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
if (data->is_seekable && data->last_op == 'w')
zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
@@ -455,7 +453,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
assert(data != NULL);
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
if (data->last_mapped_addr) {
munmap(data->last_mapped_addr, data->last_mapped_len);
data->last_mapped_addr = NULL;
@@ -477,7 +475,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
errno = 0;
ret = pclose(data->file);
-#if HAVE_SYS_WAIT_H
+#ifdef HAVE_SYS_WAIT_H
if (WIFEXITED(ret)) {
ret = WEXITSTATUS(ret);
}
@@ -538,7 +536,7 @@ static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, ze
assert(data != NULL);
if (!data->is_seekable) {
- php_error_docref(NULL, E_WARNING, "cannot seek on this stream");
+ php_error_docref(NULL, E_WARNING, "Cannot seek on this stream");
return -1;
}
@@ -706,7 +704,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
break;
case PHP_STREAM_OPTION_MMAP_API:
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
{
php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam;
int prot, flags;
@@ -884,7 +882,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
return PHP_STREAM_OPTION_RETURN_ERR;
}
-#if defined(_WIN64)
+#ifdef _WIN64
sz.QuadPart = new_size;
#else
sz.HighPart = 0;
@@ -905,6 +903,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
#endif
}
}
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
#ifdef PHP_WIN32
case PHP_STREAM_OPTION_PIPE_BLOCKING:
@@ -1031,7 +1030,7 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zen
if (FAILURE == php_stream_parse_fopen_modes(mode, &open_flags)) {
if (options & REPORT_ERRORS) {
- php_error_docref(NULL, E_WARNING, "`%s' is not a valid mode for fopen", mode);
+ zend_value_error("`%s' is not a valid mode for fopen", mode);
}
return NULL;
}
@@ -1228,7 +1227,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
if (php_copy_file(url_from, url_to) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
success = 1;
-# if !defined(TSRM_WIN32)
+# ifndef TSRM_WIN32
/*
* Try to set user and permission info on the target.
* If we're not root, then some of these may fail.
@@ -1295,7 +1294,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
if (!recursive) {
ret = php_mkdir(dir, mode);
} else {
- /* we look for directory separator from the end of string, thus hopefuly reducing our work load */
+ /* we look for directory separator from the end of string, thus hopefully reducing our work load */
char *e;
zend_stat_t sb;
size_t dir_len = strlen(dir), offset = 0;
@@ -1466,7 +1465,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
ret = VCWD_CHMOD(url, mode);
break;
default:
- php_error_docref1(NULL, url, E_WARNING, "Unknown option %d for stream_metadata", option);
+ zend_value_error("Unknown option %d for stream_metadata", option);
return 0;
}
if (ret == -1) {
diff --git a/main/streams/streams.c b/main/streams/streams.c
index f1f8bf7eab..90475a8d90 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -26,7 +24,7 @@
#include "php_network.h"
#include "php_open_temporary_file.h"
#include "ext/standard/file.h"
-#include "ext/standard/basic_functions.h" /* for BG(mmap_file) (not strictly required) */
+#include "ext/standard/basic_functions.h" /* for BG(CurrentStatFile) */
#include "ext/standard/php_string.h" /* for php_memnstr, used by php_stream_get_record() */
#include <stddef.h>
#include <fcntl.h>
@@ -247,7 +245,7 @@ PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int
vspprintf(&buffer, 0, fmt, args);
va_end(args);
- if (options & REPORT_ERRORS || wrapper == NULL) {
+ if ((options & REPORT_ERRORS) || wrapper == NULL) {
php_error_docref(NULL, E_WARNING, "%s", buffer);
efree(buffer);
} else {
@@ -705,7 +703,7 @@ PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t size)
break;
}
- if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) {
+ if (!stream->readfilters.head && ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) || stream->chunk_size == 1)) {
toread = stream->ops->read(stream, buf, size);
if (toread < 0) {
/* Report an error if the read failed and we did not read any data
@@ -1120,7 +1118,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con
/* Writes a buffer directly to a stream, using multiple of the chunk size */
static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, size_t count)
{
- ssize_t didwrite = 0, justwrote;
+ ssize_t didwrite = 0;
/* if we have a seekable stream we need to ensure that data is written at the
* current stream->position. This means invalidating the read buffer and then
@@ -1131,13 +1129,8 @@ static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, siz
stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position);
}
-
while (count > 0) {
- size_t towrite = count;
- if (towrite > stream->chunk_size)
- towrite = stream->chunk_size;
-
- justwrote = stream->ops->write(stream, buf, towrite);
+ ssize_t justwrote = stream->ops->write(stream, buf, count);
if (justwrote <= 0) {
/* If we already successfully wrote some bytes and a write error occurred
* later, report the successfully written bytes. */
@@ -1373,7 +1366,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
return 0;
}
- php_error_docref(NULL, E_WARNING, "stream does not support seeking");
+ php_error_docref(NULL, E_WARNING, "Stream does not support seeking");
return -1;
}
@@ -1862,7 +1855,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
if (localhost == 0 && path[n+3] != '\0' && path[n+3] != '/') {
#endif
if (options & REPORT_ERRORS) {
- php_error_docref(NULL, E_WARNING, "remote host file access not supported, %s", path);
+ php_error_docref(NULL, E_WARNING, "Remote host file access not supported, %s", path);
}
return NULL;
}
@@ -2039,7 +2032,7 @@ PHPAPI php_stream *_php_stream_opendir(const char *path, int options,
php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS, "not implemented");
}
if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open dir");
+ php_stream_display_wrapper_errors(wrapper, path, "Failed to open directory");
}
php_stream_tidy_wrapper_error_log(wrapper);
@@ -2095,7 +2088,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
path_to_open = path;
wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options);
- if (options & STREAM_USE_URL && (!wrapper || !wrapper->is_url)) {
+ if ((options & STREAM_USE_URL) && (!wrapper || !wrapper->is_url)) {
php_error_docref(NULL, E_WARNING, "This function may only be used against URLs");
if (resolved_path) {
zend_string_release_ex(resolved_path, 0);
@@ -2188,7 +2181,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open stream");
+ php_stream_display_wrapper_errors(wrapper, path, "Failed to open stream");
if (opened_path && *opened_path) {
zend_string_release_ex(*opened_path, 0);
*opened_path = NULL;
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 74fbef58d8..fcc3f29330 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -359,7 +357,7 @@ PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_cr
return param.outputs.returncode;
}
- php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ php_error_docref("streams.crypto", E_WARNING, "This stream does not support SSL/crypto");
return ret;
}
@@ -379,7 +377,7 @@ PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate)
return param.outputs.returncode;
}
- php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ php_error_docref("streams.crypto", E_WARNING, "This stream does not support SSL/crypto");
return ret;
}
@@ -401,7 +399,7 @@ PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t bufle
}
if (stream->readfilters.head) {
- php_error_docref(NULL, E_WARNING, "cannot peek or fetch OOB data from a filtered stream");
+ php_error_docref(NULL, E_WARNING, "Cannot peek or fetch OOB data from a filtered stream");
return -1;
}
@@ -471,7 +469,7 @@ PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t b
oob = (flags & STREAM_OOB) == STREAM_OOB;
if ((oob || addr) && stream->writefilters.head) {
- php_error_docref(NULL, E_WARNING, "cannot write OOB data, or data to a targeted address on a filtered stream");
+ php_error_docref(NULL, E_WARNING, "Cannot write OOB data, or data to a targeted address on a filtered stream");
return -1;
}
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 9cf1580a35..ffdd0754e4 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -500,7 +498,7 @@ PHP_FUNCTION(stream_wrapper_register)
zend_long flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &protocol, &classname, &flags) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
uwrap = (struct php_user_stream_wrapper *)ecalloc(1, sizeof(*uwrap));
@@ -525,7 +523,7 @@ PHP_FUNCTION(stream_wrapper_register)
}
}
} else {
- php_error_docref(NULL, E_WARNING, "class '%s' is undefined", ZSTR_VAL(classname));
+ php_error_docref(NULL, E_WARNING, "Class '%s' is undefined", ZSTR_VAL(classname));
}
zend_list_delete(rsrc);
@@ -540,7 +538,7 @@ PHP_FUNCTION(stream_wrapper_unregister)
zend_string *protocol;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
if (php_unregister_url_stream_wrapper_volatile(protocol) == FAILURE) {
@@ -562,7 +560,7 @@ PHP_FUNCTION(stream_wrapper_restore)
HashTable *global_wrapper_hash;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
global_wrapper_hash = php_stream_get_url_stream_wrappers_hash_global();
@@ -1002,7 +1000,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
case PHP_STREAM_TRUNCATE_SUPPORTED:
if (zend_is_callable_ex(&func_name,
Z_ISUNDEF(us->object)? NULL : Z_OBJ(us->object),
- IS_CALLABLE_CHECK_SILENT, NULL, NULL, NULL))
+ 0, NULL, NULL, NULL))
ret = PHP_STREAM_OPTION_RETURN_OK;
else
ret = PHP_STREAM_OPTION_RETURN_ERR;
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 46b23b63ad..f3370e89f7 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -25,7 +23,7 @@
# undef AF_UNIX
#endif
-#if defined(AF_UNIX)
+#ifdef AF_UNIX
#include <sys/un.h>
#endif
@@ -106,7 +104,7 @@ retry:
}
estr = php_socket_strerror(err, NULL, 0);
- php_error_docref(NULL, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
+ php_error_docref(NULL, E_NOTICE, "Send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
(zend_long)count, err, estr);
efree(estr);
}
@@ -239,7 +237,7 @@ static int php_sockop_flush(php_stream *stream)
static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb)
{
-#if ZEND_WIN32
+#ifdef ZEND_WIN32
return 0;
#else
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
@@ -451,12 +449,11 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
#endif
default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
+ break;
}
-
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
static int php_sockop_cast(php_stream *stream, int castas, void **ret)
diff --git a/main/strlcat.c b/main/strlcat.c
index 6ef5644568..3c18360e96 100644
--- a/main/strlcat.c
+++ b/main/strlcat.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/strlcpy.c b/main/strlcpy.c
index 31e13489d8..55959b2f3a 100644
--- a/main/strlcpy.c
+++ b/main/strlcpy.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |