summaryrefslogtreecommitdiffstats
path: root/src/p_args.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-03 18:37:45 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-03 18:37:45 +0200
commit93fd5f480c4fb841945611ed13ca3fa81b376dff (patch)
tree329a90d5b4fb34ea1d3669277763b33e46c26552 /src/p_args.c
parentGenius in progress (diff)
download42-minishell-93fd5f480c4fb841945611ed13ca3fa81b376dff.tar.gz
42-minishell-93fd5f480c4fb841945611ed13ca3fa81b376dff.tar.bz2
42-minishell-93fd5f480c4fb841945611ed13ca3fa81b376dff.tar.xz
42-minishell-93fd5f480c4fb841945611ed13ca3fa81b376dff.tar.zst
42-minishell-93fd5f480c4fb841945611ed13ca3fa81b376dff.zip
Better conditions, fuck the norm niggas
Diffstat (limited to 'src/p_args.c')
-rw-r--r--src/p_args.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/p_args.c b/src/p_args.c
index 572b965..953fa17 100644
--- a/src/p_args.c
+++ b/src/p_args.c
@@ -43,6 +43,8 @@ static char
*p_skip_delim(char *ptr, char c)
{
ptr++;
+ if (*ptr == c)
+ return (++ptr);
while (*ptr != C_NULL && *ptr != c)
{
ptr++;
@@ -83,7 +85,9 @@ static uint16_t
else if (*ptr == C_SQUOTE || *ptr == C_DQUOTE)
{
ptr = p_skip_delim(ptr, *ptr);
- if (ft_iswhitespace(*ptr) == FALSE)
+ if (*ptr == C_NULL)
+ return (argc += 1);
+ else if (ft_iswhitespace(*ptr) == FALSE)
return (p_count_args(head, ptr, argc, start));
}
else if (*ptr == C_NULL)
@@ -116,6 +120,7 @@ static char
ptr = (char*)word;
argc = p_count_args(word, ptr, 0, start);
+ ft_printf("%hu\n", argc);
if ((words = (char**)malloc((argc + 1) * sizeof(char*))) == NULL)
return (NULL);
words[argc] = NULL;