diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-03 16:09:12 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-03 16:09:12 +0200 |
commit | f3f724dd7f434f2731f63d03a925b0e24983b484 (patch) | |
tree | 59d4d65e4adfe9608680d2480935c4ba936c57c8 /src/p_args.c | |
parent | Shit in progress (diff) | |
download | 42-minishell-f3f724dd7f434f2731f63d03a925b0e24983b484.tar.gz 42-minishell-f3f724dd7f434f2731f63d03a925b0e24983b484.tar.bz2 42-minishell-f3f724dd7f434f2731f63d03a925b0e24983b484.tar.xz 42-minishell-f3f724dd7f434f2731f63d03a925b0e24983b484.tar.zst 42-minishell-f3f724dd7f434f2731f63d03a925b0e24983b484.zip |
how tf do i use tok
Diffstat (limited to 'src/p_args.c')
-rw-r--r-- | src/p_args.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/p_args.c b/src/p_args.c index f14b467..6a15cb8 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -15,6 +15,7 @@ #include <stdlib.h> #include "d_define.h" +#include "p_args_next.h" /* ================= */ /* TODO: DELETE THIS */ @@ -86,6 +87,17 @@ static uint16_t else if (*ptr == C_NULL) return (argc); return (p_count_args(ptr, argc + 1)); + /* TODO: quotes parse error */ +} + +static void + p_del_alloced_words(char *words[], uint16_t to_del, uint16_t i) +{ + while (i > to_del) + { + ft_memdel((void*)&words[i]); + i--; + } } static char @@ -94,6 +106,7 @@ static char char **words; char *ptr; uint16_t argc; + uint16_t to_del; ptr = (char*)word; argc = p_count_args(ptr, 0); @@ -102,14 +115,18 @@ static char if ((words = (char**)malloc((argc + 1) * sizeof(char*))) == NULL) return (NULL); words[argc] = NULL; + if ((to_del = p_dup_words(words, word, argc)) != 0) + { + p_del_alloced_words(words, to_del, argc); + return (NULL); + } return (words); } - char **p_split_args(const char word[], int8_t redir) { - char **words; + char **words; words = NULL; ft_printf("word at start: [%s]\n", word); |