From 4387723ef779135dfdaf36f1a3f451ca4c564877 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Sun, 13 Apr 2014 08:34:16 +0100 Subject: [PATCH] fix argc/argv --- phpdbg.c | 3 ++- phpdbg_prompt.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index 37a938f555..8903073151 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1120,12 +1120,13 @@ phpdbg_main: if (phpdbg->startup(phpdbg) == SUCCESS) { int i; + SG(request_info).argc = argc - php_optind + 1; SG(request_info).argv = emalloc(SG(request_info).argc * sizeof(char *)); for (i = SG(request_info).argc; --i;) { SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); } - SG(request_info).argv[php_optind - 1] = exec?exec:""; + SG(request_info).argv[i] = exec?exec:""; php_request_startup(TSRMLS_C); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 373260c1d1..85f22ca9b5 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -191,7 +191,9 @@ static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ * void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_init TSRMLS_DC) /* {{{ */ { struct stat sb; - + + printf("try %s\n", init_file); + if (init_file && VCWD_STAT(init_file, &sb) != -1) { FILE *fp = fopen(init_file, "r"); if (fp) { @@ -304,7 +306,7 @@ next_line: if (free_init) { free(init_file); } - } + } else printf("failed to open %s\n", init_file); } /* }}} */ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default TSRMLS_DC) /* {{{ */ @@ -648,7 +650,8 @@ PHPDBG_COMMAND(run) /* {{{ */ char **argv = emalloc(5 * sizeof(char *)); int argc = 0; int i; - char *argv_str = strtok(input->string, " "); + char *argv_str = NULL; + printf("param->str: %s\n", param->str); while (argv_str) { if (argc >= 4 && argc == (argc & -argc)) { argv = erealloc(argv, (argc * 2 + 1) * sizeof(char *)); -- 2.40.0