From 22b7a4feea79509c999a0672721f8ece6389c86f Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 16 Feb 2023 13:53:49 +0100 Subject: [PATCH] fix: quote infinit loop --- spacer.c | 17 +++++++---------- syntatics.c | 4 ++-- utils/ft_quote_remover.c | 4 ++-- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/spacer.c b/spacer.c index 98cd434..62a41e0 100644 --- a/spacer.c +++ b/spacer.c @@ -6,7 +6,7 @@ /* By: cchauvet <|", out[i - 1])) { while (str[i] == out[i - 1]) @@ -54,8 +54,8 @@ static char *ft_spacer_before(const char *str) i = 0; while (out[i + 1] != '\0') { - if (ft_is_in_quote(out, i)) - continue ; + while (ft_is_in_quote(out, i)) + i++; if (ft_is_in("><|", out[i + 1])) { while (out[i] == ' ') @@ -81,14 +81,11 @@ static void ft_space_simplifier(char *str) i = 0; while (str[i] != '\0') { + if (ft_is_in_quote(str, i)) + i++; y = 0; while (str[y + i] == ' ') y++; - if (ft_is_in_quote(str, i + y)) - { - i = i + y; - continue ; - } if (y > 1) { ft_strshift(str + i, -y + 1); diff --git a/syntatics.c b/syntatics.c index 12e5939..60762d8 100644 --- a/syntatics.c +++ b/syntatics.c @@ -47,8 +47,8 @@ static int ft_special_char_dub(const char *str) i = 0; while (str[i] != '\0') { - if (ft_is_in_quote(str, i)) - continue ; + while (ft_is_in_quote(str, i)) + i++; if (ft_is_in("|<>", str[i])) { y = 0; diff --git a/utils/ft_quote_remover.c b/utils/ft_quote_remover.c index 923c976..3fedb64 100644 --- a/utils/ft_quote_remover.c +++ b/utils/ft_quote_remover.c @@ -6,7 +6,7 @@ /* By: cchauvet