com php-src: argc/argv started: phpdbg_cmd.c phpdbg_cmd .h phpdbg_prompt.c
| From: | Bob Weinand | Date: | Tue, 19 Nov 2013 17:18:58 +0000 |
| Subject: | com php-src: argc/argv started: phpdbg_cmd.c phpdbg_cmd .h phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74799@lists.php.net to get a copy of this message | ||
Commit: 8ac46de2cfb5dee208451653022f6bf1dfac2864
Author: krakjoe <joe.watkins@live.co.uk> Tue, 19 Nov 2013 17:18:58 +0000
Parents: 71811f1f7f68d1e7331b06c95cec1f86da5cdfc2
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8ac46de2cfb5dee208451653022f6bf1dfac2864
Log:
argc/argv started
Changed paths:
M phpdbg_cmd.c
M phpdbg_cmd.h
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c
index e192c2b..b03aecc 100644
--- a/phpdbg_cmd.c
+++ b/phpdbg_cmd.c
@@ -118,6 +118,73 @@ void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
} /* }}} */
+static inline phpdbg_input_t** phpdbg_read_argv(char *buffer, int *count TSRMLS_DC) /* {{{ */
+{
+ char *p, *s;
+ enum states {
+ IN_BETWEEN,
+ IN_WORD,
+ IN_STRING
+ } state = IN_BETWEEN;
+ phpdbg_input_t **inputs;
+
+ (*count) = 0;
+ inputs = (phpdbg_input_t**) emalloc(
+ sizeof(phpdbg_input_t*) * 1);
+
+#define RESET_STATE() do {\
+ phpdbg_input_t *next = emalloc(sizeof(phpdbg_input_t));\
+ if (next) {\
+ next->string = estrndup(\
+ s, ((p-1) - s)+1);\
+ inputs[(*count)++] = next;\
+ }\
+ state = IN_BETWEEN;\
+} while(0);
+
+ for (p = buffer; *p != '\0'; p++) {
+ int c = (unsigned char) *p;
+ switch (state) {
+ case IN_BETWEEN:
+ if (isspace(c)) {
+ continue;
+ }
+ if (c == '"') {
+ state = IN_STRING;
+ s = p + 1;
+ continue;
+ }
+ state = IN_WORD;
+ s = p;
+ continue;
+
+ case IN_STRING:
+ if (c == '"') {
+ RESET_STATE();
+ }
+ continue;
+
+ case IN_WORD:
+ if (isspace(c)) {
+ RESET_STATE();
+ }
+ continue;
+ }
+ }
+
+ switch (state) {
+ case IN_WORD: {
+ RESET_STATE();
+ } break;
+
+ case IN_STRING:
+ phpdbg_error("Malformed command line !");
+ break;
+ }
+
+ return inputs;
+} /* }}} */
+
phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
{
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
@@ -169,6 +236,26 @@ phpdbg_input_t* phpdbg_read_input(TSRMLS_D) /* {{{ */
buffer->string[buffer->length] = '\0';
/* store constant pointer to start of buffer */
buffer->start = (char* const*) buffer->string;
+ {
+ /* temporary, when we switch to argv/argc handling
+ will be unnecessary */
+ char *store = (char*) estrdup(buffer->string);
+
+ buffer->argv = phpdbg_read_argv(
+ store, &buffer->argc TSRMLS_CC);
+
+ if (buffer->argc) {
+ int arg = 0;
+
+ while (arg < buffer->argc) {
+ phpdbg_debug(
+ "argv %d=%s", arg, buffer->argv[arg]->string);
+ arg++;
+ }
+ }
+
+ efree(store);
+ }
}
}
diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h
index 03fbd0a..a8865ce 100644
--- a/phpdbg_cmd.h
+++ b/phpdbg_cmd.h
@@ -40,11 +40,16 @@ typedef enum {
NUMERIC_PARAM
} phpdbg_param_type;
-typedef struct {
- char* const* start;
- char *string;
- size_t length;
-} phpdbg_input_t;
+typedef struct _phpdbg_input_t phpdbg_input_t;
+
+struct _phpdbg_input_t {
+ char* const* start;
+ char *string;
+ size_t length;
+
+ phpdbg_input_t **argv;
+ int argc;
+};
typedef struct _phpdbg_param {
phpdbg_param_type type;
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 9a12454..f84ced0 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -690,7 +690,7 @@ static PHPDBG_COMMAND(register) /* {{{ */
phpdbg_notice(
"Registered %s", lcname);
} else {
- phpdbg_error("Failed to find function %s", param->str);
+ phpdbg_error("The requested function (%s) could not be found", param->str);
}
} else {
phpdbg_error(