]> granicus.if.org Git - php/commitdiff
restore sanity to commands/handlers/the universe
authorkrakjoe <joe.watkins@live.co.uk>
Wed, 20 Nov 2013 21:47:44 +0000 (21:47 +0000)
committerkrakjoe <joe.watkins@live.co.uk>
Wed, 20 Nov 2013 21:47:44 +0000 (21:47 +0000)
phpdbg_break.c
phpdbg_cmd.c
phpdbg_cmd.h
phpdbg_prompt.c

index b0345a0a614b649f066cea7ea9b2eb37f1c36872..d4bf62f04bdcf7a1680bcc3e2d7ea1aab38d9bde 100644 (file)
@@ -66,13 +66,7 @@ PHPDBG_BREAK(address) /* {{{ */
 } /* }}} */
 
 PHPDBG_BREAK(on) /* {{{ */
-{
-       if (input && input->argc > 2) {
-               phpdbg_error(
-                       "Unquoted complex expression detected, please \"quote\" complex expressions");
-               return SUCCESS;
-       }
-       
+{      
     switch (param->type) {
         case STR_PARAM:
             phpdbg_set_breakpoint_expression(param->str, param->len TSRMLS_CC);
index f26fbbc04c07b841a1386a6bd3a6fb846245181a..4aefde34c548737301da99474b4f7584c59fa602 100644 (file)
@@ -303,7 +303,7 @@ void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
        }
 } /* }}} */
 
-int phpdbg_do_cmd(const phpdbg_command_t *command, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */
+int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */
 {
        int rc = FAILURE;
 
@@ -318,26 +318,51 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, const phpdbg_input_t *input T
                                phpdbg_param_t param;
 
                                param.type = EMPTY_PARAM;
-
+                               
                                if (input->argc > 1) {
                                        if (command->subs) {
                                                phpdbg_input_t sub;
                                                
+                                               sub.length = input->length;
+                                               sub.string = input->string;
+                                               sub.start = input->start;
+                                               
+                                               sub.string += input->argv[0]->length;
+                                               sub.length -= input->argv[0]->length;
+                                               while (isspace(*sub.string)) {
+                                                       sub.string++;
+                                                       sub.length--;
+                                               }
                                                sub.argc = input->argc-1;
                                                sub.argv = &input->argv[1];
-
+                                               sub.string = estrndup(sub.string, sub.length);
+                                               
                                                phpdbg_debug(
                                                        "trying sub commands in \"%s\" for \"%s\" with %d arguments",
                                                        command->name, sub.argv[0]->string, sub.argc-1);
                                                if (phpdbg_do_cmd(command->subs, &sub TSRMLS_CC) == SUCCESS) {
+                                                       efree(sub.string);
                                                        return SUCCESS;
                                                }
+                                               
+                                               efree(sub.string);
+                                       } else {
+                                               char *store = input->string;
+                                               
+                                               input->string += input->argv[0]->length;
+                                               input->length -= input->argv[0]->length;
+                                               while (isspace(*input->string)) {
+                                                       input->string++;
+                                                       input->length--;
+                                               }
+                                               input->string = estrndup(input->string, input->length);
+                                               efree(store);
                                        }
                                        
                                        /* pass parameter on */
                                        phpdbg_parse_param(
-                                               input->argv[1]->string,
-                                               input->argv[1]->length,
+                                               input->string,
+                                               input->length,
                                                &param TSRMLS_CC);
                                }
                                
index 259078ac9d26e6448f6a03539ae0a00c21be5e4e..e9c52a7292f952203c06ff538df41e74fcb4f726 100644 (file)
@@ -114,7 +114,7 @@ const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC);
 /*
 * Command Executor
 */
-int phpdbg_do_cmd(const phpdbg_command_t*, const phpdbg_input_t* TSRMLS_DC);
+int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t* TSRMLS_DC);
 
 /**
  * Command Declarators
index f15c802feeb1e5ca24abe56d0bacaf3637c65098..b06cb059e1ed363355cce2683f44e6f5bb462f84 100644 (file)
@@ -485,42 +485,34 @@ out:
 
 PHPDBG_COMMAND(eval) /* {{{ */
 {
-       zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING);
-       zval retval;
-       char *code = NULL;
-
-       if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) {
-               PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING;
-       }
-
-       if (input && input->start) {
-               code = (char*) input->start;
+       switch (param->type) {
+               case STR_PARAM: {
+                       zend_bool stepping = ((PHPDBG_G(flags) & PHPDBG_IS_STEPPING)==PHPDBG_IS_STEPPING);
+                       zval retval;
 
-               if (memcmp(
-                       code, "eval", sizeof("eval")-1) == SUCCESS) {
-                       code += sizeof("eval")-1;
-               } else code += sizeof("E")-1;
+                       if (!(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) {
+                               PHPDBG_G(flags) &= ~ PHPDBG_IS_STEPPING;
+                       }
 
-               while (code && isspace(*code)) {
-                       code++;
-               }
-       } else phpdbg_error("Nothing to execute");
-
-       /* disable stepping while eval() in progress */
-       PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
-       if (zend_eval_stringl(code, strlen(code),
-               &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) {
-               zend_print_zval_r(
-                       &retval, 0 TSRMLS_CC);
-               phpdbg_writeln(EMPTY);
-               zval_dtor(&retval);
-       }
-       PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
+                       /* disable stepping while eval() in progress */
+                       PHPDBG_G(flags) |= PHPDBG_IN_EVAL;
+                       if (zend_eval_stringl(param->str, param->len,
+                               &retval, "eval()'d code" TSRMLS_CC) == SUCCESS) {
+                               zend_print_zval_r(
+                                       &retval, 0 TSRMLS_CC);
+                               phpdbg_writeln(EMPTY);
+                               zval_dtor(&retval);
+                       }
+                       PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;
 
-    /* switch stepping back on */
-       if (stepping &&
-               !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) {
-               PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
+                       /* switch stepping back on */
+                       if (stepping &&
+                               !(PHPDBG_G(flags) & PHPDBG_IS_STEPONEVAL)) {
+                               PHPDBG_G(flags) |= PHPDBG_IS_STEPPING;
+                       }
+               } break;
+               
+               phpdbg_default_switch_case();
        }
 
        return SUCCESS;
@@ -652,28 +644,12 @@ PHPDBG_COMMAND(shell) /* {{{ */
        switch (param->type) {
                case STR_PARAM: {
                        FILE *fd = NULL;
-                       char * program = NULL;
-
-                       /* we expect an input, I hope we get one ! */
-                       if (input && input->start) {
-                               program = (char*) input->start;
-
-                               if (memcmp(
-                                       program, "shell", sizeof("shell")-1) == SUCCESS) {
-                                       program += sizeof("shell")-1;
-                               } else program += sizeof("-")-1;
-
-                               while (program && isspace(*program)) {
-                                       program++;
-                               }
-                       } else program = param->str;
-
-                       if ((fd=VCWD_POPEN((char*)program, "w"))) {
+                       if ((fd=VCWD_POPEN((char*)param->str, "w"))) {
                                /* do something perhaps ?? do we want input ?? */
                                fclose(fd);
                        } else {
                                phpdbg_error(
-                                       "Failed to execute %s", program);
+                                       "Failed to execute %s", param->str);
                        }
                } break;