fix: quote closed verif
This commit is contained in:
parent
3374d21cad
commit
41bbe2bc0b
@ -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 12:45:18 by cchauvet ### ########.fr */
|
/* Updated: 2023/03/30 15:42:13 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] == ' ')
|
while (str[i] == ' ' || str[i] == '\"' || str[i] == '\'')
|
||||||
i++;
|
i++;
|
||||||
return (str[i] == '\0');
|
return (str[i] == '\0');
|
||||||
}
|
}
|
||||||
|
@ -3,39 +3,38 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_is_in_quote.c :+: :+: :+: */
|
/* ft_is_in_quote.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/02/21 12:59:34 by cchauvet #+# #+# */
|
/* Created: 2023/03/30 15:39:25 by cchauvet #+# #+# */
|
||||||
/* Updated: 2023/03/27 15:32:44 by cchauvet ### ########.fr */
|
/* Updated: 2023/03/30 15:40:06 by cchauvet ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
int ft_is_in_quote(const char *str, size_t n)
|
int ft_is_in_quote(const char *str, size_t n)
|
||||||
{
|
{
|
||||||
ssize_t i;
|
size_t i;
|
||||||
|
ssize_t start;
|
||||||
|
|
||||||
i = -1;
|
start = -1;
|
||||||
while (str[++i] != '\0' && i < (ssize_t) n)
|
i = 0;
|
||||||
|
while (str[i] != '\0')
|
||||||
{
|
{
|
||||||
if (str[i] == '\'')
|
if (i == n)
|
||||||
|
break ;
|
||||||
|
if (str[i] == '\"' || str[i] == '\'')
|
||||||
{
|
{
|
||||||
i++;
|
if (start == -1)
|
||||||
while (str[i] != '\'' && str[i] != '\0')
|
start = i;
|
||||||
{
|
else if (str[i] == str[start])
|
||||||
if (i == (ssize_t) n)
|
start = -1;
|
||||||
return (1);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (str[i] == '"')
|
|
||||||
{
|
|
||||||
while (str[++i] != '"' && str[i] != '\0')
|
|
||||||
if (i == (ssize_t) n)
|
|
||||||
return (2);
|
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
return (0);
|
if (start == -1)
|
||||||
|
return ((str[i] == '\'') + (str[i] == '\"') * 2);
|
||||||
|
if (str[start] == '\'')
|
||||||
|
return (1);
|
||||||
|
return (2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user