com php-src: restore sanity to commands/handlers/the universe: phpdbg_break.c phpdbg_cmd.c phpdbg_cmd.h phpd bg_prompt.c

From: Date: Wed, 20 Nov 2013 21:47:44 +0000
Subject: com php-src: restore sanity to commands/handlers/the universe: phpdbg_break.c phpdbg_cmd.c phpdbg_cmd.h phpd bg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74738@lists.php.net to get a copy of this message
Commit: 5ec586ce94f4f87c976ee83866f18098f0289f91 Author: krakjoe <joe.watkins@live.co.uk> Wed, 20 Nov 2013 21:47:44 +0000 Parents: 75e2e7ddf5524e74215c6add92a076b622e3ccb9 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5ec586ce94f4f87c976ee83866f18098f0289f91 Log: restore sanity to commands/handlers/the universe Changed paths: M phpdbg_break.c M phpdbg_cmd.c M phpdbg_cmd.h M phpdbg_prompt.c Diff: diff --git a/phpdbg_break.c b/phpdbg_break.c index b0345a0..d4bf62f 100644 --- a/phpdbg_break.c +++ b/phpdbg_break.c @@ -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); diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index f26fbbc..4aefde3 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -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); } diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h index 259078a..e9c52a7 100644 --- a/phpdbg_cmd.h +++ b/phpdbg_cmd.h @@ -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 diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index f15c802..b06cb05 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -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;

« previous php.cvs (#74738) next »