diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-03 18:37:45 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-03 18:37:45 +0200 |
commit | 93fd5f480c4fb841945611ed13ca3fa81b376dff (patch) | |
tree | 329a90d5b4fb34ea1d3669277763b33e46c26552 /src/p_args_next.c | |
parent | Genius in progress (diff) | |
download | 42-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 '')
-rw-r--r-- | src/p_args_next.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/p_args_next.c b/src/p_args_next.c index 5967963..28410cd 100644 --- a/src/p_args_next.c +++ b/src/p_args_next.c @@ -13,15 +13,51 @@ #include <libft.h> #include <stdint.h> +#include "d_define.h" #include "p_args.h" static size_t + p_skip_delim_size(const char word[], char c, size_t end) +{ + end++; + if (word[end] == c) + return (end + 1); + while (word[end] != C_NULL && word[end] != c) + { + end++; + if (word[end] == c && c == C_DQUOTE) + { + if (word[end - 1] == C_BACKSLASH) + { + if (word[end - 2] != C_BACKSLASH) + end++; + } + } + } + if (word[end] != C_NULL) + { + end++; + } + return (end); +} + +static size_t p_arg_len(const char word[], const size_t start) { size_t end; - (void)word; end = start; + if (word[start] != C_SQUOTE && + word[start] != C_DQUOTE && + word[start] != C_NULL) + { + while (word[end] != C_NULL && ft_iswhitespace(word[end]) == FALSE) + end++; + } + else if (word[end] == C_SQUOTE || word[end] == C_DQUOTE) + { + end = p_skip_delim_size(word, word[end], end); + } return (end); } |