summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/p_args_escape.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/p_args_escape.c b/src/p_args_escape.c
index 2df2e0f..8a2e27f 100644
--- a/src/p_args_escape.c
+++ b/src/p_args_escape.c
@@ -17,7 +17,7 @@
#include "u_utils.h"
static t_quote_mode
- p_escape_squote(char *ptr, char word[], t_quote_mode mode)
+ p_escape_squote(char *ptr, char **p, char word[], t_quote_mode mode)
{
if (mode == Q_NONE)
{
@@ -25,6 +25,7 @@ static t_quote_mode
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ *(p) -= 1;
return (Q_SINGLE);
}
else
@@ -36,13 +37,14 @@ static t_quote_mode
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ *(p) -= 1;
return (Q_NONE);
}
return (mode);
}
static t_quote_mode
- p_escape_dquote(char *ptr, char word[], t_quote_mode mode)
+ p_escape_dquote(char *ptr, char **p, char word[], t_quote_mode mode)
{
if (mode == Q_NONE)
{
@@ -50,6 +52,7 @@ static t_quote_mode
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ *(p) -= 1;
return (Q_DOUBLE);
}
else
@@ -61,18 +64,24 @@ static t_quote_mode
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ *(p) -= 1;
return (Q_NONE);
}
return (mode);
}
static void
- p_escape_bs(char *ptr, char word[], t_quote_mode mode)
+ p_escape_bs(char *ptr, char **p, char word[], t_quote_mode mode)
{
if (mode == Q_NONE)
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ if (*ptr == C_BS)
+ {
+ *(word + (ptr - word)) = 26;
+ }
+ *(p) -= 1;
}
else if (mode == Q_DOUBLE)
{
@@ -81,11 +90,13 @@ static void
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
*(word + (ptr - word)) = 26;
+ *(p) -= 1;
}
else if (*(ptr + 1) == C_DQUOTE)
{
(void)ft_memmove(word + (ptr - word), ptr + 1,
(ft_strlen(ptr + 1) + 1) * sizeof(char));
+ *(p) -= 1;
}
}
}
@@ -101,11 +112,11 @@ static void
while (*ptr != C_NULL)
{
if (*ptr == C_SQUOTE)
- mode = p_escape_squote(ptr, word, mode);
+ mode = p_escape_squote(ptr, &ptr, word, mode);
else if (*ptr == C_DQUOTE)
- mode = p_escape_dquote(ptr, word, mode);
+ mode = p_escape_dquote(ptr, &ptr, word, mode);
if (*ptr == C_BS)
- p_escape_bs(ptr, word, mode);
+ p_escape_bs(ptr, &ptr, word, mode);
ptr++;
}
}