diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-05 19:05:22 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-05 19:05:22 +0200 |
commit | f359ecc021b8ec5360cfd9e7806d445f69a3fb63 (patch) | |
tree | 718d2c1fad62a06cebdb8dbf4fc300b4c9696c28 /src | |
parent | Clean af (diff) | |
download | 42-minishell-f359ecc021b8ec5360cfd9e7806d445f69a3fb63.tar.gz 42-minishell-f359ecc021b8ec5360cfd9e7806d445f69a3fb63.tar.bz2 42-minishell-f359ecc021b8ec5360cfd9e7806d445f69a3fb63.tar.xz 42-minishell-f359ecc021b8ec5360cfd9e7806d445f69a3fb63.tar.zst 42-minishell-f359ecc021b8ec5360cfd9e7806d445f69a3fb63.zip |
In progress boyyy
Diffstat (limited to 'src')
-rw-r--r-- | src/p_args.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/p_args.c b/src/p_args.c index f3e7403..ee2b937 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -93,6 +93,14 @@ static t_bool return (FALSE); } +static char + *p_skip_whitespace(char *ptr) +{ + while (*ptr != C_NULL && ft_iswhitespace(*ptr)) + ptr++; + return (ptr); +} + static uint16_t p_count_args(const char word[], size_t start[]) { @@ -100,10 +108,11 @@ static uint16_t t_quote_mode mode; uint16_t count; - (void)start; ptr = (char *)word; mode = Q_NONE; - count = 0; + count = 1; + ptr = p_skip_whitespace(ptr); + start[0] = (ptr - word); while (*ptr != C_NULL) { if (*ptr == C_DQUOTE) @@ -114,10 +123,9 @@ static uint16_t p_meet_whitespace((char*)word, ptr, mode) == TRUE) { count += 1; - while (*ptr != C_NULL && ft_iswhitespace(*ptr)) - ptr++; + ptr = p_skip_whitespace(ptr); + start[count - 1] = (ptr - word); ptr -= 1; - ft_printf("[%s]\n", ptr); } ptr++; } @@ -135,7 +143,6 @@ static char argc = p_count_args(word, start); ft_printf("argc: %hu\n", argc); - exit(0); if ((words = (char**)malloc((argc + 1) * sizeof(char*))) == NULL) return (NULL); words[argc] = NULL; |