summaryrefslogtreecommitdiffstats
path: root/src/p_args.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/p_args.c43
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);
}