From 93ec22714f7021e874e5418d1f5743ccdd258cdc Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 1 Sep 2020 18:39:30 +0200 Subject: Better, removed debug printf --- src/m_loop_next.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/m_loop_next.c') 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); -- cgit v1.2.3