diff options
author | twosee <twose@qq.com> | 2020-06-07 17:01:19 +0800 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-08 10:38:45 +0200 |
commit | 88355dd338835f7a59415ecb2e7e970658f3867f (patch) | |
tree | f203c58d7656c341273565e2d6fb84d89837bad2 /sapi/phpdbg/phpdbg_cmd.c | |
parent | f6db43fec8da3d3c0c7def077e9f493ce6129c45 (diff) | |
download | php-git-88355dd338835f7a59415ecb2e7e970658f3867f.tar.gz |
Constify char * arguments of APIs
Closes GH-5676.
Diffstat (limited to 'sapi/phpdbg/phpdbg_cmd.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_cmd.c | 20 |
1 files changed, 7 insertions, 13 deletions
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)) { |