From 1c046c02b8001f114fc14997f3b14492da74b219 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Wed, 20 Nov 2013 22:03:36 +0000 Subject: [PATCH] tidy --- phpdbg_cmd.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 4aefde34c5..b324079f27 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -321,25 +321,21 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_ if (input->argc > 1) { if (command->subs) { - phpdbg_input_t sub; - - sub.length = input->length; - sub.string = input->string; - sub.start = input->start; + phpdbg_input_t sub = *input; 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); + + sub.string = phpdbg_trim( + sub.string, sub.length, &sub.length); + + sub.argc--; + sub.argv++; 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; @@ -351,11 +347,10 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_ 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); + + input->string = phpdbg_trim( + input->string, input->length, &input->length); + efree(store); } -- 2.40.0