42_minishell/utils/ft_is_in_quote.c
2023-03-13 19:28:46 +01:00

46 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_is_in_quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:59:34 by cchauvet #+# #+# */
/* Updated: 2023/02/21 23:08:10 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "utils.h"
int ft_is_in_quote(const char *str, size_t n)
{
size_t i;
i = 0;
while (str[i] != '\0' && i < n)
{
if (str[i] == '\'')
{
i++;
while (str[i] != '\'' && str[i] != '\0')
{
if (i == n)
return (1);
i++;
}
}
if (str[i] == '"')
{
i++;
while (str[i] != '"' && str[i] != '\0')
{
if (i == n)
return (2);
i++;
}
}
i++;
}
return (0);
}