]> granicus.if.org Git - php/commitdiff
buffer input to repeat commands
authorkrakjoe <joe.watkins@live.co.uk>
Mon, 21 Apr 2014 20:43:19 +0000 (21:43 +0100)
committerkrakjoe <joe.watkins@live.co.uk>
Mon, 21 Apr 2014 20:43:19 +0000 (21:43 +0100)
phpdbg.c
phpdbg.h
phpdbg_cmd.c
phpdbg_prompt.c

index d7eb5c8b382f0361721d87ec346851624c21978d..5b235ee3a8f8dfba80e1ed7d6b5d4b69f8ed458e 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -61,16 +61,15 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */
 
        pg->exec = NULL;
        pg->exec_len = 0;
+       pg->buffer = NULL;
        pg->ops = NULL;
        pg->vmret = 0;
        pg->bp_count = 0;
-       pg->lcmd = NULL;
        pg->flags = PHPDBG_DEFAULT_FLAGS;
        pg->oplog = NULL;
        pg->io[PHPDBG_STDIN] = NULL;
        pg->io[PHPDBG_STDOUT] = NULL;
        pg->io[PHPDBG_STDERR] = NULL;
-       memset(&pg->lparam, 0, sizeof(phpdbg_param_t));
        pg->frame.num = 0;
 } /* }}} */
 
@@ -184,6 +183,11 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
        zend_hash_destroy(&PHPDBG_G(watchpoints));
        zend_llist_destroy(&PHPDBG_G(watchlist_mem));
 
+       if (PHPDBG_G(buffer)) {
+               efree(PHPDBG_G(buffer));
+               PHPDBG_G(buffer) = NULL;
+       }
+       
        if (PHPDBG_G(exec)) {
                efree(PHPDBG_G(exec));
                PHPDBG_G(exec) = NULL;
index d25e0be4379dbd884c417e1fc8c8469cde8c6d03..be009e40d042221f44e6a82d4d21979b56f20477 100644 (file)
--- a/phpdbg.h
+++ b/phpdbg.h
@@ -199,9 +199,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
 
        char *prompt[2];                             /* prompt */
        const phpdbg_color_t *colors[PHPDBG_COLORS]; /* colors */
-
-       phpdbg_command_t *lcmd;                      /* last command */
-       phpdbg_param_t    lparam;                    /* last param */
+       char *buffer;                                /* buffer */
 
        zend_ulong flags;                            /* phpdbg flags */
 ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */
index ce66ba39eca5c28a8920335e195491c270660131..d4ce8ebc55f36b4c28ab478a6b441eb2b1e54052 100644 (file)
@@ -858,6 +858,27 @@ readline:
 #endif
        }
 
+       if (buffer && isspace(*buffer)) {
+               char *trimmed = buffer;
+               while (isspace(*trimmed))
+                       trimmed++;
+
+               trimmed = estrdup(trimmed);
+               efree(buffer);
+               buffer = trimmed;
+       }
+
+       if (buffer && strlen(buffer)) {
+               if (PHPDBG_G(buffer)) {
+                       efree(PHPDBG_G(buffer));
+               }
+               PHPDBG_G(buffer) = estrdup(buffer);
+       } else {
+               if (PHPDBG_G(buffer)) {
+                       buffer = estrdup(PHPDBG_G(buffer));
+               }
+       }
+       
        return buffer;
 } /* }}} */
 
index d93b55374e426018f03aed61838da51465c7709b..2e07c3217472365e8ffe2207f4a21422a677724c 100644 (file)
@@ -1028,13 +1028,13 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
                        if (yyparse(&stack, scanner) <= 0) {
                                switch (ret = phpdbg_stack_execute(&stack, &why TSRMLS_CC)) {
                                        case FAILURE:
-//                                             if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
+                                               if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
                                                        if (phpdbg_call_register(&stack TSRMLS_CC) == FAILURE) {
                                                                if (why) {
                                                                        phpdbg_error("%s", why);
                                                                }
                                                        }
-//                                             }
+                                               }
 
                                                if (why) {
                                                        free(why);
@@ -1066,17 +1066,6 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
                        phpdbg_destroy_input(&input TSRMLS_CC);
 
                } while ((input = phpdbg_read_input(NULL TSRMLS_CC)));
-
-               if (!input)
-                       goto last;
-
-       } else {
-last:
-               if (PHPDBG_G(lcmd)) {
-                       ret = PHPDBG_G(lcmd)->handler(
-                                       &PHPDBG_G(lparam) TSRMLS_CC);
-                       goto out;
-               }
        }
 
 out: