]> granicus.if.org Git - php/commitdiff
Constify some char* arguments or return values of ZEND_API
authortwosee <twose@qq.com>
Sun, 26 May 2019 05:53:26 +0000 (13:53 +0800)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 12 Jun 2019 14:49:32 +0000 (16:49 +0200)
Closes GH-4247.

17 files changed:
Zend/zend.c
Zend/zend.h
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_constants.c
Zend/zend_constants.h
Zend/zend_execute.h
Zend/zend_execute_API.c
Zend/zend_highlight.h
Zend/zend_language_scanner.h
Zend/zend_language_scanner.l
ext/reflection/php_reflection.c
ext/standard/info.c
sapi/phpdbg/phpdbg.h
sapi/phpdbg/phpdbg_list.c

index d71be2266f0cb80763e2fe621939d28f8aaa5d81..bde93a4abeb464fa941872f1ecf022a71202da59 100644 (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;
 }
index a2b76291da4e6f912d474667ce29f36f29898b4a..6d7195cee8f3e975507c2f8e8c86493dc4eb8709 100644 (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);
index 37a002f003151175c9ce766536be6c861b7cc31d..5904ba5c33e452bf0cb9011530f2a751808553e2 100644 (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);
index fcc7313084f30082cef501dfbcda25eda9885980..68245ba4d0c757478c56e0d9dde54130eb59414f 100644 (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
index d62ff3ed320372b9388979b562b376cb1521f7b7..94a571d21c615af07d60e859f98b1acfc4072262 100644 (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;
index e8911f732aa405d01c2a6111ca8d0d10bc8a8001..0a245642592b1b7cc4a03145dc5811d7fe9cb18a 100644 (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);
index 2c0d8e2725cfbbcacd67782883fbded3c3d37f54..3148180a9a5c6219b0cc51e3fe9a56c9f300953d 100644 (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);
 }
index 4d3335a49091c63bc50598b53ffc51fa4aacfc25..75be4c32b268c3dbb2f71315ab8b30641d7aef10 100644 (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);
index 053d22afd0c0dd61460596a4e65a870377d0f322..6ef9baf252764a54d1ecc4bbd4d42bfcb00610fa 100644 (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;
index 4ad19d67641886654220db8596d94446aadea6bf..a60883fb74fe9b47ee05511974104a3964a284b7 100644 (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);
 }
index 92a4dbccd3ca8255f62a75a9125884d55c1bc034..8ea1518ca662ff7fe93be8a10e1fd229fee2e60f 100644 (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()
index 3640b9a5ea946e8ddfaa6a741a9c4cc2fa629ecc..4d51a064fc6b18e6c887e393dfbad7cf285934d0 100644 (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);
index 497b02230bbcb8fc78d3892ac86698620671df64..6d9ce9cea2405a2dae11597bbbf0309a6a9e6465 100644 (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;
index ee5f5d82b83f29a9f753eb14bd28d60b067eca66..c91d1e199eb2471378502c9f3bf3731a1bf6f34a 100644 (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);
        }
 }
index 922663ab482f44eb73eab8cb93c4f4299eac07cd..ff7ead64600ecfb6bc721dae94bc9b0c87218593 100644 (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');
index d1b22e6f4056ed89f8e3795fdf4aa0351867743e..f22d2ce1c23bfab11b6df9d00d04477a4d5b4940 100644 (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 */
index 35b023aebe4a5d6e78286e0bc480f30961b236f7..3631763747543ecc9cfd1f576c2c9e4fc9c9df49 100644 (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;