mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
better call register
This commit is contained in:
parent
7c077f7040
commit
2ebb9e48be
1 changed files with 53 additions and 55 deletions
|
@ -910,43 +910,8 @@ static PHPDBG_COMMAND(list) /* {{{ */
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
static inline int phpdbg_call_register(const char *cmd, size_t cmd_len, const char * start TSRMLS_DC)
|
||||||
{
|
{
|
||||||
size_t cmd_len;
|
|
||||||
int ret = SUCCESS;
|
|
||||||
char *start = NULL;
|
|
||||||
|
|
||||||
#ifndef HAVE_LIBREADLINE
|
|
||||||
char cmd[PHPDBG_MAX_CMD];
|
|
||||||
|
|
||||||
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING) &&
|
|
||||||
phpdbg_write(PROMPT) &&
|
|
||||||
(fgets(cmd, PHPDBG_MAX_CMD, stdin) != NULL)) {
|
|
||||||
cmd_len = strlen(cmd) - 1;
|
|
||||||
#else
|
|
||||||
char *cmd = NULL;
|
|
||||||
|
|
||||||
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
|
|
||||||
cmd = readline(PROMPT);
|
|
||||||
cmd_len = cmd ? strlen(cmd) : 0;
|
|
||||||
#endif
|
|
||||||
start = estrndup(cmd, cmd_len);
|
|
||||||
|
|
||||||
/* trim space from end of input */
|
|
||||||
while (*cmd && isspace(cmd[cmd_len-1]))
|
|
||||||
cmd_len--;
|
|
||||||
|
|
||||||
/* ensure string is null terminated */
|
|
||||||
cmd[cmd_len] = '\0';
|
|
||||||
|
|
||||||
if (*cmd && cmd_len > 0L) {
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
add_history(cmd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (ret = phpdbg_do_cmd(phpdbg_prompt_commands, cmd, cmd_len TSRMLS_CC)) {
|
|
||||||
case FAILURE:
|
|
||||||
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
|
|
||||||
size_t offset = strlen(cmd)+(sizeof(" ")-1);
|
size_t offset = strlen(cmd)+(sizeof(" ")-1);
|
||||||
|
|
||||||
if (zend_hash_exists(&PHPDBG_G(registered), cmd, strlen(cmd))) {
|
if (zend_hash_exists(&PHPDBG_G(registered), cmd, strlen(cmd))) {
|
||||||
|
@ -988,7 +953,51 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
||||||
fretval, 0 TSRMLS_CC);
|
fretval, 0 TSRMLS_CC);
|
||||||
phpdbg_writeln(EMPTY);
|
phpdbg_writeln(EMPTY);
|
||||||
}
|
}
|
||||||
} else {
|
return SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
||||||
|
{
|
||||||
|
size_t cmd_len;
|
||||||
|
int ret = SUCCESS;
|
||||||
|
char* const* start;
|
||||||
|
|
||||||
|
#ifndef HAVE_LIBREADLINE
|
||||||
|
char cmd[PHPDBG_MAX_CMD];
|
||||||
|
|
||||||
|
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING) &&
|
||||||
|
phpdbg_write(PROMPT) &&
|
||||||
|
(fgets(cmd, PHPDBG_MAX_CMD, stdin) != NULL)) {
|
||||||
|
cmd_len = strlen(cmd) - 1;
|
||||||
|
#else
|
||||||
|
char *cmd = NULL;
|
||||||
|
|
||||||
|
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
|
||||||
|
cmd = readline(PROMPT);
|
||||||
|
cmd_len = cmd ? strlen(cmd) : 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
start = (char* const*) cmd;
|
||||||
|
|
||||||
|
/* trim space from end of input */
|
||||||
|
while (*cmd && isspace(cmd[cmd_len-1]))
|
||||||
|
cmd_len--;
|
||||||
|
|
||||||
|
/* ensure string is null terminated */
|
||||||
|
cmd[cmd_len] = '\0';
|
||||||
|
|
||||||
|
if (*cmd && cmd_len > 0L) {
|
||||||
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
add_history(cmd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (ret = phpdbg_do_cmd(phpdbg_prompt_commands, cmd, cmd_len TSRMLS_CC)) {
|
||||||
|
case FAILURE:
|
||||||
|
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
|
||||||
|
if (phpdbg_call_register(cmd, cmd_len, (const char*) start TSRMLS_CC) == FAILURE) {
|
||||||
phpdbg_error("Failed to execute %s!", cmd);
|
phpdbg_error("Failed to execute %s!", cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1001,9 +1010,6 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
||||||
if (!EG(in_execution)) {
|
if (!EG(in_execution)) {
|
||||||
phpdbg_error("Not running");
|
phpdbg_error("Not running");
|
||||||
}
|
}
|
||||||
if (start) {
|
|
||||||
efree(start);
|
|
||||||
}
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1015,20 +1021,12 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (start) {
|
|
||||||
efree(start);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PHPDBG_G(lcmd)) {
|
if (PHPDBG_G(lcmd)) {
|
||||||
ret = PHPDBG_G(lcmd)->handler(
|
ret = PHPDBG_G(lcmd)->handler(
|
||||||
&PHPDBG_G(lparam) TSRMLS_CC);
|
&PHPDBG_G(lparam) TSRMLS_CC);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start) {
|
|
||||||
efree(start);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue