summaryrefslogtreecommitdiffstats
path: root/src/p_args_next.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-04 22:02:44 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-04 22:02:44 +0200
commit0e9cfacaf15bb0f4d8a7bd72bae56010d263b2c1 (patch)
tree129b3fbce4992e902e87358becf59e9be4be2851 /src/p_args_next.c
parentNext time (diff)
download42-minishell-0e9cfacaf15bb0f4d8a7bd72bae56010d263b2c1.tar.gz
42-minishell-0e9cfacaf15bb0f4d8a7bd72bae56010d263b2c1.tar.bz2
42-minishell-0e9cfacaf15bb0f4d8a7bd72bae56010d263b2c1.tar.xz
42-minishell-0e9cfacaf15bb0f4d8a7bd72bae56010d263b2c1.tar.zst
42-minishell-0e9cfacaf15bb0f4d8a7bd72bae56010d263b2c1.zip
Time to escape chars
Diffstat (limited to 'src/p_args_next.c')
-rw-r--r--src/p_args_next.c59
1 files changed, 4 insertions, 55 deletions
diff --git a/src/p_args_next.c b/src/p_args_next.c
index 10ca37f..77f8ced 100644
--- a/src/p_args_next.c
+++ b/src/p_args_next.c
@@ -15,60 +15,7 @@
#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 && 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;
-
- 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)
- {
- while (word[end] != C_NULL && ft_iswhitespace(word[end]) == FALSE)
- {
- if (word[end] == C_SQUOTE || word[end] == C_DQUOTE)
- end = p_skip_delim_size(word, word[end], end);
- else
- {
- while (word[end] != C_NULL &&
- ft_iswhitespace(word[end]) == FALSE)
- end++;
- }
- }
- }
- return (end);
-}
+#include "p_args_len.h"
static char
*p_give_me_an_arg(char tmp[],
@@ -108,7 +55,9 @@ uint16_t
i = 0;
while (i < argc)
{
- if ((words[i] = ft_strdup(p_give_me_an_arg(tmp, word, i, start))) == NULL)
+ if ((words[i] = ft_strdup(
+ p_give_me_an_arg(tmp, word, i, start)
+ )) == NULL)
return (i);
i++;
}