fix: 'echo '> >> < * ? [ ] | ; [ ] || && ( ) & # $ <<'' stop segfault now

This commit is contained in:
Camille Chauvet 2023-03-30 16:06:34 +02:00
parent 41bbe2bc0b
commit f66ab7790e
4 changed files with 7 additions and 7 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/03/29 16:53:15 by cchauvet ### ########.fr */ /* Updated: 2023/03/30 16:01:56 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -66,7 +66,7 @@ static char *ft_spacer_before(const char *str)
i = -1; i = -1;
while (out[++i] != '\0') while (out[++i] != '\0')
{ {
while (ft_is_in_quote(out, i)) while (ft_is_in_quote(out, i + 1))
i++; i++;
if (out[i] == '\0') if (out[i] == '\0')
break ; break ;

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 13:00:05 by cchauvet #+# #+# */ /* Created: 2023/02/21 13:00:05 by cchauvet #+# #+# */
/* Updated: 2023/03/30 15:42:13 by cchauvet ### ########.fr */ /* Updated: 2023/03/30 15:58:39 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -86,7 +86,7 @@ static int ft_empty_verif(const char *str)
size_t i; size_t i;
i = 0; i = 0;
while (str[i] == ' ' || str[i] == '\"' || str[i] == '\'') while (str[i] == ' ')
i++; i++;
return (str[i] == '\0'); return (str[i] == '\0');
} }

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/30 15:39:25 by cchauvet #+# #+# */ /* Created: 2023/03/30 15:39:25 by cchauvet #+# #+# */
/* Updated: 2023/03/30 15:40:06 by cchauvet ### ########.fr */ /* Updated: 2023/03/30 15:52:10 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -33,7 +33,7 @@ int ft_is_in_quote(const char *str, size_t n)
i++; i++;
} }
if (start == -1) if (start == -1)
return ((str[i] == '\'') + (str[i] == '\"') * 2); return (0);
if (str[start] == '\'') if (str[start] == '\'')
return (1); return (1);
return (2); return (2);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 14:46:40 by cchauvet #+# #+# */ /* Created: 2023/02/14 14:46:40 by cchauvet #+# #+# */
/* Updated: 2023/03/29 18:52:32 by cchauvet ### ########.fr */ /* Updated: 2023/03/30 15:38:56 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */