Commit: 9ebc61f282b33cfbb02a482b624e9d4f8c6a3497 Author: krakjoe <joe.watk...@live.co.uk> Tue, 19 Nov 2013 01:48:21 +0000 Parents: 0250a0992c2fce5810df5fe1460dc3a8b3b948fb Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9ebc61f282b33cfbb02a482b624e9d4f8c6a3497 Log: help for register better formatting for help menu Changed paths: M phpdbg_help.c M phpdbg_help.h M phpdbg_prompt.c Diff: diff --git a/phpdbg_help.c b/phpdbg_help.c index 4c17ba3..1f2246a 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -409,6 +409,21 @@ PHPDBG_HELP(oplog) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_HELP(register) /* {{{ */ +{ + phpdbg_help_header(); + phpdbg_writeln("Register any global function that accepts 0 or 1 arguments for use as a command in phpdbg console"); + phpdbg_writeln(EMPTY); + phpdbg_notice("Examples"); + phpdbg_writeln("\t%sregister scandir", PROMPT); + phpdbg_writeln("\t%sR scandir", PROMPT); + phpdbg_writeln("\tWill register the scandir function for use in phpdbg"); + phpdbg_writeln(EMPTY); + phpdbg_writeln("Note: argument will be passed as a string to the function and the return printed to the console"); + phpdbg_help_footer(); + return SUCCESS; +} /* }}} */ + PHPDBG_HELP(shell) /* {{{ */ { phpdbg_help_header(); diff --git a/phpdbg_help.h b/phpdbg_help.h index 89de11b..2768663 100644 --- a/phpdbg_help.h +++ b/phpdbg_help.h @@ -47,6 +47,7 @@ PHPDBG_HELP(back); PHPDBG_HELP(quiet); PHPDBG_HELP(list); PHPDBG_HELP(oplog); +PHPDBG_HELP(register); PHPDBG_HELP(shell); /** @@ -71,6 +72,7 @@ static const phpdbg_command_t phpdbg_help_commands[] = { PHPDBG_COMMAND_D_EX(quiet, "be quiet during execution", 'Q', help_quiet, NULL, 0), PHPDBG_COMMAND_D_EX(list, "list code gives you quick access to code", 'l', help_list, NULL, 0), PHPDBG_COMMAND_D_EX(oplog, "keep clutter off the screen by logging oplines", 'O', help_oplog, NULL, 0), + PHPDBG_COMMAND_D_EX(register, "register a php function for use as a command", 'R', help_register,NULL, 0), PHPDBG_COMMAND_D_EX(shell, "execute system commands with direct shell access", '-', help_shell, NULL, 0), PHPDBG_END_COMMAND }; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 1325078..45000a1 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -835,30 +835,30 @@ static PHPDBG_COMMAND(help) /* {{{ */ while (prompt_command && prompt_command->name) { phpdbg_writeln( - "\t%s\t%s", prompt_command->name, prompt_command->tip); + " %10s\t%s", prompt_command->name, prompt_command->tip); ++prompt_command; } - phpdbg_notice("Helpers Loaded"); + phpdbg_notice("Help Commands"); while (help_command && help_command->name) { - phpdbg_writeln("\t%s\t%s", help_command->name, help_command->tip); + phpdbg_writeln(" %10s\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(" Option\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 oplog output"); - phpdbg_writeln("\t-s\tN/A\t\t\tEnable stepping"); - phpdbg_writeln("\t-b\tN/A\t\t\tDisable colour"); - phpdbg_writeln("\t-i\t-imy.init\t\tSet .phpdbginit file"); - phpdbg_writeln("\t-I\tN/A\t\t\tIgnore default .phpdbginit"); - phpdbg_writeln("\t-O\t-Omy.oplog\t\tSets oplog output file"); + phpdbg_writeln(" -c\t-c/my/php.ini\t\tSet php.ini file to load"); + phpdbg_writeln(" -d\t-dmemory_limit=4G\tSet a php.ini directive"); + phpdbg_writeln(" -n\t-N/A\t\t\tDisable default php.ini"); + phpdbg_writeln(" -e\t-emytest.php\t\tSet execution context"); + phpdbg_writeln(" -v\tN/A\t\t\tEnable oplog output"); + phpdbg_writeln(" -s\tN/A\t\t\tEnable stepping"); + phpdbg_writeln(" -b\tN/A\t\t\tDisable colour"); + phpdbg_writeln(" -i\t-imy.init\t\tSet .phpdbginit file"); + phpdbg_writeln(" -I\tN/A\t\t\tIgnore default .phpdbginit"); + phpdbg_writeln(" -O\t-Omy.oplog\t\tSets oplog output file"); phpdbg_help_footer(); } break; @@ -914,7 +914,8 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ { size_t cmd_len; int ret = SUCCESS; - + char *start = NULL; + #ifndef HAVE_LIBREADLINE char cmd[PHPDBG_MAX_CMD]; @@ -924,13 +925,13 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ cmd_len = strlen(cmd) - 1; #else char *cmd = NULL; - const char *start = NULL; - + while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { cmd = readline(PROMPT); cmd_len = cmd ? strlen(cmd) : 0; +#endif start = estrndup(cmd, cmd_len); -#endif + /* trim space from end of input */ while (*cmd && isspace(cmd[cmd_len-1])) cmd_len--; @@ -963,7 +964,6 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ ZVAL_STRINGL(&fname, cmd, strlen(cmd), 1); - fci.size = sizeof(fci); fci.function_table = &PHPDBG_G(registered); fci.function_name = &fname; @@ -1001,6 +1001,9 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ if (!EG(in_execution)) { phpdbg_error("Not running"); } + if (start) { + efree(start); + } goto out; } } @@ -1012,12 +1015,20 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ } #endif } else { + if (start) { + efree(start); + } + if (PHPDBG_G(lcmd)) { ret = PHPDBG_G(lcmd)->handler( &PHPDBG_G(lparam) TSRMLS_CC); goto out; } } + + if (start) { + efree(start); + } } out: -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php