summaryrefslogtreecommitdiff
path: root/sapi/phpdbg
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 /sapi/phpdbg
parentf6db43fec8da3d3c0c7def077e9f493ce6129c45 (diff)
downloadphp-git-88355dd338835f7a59415ecb2e7e970658f3867f.tar.gz
Constify char * arguments of APIs
Closes GH-5676.
Diffstat (limited to 'sapi/phpdbg')
-rw-r--r--sapi/phpdbg/phpdbg.c2
-rw-r--r--sapi/phpdbg/phpdbg_cmd.c20
-rw-r--r--sapi/phpdbg/phpdbg_cmd.h4
-rw-r--r--sapi/phpdbg/phpdbg_print.c12
-rw-r--r--sapi/phpdbg/phpdbg_print.h2
5 files changed, 17 insertions, 23 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 78aa34f524..ea0653fd25 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -772,7 +772,7 @@ static void php_sapi_phpdbg_send_header(sapi_header_struct *sapi_header, void *s
}
/* }}} */
-static void php_sapi_phpdbg_log_message(char *message, int syslog_type_int) /* {{{ */
+static void php_sapi_phpdbg_log_message(const char *message, int syslog_type_int) /* {{{ */
{
/*
* We must not request TSRM before being booted
diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c
index 61f17d1c0e..757d48e739 100644
--- a/sapi/phpdbg/phpdbg_cmd.c
+++ b/sapi/phpdbg/phpdbg_cmd.c
@@ -737,10 +737,9 @@ PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, zend_bool allow_async
return SUCCESS;
} /* }}} */
-PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
+PHPDBG_API char *phpdbg_read_input(const char *buffered) /* {{{ */
{
char buf[PHPDBG_MAX_CMD];
- char *cmd = NULL;
char *buffer = NULL;
if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) {
@@ -755,11 +754,12 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
#endif
{
phpdbg_write("prompt", "", "%s", phpdbg_get_prompt());
- phpdbg_consume_stdin_line(cmd = buf);
+ phpdbg_consume_stdin_line(buf);
+ buffer = estrdup(buf);
}
#ifdef HAVE_PHPDBG_READLINE
else {
- cmd = readline(phpdbg_get_prompt());
+ char *cmd = readline(phpdbg_get_prompt());
PHPDBG_G(last_was_newline) = 1;
if (!cmd) {
@@ -768,19 +768,13 @@ PHPDBG_API char *phpdbg_read_input(char *buffered) /* {{{ */
}
add_history(cmd);
+ buffer = estrdup(cmd);
+ free(cmd);
}
#endif
} else {
- cmd = buffered;
+ buffer = estrdup(buffered);
}
-
- buffer = estrdup(cmd);
-
-#ifdef HAVE_PHPDBG_READLINE
- if (!buffered && cmd && !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) {
- free(cmd);
- }
-#endif
}
if (buffer && isspace(*buffer)) {
diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h
index dd80e61db3..3cc07d1a70 100644
--- a/sapi/phpdbg/phpdbg_cmd.h
+++ b/sapi/phpdbg/phpdbg_cmd.h
@@ -125,8 +125,8 @@ typedef struct {
/*
* Input Management
*/
-PHPDBG_API char* phpdbg_read_input(char *buffered);
-PHPDBG_API void phpdbg_destroy_input(char**);
+PHPDBG_API char *phpdbg_read_input(const char *buffered);
+PHPDBG_API void phpdbg_destroy_input(char **input);
PHPDBG_API int phpdbg_ask_user_permission(const char *question);
/**
diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c
index 7cc84b72dc..df925b6402 100644
--- a/sapi/phpdbg/phpdbg_print.c
+++ b/sapi/phpdbg/phpdbg_print.c
@@ -375,7 +375,7 @@ void phpdbg_print_opcodes_class(const char *class) {
phpdbg_print_opcodes_ce(ce);
}
-PHPDBG_API void phpdbg_print_opcodes(char *function)
+PHPDBG_API void phpdbg_print_opcodes(const char *function)
{
if (function == NULL) {
phpdbg_print_opcodes_main();
@@ -401,12 +401,12 @@ PHPDBG_API void phpdbg_print_opcodes(char *function)
}
} ZEND_HASH_FOREACH_END();
} else {
- function = zend_str_tolower_dup(function, strlen(function));
+ char *function_lowercase = zend_str_tolower_dup(function, strlen(function));
- if (strstr(function, "::") == NULL) {
- phpdbg_print_opcodes_function(function, strlen(function));
+ if (strstr(function_lowercase, "::") == NULL) {
+ phpdbg_print_opcodes_function(function_lowercase, strlen(function_lowercase));
} else {
- char *method_name, *class_name = strtok(function, "::");
+ char *method_name, *class_name = strtok(function_lowercase, "::");
if ((method_name = strtok(NULL, "::")) == NULL) {
phpdbg_print_opcodes_class(class_name);
} else {
@@ -414,6 +414,6 @@ PHPDBG_API void phpdbg_print_opcodes(char *function)
}
}
- efree(function);
+ efree(function_lowercase);
}
}
diff --git a/sapi/phpdbg/phpdbg_print.h b/sapi/phpdbg/phpdbg_print.h
index 79a77ad2a6..14f5bf6939 100644
--- a/sapi/phpdbg/phpdbg_print.h
+++ b/sapi/phpdbg/phpdbg_print.h
@@ -33,7 +33,7 @@ PHPDBG_PRINT(method);
PHPDBG_PRINT(func);
PHPDBG_PRINT(stack);
-PHPDBG_API void phpdbg_print_opcodes(char *function);
+PHPDBG_API void phpdbg_print_opcodes(const char *function);
extern const phpdbg_command_t phpdbg_print_commands[];