diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-03 19:09:05 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-03 19:09:05 +0200 |
commit | 757801bea2d236148e061324716425fc0e6aa686 (patch) | |
tree | ebe2d3a0fd391cb9147aa0bcc9987786c83dfb96 /src/p_args.c | |
parent | Better conditions, fuck the norm niggas (diff) | |
download | 42-minishell-757801bea2d236148e061324716425fc0e6aa686.tar.gz 42-minishell-757801bea2d236148e061324716425fc0e6aa686.tar.bz2 42-minishell-757801bea2d236148e061324716425fc0e6aa686.tar.xz 42-minishell-757801bea2d236148e061324716425fc0e6aa686.tar.zst 42-minishell-757801bea2d236148e061324716425fc0e6aa686.zip |
In progress
Diffstat (limited to 'src/p_args.c')
-rw-r--r-- | src/p_args.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/p_args.c b/src/p_args.c index 953fa17..a0da592 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -17,6 +17,7 @@ #include "d_define.h" #include "p_args.h" #include "p_args_next.h" +#include "p_args_quotes.h" /* ================= */ /* TODO: DELETE THIS */ @@ -63,6 +64,24 @@ static char } static uint16_t + p_skip_clean_arg(const char *head, + char **ptr, + uint16_t argc, + size_t start[]) +{ + while (*(*ptr) != C_NULL && ft_iswhitespace(*(*ptr)) == FALSE) + { + (*ptr)++; + if ((*(*ptr) == C_SQUOTE || *(*ptr) == C_DQUOTE) && *(*(ptr - 1)) != '\\') + { + (*ptr)++; + return (p_count_args(head, *ptr, argc, start)); + } + } + return (0); +} + +uint16_t p_count_args(const char *head, char *ptr, uint16_t argc, size_t start[]) { if (*ptr == C_NULL) @@ -72,15 +91,7 @@ static uint16_t start[argc] = ptr - head; if (*ptr != C_SQUOTE && *ptr != C_DQUOTE && *ptr != C_NULL) { - while (*ptr != C_NULL && ft_iswhitespace(*ptr) == FALSE) - { - ptr++; - if ((*ptr == C_SQUOTE || *ptr == C_DQUOTE) && *(ptr - 1) != '\\') - { - ptr++; - return (p_count_args(head, ptr, argc, start)); - } - } + p_skip_clean_arg(head, &ptr, argc, start); } else if (*ptr == C_SQUOTE || *ptr == C_DQUOTE) { @@ -96,19 +107,6 @@ static uint16_t /* TODO: quotes parse error */ } -static void - p_del_alloced_words(char *words[], uint16_t to_del) -{ - uint16_t i; - - i = 0; - while (i < to_del) - { - ft_memdel((void*)&words[i]); - i++; - } -} - static char **p_split_words_no_rdr(const char word[]) { @@ -129,6 +127,7 @@ static char p_del_alloced_words(words, to_del); return (NULL); } + p_args_quotes(words); return (words); } |