diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-01 19:19:01 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-01 19:19:01 +0200 |
commit | 834e84e40b9a5e489ddcb1aef43f231ccdb3dfc2 (patch) | |
tree | 89ed9f0e836b7ee1d037c8e6c849aa06d515369e /src | |
parent | Better, removed debug printf (diff) | |
download | 42-minishell-834e84e40b9a5e489ddcb1aef43f231ccdb3dfc2.tar.gz 42-minishell-834e84e40b9a5e489ddcb1aef43f231ccdb3dfc2.tar.bz2 42-minishell-834e84e40b9a5e489ddcb1aef43f231ccdb3dfc2.tar.xz 42-minishell-834e84e40b9a5e489ddcb1aef43f231ccdb3dfc2.tar.zst 42-minishell-834e84e40b9a5e489ddcb1aef43f231ccdb3dfc2.zip |
Fine
Diffstat (limited to '')
-rw-r--r-- | src/m_loop_next.c | 5 | ||||
-rw-r--r-- | src/p_args.c | 25 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/m_loop_next.c b/src/m_loop_next.c index d6c085e..1163a49 100644 --- a/src/m_loop_next.c +++ b/src/m_loop_next.c @@ -153,10 +153,7 @@ static void { if (*ptr == C_SQUOTE) { - if (*(ptr - 1) != C_BACKSLASH) - q[0] += 1; - else if (*(ptr - 2) == C_BACKSLASH) - q[0] += 1; + q[0] += 1; } else if (*ptr == C_DQUOTE) { diff --git a/src/p_args.c b/src/p_args.c index 1cab59d..d42dabe 100644 --- a/src/p_args.c +++ b/src/p_args.c @@ -37,18 +37,25 @@ p_print(char *words[]) /* TODO: DELETE ABOVE */ /* ================== */ -static void - p_skip_delim(char *ptr, char c) +static char + *p_skip_delim(char *ptr, char c) { ptr++; while (*ptr != C_NULL && *ptr != c) { ptr++; - if (*ptr == c && *(ptr - 1) == C_BACKSLASH) - ptr++; + if (*ptr == c && c == C_DQUOTE) + { + if (*(ptr - 1) == C_BACKSLASH) + { + if (*(ptr - 2) != C_BACKSLASH) + ptr++; + } + } } if (*ptr != C_NULL) ptr++; + return (ptr); } static uint16_t @@ -71,13 +78,11 @@ static uint16_t } } } - else if (*ptr == C_SQUOTE) - { - p_skip_delim(ptr, C_SQUOTE); - } - else if (*ptr == C_DQUOTE) + else if (*ptr == C_SQUOTE || *ptr == C_DQUOTE) { - p_skip_delim(ptr, C_DQUOTE); + ptr = p_skip_delim(ptr, *ptr); + if (ft_isspace(*ptr) == FALSE) + return (p_count_args(ptr, argc)); } return (p_count_args(ptr, argc + 1)); } |