Constify some char* arguments or return values of ZEND_API

Closes GH-4247.
This commit is contained in:
twosee 2019-05-26 13:53:26 +08:00 committed by Nikita Popov
parent ff8002fc7c
commit 61f78de486
17 changed files with 36 additions and 36 deletions

View File

@ -1136,7 +1136,7 @@ ZEND_API void zend_append_version_info(const zend_extension *extension) /* {{{ *
}
/* }}} */
ZEND_API char *get_zend_version(void) /* {{{ */
ZEND_API const char *get_zend_version(void) /* {{{ */
{
return zend_version_info;
}

View File

@ -244,7 +244,7 @@ ZEND_API zend_string *zend_strpprintf(size_t max_len, const char *format, ...) Z
ZEND_API size_t zend_spprintf_unchecked(char **message, size_t max_len, const char *format, ...);
ZEND_API zend_string *zend_strpprintf_unchecked(size_t max_len, const char *format, ...);
ZEND_API char *get_zend_version(void);
ZEND_API const char *get_zend_version(void);
ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy);
ZEND_API size_t zend_print_zval(zval *expr, int indent);
ZEND_API void zend_print_zval_r(zval *expr, int indent);

View File

@ -95,7 +95,7 @@ ZEND_API ZEND_COLD void zend_wrong_param_count(void) /* {{{ */
/* }}} */
/* Argument parsing API -- andrei */
ZEND_API char *zend_get_type_by_const(int type) /* {{{ */
ZEND_API const char *zend_get_type_by_const(int type) /* {{{ */
{
switch(type) {
case IS_FALSE:
@ -130,7 +130,7 @@ ZEND_API char *zend_get_type_by_const(int type) /* {{{ */
}
/* }}} */
ZEND_API char *zend_zval_type_name(const zval *arg) /* {{{ */
ZEND_API const char *zend_zval_type_name(const zval *arg) /* {{{ */
{
ZVAL_DEREF(arg);
return zend_get_type_by_const(Z_TYPE_P(arg));
@ -218,7 +218,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, z
}
/* }}} */
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg) /* {{{ */
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, const char *name, zval *arg) /* {{{ */
{
const char *space;
const char *class_name = get_active_class_name(&space);

View File

@ -257,7 +257,7 @@ ZEND_API int zend_copy_parameters_array(int param_count, zval *argument_array);
ZEND_API int zend_parse_parameters(int num_args, const char *type_spec, ...);
ZEND_API int zend_parse_parameters_ex(int flags, int num_args, const char *type_spec, ...);
ZEND_API int zend_parse_parameters_throw(int num_args, const char *type_spec, ...);
ZEND_API char *zend_zval_type_name(const zval *arg);
ZEND_API const char *zend_zval_type_name(const zval *arg);
ZEND_API zend_string *zend_zval_get_type(const zval *arg);
ZEND_API int zend_parse_method_parameters(int num_args, zval *this_ptr, const char *type_spec, ...);
@ -356,7 +356,7 @@ ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const c
ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, zend_bool silent);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, zend_bool silent);
ZEND_API char *zend_get_type_by_const(int type);
ZEND_API const char *zend_get_type_by_const(int type);
#define ZEND_THIS (&EX(This))
@ -1112,7 +1112,7 @@ typedef enum _zend_expected_type {
ZEND_API ZEND_COLD int ZEND_FASTCALL zend_wrong_parameters_none_error(void);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(int min_num_args, int max_num_args);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(int num, zend_expected_type expected_type, zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, char *name, zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(int num, const char *name, zval *arg);
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *error);
#define ZPP_ERROR_OK 0

View File

@ -71,7 +71,7 @@ static inline uint32_t zend_alloc_cache_slot(void) {
}
ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename);
ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, const char *filename);
#ifndef ZTS
ZEND_API zend_compiler_globals compiler_globals;

View File

@ -708,7 +708,7 @@ void zend_file_context_begin(zend_file_context *prev_context);
void zend_file_context_end(zend_file_context *prev_context);
extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename);
extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, const char *filename);
ZEND_API int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem);
void startup_scanner(void);
@ -766,7 +766,7 @@ ZEND_API void function_add_ref(zend_function *function);
/* helper functions in zend_language_scanner.l */
ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type);
ZEND_API zend_op_array *compile_string(zval *source_string, char *filename);
ZEND_API zend_op_array *compile_string(zval *source_string, const char *filename);
ZEND_API zend_op_array *compile_filename(int type, zval *filename);
ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...);
ZEND_API int open_file_for_scanning(zend_file_handle *file_handle);

View File

@ -193,7 +193,7 @@ ZEND_API void zend_register_double_constant(const char *name, size_t name_len, d
}
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number)
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number)
{
zend_constant c;
@ -204,7 +204,7 @@ ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len,
}
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number)
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number)
{
zend_register_stringl_constant(name, name_len, strval, strlen(strval), flags, module_number);
}

View File

@ -79,8 +79,8 @@ ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zen
ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number);
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number);
ZEND_API void zend_register_string_constant(const char *name, size_t name_len, const char *strval, int flags, int module_number);
ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, const char *strval, size_t strlen, int flags, int module_number);
ZEND_API int zend_register_constant(zend_constant *c);
#ifdef ZTS
void zend_copy_constants(HashTable *target, HashTable *sourc);

View File

@ -44,10 +44,10 @@ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name);
ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags);
ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex);
ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name);
ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name);
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions);
ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions);
ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name);
ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name);
ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions);
ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions);
/* export zend_pass_function to allow comparisons against it */
extern ZEND_API const zend_internal_function zend_pass_function;

View File

@ -986,7 +986,7 @@ ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */
}
/* }}} */
ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char *string_name) /* {{{ */
ZEND_API int zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name) /* {{{ */
{
zval pv;
zend_op_array *new_op_array;
@ -1050,13 +1050,13 @@ ZEND_API int zend_eval_stringl(char *str, size_t str_len, zval *retval_ptr, char
}
/* }}} */
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name) /* {{{ */
ZEND_API int zend_eval_string(const char *str, zval *retval_ptr, const char *string_name) /* {{{ */
{
return zend_eval_stringl(str, strlen(str), retval_ptr, string_name);
}
/* }}} */
ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */
ZEND_API int zend_eval_stringl_ex(const char *str, size_t str_len, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */
{
int result;
@ -1069,7 +1069,7 @@ ZEND_API int zend_eval_stringl_ex(char *str, size_t str_len, zval *retval_ptr, c
}
/* }}} */
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions) /* {{{ */
ZEND_API int zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, int handle_exceptions) /* {{{ */
{
return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions);
}

View File

@ -39,8 +39,8 @@ typedef struct _zend_syntax_highlighter_ini {
BEGIN_EXTERN_C()
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API void zend_strip(void);
ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name);
ZEND_API int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini);
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name);
ZEND_API void zend_html_putc(char c);
ZEND_API void zend_html_puts(const char *s, size_t len);
END_EXTERN_C()

View File

@ -66,7 +66,7 @@ typedef struct _zend_heredoc_label {
BEGIN_EXTERN_C()
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state);
ZEND_API void zend_restore_lexical_state(zend_lex_state *lex_state);
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename);
ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename);
ZEND_API void zend_multibyte_yyinput_again(zend_encoding_filter old_input_filter, const zend_encoding *old_encoding);
ZEND_API int zend_multibyte_set_filter(const zend_encoding *onetime_encoding);
ZEND_API void zend_lex_tstring(zval *zv);

View File

@ -679,7 +679,7 @@ zend_op_array *compile_filename(int type, zval *filename)
return retval;
}
ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename)
ZEND_API int zend_prepare_string_for_scanning(zval *str, const char *filename)
{
char *buf;
size_t size, old_len;
@ -747,7 +747,7 @@ ZEND_API size_t zend_get_scanned_file_offset(void)
return offset;
}
zend_op_array *compile_string(zval *source_string, char *filename)
zend_op_array *compile_string(zval *source_string, const char *filename)
{
zend_lex_state original_lex_state;
zend_op_array *op_array = NULL;
@ -778,7 +778,7 @@ zend_op_array *compile_string(zval *source_string, char *filename)
BEGIN_EXTERN_C()
int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini)
int highlight_file(const char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini)
{
zend_lex_state original_lex_state;
zend_file_handle file_handle;
@ -803,7 +803,7 @@ int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlight
return SUCCESS;
}
int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name)
int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, const char *str_name)
{
zend_lex_state original_lex_state;
zval tmp;

View File

@ -512,7 +512,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
/* {{{ _const_string */
static void _const_string(smart_str *str, char *name, zval *value, char *indent)
{
char *type = zend_zval_type_name(value);
const char *type = zend_zval_type_name(value);
if (Z_TYPE_P(value) == IS_ARRAY) {
smart_str_append_printf(str, "%s Constant [ %s %s ] { Array }\n",
@ -534,7 +534,7 @@ static void _const_string(smart_str *str, char *name, zval *value, char *indent)
static void _class_const_string(smart_str *str, char *name, zend_class_constant *c, char *indent)
{
char *visibility = zend_visibility_string(Z_ACCESS_FLAGS(c->value));
char *type;
const char *type;
zval_update_constant_ex(&c->value, c->ce);
type = zend_zval_type_name(&c->value);
@ -2860,7 +2860,7 @@ static zend_string *reflection_type_name(type_reference *param) {
} else if (ZEND_TYPE_IS_CE(param->type)) {
return zend_string_copy(ZEND_TYPE_CE(param->type)->name);
} else {
char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->type));
const char *name = zend_get_type_by_const(ZEND_TYPE_CODE(param->type));
return zend_string_init(name, strlen(name), 0);
}
}

View File

@ -770,7 +770,7 @@ PHPAPI ZEND_COLD void php_print_info(int flag)
}
if (flag & PHP_INFO_GENERAL) {
char *zend_version = get_zend_version();
const char *zend_version = get_zend_version();
char temp_api[10];
php_uname = php_get_uname('a');

View File

@ -277,7 +277,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type);
zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type);
zend_op_array *(*compile_string)(zval *source_string, char *filename);
zend_op_array *(*compile_string)(zval *source_string, const char *filename);
HashTable file_sources;
FILE *oplog; /* opline log */

View File

@ -318,7 +318,7 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
return op_array;
}
zend_op_array *phpdbg_compile_string(zval *source_string, char *filename) {
zend_op_array *phpdbg_compile_string(zval *source_string, const char *filename) {
zend_string *fake_name;
zend_op_array *op_array;
phpdbg_file_source *dataptr;