diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/p_args.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/p_args.c b/src/p_args.c index 6431cfc..d005947 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -53,15 +53,14 @@ static char *p_skip_whitespace(char *ptr) ** TODO: quotes parse error */ -static uint16_t p_count_args(const char word[], size_t start[]) +static uint16_t p_count_args(const char word[], + size_t start[], + uint16_t count, + t_quote_mode mode) { char *ptr; - t_quote_mode mode; - uint16_t count; ptr = (char *)word; - mode = Q_NONE; - count = 1; ptr = p_skip_whitespace(ptr); start[0] = (ptr - word); while (*ptr != C_NUL) @@ -77,8 +76,7 @@ static uint16_t p_count_args(const char word[], size_t start[]) { ptr = p_skip_whitespace(ptr); start[count] = (ptr - word); - if (*ptr != C_NUL) - count += 1; + count += (*ptr != C_NUL) ? (1) : (0); ptr -= 1; } ptr++; @@ -88,13 +86,13 @@ static uint16_t p_count_args(const char word[], size_t start[]) char **p_split_args(char word[]) { - char **words; size_t start[512]; + char **words; uint16_t argc; uint16_t to_del; words = NULL; - argc = p_count_args(word, start); + argc = p_count_args(word, start, 1, Q_NONE); if ((words = (char**)malloc((argc + 1) * sizeof(char*))) == NULL) return (NULL); words[argc] = NULL; |