Commit:    188f4d3c519db77fd592cc733fcac9679ea24ae8
Author:    krakjoe <joe.watk...@live.co.uk>         Wed, 13 Nov 2013 17:35:51 
+0000
Parents:   a6a909101f84cbcedc2a0d7cdfd7579a0a5a66d9
Branches:  PHP-5.6

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=188f4d3c519db77fd592cc733fcac9679ea24ae8

Log:
aliasing commands

Changed paths:
  M  phpdbg_help.h
  M  phpdbg_print.h
  M  phpdbg_prompt.c
  M  phpdbg_prompt.h


Diff:
diff --git a/phpdbg_help.h b/phpdbg_help.h
index 9c89f3d..8cf7b1d 100644
--- a/phpdbg_help.h
+++ b/phpdbg_help.h
@@ -27,7 +27,7 @@
  * Command Declarators
  */
 #define PHPDBG_HELP_D(name, tip) \
-       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, phpdbg_do_help_##name}
+       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, 0, phpdbg_do_help_##name}
 #define PHPDBG_HELP(name) \
        int phpdbg_do_help_##name(const char *expr, size_t expr_len TSRMLS_DC)
 
diff --git a/phpdbg_print.h b/phpdbg_print.h
index d906ab0..7e48f7b 100644
--- a/phpdbg_print.h
+++ b/phpdbg_print.h
@@ -27,7 +27,7 @@
  * Command Declarators
  */
 #define PHPDBG_PRINT_D(name, tip) \
-       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, phpdbg_do_print_##name}
+       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, 0, phpdbg_do_print_##name}
 #define PHPDBG_PRINT(name) \
        int phpdbg_do_print_##name(const char *expr, size_t expr_len TSRMLS_DC)
 
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index a3d95d4..b076d8c 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -36,20 +36,24 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
 static PHPDBG_COMMAND(exec) /* {{{ */
 {
-       if (PHPDBG_G(exec)) {
-               phpdbg_notice("Unsetting old execution context: %s", 
PHPDBG_G(exec));
-               efree(PHPDBG_G(exec));
-               PHPDBG_G(exec) = NULL;
-       }
+       if (expr && expr_len > 0L) {
+           if (PHPDBG_G(exec)) {
+                   phpdbg_notice("Unsetting old execution context: %s", 
PHPDBG_G(exec));
+                   efree(PHPDBG_G(exec));
+                   PHPDBG_G(exec) = NULL;
+           }
 
-       if (PHPDBG_G(ops)) {
-               phpdbg_notice("Destroying compiled opcodes");
-               phpdbg_clean(0 TSRMLS_CC);
-       }
+           if (PHPDBG_G(ops)) {
+                   phpdbg_notice("Destroying compiled opcodes");
+                       phpdbg_clean(0 TSRMLS_CC);
+           }
 
-       PHPDBG_G(exec) = estrndup(expr, PHPDBG_G(exec_len) = expr_len);
+           PHPDBG_G(exec) = estrndup(expr, PHPDBG_G(exec_len) = expr_len);
 
-       phpdbg_notice("Set execution context: %s", PHPDBG_G(exec));
+           phpdbg_notice("Set execution context: %s", PHPDBG_G(exec));
+       } else {
+           phpdbg_error("No expression provided");
+       }
 
        return SUCCESS;
 } /* }}} */
@@ -420,6 +424,28 @@ static PHPDBG_COMMAND(clear) /* {{{ */
     return SUCCESS;
 } /* }}} */
 
+static PHPDBG_COMMAND(aliases) /* {{{ */
+{
+    phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s",
+               PHPDBG_VERSION);
+
+    phpdbg_notice("Aliases");
+       {
+           const phpdbg_command_t *prompt_command = phpdbg_prompt_commands;
+
+           while (prompt_command && prompt_command->name) {
+                   if (prompt_command->alias) {
+                       phpdbg_writeln(
+                           "\t%c -> %s", prompt_command->alias, 
prompt_command->name);
+                   }
+                   ++prompt_command;
+           }
+       }
+       phpdbg_notice("Please report bugs to <%s>", PHPDBG_ISSUES);
+       
+       return SUCCESS;
+} /* }}} */
+
 static PHPDBG_COMMAND(help) /* {{{ */
 {
        phpdbg_notice("Welcome to phpdbg, the interactive PHP debugger, v%s",
@@ -438,10 +464,11 @@ static PHPDBG_COMMAND(help) /* {{{ */
                phpdbg_notice("Commands");
 
                while (prompt_command && prompt_command->name) {
-                       phpdbg_writeln("\t%s\t%s", prompt_command->name, 
prompt_command->tip);
+                       phpdbg_writeln(
+                           "\t%s\t%s", prompt_command->name, 
prompt_command->tip);
                        ++prompt_command;
                }
-
+               
                phpdbg_notice("Helpers Loaded");
 
                while (help_command && help_command->name) {
@@ -519,21 +546,22 @@ static PHPDBG_COMMAND(list) /* {{{ */
 } /* }}} */
 
 static const phpdbg_command_t phpdbg_prompt_commands[] = {
-       PHPDBG_COMMAND_D(exec,      "set execution context"),
-       PHPDBG_COMMAND_D(compile,   "attempt to pre-compile execution context"),
-       PHPDBG_COMMAND_D(step,      "step through execution"),
-       PHPDBG_COMMAND_D(next,      "continue execution"),
-       PHPDBG_COMMAND_D(run,       "attempt execution"),
-       PHPDBG_COMMAND_D(eval,      "evaluate some code"),
-       PHPDBG_COMMAND_D(print,     "print something"),
-       PHPDBG_COMMAND_D(break,     "set breakpoint"),
-       PHPDBG_COMMAND_D(back,      "show backtrace"),
-       PHPDBG_COMMAND_D(list,      "list specified line or function"),
-       PHPDBG_COMMAND_D(clean,     "clean the execution environment"),
-       PHPDBG_COMMAND_D(clear,     "clear breakpoints"),
-       PHPDBG_COMMAND_D(help,      "show help menu"),
-       PHPDBG_COMMAND_D(quiet,     "silence some output"),
-       PHPDBG_COMMAND_D(quit,      "exit phpdbg"),
+       PHPDBG_COMMAND_EX_D(exec,       "set execution context", 'e'),
+       PHPDBG_COMMAND_EX_D(compile,    "attempt to pre-compile execution 
context", 'c'),
+       PHPDBG_COMMAND_EX_D(step,       "step through execution", 's'),
+       PHPDBG_COMMAND_EX_D(next,       "continue execution", 'n'),
+       PHPDBG_COMMAND_EX_D(run,        "attempt execution", 'r'),
+       PHPDBG_COMMAND_EX_D(eval,       "evaluate some code", 'E'),
+       PHPDBG_COMMAND_EX_D(print,      "print something", 'p'),
+       PHPDBG_COMMAND_EX_D(break,      "set breakpoint", 'b'),
+       PHPDBG_COMMAND_EX_D(back,       "show trace", 't'),
+       PHPDBG_COMMAND_EX_D(list,       "list specified line or function", 'l'),
+       PHPDBG_COMMAND_D(clean,         "clean the execution environment"),
+       PHPDBG_COMMAND_D(clear,         "clear breakpoints"),
+       PHPDBG_COMMAND_EX_D(help,       "show help menu", 'h'),
+       PHPDBG_COMMAND_D(quiet,         "silence some output"),
+       PHPDBG_COMMAND_EX_D(aliases,    "show alias list", 'a'),
+       PHPDBG_COMMAND_EX_D(quit,       "exit phpdbg", 'q'),
        {NULL, 0, 0}
 };
 
@@ -548,8 +576,9 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, char 
*cmd_line, size_t cmd_le
        size_t expr_len = (cmd != NULL) ? strlen(cmd) : 0;
     
        while (command && command->name && command->handler) {
-               if (command->name_len == expr_len
-                           && memcmp(cmd, command->name, expr_len) == 0) {
+               if ((command->name_len == expr_len
+                           && memcmp(cmd, command->name, expr_len) == 0)
+                  ||(command->alias && command->alias == cmd_line[0])) {
                        
                        PHPDBG_G(last) = (phpdbg_command_t*) command;
                        PHPDBG_G(last_params) = expr;
diff --git a/phpdbg_prompt.h b/phpdbg_prompt.h
index 2a4fa4b..2739ac7 100644
--- a/phpdbg_prompt.h
+++ b/phpdbg_prompt.h
@@ -42,6 +42,7 @@ struct _phpdbg_command_t {
        size_t name_len;                    /* Command name length */
        const char *tip;                    /* Menu tip */
        size_t tip_len;                     /* Menu tip length */
+       char alias;                         /* Alias */
        phpdbg_command_handler_t handler;   /* Command handler */
 } ;
 
@@ -54,7 +55,9 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, char 
*cmd_line, size_t cmd_le
  * Command Declarators
  */
 #define PHPDBG_COMMAND_D(name, tip) \
-       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, phpdbg_do_##name}
+       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, 0, phpdbg_do_##name}
+#define PHPDBG_COMMAND_EX_D(name, tip, alias) \
+       {PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name}
 #define PHPDBG_COMMAND(name) \
        int phpdbg_do_##name(const char *expr, size_t expr_len TSRMLS_DC)


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to