com php-src: consistency in prompt/list, do not return FAILURE from command handlers: phpdbg_list.c phpdbg_prompt.c
| From: | Bob Weinand | Date: | Sat, 16 Nov 2013 23:35:11 +0000 |
| Subject: | com php-src: consistency in prompt/list, do not return FAILURE from command handlers: phpdbg_list.c phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74906@lists.php.net to get a copy of this message | ||
Commit: 434949c5b40d56d5f1d97180a78cff8b968a50d2
Author: krakjoe <joe.watkins@live.co.uk> Sat, 16 Nov 2013 23:35:11 +0000
Parents: 8f4f4f06284c028be574178257a228526c7670b9
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=434949c5b40d56d5f1d97180a78cff8b968a50d2
Log:
consistency in prompt/list, do not return FAILURE from command handlers
Changed paths:
M phpdbg_list.c
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg_list.c b/phpdbg_list.c
index ce1a7f1..a778f64 100644
--- a/phpdbg_list.c
+++ b/phpdbg_list.c
@@ -227,7 +227,7 @@ void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC)
{
HashTable *func_table = EG(function_table);
zend_function* fbc;
- char *func_name = str;
+ char *func_name = (char*) str;
size_t func_name_len = len;
/* search active scope if begins with period */
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 100d4af..d3876be 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -211,7 +211,7 @@ static PHPDBG_COMMAND(exec) /* {{{ */
if (!PHPDBG_G(exec)) {
phpdbg_error("Cannot get real file path");
- return FAILURE;
+ return SUCCESS;
}
PHPDBG_G(exec_len) = strlen(PHPDBG_G(exec));
@@ -262,8 +262,9 @@ static PHPDBG_COMMAND(compile) /* {{{ */
{
if (!PHPDBG_G(exec)) {
phpdbg_error("No execution context");
- return FAILURE;
+ return SUCCESS;
}
+
if (!EG(in_execution)) {
if (PHPDBG_G(ops)) {
phpdbg_error("Destroying previously compiled opcodes");
@@ -271,7 +272,9 @@ static PHPDBG_COMMAND(compile) /* {{{ */
}
}
- return phpdbg_compile(TSRMLS_C);
+ phpdbg_compile(TSRMLS_C);
+
+ return SUCCESS;
} /* }}} */
static PHPDBG_COMMAND(step) /* {{{ */
@@ -309,7 +312,7 @@ static PHPDBG_COMMAND(run) /* {{{ */
{
if (EG(in_execution)) {
phpdbg_error("Cannot start another execution while one is in progress");
- return FAILURE;
+ return SUCCESS;
}
if (PHPDBG_G(ops) || PHPDBG_G(exec)) {
@@ -319,8 +322,9 @@ static PHPDBG_COMMAND(run) /* {{{ */
if (!PHPDBG_G(ops)) {
if (phpdbg_compile(TSRMLS_C) == FAILURE) {
- phpdbg_error("Failed to compile %s, cannot run", PHPDBG_G(exec));
- return FAILURE;
+ phpdbg_error(
+ "Failed to compile %s, cannot run", PHPDBG_G(exec));
+ goto out;
}
}
@@ -340,19 +344,20 @@ static PHPDBG_COMMAND(run) /* {{{ */
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
phpdbg_error("Caught excetion in VM");
- return FAILURE;
- } else return SUCCESS;
+ goto out;
+ }
} zend_end_try();
EG(active_op_array) = orig_op_array;
EG(opline_ptr) = orig_opline;
EG(return_value_ptr_ptr) = orig_retval_ptr;
- return SUCCESS;
} else {
phpdbg_error("Nothing to execute!");
- return FAILURE;
}
+
+out:
+ return SUCCESS;
} /* }}} */
static PHPDBG_COMMAND(eval) /* {{{ */
@@ -391,7 +396,7 @@ static PHPDBG_COMMAND(back) /* {{{ */
{
if (!EG(in_execution)) {
phpdbg_error("Not executing!");
- return FAILURE;
+ return SUCCESS;
}
switch (param->type) {
@@ -518,7 +523,7 @@ static PHPDBG_COMMAND(clean) /* {{{ */
{
if (EG(in_execution)) {
phpdbg_error("Cannot clean environment while executing");
- return FAILURE;
+ return SUCCESS;
}
phpdbg_notice("Cleaning Execution Environment");
@@ -622,64 +627,65 @@ static PHPDBG_COMMAND(oplog) /* {{{ */
static PHPDBG_COMMAND(help) /* {{{ */
{
- if (param->type == EMPTY_PARAM) {
- const phpdbg_command_t *prompt_command = phpdbg_prompt_commands;
- const phpdbg_command_t *help_command = phpdbg_help_commands;
-
- phpdbg_help_header();
- phpdbg_writeln("To get help regarding a specific command type \"help
command\"");
+ switch (param->type) {
+ case EMPTY_PARAM: {
+ const phpdbg_command_t *prompt_command = phpdbg_prompt_commands;
+ const phpdbg_command_t *help_command = phpdbg_help_commands;
+
+ phpdbg_help_header();
+ phpdbg_writeln("To get help regarding a specific command type \"help
command\"");
- phpdbg_notice("Commands");
+ phpdbg_notice("Commands");
- while (prompt_command && prompt_command->name) {
- phpdbg_writeln(
- "\t%s\t%s", prompt_command->name, prompt_command->tip);
- ++prompt_command;
- }
+ while (prompt_command && prompt_command->name) {
+ phpdbg_writeln(
+ "\t%s\t%s", prompt_command->name, prompt_command->tip);
+ ++prompt_command;
+ }
- phpdbg_notice("Helpers Loaded");
+ phpdbg_notice("Helpers Loaded");
- while (help_command && help_command->name) {
- phpdbg_writeln("\t%s\t%s", help_command->name, help_command->tip);
- ++help_command;
- }
+ while (help_command && help_command->name) {
+ phpdbg_writeln("\t%s\t%s", help_command->name, help_command->tip);
+ ++help_command;
+ }
- phpdbg_notice("Command Line Options and Flags");
- phpdbg_writeln("\tOption\tExample\t\t\tPurpose");
- phpdbg_writeln(EMPTY);
- phpdbg_writeln("\t-c\t-c/my/php.ini\t\tSet php.ini file to load");
- phpdbg_writeln("\t-d\t-dmemory_limit=4G\tSet a php.ini directive");
- phpdbg_writeln("\t-n\t-N/A\t\t\tDisable default php.ini");
- phpdbg_writeln("\t-e\t-emytest.php\t\tSet execution context");
- phpdbg_writeln("\t-v\tN/A\t\t\tEnable opline output while executing");
- phpdbg_writeln("\t-s\tN/A\t\t\tEnable stepping");
- phpdbg_writeln("\t-b\tN/A\t\t\tDisable the use of colours");
- phpdbg_writeln("\t-i\t-imy.init\t\tSet the phpdbginit file");
- phpdbg_writeln("\t-I\tN/A\t\t\tDisable loading .phpdbginit");
- phpdbg_writeln("\t-O\t-Omy.oplog\t\tSets oplog output file");
- phpdbg_help_footer();
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param
TSRMLS_CC));
- return FAILURE;
- }
+ phpdbg_notice("Command Line Options and Flags");
+ phpdbg_writeln("\tOption\tExample\t\t\tPurpose");
+ phpdbg_writeln(EMPTY);
+ phpdbg_writeln("\t-c\t-c/my/php.ini\t\tSet php.ini file to load");
+ phpdbg_writeln("\t-d\t-dmemory_limit=4G\tSet a php.ini directive");
+ phpdbg_writeln("\t-n\t-N/A\t\t\tDisable default php.ini");
+ phpdbg_writeln("\t-e\t-emytest.php\t\tSet execution context");
+ phpdbg_writeln("\t-v\tN/A\t\t\tEnable opline output while executing");
+ phpdbg_writeln("\t-s\tN/A\t\t\tEnable stepping");
+ phpdbg_writeln("\t-b\tN/A\t\t\tDisable the use of colours");
+ phpdbg_writeln("\t-i\t-imy.init\t\tSet the phpdbginit file");
+ phpdbg_writeln("\t-I\tN/A\t\t\tDisable loading .phpdbginit");
+ phpdbg_writeln("\t-O\t-Omy.oplog\t\tSets oplog output file");
+ phpdbg_help_footer();
+ } break;
+
+ phpdbg_default_switch_case();
+ }
return SUCCESS;
} /* }}} */
-static PHPDBG_COMMAND(quiet) { /* {{{ */
- if (param->type == NUMERIC_PARAM) {
- if (param->num) {
- PHPDBG_G(flags) |= PHPDBG_IS_QUIET;
- } else {
- PHPDBG_G(flags) &= ~PHPDBG_IS_QUIET;
- }
- phpdbg_notice("Quietness %s",
- (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "enabled" : "disabled");
- } else {
- phpdbg_error(
- "Unsupported parameter type (%s) for command", phpdbg_get_param_type(param
TSRMLS_CC));
- return FAILURE;
+static PHPDBG_COMMAND(quiet) /* {{{ */
+{
+ switch (param->type) {
+ case NUMERIC_PARAM: {
+ if (param->num) {
+ PHPDBG_G(flags) |= PHPDBG_IS_QUIET;
+ } else {
+ PHPDBG_G(flags) &= ~PHPDBG_IS_QUIET;
+ }
+ phpdbg_notice("Quietness %s",
+ (PHPDBG_G(flags) & PHPDBG_IS_QUIET) ? "enabled" :
"disabled");
+ } break;
+
+ phpdbg_default_switch_case();
}
return SUCCESS;
@@ -764,7 +770,7 @@ int phpdbg_do_cmd( const phpdbg_command_t *command,
}
}
- *selected = command;
+ *selected = (phpdbg_command_t*) command;
rc = command->handler(param TSRMLS_CC);