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-03-28 09:55:08 -04:00
|
|
|
/* Updated: 2023/03/27 15:32:44 by cchauvet ### ########.fr */
|
2023-02-21 08:35:08 -05:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2023-02-01 11:28:38 -05:00
|
|
|
#include "utils.h"
|
2023-03-28 09:55:08 -04:00
|
|
|
#include <sys/types.h>
|
2023-02-01 11:28:38 -05:00
|
|
|
|
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
|
|
|
{
|
2023-03-28 09:55:08 -04:00
|
|
|
ssize_t i;
|
2023-02-01 11:28:38 -05:00
|
|
|
|
2023-03-28 09:55:08 -04:00
|
|
|
i = -1;
|
|
|
|
while (str[++i] != '\0' && i < (ssize_t) n)
|
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')
|
|
|
|
{
|
2023-03-28 09:55:08 -04:00
|
|
|
if (i == (ssize_t) n)
|
2023-03-13 14:28:46 -04:00
|
|
|
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-28 09:55:08 -04:00
|
|
|
while (str[++i] != '"' && str[i] != '\0')
|
|
|
|
if (i == (ssize_t) n)
|
2023-03-13 14:28:46 -04:00
|
|
|
return (2);
|
2023-02-01 11:28:38 -05:00
|
|
|
}
|
|
|
|
}
|
2023-03-13 14:28:46 -04:00
|
|
|
return (0);
|
2023-02-01 11:28:38 -05:00
|
|
|
}
|