summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortwosee <twose@qq.com>2020-06-07 17:01:19 +0800
committerNikita Popov <nikita.ppv@gmail.com>2020-06-08 10:38:45 +0200
commit88355dd338835f7a59415ecb2e7e970658f3867f (patch)
treef203c58d7656c341273565e2d6fb84d89837bad2 /ext
parentf6db43fec8da3d3c0c7def077e9f493ce6129c45 (diff)
downloadphp-git-88355dd338835f7a59415ecb2e7e970658f3867f.tar.gz
Constify char * arguments of APIs
Closes GH-5676.
Diffstat (limited to 'ext')
-rw-r--r--ext/com_dotnet/com_olechar.c2
-rw-r--r--ext/com_dotnet/com_typeinfo.c2
-rw-r--r--ext/com_dotnet/php_com_dotnet_internal.h4
-rw-r--r--ext/date/php_date.c23
-rw-r--r--ext/date/php_date.h6
-rw-r--r--ext/filter/filter.c4
-rw-r--r--ext/json/json.c2
-rw-r--r--ext/json/json_parser.y4
-rw-r--r--ext/json/json_scanner.re2
-rw-r--r--ext/json/php_json.h4
-rw-r--r--ext/json/php_json_parser.h4
-rw-r--r--ext/json/php_json_scanner.h2
-rw-r--r--ext/opcache/ZendAccelerator.c2
-rw-r--r--ext/openssl/openssl.c44
-rw-r--r--ext/openssl/php_openssl.h26
-rw-r--r--ext/pcre/php_pcre.c22
-rw-r--r--ext/pcre/php_pcre.h4
-rw-r--r--ext/pdo/pdo_sql_parser.re13
-rw-r--r--ext/pdo/php_pdo_driver.h2
-rw-r--r--ext/phar/phar_object.c14
-rw-r--r--ext/session/php_session.h7
-rw-r--r--ext/session/session.c8
-rwxr-xr-xext/standard/basic_functions.c8
-rw-r--r--ext/standard/basic_functions.h8
-rw-r--r--ext/standard/dl.c54
-rw-r--r--ext/standard/dl.h6
-rw-r--r--ext/standard/exec.c6
-rw-r--r--ext/standard/exec.h6
-rw-r--r--ext/standard/head.c8
-rw-r--r--ext/standard/html.c8
-rw-r--r--ext/standard/html.h6
-rw-r--r--ext/standard/http.c2
-rw-r--r--ext/standard/image.c2
-rw-r--r--ext/standard/info.c8
-rw-r--r--ext/standard/info.h5
-rw-r--r--ext/standard/mail.c16
-rw-r--r--ext/standard/math.c4
-rw-r--r--ext/standard/php_http.h2
-rw-r--r--ext/standard/php_image.h2
-rw-r--r--ext/standard/php_mail.h2
-rw-r--r--ext/standard/php_math.h6
-rw-r--r--ext/standard/php_string.h12
-rw-r--r--ext/standard/php_uuencode.h4
-rw-r--r--ext/standard/sha1.c2
-rw-r--r--ext/standard/sha1.h2
-rw-r--r--ext/standard/string.c22
-rw-r--r--ext/standard/url_scanner_ex.h4
-rw-r--r--ext/standard/url_scanner_ex.re12
-rw-r--r--ext/standard/uuencode.c10
49 files changed, 239 insertions, 189 deletions
diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c
index 665773b120..7eda51b73b 100644
--- a/ext/com_dotnet/com_olechar.c
+++ b/ext/com_dotnet/com_olechar.c
@@ -26,7 +26,7 @@
#include "php_com_dotnet_internal.h"
-PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, size_t string_len, int codepage)
+PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string, size_t string_len, int codepage)
{
OLECHAR *olestring = NULL;
DWORD flags = codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS;
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index acd2e3d512..ffd2400f75 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -260,7 +260,7 @@ ITypeLib *php_com_cache_typelib(ITypeLib* TL, char *cache_key, zend_long cache_k
return result;
}
-PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
+PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string,
int codepage, int *cached)
{
ITypeLib *TL;
diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h
index 8521277083..4974bb78e3 100644
--- a/ext/com_dotnet/php_com_dotnet_internal.h
+++ b/ext/com_dotnet/php_com_dotnet_internal.h
@@ -82,7 +82,7 @@ int php_com_saproxy_create(zend_object *com_object, zval *proxy_out, zval *index
/* com_olechar.c */
PHP_COM_DOTNET_API char *php_com_olestring_to_string(OLECHAR *olestring,
size_t *string_len, int codepage);
-PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string,
+PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(const char *string,
size_t string_len, int codepage);
@@ -130,7 +130,7 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v,
PHP_COM_DOTNET_API int php_com_safearray_get_elem(VARIANT *array, VARIANT *dest, LONG dim1);
/* com_typeinfo.c */
-PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,
+PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(const char *search_string,
int codepage, int *cached);
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codepage);
PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode,
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 51c56afb3c..a908fed2c7 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -617,7 +617,7 @@ static const char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib
/* }}} */
/* {{{ date_format - (gm)date helper */
-static zend_string *date_format(char *format, size_t format_len, timelib_time *t, int localtime)
+static zend_string *date_format(const char *format, size_t format_len, timelib_time *t, int localtime)
{
smart_str string = {0};
size_t i;
@@ -798,7 +798,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime)
}
/* }}} */
-PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime) /* {{{ */
+PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime) /* {{{ */
{
timelib_time *t;
timelib_tzinfo *tzi;
@@ -982,14 +982,14 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
/* }}} */
/* {{{ php_parse_date: Backwards compatibility function */
-PHPAPI zend_long php_parse_date(char *string, zend_long *now)
+PHPAPI zend_long php_parse_date(const char *string, zend_long *now)
{
timelib_time *parsed_time;
timelib_error_container *error = NULL;
int error2;
zend_long retval;
- parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+ parsed_time = timelib_strtotime((char *) string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if (error->error_count) {
timelib_time_dtor(parsed_time);
timelib_error_container_dtor(error);
@@ -2187,7 +2187,7 @@ static void php_date_get_current_time_with_fraction(time_t *sec, suseconds_t *us
#endif
}
-PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, size_t time_str_len, char *format, zval *timezone_object, int ctor) /* {{{ */
+PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int ctor) /* {{{ */
{
timelib_time *now;
timelib_tzinfo *tzi = NULL;
@@ -2202,9 +2202,18 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
timelib_time_dtor(dateobj->time);
}
if (format) {
- dateobj->time = timelib_parse_from_format(format, time_str_len ? time_str : "", time_str_len ? time_str_len : 0, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+ if (time_str_len == 0) {
+ time_str = "";
+ }
+ // TODO: drop this const casts
+ dateobj->time = timelib_parse_from_format((char *) format, (char *) time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
} else {
- dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
+ if (time_str_len == 0) {
+ time_str = "now";
+ time_str_len = sizeof("now") - 1;
+ }
+ // TODO: drop this const casts
+ dateobj->time = timelib_strtotime((char *) time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
}
/* update last errors and warnings */
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index 1ab7b3ccd9..b89438e0c5 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -108,14 +108,14 @@ ZEND_END_MODULE_GLOBALS(date)
PHPAPI time_t php_time(void);
/* Backwards compatibility wrapper */
-PHPAPI zend_long php_parse_date(char *string, zend_long *now);
+PHPAPI zend_long php_parse_date(const char *string, zend_long *now);
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
PHPAPI int php_idate(char format, time_t ts, int localtime);
#define _php_strftime php_strftime
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm);
-PHPAPI zend_string *php_format_date(char *format, size_t format_len, time_t ts, int localtime);
+PHPAPI zend_string *php_format_date(const char *format, size_t format_len, time_t ts, int localtime);
/* Mechanism to set new TZ database */
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
@@ -131,7 +131,7 @@ PHPAPI zend_class_entry *php_date_get_period_ce(void);
/* Functions for creating DateTime objects, and initializing them from a string */
PHPAPI zval *php_date_instantiate(zend_class_entry *pce, zval *object);
-PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, size_t time_str_len, char *format, zval *timezone_object, int ctor);
+PHPAPI int php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int ctor);
#endif /* PHP_DATE_H */
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index 8feae0a3df..0e01c30097 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -75,7 +75,7 @@ static const filter_list_entry filter_list[] = {
#define PARSE_SESSION 6
#endif
-static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);
+static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
static unsigned int php_sapi_filter_init(void);
/* {{{ filter_module_entry
@@ -360,7 +360,7 @@ handle_default:
}
/* }}} */
-static unsigned int php_sapi_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */
+static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len) /* {{{ */
{
zval new_var, raw_var;
zval *array_ptr = NULL, *orig_array_ptr = NULL;
diff --git a/ext/json/json.c b/ext/json/json.c
index 68990f5ca4..1797c00c9c 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -195,7 +195,7 @@ static const char *php_json_get_error_msg(php_json_error_code error_code) /* {{{
}
/* }}} */
-PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */
+PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth) /* {{{ */
{
php_json_parser parser;
diff --git a/ext/json/json_parser.y b/ext/json/json_parser.y
index 4705e498a6..8802d18439 100644
--- a/ext/json/json_parser.y
+++ b/ext/json/json_parser.y
@@ -301,7 +301,7 @@ static const php_json_parser_methods default_parser_methods =
PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser,
zval *return_value,
- char *str,
+ const char *str,
size_t str_len,
int options,
int max_depth,
@@ -317,7 +317,7 @@ PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser,
PHP_JSON_API void php_json_parser_init(php_json_parser *parser,
zval *return_value,
- char *str,
+ const char *str,
size_t str_len,
int options,
int max_depth)
diff --git a/ext/json/json_scanner.re b/ext/json/json_scanner.re
index 5b571e6dd2..03ccdde58b 100644
--- a/ext/json/json_scanner.re
+++ b/ext/json/json_scanner.re
@@ -91,7 +91,7 @@ static int php_json_ucs2_to_int(php_json_scanner *s, int size)
return php_json_ucs2_to_int_ex(s, size, 1);
}
-void php_json_scanner_init(php_json_scanner *s, char *str, size_t str_len, int options)
+void php_json_scanner_init(php_json_scanner *s, const char *str, size_t str_len, int options)
{
s->cursor = (php_json_ctype *) str;
s->limit = (php_json_ctype *) str + str_len;
diff --git a/ext/json/php_json.h b/ext/json/php_json.h
index 4fc7ded7d4..ee8affa1d1 100644
--- a/ext/json/php_json.h
+++ b/ext/json/php_json.h
@@ -98,9 +98,9 @@ ZEND_TSRMLS_CACHE_EXTERN()
PHP_JSON_API int php_json_encode_ex(smart_str *buf, zval *val, int options, zend_long depth);
PHP_JSON_API int php_json_encode(smart_str *buf, zval *val, int options);
-PHP_JSON_API int php_json_decode_ex(zval *return_value, char *str, size_t str_len, zend_long options, zend_long depth);
+PHP_JSON_API int php_json_decode_ex(zval *return_value, const char *str, size_t str_len, zend_long options, zend_long depth);
-static inline int php_json_decode(zval *return_value, char *str, int str_len, zend_bool assoc, zend_long depth)
+static inline int php_json_decode(zval *return_value, const char *str, int str_len, zend_bool assoc, zend_long depth)
{
return php_json_decode_ex(return_value, str, str_len, assoc ? PHP_JSON_OBJECT_AS_ARRAY : 0, depth);
}
diff --git a/ext/json/php_json_parser.h b/ext/json/php_json_parser.h
index 05f7a061c6..dc0453f4fa 100644
--- a/ext/json/php_json_parser.h
+++ b/ext/json/php_json_parser.h
@@ -61,7 +61,7 @@ struct _php_json_parser {
PHP_JSON_API void php_json_parser_init_ex(
php_json_parser *parser,
zval *return_value,
- char *str,
+ const char *str,
size_t str_len,
int options,
int max_depth,
@@ -70,7 +70,7 @@ PHP_JSON_API void php_json_parser_init_ex(
PHP_JSON_API void php_json_parser_init(
php_json_parser *parser,
zval *return_value,
- char *str,
+ const char *str,
size_t str_len,
int options,
int max_depth);
diff --git a/ext/json/php_json_scanner.h b/ext/json/php_json_scanner.h
index 7a2d841703..e5a4979591 100644
--- a/ext/json/php_json_scanner.h
+++ b/ext/json/php_json_scanner.h
@@ -40,7 +40,7 @@ typedef struct _php_json_scanner {
} php_json_scanner;
-void php_json_scanner_init(php_json_scanner *scanner, char *str, size_t str_len, int options);
+void php_json_scanner_init(php_json_scanner *scanner, const char *str, size_t str_len, int options);
int php_json_scan(php_json_scanner *s);
#endif /* PHP_JSON_SCANNER_H */
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index ef8f39f7a9..aa81410c82 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -4798,7 +4798,7 @@ static int accel_finish_startup(void)
int (*orig_header_handler)(sapi_header_struct *sapi_header, sapi_header_op_enum op, sapi_headers_struct *sapi_headers) = sapi_module.header_handler;
int (*orig_send_headers)(sapi_headers_struct *sapi_headers) = sapi_module.send_headers;
void (*orig_send_header)(sapi_header_struct *sapi_header, void *server_context)= sapi_module.send_header;
- char *(*orig_getenv)(char *name, size_t name_len) = sapi_module.getenv;
+ char *(*orig_getenv)(const char *name, size_t name_len) = sapi_module.getenv;
size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write;
void (*orig_flush)(void *server_context) = sapi_module.flush;
uint32_t orig_compiler_options = CG(compiler_options);
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 1a0ec6719f..b2c5cefc70 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -6888,7 +6888,7 @@ static void php_openssl_load_cipher_mode(struct php_openssl_cipher_mode *mode, c
}
/* }}} */
-static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_required_len,
+static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_required_len,
zend_bool *free_iv, EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode) /* {{{ */
{
char *iv_new;
@@ -6942,9 +6942,9 @@ static int php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_requir
static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode,
- char **ppassword, size_t *ppassword_len, zend_bool *free_password,
- char **piv, size_t *piv_len, zend_bool *free_iv,
- char *tag, int tag_len, zend_long options, int enc) /* {{{ */
+ const char **ppassword, size_t *ppassword_len, zend_bool *free_password,
+ const char **piv, size_t *piv_len, zend_bool *free_iv,
+ const char *tag, int tag_len, zend_long options, int enc) /* {{{ */
{
unsigned char *key;
int key_len, password_len;
@@ -7014,8 +7014,8 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
EVP_CIPHER_CTX *cipher_ctx, struct php_openssl_cipher_mode *mode,
- zend_string **poutbuf, int *poutlen, char *data, size_t data_len,
- char *aad, size_t aad_len, int enc) /* {{{ */
+ zend_string **poutbuf, int *poutlen, const char *data, size_t data_len,
+ const char *aad, size_t aad_len, int enc) /* {{{ */
{
int i = 0;
@@ -7025,7 +7025,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
return FAILURE;
}
- if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (unsigned char *)aad, (int)aad_len)) {
+ if (mode->is_aead && !EVP_CipherUpdate(cipher_ctx, NULL, &i, (const unsigned char *) aad, (int) aad_len)) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Setting of additional application data failed");
return FAILURE;
@@ -7034,7 +7034,7 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
*poutbuf = zend_string_alloc((int)data_len + EVP_CIPHER_block_size(cipher_type), 0);
if (!EVP_CipherUpdate(cipher_ctx, (unsigned char*)ZSTR_VAL(*poutbuf),
- &i, (unsigned char *)data, (int)data_len)) {
+ &i, (const unsigned char *)data, (int)data_len)) {
/* we don't show warning when we fail but if we ever do, then it should look like this:
if (mode->is_single_run_aead && !enc) {
php_error_docref(NULL, E_WARNING, "Tag verifycation failed");
@@ -7054,7 +7054,14 @@ static int php_openssl_cipher_update(const EVP_CIPHER *cipher_type,
/* }}} */
-PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, char *method, size_t method_len, char *password, size_t password_len, zend_long options, char *iv, size_t iv_len, zval *tag, zend_long tag_len, char *aad, size_t aad_len)
+PHP_OPENSSL_API zend_string* php_openssl_encrypt(
+ const char *data, size_t data_len,
+ const char *method, size_t method_len,
+ const char *password, size_t password_len,
+ zend_long options,
+ const char *iv, size_t iv_len,
+ zval *tag, zend_long tag_len,
+ const char *aad, size_t aad_len)
{
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX *cipher_ctx;
@@ -7130,10 +7137,10 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len, ch
}
if (free_password) {
- efree(password);
+ efree((void *) password);
}
if (free_iv) {
- efree(iv);
+ efree((void *) iv);
}
EVP_CIPHER_CTX_reset(cipher_ctx);
EVP_CIPHER_CTX_free(cipher_ctx);
@@ -7163,7 +7170,14 @@ PHP_FUNCTION(openssl_encrypt)
}
/* }}} */
-PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, char *method, size_t method_len, char *password, size_t password_len, zend_long options, char *iv, size_t iv_len, char *tag, zend_long tag_len, char *aad, size_t aad_len)
+PHP_OPENSSL_API zend_string* php_openssl_decrypt(
+ const char *data, size_t data_len,
+ const char *method, size_t method_len,
+ const char *password, size_t password_len,
+ zend_long options,
+ const char *iv, size_t iv_len,
+ const char *tag, zend_long tag_len,
+ const char *aad, size_t aad_len)
{
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX *cipher_ctx;
@@ -7222,10 +7236,10 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len, ch
}
if (free_password) {
- efree(password);
+ efree((void *) password);
}
if (free_iv) {
- efree(iv);
+ efree((void *) iv);
}
if (base64_str) {
zend_string_release_ex(base64_str, 0);
@@ -7262,7 +7276,7 @@ PHP_FUNCTION(openssl_decrypt)
}
/* }}} */
-PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(char *method)
+PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method)
{
const EVP_CIPHER *cipher_type;
diff --git a/ext/openssl/php_openssl.h b/ext/openssl/php_openssl.h
index f786772f58..0ae0f9698c 100644
--- a/ext/openssl/php_openssl.h
+++ b/ext/openssl/php_openssl.h
@@ -92,16 +92,24 @@ php_stream_transport_factory_func php_openssl_ssl_socket_factory;
void php_openssl_store_errors();
-PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(char *method);
+PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method);
PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long length);
-PHP_OPENSSL_API zend_string* php_openssl_encrypt(char *data, size_t data_len,
- char *method, size_t method_len, char *password,
- size_t password_len, zend_long options, char *iv, size_t iv_len,
- zval *tag, zend_long tag_len, char *aad, size_t add_len);
-PHP_OPENSSL_API zend_string* php_openssl_decrypt(char *data, size_t data_len,
- char *method, size_t method_len, char *password,
- size_t password_len, zend_long options, char *iv, size_t iv_len,
- char *tag, zend_long tag_len, char *aad, size_t add_len);
+PHP_OPENSSL_API zend_string* php_openssl_encrypt(
+ const char *data, size_t data_len,
+ const char *method, size_t method_len,
+ const char *password, size_t password_len,
+ zend_long options,
+ const char *iv, size_t iv_len,
+ zval *tag, zend_long tag_len,
+ const char *aad, size_t aad_len);
+PHP_OPENSSL_API zend_string* php_openssl_decrypt(
+ const char *data, size_t data_len,
+ const char *method, size_t method_len,
+ const char *password, size_t password_len,
+ zend_long options,
+ const char *iv, size_t iv_len,
+ const char *tag, zend_long tag_len,
+ const char *aad, size_t aad_len);
PHP_MINIT_FUNCTION(openssl);
PHP_MSHUTDOWN_FUNCTION(openssl);
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 9f67bff14c..55f9d2db7b 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -555,12 +555,12 @@ static zend_string **make_subpats_table(uint32_t num_subpats, pcre_cache_entry *
/* {{{ static calculate_unit_length */
/* Calculates the byte length of the next character. Assumes valid UTF-8 for PCRE2_UTF. */
-static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, char *start)
+static zend_always_inline size_t calculate_unit_length(pcre_cache_entry *pce, const char *start)
{
size_t unit_len;
if (pce->compile_options & PCRE2_UTF) {
- char *end = start;
+ const char *end = start;
/* skip continuation bytes */
while ((*++end & 0xC0) == 0x80);
@@ -1038,7 +1038,7 @@ static inline void add_offset_pair(
/* }}} */
static void populate_subpat_array(
- zval *subpats, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names,
+ zval *subpats, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names,
uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags) {
zend_bool offset_capture = (flags & PREG_OFFSET_CAPTURE) != 0;
zend_bool unmatched_as_null = (flags & PREG_UNMATCHED_AS_NULL) != 0;
@@ -1531,7 +1531,7 @@ static int preg_get_backref(char **str, int *backref)
/* {{{ preg_do_repl_func
*/
-static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags)
+static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cache *fcc, const char *subject, PCRE2_SIZE *offsets, zend_string **subpat_names, uint32_t num_subpats, int count, const PCRE2_SPTR mark, zend_long flags)
{
zend_string *result_str;
zval retval; /* Function return value */
@@ -1570,7 +1570,7 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
*/
PHPAPI zend_string *php_pcre_replace(zend_string *regex,
zend_string *subject_str,
- char *subject, size_t subject_len,
+ const char *subject, size_t subject_len,
zend_string *replace_str,
size_t limit, size_t *replace_count)
{
@@ -1596,7 +1596,7 @@ PHPAPI zend_string *php_pcre_replace(zend_string *regex,
/* }}} */
/* {{{ php_pcre_replace_impl() */
-PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count)
+PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count)
{
uint32_t options; /* Execution options */
int count; /* Count of matched subpatterns */
@@ -1610,10 +1610,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
size_t last_end_offset; /* Where the last search ended */
char *walkbuf, /* Location of current replacement in the result */
*walk, /* Used to walk the replacement string */
- *match, /* The current match */
- *piece, /* The current piece of subject */
- *replace_end, /* End of replacement string */
walk_last; /* Last walked character */
+ const char *match, /* The current match */
+ *piece, /* The current piece of subject */
+ *replace_end; /* End of replacement string */
size_t result_len; /* Length of result */
zend_string *result; /* Result of replacement */
pcre2_match_data *match_data;
@@ -1838,7 +1838,7 @@ error:
/* }}} */
/* {{{ php_pcre_replace_func_impl() */
-static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags)
+static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_fcall_info *fci, zend_fcall_info_cache *fcc, size_t limit, size_t *replace_count, zend_long flags)
{
uint32_t options; /* Execution options */
int count; /* Count of matched subpatterns */
@@ -1849,7 +1849,7 @@ static zend_string *php_pcre_replace_func_impl(pcre_cache_entry *pce, zend_strin
size_t alloc_len; /* Actual allocated length */
PCRE2_SIZE start_offset; /* Where the new search starts */
size_t last_end_offset; /* Where the last search ended */
- char *match, /* The current match */
+ const char *match, /* The current match */
*piece; /* The current piece of subject */
size_t result_len; /* Length of result */
zend_string *result; /* Result of replacement */
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index 4666f11b78..808b671bb8 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -25,7 +25,7 @@
#include <locale.h>
-PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
+PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count);
PHPAPI pcre2_code* pcre_get_compiled_regex_ex(zend_string *regex, uint32_t *capture_count, uint32_t *preg_options, uint32_t *coptions);
@@ -53,7 +53,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
zval *subpats, int global, int use_flags, zend_long flags, zend_off_t start_offset);
-PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str,
+PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *subject_str, const char *subject, size_t subject_len, zend_string *replace_str,
size_t limit, size_t *replace_count);
PHPAPI void php_pcre_split_impl( pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re
index 31da8ffdf9..ee0ce7168d 100644
--- a/ext/pdo/pdo_sql_parser.re
+++ b/ext/pdo/pdo_sql_parser.re
@@ -36,12 +36,12 @@
#define YYFILL(n) { RET(PDO_PARSER_EOI); }
typedef struct Scanner {
- char *ptr, *cur, *tok, *end;
+ const char *ptr, *cur, *tok, *end;
} Scanner;
static int scan(Scanner *s)
{
- char *cursor = s->cur;
+ const char *cursor = s->cur;
s->tok = cursor;
/*!re2c
@@ -68,9 +68,9 @@ static int scan(Scanner *s)
}
struct placeholder {
- char *pos;
+ const char *pos;
size_t len;
- size_t qlen; /* quoted length of value */
+ size_t qlen; /* quoted length of value */
char *quoted; /* quoted value */
int freeq;
int bindno;
@@ -81,11 +81,12 @@ static void free_param_name(zval *el) {
efree(Z_PTR_P(el));
}
-PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
+PDO_API int pdo_parse_params(pdo_stmt_t *stmt, const char *inquery, size_t inquery_len,
char **outquery, size_t *outquery_len)
{
Scanner s;
- char *ptr, *newbuffer;
+ const char *ptr;
+ char *newbuffer;
ptrdiff_t t;
uint32_t bindno = 0;
int ret = 0, escapes = 0;
diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h
index 7f4861db20..2fd3b00e99 100644
--- a/ext/pdo/php_pdo_driver.h
+++ b/ext/pdo/php_pdo_driver.h
@@ -677,7 +677,7 @@ PDO_API int php_pdo_parse_data_source(const char *data_source,
PDO_API zend_class_entry *php_pdo_get_dbh_ce(void);
PDO_API zend_class_entry *php_pdo_get_exception(void);
-PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
+PDO_API int pdo_parse_params(pdo_stmt_t *stmt, const char *inquery, size_t inquery_len,
char **outquery, size_t *outquery_len);
PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index d67c4dee47..351d342c53 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -168,12 +168,12 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char
case PHAR_MIME_OTHER:
/* send headers, output file contents */
efree(basename);
- ctr.line_len = spprintf(&(ctr.line), 0, "Content-type: %s", mime_type);
+ ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-type: %s", mime_type);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
- efree(ctr.line);
- ctr.line_len = spprintf(&(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
+ efree((void *) ctr.line);
+ ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-length: %u", info->uncompressed_filesize);
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
- efree(ctr.line);
+ efree((void *) ctr.line);
if (FAILURE == sapi_send_headers()) {
zend_bailout();
@@ -790,9 +790,9 @@ PHP_METHOD(Phar, webPhar)
ctr.response_code = 0;
if (path_info[strlen(path_info)-1] == '/') {
- ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1);
+ ctr.line_len = spprintf((char **) &(ctr.line), 4096, "Location: %s%s", path_info, entry + 1);
} else {
- ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry);
+ ctr.line_len = spprintf((char **) &(ctr.line), 4096, "Location: %s%s", path_info, entry);
}
if (not_cgi) {
@@ -805,7 +805,7 @@ PHP_METHOD(Phar, webPhar)
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
sapi_send_headers();
- efree(ctr.line);
+ efree((void *) ctr.line);
zend_bailout();
}
}
diff --git a/ext/session/php_session.h b/ext/session/php_session.h
index 6f96644024..73f8bf31c8 100644
--- a/ext/session/php_session.h
+++ b/ext/session/php_session.h
@@ -247,7 +247,7 @@ PHPAPI zend_string *php_session_create_id(PS_CREATE_SID_ARGS);
PHPAPI int php_session_validate_sid(PS_VALIDATE_SID_ARGS);
PHPAPI int php_session_update_timestamp(PS_UPDATE_TIMESTAMP_ARGS);
-PHPAPI void session_adapt_url(const char *, size_t, char **, size_t *);
+PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len);
PHPAPI int php_session_destroy(void);
PHPAPI void php_add_session_var(zend_string *name);
@@ -260,12 +260,11 @@ PHPAPI int php_session_register_serializer(const char *name,
zend_string *(*encode)(PS_SERIALIZER_ENCODE_ARGS),
int (*decode)(PS_SERIALIZER_DECODE_ARGS));
-PHPAPI void php_session_set_id(char *id);
PHPAPI int php_session_start(void);
PHPAPI int php_session_flush(int write);
-PHPAPI const ps_module *_php_find_ps_module(char *name);
-PHPAPI const ps_serializer *_php_find_ps_serializer(char *name);
+PHPAPI const ps_module *_php_find_ps_module(const char *name);
+PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name);
PHPAPI int php_session_valid_key(const char *key);
PHPAPI int php_session_reset_id(void);
diff --git a/ext/session/session.c b/ext/session/session.c
index 993f6a063f..418a89d883 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1374,7 +1374,7 @@ static int php_session_send_cookie(void) /* {{{ */
}
/* }}} */
-PHPAPI const ps_module *_php_find_ps_module(char *name) /* {{{ */
+PHPAPI const ps_module *_php_find_ps_module(const char *name) /* {{{ */
{
const ps_module *ret = NULL;
const ps_module **mod;
@@ -1390,7 +1390,7 @@ PHPAPI const ps_module *_php_find_ps_module(char *name) /* {{{ */
}
/* }}} */
-PHPAPI const ps_serializer *_php_find_ps_serializer(char *name) /* {{{ */
+PHPAPI const ps_serializer *_php_find_ps_serializer(const char *name) /* {{{ */
{
const ps_serializer *ret = NULL;
const ps_serializer *mod;
@@ -1648,10 +1648,10 @@ static int php_session_reset(void) /* {{{ */
/* This API is not used by any PHP modules including session currently.
session_adapt_url() may be used to set Session ID to target url without
starting "URL-Rewriter" output handler. */
-PHPAPI void session_adapt_url(const char *url, size_t urllen, char **new, size_t *newlen) /* {{{ */
+PHPAPI void session_adapt_url(const char *url, size_t url_len, char **new_url, size_t *new_len) /* {{{ */
{
if (APPLY_TRANS_SID && (PS(session_status) == php_session_active)) {
- *new = php_url_scanner_adapt_single_url(url, urllen, PS(session_name), ZSTR_VAL(PS(id)), newlen, 1);
+ *new_url = php_url_scanner_adapt_single_url(url, url_len, PS(session_name), ZSTR_VAL(PS(id)), new_len, 1);
}
}
/* }}} */
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 090f11e0ab..883b5d45c5 100755
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1472,13 +1472,13 @@ PHP_FUNCTION(error_log)
/* }}} */
/* For BC (not binary-safe!) */
-PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers) /* {{{ */
+PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers) /* {{{ */
{
return _php_error_log_ex(opt_err, message, (opt_err == 3) ? strlen(message) : 0, opt, headers);
}
/* }}} */
-PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers) /* {{{ */
+PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers) /* {{{ */
{
php_stream *stream = NULL;
size_t nbytes;
@@ -1870,7 +1870,7 @@ PHP_FUNCTION(register_shutdown_function)
}
/* }}} */
-PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */
+PHPAPI zend_bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry) /* {{{ */
{
if (!BG(user_shutdown_function_names)) {
ALLOC_HASHTABLE(BG(user_shutdown_function_names));
@@ -1882,7 +1882,7 @@ PHPAPI zend_bool register_user_shutdown_function(char *function_name, size_t fun
}
/* }}} */
-PHPAPI zend_bool remove_user_shutdown_function(char *function_name, size_t function_len) /* {{{ */
+PHPAPI zend_bool remove_user_shutdown_function(const char *function_name, size_t function_len) /* {{{ */
{
if (BG(user_shutdown_function_names)) {
return zend_hash_str_del(BG(user_shutdown_function_names), function_name, function_len) != FAILURE;
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
index 147bc1dd3a..00727668dc 100644
--- a/ext/standard/basic_functions.h
+++ b/ext/standard/basic_functions.h
@@ -47,8 +47,8 @@ PHP_RSHUTDOWN_FUNCTION(user_filters);
PHP_RSHUTDOWN_FUNCTION(browscap);
/* Left for BC (not binary safe!) */
-PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers);
-PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers);
+PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers);
+PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers);
PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, zend_bool add_underscore);
#define MT_N (624)
@@ -150,8 +150,8 @@ typedef struct _php_shutdown_function_entry {
int arg_count;
} php_shutdown_function_entry;
-PHPAPI extern zend_bool register_user_shutdown_function(char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry);
-PHPAPI extern zend_bool remove_user_shutdown_function(char *function_name, size_t function_len);
+PHPAPI extern zend_bool register_user_shutdown_function(const char *function_name, size_t function_len, php_shutdown_function_entry *shutdown_function_entry);
+PHPAPI extern zend_bool remove_user_shutdown_function(const char *function_name, size_t function_len);
PHPAPI extern zend_bool append_user_shutdown_function(php_shutdown_function_entry shutdown_function_entry);
PHPAPI void php_call_shutdown_functions(void);
diff --git a/ext/standard/dl.c b/ext/standard/dl.c
index ed387761a8..f70ab6fbb5 100644
--- a/ext/standard/dl.c
+++ b/ext/standard/dl.c
@@ -70,7 +70,7 @@ PHPAPI PHP_FUNCTION(dl)
/* {{{ php_load_shlib
*/
-PHPAPI void *php_load_shlib(char *path, char **errp)
+PHPAPI void *php_load_shlib(const char *path, char **errp)
{
void *handle;
char *err;
@@ -98,7 +98,7 @@ PHPAPI void *php_load_shlib(char *path, char **errp)
/* {{{ php_load_extension
*/
-PHPAPI int php_load_extension(char *filename, int type, int start_now)
+PHPAPI int php_load_extension(const char *filename, int type, int start_now)
{
void *handle;
char *libpath;
@@ -243,35 +243,47 @@ PHPAPI int php_load_extension(char *filename, int type, int start_now)
}
/* }}} */
-/* {{{ php_dl
- */
-PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now)
+#else
+
+static void php_dl_error(const char *filename)
{
- /* Load extension */
- if (php_load_extension(file, type, start_now) == FAILURE) {
- RETVAL_FALSE;
- } else {
- RETVAL_TRUE;
- }
+ php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", filename);
}
-/* }}} */
-PHP_MINFO_FUNCTION(dl)
+PHPAPI void *php_load_shlib(const char *path, char **errp)
{
- php_info_print_table_row(2, "Dynamic Library Support", "enabled");
+ php_dl_error(filename);
+ (*errp) = estrdup("No DL support");
}
-#else
-
-PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now)
+PHPAPI int php_load_extension(const char *filename, int type, int start_now)
{
- php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", file);
- RETVAL_FALSE;
+ php_dl_error(filename);
+
+ return FAILURE;
}
-PHP_MINFO_FUNCTION(dl)
+#endif
+
+/* {{{ php_dl
+ */
+PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now)
{
- PUTS("Dynamic Library support not available<br />.\n");
+ /* Load extension */
+ if (php_load_extension(file, type, start_now) == FAILURE) {
+ RETVAL_FALSE;
+ } else {
+ RETVAL_TRUE;
+ }
}
+/* }}} */
+PHP_MINFO_FUNCTION(dl)
+{
+#if defined(HAVE_LIBDL)
+#define PHP_DL_SUPPORT_STATUS "enabled"
+#else
+#define PHP_DL_SUPPORT_STATUS "unavailable"
#endif
+ php_info_print_table_row(2, "Dynamic Library Support", PHP_DL_SUPPORT_STATUS);
+}
diff --git a/ext/standard/dl.h b/ext/standard/dl.h
index d51df044d2..9d13b97ff7 100644
--- a/ext/standard/dl.h
+++ b/ext/standard/dl.h
@@ -19,9 +19,9 @@
#ifndef DL_H
#define DL_H
-PHPAPI int php_load_extension(char *filename, int type, int start_now);
-PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now);
-PHPAPI void *php_load_shlib(char *path, char **errp);
+PHPAPI int php_load_extension(const char *filename, int type, int start_now);
+PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now);
+PHPAPI void *php_load_shlib(const char *path, char **errp);
/* dynamic loading functions */
PHPAPI PHP_FUNCTION(dl);
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 9935e2b34c..8ba205a9ed 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -111,7 +111,7 @@ static size_t handle_line(int type, zval *array, char *buf, size_t bufl) {
* If type==3, output will be printed binary, no lines will be saved or returned (passthru)
*
*/
-PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value)
+PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value)
{
FILE *fp;
char *buf;
@@ -282,7 +282,7 @@ PHP_FUNCTION(passthru)
*NOT* safe for binary strings
*/
-PHPAPI zend_string *php_escape_shell_cmd(char *str)
+PHPAPI zend_string *php_escape_shell_cmd(const char *str)
{
register size_t x, y;
size_t l = strlen(str);
@@ -389,7 +389,7 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
/* {{{ php_escape_shell_arg
*/
-PHPAPI zend_string *php_escape_shell_arg(char *str)
+PHPAPI zend_string *php_escape_shell_arg(const char *str)
{
size_t x, y = 0;
size_t l = strlen(str);
diff --git a/ext/standard/exec.h b/ext/standard/exec.h
index 97edbd099a..6ad9ee0b40 100644
--- a/ext/standard/exec.h
+++ b/ext/standard/exec.h
@@ -20,8 +20,8 @@
PHP_MINIT_FUNCTION(proc_open);
PHP_MINIT_FUNCTION(exec);
-PHPAPI zend_string *php_escape_shell_cmd(char *);
-PHPAPI zend_string *php_escape_shell_arg(char *);
-PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value);
+PHPAPI zend_string *php_escape_shell_cmd(const char *str);
+PHPAPI zend_string *php_escape_shell_arg(const char *str);
+PHPAPI int php_exec(int type, const char *cmd, zval *array, zval *return_value);
#endif /* EXEC_H */
diff --git a/ext/standard/head.c b/ext/standard/head.c
index 657510de5b..06496f04aa 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -34,15 +34,17 @@ PHP_FUNCTION(header)
{
zend_bool rep = 1;
sapi_header_line ctr = {0};
+ char *line;
size_t len;
ZEND_PARSE_PARAMETERS_START(1, 3)
- Z_PARAM_STRING(ctr.line, len)
+ Z_PARAM_STRING(line, len)
Z_PARAM_OPTIONAL
Z_PARAM_BOOL(rep)
Z_PARAM_LONG(ctr.response_code)
ZEND_PARSE_PARAMETERS_END();
+ ctr.line = line;
ctr.line_len = (uint32_t)len;
sapi_header_op(rep ? SAPI_HEADER_REPLACE:SAPI_HEADER_ADD, &ctr);
}
@@ -53,13 +55,15 @@ PHP_FUNCTION(header)
PHP_FUNCTION(header_remove)
{
sapi_header_line ctr = {0};
+ char *line = NULL;
size_t len = 0;
ZEND_PARSE_PARAMETERS_START(0, 1)
Z_PARAM_OPTIONAL
- Z_PARAM_STRING(ctr.line, len)
+ Z_PARAM_STRING(line, len)
ZEND_PARSE_PARAMETERS_END();
+ ctr.line = line;
ctr.line_len = (uint32_t)len;
sapi_header_op(ZEND_NUM_ARGS() == 0 ? SAPI_HEADER_DELETE_ALL : SAPI_HEADER_DELETE, &ctr);
}
diff --git a/ext/standard/html.c b/ext/standard/html.c
index e1a0799375..8e5b65d80c 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -367,7 +367,7 @@ static inline unsigned int get_next_char(
/* {{{ entity_charset determine_charset
* Returns the charset identifier based on an explicitly provided charset,
* the internal_encoding and default_charset ini settings, or UTF-8 by default. */
-static enum entity_charset determine_charset(char *charset_hint, zend_bool quiet)
+static enum entity_charset determine_charset(const char *charset_hint, zend_bool quiet)
{
if (!charset_hint || !*charset_hint) {
charset_hint = get_default_charset();
@@ -979,7 +979,7 @@ static entity_table_opt determine_entity_table(int all, int doctype)
* only the basic ones, i.e., those in basic_entities_ex + the numeric entities
* that correspond to quotes.
*/
-PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, char *hint_charset)
+PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset)
{
zend_string *ret;
enum entity_charset charset;
@@ -1015,7 +1015,7 @@ PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int fl
}
/* }}} */
-PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset)
+PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset)
{
return php_escape_html_entities_ex(old, oldlen, all, flags, hint_charset, 1, /* quiet */ 0);
}
@@ -1103,7 +1103,7 @@ static inline void find_entity_for_char_basic(
/* {{{ php_escape_html_entities
*/
-PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode, zend_bool quiet)
+PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, zend_bool double_encode, zend_bool quiet)
{
size_t cursor, maxlen, len;
zend_string *replaced;
diff --git a/ext/standard/html.h b/ext/standard/html.h
index 818ee1a0ca..3aee85cd87 100644
--- a/ext/standard/html.h
+++ b/ext/standard/html.h
@@ -44,9 +44,9 @@
void register_html_constants(INIT_FUNC_ARGS);
-PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset);
-PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, char *hint_charset, zend_bool double_encode, zend_bool quiet);
-PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, char *hint_charset);
+PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset);
+PHPAPI zend_string *php_escape_html_entities_ex(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset, zend_bool double_encode, zend_bool quiet);
+PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int flags, const char *hint_charset);
PHPAPI unsigned int php_next_utf8_char(const unsigned char *str, size_t str_len, size_t *cursor, int *status);
#endif /* HTML_H */
diff --git a/ext/standard/http.c b/ext/standard/http.c
index 4b6866d3f8..386a0df1eb 100644
--- a/ext/standard/http.c
+++ b/ext/standard/http.c
@@ -25,7 +25,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, size_t num_prefix_len,
const char *key_prefix, size_t key_prefix_len,
const char *key_suffix, size_t key_suffix_len,
- zval *type, char *arg_sep, int enc_type)
+ zval *type, const char *arg_sep, int enc_type)
{
zend_string *key = NULL;
char *newprefix, *p;
diff --git a/ext/standard/image.c b/ext/standard/image.c
index e967aaeee0..147a146e5c 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -1293,7 +1293,7 @@ PHP_FUNCTION(image_type_to_extension)
/* {{{ php_imagetype
detect filetype from first bytes */
-PHPAPI int php_getimagetype(php_stream * stream, char *input, char *filetype)
+PHPAPI int php_getimagetype(php_stream * stream, const char *input, char *filetype)
{
char tmp[12];
int twelve_bytes_read;
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 8a090d20e5..262e95ae27 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -57,7 +57,7 @@ static ZEND_COLD int php_info_print_html_esc(const char *str, size_t len) /* {{{
size_t written;
zend_string *new_str;
- new_str = php_escape_html_entities((unsigned char *) str, len, 0, ENT_QUOTES, "utf-8");
+ new_str = php_escape_html_entities((const unsigned char *) str, len, 0, ENT_QUOTES, "utf-8");
written = php_output_write(ZSTR_VAL(new_str), ZSTR_LEN(new_str));
zend_string_free(new_str);
return written;
@@ -249,9 +249,9 @@ PHPAPI ZEND_COLD void ZEND_COLD php_info_print_style(void)
/* {{{ php_info_html_esc
*/
-PHPAPI ZEND_COLD zend_string *php_info_html_esc(char *string)
+PHPAPI ZEND_COLD zend_string *php_info_html_esc(const char *string)
{
- return php_escape_html_entities((unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL);
+ return php_escape_html_entities((const unsigned char *) string, strlen(string), 0, ENT_QUOTES, NULL);
}
/* }}} */
@@ -1095,7 +1095,7 @@ PHPAPI ZEND_COLD void php_info_print_hr(void) /* {{{ */
}
/* }}} */
-PHPAPI ZEND_COLD void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */
+PHPAPI ZEND_COLD void php_info_print_table_colspan_header(int num_cols, const char *header) /* {{{ */
{
int spaces;
diff --git a/ext/standard/info.h b/ext/standard/info.h
index 95eec2d2ad..cb9a4930a9 100644
--- a/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S+pYjywnXYwcyOZfI4mKgHj9N2ttHqbRfSlQXhjw5XXy4S7ZbzOovkxVRsphHp8ia3HlyleZS1zHcvoVrdjuNFdEe7edGHzSbpSria/WZ3+cxYV5DCx/4w7FUfyfTW0WO+i7x2YrzKUXZFw/sut+OxJDGkHUxEZPwgCquQcIgxZR9oXekDQk8FF60bqwocupaIoEz6EmaC3C+0Ro6Wgp4eb2tpPJqN+4xXFXQ3TfUfCc5PDNnLZDpLIV1NADKyjZa87mHgmWX57bYdIfIY3pdCGf43xQUXI62kBn3fZxi4SPC8crIjDQ4yzFAaz/XcPJn7xf03VRzIB5Z7qCbBzPQi5jga2E9bCD+ELug8ficEZCk/Cmj8Ro3aLtLxDR1/QffhIHNRTUZCf+S5G7SJBp2b7G31B9+EjcVAFEInZQ2LU7jiN1zf4gu7DR+KwTvkfO9bGx6BNnEQ8XXmN5cT3fEH34SNxwN4A9dgknIEwyWNbeRTwV7WYHBVwFQfbwKb7vOUjiYAiKVT1PczXqCLD/n5UbuLcNxTKoCgExSFNmsFCHI6iJBQFnUbqqbWPHyFceDAOrC/oPpIN+FVaVLrNUa6dLPbvoEQdO4pd1OUylBVkCutsOkqosbNvwcE6qL6g+0hG3MY4ejots1pT3kE4P9QDdfuLKeDfHswD6gu6j2TF2yQcLoqEGurre9EdP1QTfmxJRdn0NlrvD+jmY69Egz+UQvxfgAEALJ4EcRDa/toAAAAASUVORK5CYII="
BEGIN_EXTERN_C()
-PHPAPI zend_string *php_info_html_esc(char *string);
-PHPAPI void php_info_html_esc_write(char *string, int str_len);
+PHPAPI zend_string *php_info_html_esc(const char *string);
PHPAPI void php_print_info_htmlhead(void);
PHPAPI void php_print_info(int flag);
PHPAPI void php_print_style(void);
PHPAPI void php_info_print_style(void);
-PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header);
+PHPAPI void php_info_print_table_colspan_header(int num_cols, const char *header);
PHPAPI void php_info_print_table_header(int num_cols, ...);
PHPAPI void php_info_print_table_row(int num_cols, ...);
PHPAPI void php_info_print_table_row_ex(int num_cols, const char *, ...);
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index 096f432c9a..7b8cb08236 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -386,7 +386,7 @@ void php_mail_log_to_file(char *filename, char *message, size_t message_size) {
}
-static int php_mail_detect_multiple_crlf(char *hdr) {
+static int php_mail_detect_multiple_crlf(const char *hdr) {
/* This function detects multiple/malformed multiple newlines. */
if (!hdr || !strlen(hdr)) {
@@ -425,7 +425,7 @@ static int php_mail_detect_multiple_crlf(char *hdr) {
/* {{{ php_mail
*/
-PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd)
+PHPAPI int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd)
{
#ifdef PHP_WIN32
int tsm_err;
@@ -436,14 +436,15 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
char *sendmail_path = INI_STR("sendmail_path");
char *sendmail_cmd = NULL;
char *mail_log = INI_STR("mail.log");
- char *hdr = headers;
+ const char *hdr = headers;
+ char *ahdr = NULL;
#if PHP_SIGCHILD
void (*sig_handler)() = NULL;
#endif
#define MAIL_RET(val) \
- if (hdr != headers) { \
- efree(hdr); \
+ if (ahdr != NULL) { \
+ efree(ahdr); \
} \
return val; \
@@ -486,10 +487,11 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
f = php_basename(tmp, strlen(tmp), NULL, 0);
if (headers != NULL && *headers) {
- spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers);
+ spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers);
} else {
- spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f));
+ spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f));
}
+ hdr = ahdr;
zend_string_release_ex(f, 0);
}
diff --git a/ext/standard/math.c b/ext/standard/math.c
index ca6c1f4b9d..fe23a189c2 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -1026,8 +1026,8 @@ PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, c
return _php_math_number_format_ex(d, dec, &dec_point, 1, &thousand_sep, 1);
}
-PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, char *dec_point,
- size_t dec_point_len, char *thousand_sep, size_t thousand_sep_len)
+PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point,
+ size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len)
{
zend_string *res;
zend_string *tmpbuf;
diff --git a/ext/standard/php_http.h b/ext/standard/php_http.h
index 728ea33fd1..b77cd0bda3 100644
--- a/ext/standard/php_http.h
+++ b/ext/standard/php_http.h
@@ -24,7 +24,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
const char *num_prefix, size_t num_prefix_len,
const char *key_prefix, size_t key_prefix_len,
const char *key_suffix, size_t key_suffix_len,
- zval *type, char *arg_sep, int enc_type);
+ zval *type, const char *arg_sep, int enc_type);
#define php_url_encode_hash(ht, formstr) php_url_encode_hash_ex((ht), (formstr), NULL, 0, NULL, 0, NULL, 0, NULL)
#endif
diff --git a/ext/standard/php_image.h b/ext/standard/php_image.h
index d532496ea6..3649e62198 100644
--- a/ext/standard/php_image.h
+++ b/ext/standard/php_image.h
@@ -50,7 +50,7 @@ typedef enum
PHP_MINIT_FUNCTION(imagetypes);
-PHPAPI int php_getimagetype(php_stream *stream, char *input, char *filetype);
+PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetype);
PHPAPI char * php_image_type_to_mime_type(int image_type);
diff --git a/ext/standard/php_mail.h b/ext/standard/php_mail.h
index 3a2ccdc4b1..2a561d5523 100644
--- a/ext/standard/php_mail.h
+++ b/ext/standard/php_mail.h
@@ -20,7 +20,7 @@
PHP_MINFO_FUNCTION(mail);
PHPAPI zend_string *php_mail_build_headers(HashTable *headers);
-PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd);
+PHPAPI extern int php_mail(const char *to, const char *subject, const char *message, const char *headers, const char *extra_cmd);
#define PHP_MAIL_BUILD_HEADER_CHECK(target, s, key, val) \
do { \
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index a8d1f2dbf3..c3ce7cc728 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -18,9 +18,9 @@
#ifndef PHP_MATH_H
#define PHP_MATH_H
-PHPAPI double _php_math_round(double, int, int);
-PHPAPI zend_string *_php_math_number_format(double, int, char, char);
-PHPAPI zend_string *_php_math_number_format_ex(double, int, char *, size_t, char *, size_t);
+PHPAPI double _php_math_round(double value, int places, int mode);
+PHPAPI zend_string *_php_math_number_format(double d, int dec, char dec_point, char thousand_sep);
+PHPAPI zend_string *_php_math_number_format_ex(double d, int dec, const char *dec_point, size_t dec_point_len, const char *thousand_sep, size_t thousand_sep_len);
PHPAPI zend_string * _php_math_longtobase(zval *arg, int base);
PHPAPI zend_long _php_math_basetolong(zval *arg, int base);
PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret);
diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h
index 7a813c2610..43e50dffc1 100644
--- a/ext/standard/php_string.h
+++ b/ext/standard/php_string.h
@@ -42,22 +42,22 @@ PHPAPI zend_string *php_string_tolower(zend_string *s);
PHPAPI char *php_strtr(char *str, size_t len, const char *str_from, const char *str_to, size_t trlen);
PHPAPI zend_string *php_addslashes(zend_string *str);
PHPAPI void php_stripslashes(zend_string *str);
-PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t what_len);
-PHPAPI zend_string *php_addcslashes(zend_string *str, char *what, size_t what_len);
+PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t what_len);
+PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t what_len);
PHPAPI void php_stripcslashes(zend_string *str);
-PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t sufflen);
+PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t sufflen);
PHPAPI size_t php_dirname(char *str, size_t len);
PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len);
PHPAPI zend_string *php_str_to_str(const char *haystack, size_t length, const char *needle,
size_t needle_len, const char *str, size_t str_len);
-PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode);
+PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode);
PHPAPI size_t php_strip_tags(char *rbuf, size_t len, const char *allow, size_t allow_len);
PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, const char *allow, size_t allow_len, zend_bool allow_tag_spaces);
PHPAPI void php_implode(const zend_string *delim, HashTable *arr, zval *return_value);
PHPAPI void php_explode(const zend_string *delim, zend_string *str, zval *return_value, zend_long limit);
-PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end);
-PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end);
+PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
+PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end);
PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive);
PHPAPI int string_natural_compare_function(zval *result, zval *op1, zval *op2);
diff --git a/ext/standard/php_uuencode.h b/ext/standard/php_uuencode.h
index 82549f56d1..5d5c84a9b3 100644
--- a/ext/standard/php_uuencode.h
+++ b/ext/standard/php_uuencode.h
@@ -17,7 +17,7 @@
#ifndef PHP_UUENCODE_H
#define PHP_UUENCODE_H
-PHPAPI zend_string *php_uudecode(char *src, size_t src_len);
-PHPAPI zend_string *php_uuencode(char *src, size_t src_len);
+PHPAPI zend_string *php_uudecode(const char *src, size_t src_len);
+PHPAPI zend_string *php_uuencode(const char *src, size_t src_len);
#endif /* PHP_UUENCODE_H */
diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c
index 269fe8a947..562e6e9de6 100644
--- a/ext/standard/sha1.c
+++ b/ext/standard/sha1.c
@@ -21,7 +21,7 @@
#include "sha1.h"
#include "md5.h"
-PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest)
+PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest)
{
make_digest_ex(sha1str, digest, 20);
}
diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h
index 81a9cae460..c904969dd3 100644
--- a/ext/standard/sha1.h
+++ b/ext/standard/sha1.h
@@ -29,6 +29,6 @@ typedef struct {
PHPAPI void PHP_SHA1Init(PHP_SHA1_CTX *);
PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX *, const unsigned char *, size_t);
PHPAPI void PHP_SHA1Final(unsigned char[20], PHP_SHA1_CTX *);
-PHPAPI void make_sha1_digest(char *sha1str, unsigned char *digest);
+PHPAPI void make_sha1_digest(char *sha1str, const unsigned char *digest);
#endif
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 06ad0f2d24..635f5daf8f 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -765,7 +765,7 @@ static inline int php_charmask(const unsigned char *input, size_t len, char *mas
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
*/
-static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what, size_t what_len, int mode)
+static zend_always_inline zend_string *php_trim_int(zend_string *str, const char *what, size_t what_len, int mode)
{
const char *start = ZSTR_VAL(str);
const char *end = start + ZSTR_LEN(str);
@@ -793,7 +793,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what
}
}
} else {
- php_charmask((unsigned char*)what, what_len, mask);
+ php_charmask((const unsigned char *) what, what_len, mask);
if (mode & 1) {
while (start != end) {
@@ -857,7 +857,7 @@ static zend_always_inline zend_string *php_trim_int(zend_string *str, char *what
* mode 3 : trim left and right
* what indicates which chars are to be trimmed. NULL->default (' \t\n\r\v\0')
*/
-PHPAPI zend_string *php_trim(zend_string *str, char *what, size_t what_len, int mode)
+PHPAPI zend_string *php_trim(zend_string *str, const char *what, size_t what_len, int mode)
{
return php_trim_int(str, what, what_len, mode);
}
@@ -1508,7 +1508,7 @@ PHP_FUNCTION(strtolower)
/* {{{ php_basename
*/
-PHPAPI zend_string *php_basename(const char *s, size_t len, char *suffix, size_t suffix_len)
+PHPAPI zend_string *php_basename(const char *s, size_t len, const char *suffix, size_t suffix_len)
{
/* State 0 is directly after a directory separator (or at the start of the string).
* State 1 is everything else. */
@@ -1745,7 +1745,7 @@ PHPAPI char *php_stristr(char *s, char *t, size_t s_len, size_t t_len)
/* {{{ php_strspn
*/
-PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end)
+PHPAPI size_t php_strspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end)
{
register const char *p = s1, *spanp;
register char c = *p;
@@ -1763,7 +1763,7 @@ cont:
/* {{{ php_strcspn
*/
-PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end)
+PHPAPI size_t php_strcspn(const char *s1, const char *s2, const char *s1_end, const char *s2_end)
{
register const char *p, *spanp;
register char c = *s1;
@@ -2720,7 +2720,7 @@ PHP_FUNCTION(ucwords)
RETURN_EMPTY_STRING();
}
- php_charmask((unsigned char *)delims, delims_len, mask);
+ php_charmask((const unsigned char *) delims, delims_len, mask);
ZVAL_STRINGL(return_value, ZSTR_VAL(str), ZSTR_LEN(str));
r = Z_STRVAL_P(return_value);
@@ -3642,7 +3642,7 @@ PHPAPI void php_stripcslashes(zend_string *str)
/* {{{ php_addcslashes_str
*/
-PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what, size_t wlength)
+PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, const char *what, size_t wlength)
{
char flags[256];
char *target;
@@ -3651,7 +3651,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what,
size_t newlen;
zend_string *new_str = zend_string_safe_alloc(4, len, 0, 0);
- php_charmask((unsigned char *)what, wlength, flags);
+ php_charmask((const unsigned char *) what, wlength, flags);
for (source = str, end = source + len, target = ZSTR_VAL(new_str); source < end; source++) {
c = *source;
@@ -3685,7 +3685,7 @@ PHPAPI zend_string *php_addcslashes_str(const char *str, size_t len, char *what,
/* {{{ php_addcslashes
*/
-PHPAPI zend_string *php_addcslashes(zend_string *str, char *what, size_t wlength)
+PHPAPI zend_string *php_addcslashes(zend_string *str, const char *what, size_t wlength)
{
return php_addcslashes_str(ZSTR_VAL(str), ZSTR_LEN(str), what, wlength);
}
@@ -5909,7 +5909,7 @@ PHP_FUNCTION(str_word_count)
}
if (char_list) {
- php_charmask((unsigned char *)char_list, char_list_len, ch);
+ php_charmask((const unsigned char *) char_list, char_list_len, ch);
}
p = ZSTR_VAL(str);
diff --git a/ext/standard/url_scanner_ex.h b/ext/standard/url_scanner_ex.h
index a756db6586..6252fdce54 100644
--- a/ext/standard/url_scanner_ex.h
+++ b/ext/standard/url_scanner_ex.h
@@ -24,10 +24,10 @@ PHP_RINIT_FUNCTION(url_scanner_ex);
PHP_RSHUTDOWN_FUNCTION(url_scanner_ex);
PHPAPI char *php_url_scanner_adapt_single_url(const char *url, size_t urllen, const char *name, const char *value, size_t *newlen, int encode);
-PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode);
+PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_reset_session_var(zend_string *name, int encode);
PHPAPI int php_url_scanner_reset_session_vars(void);
-PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode);
+PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode);
PHPAPI int php_url_scanner_reset_var(zend_string *name, int encode);
PHPAPI int php_url_scanner_reset_vars(void);
diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re
index d80bd0d2a1..bef17733e2 100644
--- a/ext/standard/url_scanner_ex.re
+++ b/ext/standard/url_scanner_ex.re
@@ -725,7 +725,7 @@ static void php_url_scanner_output_handler(char *output, size_t output_len, char
php_url_scanner_session_handler_impl(output, output_len, handled_output, handled_output_len, mode, 0);
}
-static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char *value, size_t value_len, int encode, int type)
+static inline int php_url_scanner_add_var_impl(const char *name, size_t name_len, const char *value, size_t value_len, int encode, int type)
{
smart_str sname = {0};
smart_str svalue = {0};
@@ -758,9 +758,9 @@ static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char
smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
encoded = php_raw_url_encode(value, value_len);
smart_str_appendl(&svalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
- encoded = php_escape_html_entities_ex((unsigned char*)name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
+ encoded = php_escape_html_entities_ex((const unsigned char *) name, name_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
- encoded = php_escape_html_entities_ex((unsigned char*)value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
+ encoded = php_escape_html_entities_ex((const unsigned char *) value, value_len, 0, ENT_QUOTES|ENT_SUBSTITUTE, NULL, /* double_encode */ 0, /* quiet */ 1);
smart_str_appendl(&hvalue, ZSTR_VAL(encoded), ZSTR_LEN(encoded)); zend_string_free(encoded);
} else {
smart_str_appendl(&sname, name, name_len);
@@ -788,13 +788,13 @@ static inline int php_url_scanner_add_var_impl(char *name, size_t name_len, char
}
-PHPAPI int php_url_scanner_add_session_var(char *name, size_t name_len, char *value, size_t value_len, int encode)
+PHPAPI int php_url_scanner_add_session_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode)
{
return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 1);
}
-PHPAPI int php_url_scanner_add_var(char *name, size_t name_len, char *value, size_t value_len, int encode)
+PHPAPI int php_url_scanner_add_var(const char *name, size_t name_len, const char *value, size_t value_len, int encode)
{
return php_url_scanner_add_var_impl(name, name_len, value, value_len, encode, 0);
}
@@ -860,7 +860,7 @@ static inline int php_url_scanner_reset_var_impl(zend_string *name, int encode,
encoded = php_raw_url_encode(ZSTR_VAL(name), ZSTR_LEN(name));
smart_str_appendl(&sname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
zend_string_free(encoded);
- encoded = php_escape_html_entities_ex((unsigned char *)ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), /* double_encode */ 0, /* quiet */ 1);
+ encoded = php_escape_html_entities_ex((const unsigned char *) ZSTR_VAL(name), ZSTR_LEN(name), 0, ENT_QUOTES|ENT_SUBSTITUTE, SG(default_charset), /* double_encode */ 0, /* quiet */ 1);
smart_str_appendl(&hname, ZSTR_VAL(encoded), ZSTR_LEN(encoded));
zend_string_free(encoded);
} else {
diff --git a/ext/standard/uuencode.c b/ext/standard/uuencode.c
index 036e190f24..b00ddb520d 100644
--- a/ext/standard/uuencode.c
+++ b/ext/standard/uuencode.c
@@ -61,10 +61,11 @@
#define PHP_UU_DEC(c) (((c) - ' ') & 077)
-PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
+PHPAPI zend_string *php_uuencode(const char *src, size_t src_len) /* {{{ */
{
size_t len = 45;
- unsigned char *p, *s, *e, *ee;
+ unsigned char *p;
+ const unsigned char *s, *e, *ee;
zend_string *dest;
/* encoded length is ~ 38% greater than the original
@@ -125,10 +126,11 @@ PHPAPI zend_string *php_uuencode(char *src, size_t src_len) /* {{{ */
}
/* }}} */
-PHPAPI zend_string *php_uudecode(char *src, size_t src_len) /* {{{ */
+PHPAPI zend_string *php_uudecode(const char *src, size_t src_len) /* {{{ */
{
size_t len, total_len=0;
- char *s, *e, *p, *ee;
+ char *p;
+ const char *s, *e, *ee;
zend_string *dest;
dest = zend_string_alloc((size_t) ceil(src_len * 0.75), 0);