summaryrefslogtreecommitdiffstats
path: root/src/p_args_next.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-03 17:18:41 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-03 17:18:41 +0200
commit869498a720e3c54b206f346dea6bf9b7995a7778 (patch)
tree92f1baffbb318fd8d86a1e82942d0992530f9c87 /src/p_args_next.c
parenthow tf do i use tok (diff)
download42-minishell-869498a720e3c54b206f346dea6bf9b7995a7778.tar.gz
42-minishell-869498a720e3c54b206f346dea6bf9b7995a7778.tar.bz2
42-minishell-869498a720e3c54b206f346dea6bf9b7995a7778.tar.xz
42-minishell-869498a720e3c54b206f346dea6bf9b7995a7778.tar.zst
42-minishell-869498a720e3c54b206f346dea6bf9b7995a7778.zip
Genius in progress
Diffstat (limited to 'src/p_args_next.c')
-rw-r--r--src/p_args_next.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/p_args_next.c b/src/p_args_next.c
index d371ba0..5967963 100644
--- a/src/p_args_next.c
+++ b/src/p_args_next.c
@@ -13,24 +13,48 @@
#include <libft.h>
#include <stdint.h>
-static char
- p_give_me_an_arg(const char word[])
+#include "p_args.h"
+
+static size_t
+ p_arg_len(const char word[], const size_t start)
{
- char str[4096];
+ size_t end;
- str[0] = '\0';
- return (str);
+ (void)word;
+ end = start;
+ return (end);
+}
+
+static char
+ *p_give_me_an_arg(char tmp[],
+ const char word[],
+ const uint16_t i,
+ const size_t start[])
+{
+ tmp[0] = '\0';
+ ft_strlcpy(tmp,
+ word + start[i],
+ (p_arg_len(word, start[i]) - start[i]) + 1);
+ /* TODO: remove quotes */
+ return (tmp);
}
uint16_t
- p_dup_words(char *words[], const char word[], uint16_t i)
+ p_dup_words(char *words[],
+ const char word[],
+ const uint16_t argc,
+ const size_t start[])
{
- while (i > 0)
+ char tmp[4096];
+ uint16_t i;
+
+ i = 0;
+ while (i < argc)
{
- if ((words[i] = ft_strdup(p_give_me_an_arg(word))) == NULL)
+ if ((words[i] = ft_strdup(p_give_me_an_arg(tmp, word, i, start))) == NULL)
return (i);
- i--;
+ i++;
}
- return (0);
+ return (i);
}