Skip to content

Commit dd71744

Browse files
committed
Merge branch 'master' of https://github.com/krakjoe/phpdbg
2 parents 6417e47 + 3e6f942 commit dd71744

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

phpdbg_cmd.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -250,29 +250,23 @@ phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
250250

251251
buffer->string = phpdbg_trim(cmd, strlen(cmd), &buffer->length);
252252

253-
if (buffer->string) {
254-
/* temporary, when we switch to argv/argc handling
255-
will be unnecessary */
256-
char *store = (char*) estrdup(buffer->string);
253+
/* store constant pointer to start of buffer */
254+
buffer->start = (char* const*) buffer->string;
257255

258-
/* store constant pointer to start of buffer */
259-
buffer->start = (char* const*) buffer->string;
256+
buffer->argv = phpdbg_read_argv(
257+
buffer->string, &buffer->argc TSRMLS_CC);
260258

261-
buffer->argv = phpdbg_read_argv(
262-
store, &buffer->argc TSRMLS_CC);
259+
#ifdef PHPDBG_DEBUG
260+
if (buffer->argc) {
261+
int arg = 0;
263262

264-
if (buffer->argc) {
265-
int arg = 0;
266-
267-
while (arg < buffer->argc) {
268-
phpdbg_debug(
269-
"argv %d=%s", arg, buffer->argv[arg]->string);
270-
arg++;
271-
}
263+
while (arg < buffer->argc) {
264+
phpdbg_debug(
265+
"argv %d=%s", arg, buffer->argv[arg]->string);
266+
arg++;
272267
}
273-
274-
efree(store);
275268
}
269+
#endif
276270

277271
#ifdef HAVE_LIBREADLINE
278272
if (!buffered && cmd) {
@@ -320,9 +314,9 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
320314
(command->alias &&
321315
(input->argv[0]->length == 1) &&
322316
(command->alias == *input->argv[0]->string))) {
323-
317+
324318
phpdbg_param_t param;
325-
319+
326320
param.type = EMPTY_PARAM;
327321

328322
if (input->argc > 1) {
@@ -333,9 +327,8 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
333327
sub.argv = &input->argv[1];
334328

335329
phpdbg_debug(
336-
"trying sub commands in \"%s\" for \"%s\" with %d arguments",
330+
"trying sub commands in \"%s\" for \"%s\" with %d arguments",
337331
command->name, sub.argv[0]->string, sub.argc-1);
338-
339332
return phpdbg_do_cmd(command->subs, &sub TSRMLS_CC);
340333
} else {
341334
phpdbg_parse_param(
@@ -344,7 +337,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
344337
&param TSRMLS_CC);
345338
}
346339
}
347-
340+
348341
phpdbg_debug(
349342
"found command %s for %s with %d arguments",
350343
command->name, input->argv[0]->string, input->argc-1);
@@ -358,12 +351,12 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
358351
input->argv[arg]->length);
359352
}
360353
}
361-
354+
362355
PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
363356
phpdbg_clear_param(
364357
&PHPDBG_G(lparam) TSRMLS_CC);
365358
PHPDBG_G(lparam) = param;
366-
359+
367360
rc = command->handler(&param TSRMLS_CC);
368361
break;
369362
}

phpdbg_cmd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct _phpdbg_input_t {
4646
char* const* start;
4747
char *string;
4848
size_t length;
49-
49+
5050
phpdbg_input_t **argv;
5151
int argc;
5252
};
@@ -93,6 +93,7 @@ int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
9393
phpdbg_param_type phpdbg_parse_param(const char*, size_t, phpdbg_param_t* TSRMLS_DC);
9494
void phpdbg_clear_param(phpdbg_param_t* TSRMLS_DC);
9595
const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC);
96+
void phpdbg_destroy_input(phpdbg_input_t** TSRMLS_DC);
9697

9798
/**
9899
* Command Declarators

0 commit comments

Comments
 (0)