summaryrefslogtreecommitdiffstats
path: root/src/p_args_escape.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-05 18:40:28 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-05 18:40:28 +0200
commitc75434256658e3009a5c61d02524cb49492bd120 (patch)
tree67715ca37c63883b84050598970e98eeeb1e2c67 /src/p_args_escape.c
parentBetter defines (diff)
download42-minishell-c75434256658e3009a5c61d02524cb49492bd120.tar.gz
42-minishell-c75434256658e3009a5c61d02524cb49492bd120.tar.bz2
42-minishell-c75434256658e3009a5c61d02524cb49492bd120.tar.xz
42-minishell-c75434256658e3009a5c61d02524cb49492bd120.tar.zst
42-minishell-c75434256658e3009a5c61d02524cb49492bd120.zip
Clean af
Diffstat (limited to '')
-rw-r--r--src/p_args_escape.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/p_args_escape.c b/src/p_args_escape.c
index 182ef2f..2df2e0f 100644
--- a/src/p_args_escape.c
+++ b/src/p_args_escape.c
@@ -21,9 +21,16 @@ static t_quote_mode
{
if (mode == Q_NONE)
{
- (void)ft_memmove(word + (ptr - word), ptr + 1,
- (ft_strlen(ptr + 1) + 1) * sizeof(char));
- return (Q_SINGLE);
+ if (u_is_not_escaped(word, ptr) == TRUE)
+ {
+ (void)ft_memmove(word + (ptr - word), ptr + 1,
+ (ft_strlen(ptr + 1) + 1) * sizeof(char));
+ return (Q_SINGLE);
+ }
+ else
+ {
+ return (Q_NONE);
+ }
}
else if (mode == Q_SINGLE)
{
@@ -39,20 +46,21 @@ static t_quote_mode
{
if (mode == Q_NONE)
{
- if (u_is_true_quote(word, ptr) == TRUE)
+ if (u_is_not_escaped(word, ptr) == TRUE)
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ return (Q_DOUBLE);
}
- return (Q_DOUBLE);
- }
- else if (mode == Q_DOUBLE)
- {
- if (u_is_true_quote(word, ptr) == TRUE)
+ else
{
- (void)ft_memmove(word + (ptr - word), ptr + 1,
- (ft_strlen(ptr + 1) + 1) * sizeof(char));
+ return (Q_NONE);
}
+ }
+ else if (mode == Q_DOUBLE && u_is_not_escaped(word, ptr) == TRUE)
+ {
+ (void)ft_memmove(word + (ptr - word), ptr + 1,
+ (ft_strlen(ptr + 1) + 1) * sizeof(char));
return (Q_NONE);
}
return (mode);
@@ -118,8 +126,8 @@ void
{
/* TODO: escape \ */
/* TODO: escape $# special vars */
+ /* TODO: comments ################ */
/* TODO: escape my life */
- /* TODO: comments */
char **ptr;
ptr = words;