From 71811f1f7f68d1e7331b06c95cec1f86da5cdfc2 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Tue, 19 Nov 2013 14:28:57 +0000 Subject: [PATCH] include registered functions in help for register command --- phpdbg.c | 4 ---- phpdbg_cmd.c | 2 -- phpdbg_help.c | 14 ++++++++++++++ phpdbg_prompt.c | 10 ++++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index e7f3403610..c8a39957cd 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -60,15 +60,11 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ REGISTER_LONG_CONSTANT("PHPDBG_LINENO", NUMERIC_PARAM, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_FUNC", STR_PARAM, CONST_CS|CONST_PERSISTENT); - php_output_startup(); - return SUCCESS; } /* }}} */ static PHP_MSHUTDOWN_FUNCTION(phpdbg) { - php_output_shutdown(); - return SUCCESS; } diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index ca026cf7de..e192c2b953 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -198,9 +198,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_le while (command && command->name && command->handler) { if ((command->name_len == expr_len && memcmp(cmd, command->name, expr_len) == 0) || (expr_len == 1 && command->alias && command->alias == cmd_line[0])) { - phpdbg_param_t param; - phpdbg_parse_param( expr, (cmd_len - expr_len) ? (((cmd_len - expr_len) - sizeof(" "))+1) : 0, diff --git a/phpdbg_help.c b/phpdbg_help.c index 1f2246a8a9..9aa37310e9 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -420,6 +420,20 @@ PHPDBG_HELP(register) /* {{{ */ 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"); + if (zend_hash_num_elements(&PHPDBG_G(registered))) { + HashPosition position; + char *name = NULL; + zend_uint name_len = 0; + + phpdbg_notice("Registered Functions (%d)", zend_hash_num_elements(&PHPDBG_G(registered))); + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(registered), &position); + zend_hash_get_current_key_ex(&PHPDBG_G(registered), &name, &name_len, NULL, 1, &position) == HASH_KEY_IS_STRING; + zend_hash_move_forward_ex(&PHPDBG_G(registered), &position)) { + phpdbg_writeln("|-------> %s", name); + efree(name); + } + } + phpdbg_help_footer(); return SUCCESS; } /* }}} */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 1cbc7db3a0..9a12454e7c 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -681,10 +681,10 @@ static PHPDBG_COMMAND(register) /* {{{ */ char *lcname = zend_str_tolower_dup(param->str, param->len); size_t lcname_len = strlen(lcname); - if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len)) { + if (!zend_hash_exists(&PHPDBG_G(registered), lcname, lcname_len+1)) { if (zend_hash_find(EG(function_table), lcname, lcname_len+1, (void**) &function) == SUCCESS) { zend_hash_update( - &PHPDBG_G(registered), lcname, lcname_len, (void*)&function, sizeof(zend_function), NULL); + &PHPDBG_G(registered), lcname, lcname_len+1, (void*)&function, sizeof(zend_function), NULL); function_add_ref(function); phpdbg_notice( @@ -696,6 +696,8 @@ static PHPDBG_COMMAND(register) /* {{{ */ phpdbg_error( "The requested name (%s) is already in use", lcname); } + + efree(lcname); } break; phpdbg_default_switch_case(); @@ -917,8 +919,8 @@ static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ * size_t cmd_len = input->length; const char *start = (const char*) input->start; 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)+1)) { zval fname, *fretval, *farg = NULL; zend_fcall_info fci; zend_fcall_info_cache fcic; -- 2.40.0