fix: quote infinit loop

This commit is contained in:
Camille Chauvet 2023-02-16 13:53:49 +01:00
parent 8366b63821
commit 22b7a4feea
3 changed files with 11 additions and 14 deletions

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 13:35:50 by cchauvet #+# #+# */ /* Created: 2023/02/15 13:35:50 by cchauvet #+# #+# */
/* Updated: 2023/02/15 20:00:42 by cchauvet ### ########.fr */ /* Updated: 2023/02/16 13:17:24 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,8 +25,8 @@ static char *ft_spacer_after(const char *str)
i = 1; i = 1;
while (out[i] != '\0') while (out[i] != '\0')
{ {
if (ft_is_in_quote(out, i)) while (ft_is_in_quote(out, i))
continue ; i++;
if (ft_is_in("><|", out[i - 1])) if (ft_is_in("><|", out[i - 1]))
{ {
while (str[i] == out[i - 1]) while (str[i] == out[i - 1])
@ -54,8 +54,8 @@ static char *ft_spacer_before(const char *str)
i = 0; i = 0;
while (out[i + 1] != '\0') while (out[i + 1] != '\0')
{ {
if (ft_is_in_quote(out, i)) while (ft_is_in_quote(out, i))
continue ; i++;
if (ft_is_in("><|", out[i + 1])) if (ft_is_in("><|", out[i + 1]))
{ {
while (out[i] == ' ') while (out[i] == ' ')
@ -81,14 +81,11 @@ static void ft_space_simplifier(char *str)
i = 0; i = 0;
while (str[i] != '\0') while (str[i] != '\0')
{ {
if (ft_is_in_quote(str, i))
i++;
y = 0; y = 0;
while (str[y + i] == ' ') while (str[y + i] == ' ')
y++; y++;
if (ft_is_in_quote(str, i + y))
{
i = i + y;
continue ;
}
if (y > 1) if (y > 1)
{ {
ft_strshift(str + i, -y + 1); ft_strshift(str + i, -y + 1);

View File

@ -47,8 +47,8 @@ static int ft_special_char_dub(const char *str)
i = 0; i = 0;
while (str[i] != '\0') while (str[i] != '\0')
{ {
if (ft_is_in_quote(str, i)) while (ft_is_in_quote(str, i))
continue ; i++;
if (ft_is_in("|<>", str[i])) if (ft_is_in("|<>", str[i]))
{ {
y = 0; y = 0;

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/15 14:12:00 by cchauvet #+# #+# */ /* Created: 2023/02/15 14:12:00 by cchauvet #+# #+# */
/* Updated: 2023/02/15 17:59:50 by cchauvet ### ########.fr */ /* Updated: 2023/02/16 13:20:50 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -37,7 +37,7 @@ char *ft_quote_remover(char *str)
if (start != -1) if (start != -1)
{ {
ft_strshift(str, -1); ft_strshift(str, -1);
str[stop] = '\0'; ft_strshift(str + stop - 1, -1);
} }
return (str); return (str);
} }