summaryrefslogtreecommitdiffstats
path: root/src/m_loop_next.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/m_loop_next.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/m_loop_next.c b/src/m_loop_next.c
index 22eadba..d6c085e 100644
--- a/src/m_loop_next.c
+++ b/src/m_loop_next.c
@@ -80,7 +80,6 @@ static char
ft_strlen(counter_line) + 1);
}
ft_memdel((void*)&counter_line);
- ft_printf("[%s]\n", line);
return (line);
}
@@ -142,23 +141,40 @@ char
return (line);
}
-char
- *m_check_multi_quotes(int32_t fd, char line[], t_msh *msh)
+static void
+ m_set_q_arr(size_t q[], char line[])
{
char *ptr;
- size_t q[2];
q[0] = 0;
q[1] = 0;
ptr = line;
while (*ptr != C_NULL)
{
- if (*ptr == C_SQUOTE && *(ptr - 1) != C_BACKSLASH)
- q[0] += 1;
- else if (*ptr == C_DQUOTE && *(ptr - 1) != C_BACKSLASH)
- q[1] += 1;
+ if (*ptr == C_SQUOTE)
+ {
+ if (*(ptr - 1) != C_BACKSLASH)
+ q[0] += 1;
+ else if (*(ptr - 2) == C_BACKSLASH)
+ q[0] += 1;
+ }
+ else if (*ptr == C_DQUOTE)
+ {
+ if (*(ptr - 1) != C_BACKSLASH)
+ q[1] += 1;
+ else if (*(ptr - 2) == C_BACKSLASH)
+ q[1] += 1;
+ }
ptr++;
}
+}
+
+char
+ *m_check_multi_quotes(int32_t fd, char line[], t_msh *msh)
+{
+ size_t q[2];
+
+ m_set_q_arr(q, line);
if (q[0] % 2 == 1 || q[1] % 2 == 1)
{
line = m_counter_line_quotes(fd, 2, line, msh);