2023-02-21 08:35:08 -05:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* ft_is_in_quote.c :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2023/02/21 12:59:34 by cchauvet #+# #+# */
|
2023-02-21 17:12:16 -05:00
|
|
|
/* Updated: 2023/02/21 23:08:10 by cchauvet ### ########.fr */
|
2023-02-21 08:35:08 -05:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2023-02-01 11:28:38 -05:00
|
|
|
#include "utils.h"
|
|
|
|
|
2023-02-06 14:41:10 -05:00
|
|
|
int ft_is_in_quote(const char *str, size_t n)
|
2023-02-01 11:28:38 -05:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (str[i] != '\0' && i < n)
|
|
|
|
{
|
2023-03-13 14:28:46 -04:00
|
|
|
if (str[i] == '\'')
|
2023-02-01 11:28:38 -05:00
|
|
|
{
|
2023-03-13 14:28:46 -04:00
|
|
|
i++;
|
|
|
|
while (str[i] != '\'' && str[i] != '\0')
|
|
|
|
{
|
|
|
|
if (i == n)
|
|
|
|
return (1);
|
|
|
|
i++;
|
|
|
|
}
|
2023-02-01 11:28:38 -05:00
|
|
|
}
|
2023-03-13 14:28:46 -04:00
|
|
|
if (str[i] == '"')
|
2023-02-01 11:28:38 -05:00
|
|
|
{
|
2023-03-13 14:28:46 -04:00
|
|
|
i++;
|
|
|
|
while (str[i] != '"' && str[i] != '\0')
|
|
|
|
{
|
|
|
|
if (i == n)
|
|
|
|
return (2);
|
|
|
|
i++;
|
|
|
|
}
|
2023-02-01 11:28:38 -05:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2023-03-13 14:28:46 -04:00
|
|
|
return (0);
|
2023-02-01 11:28:38 -05:00
|
|
|
}
|