2023-02-01 11:28:38 -05:00
|
|
|
#include "utils.h"
|
|
|
|
|
2023-02-14 01:26:18 -05:00
|
|
|
int ft_is_in_quote(const char *str, size_t n)
|
2023-02-01 11:28:38 -05:00
|
|
|
{
|
|
|
|
size_t double_quoted;
|
|
|
|
size_t simple_quoted;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
double_quoted = 0;
|
|
|
|
simple_quoted = 0;
|
|
|
|
i = 0;
|
|
|
|
while (str[i] != '\0' && i < n)
|
|
|
|
{
|
|
|
|
if (str[i] == '"')
|
|
|
|
{
|
|
|
|
if (simple_quoted == 0)
|
|
|
|
double_quoted = !double_quoted;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (str[i] == '\'')
|
|
|
|
{
|
|
|
|
if (double_quoted == 0)
|
|
|
|
simple_quoted = !simple_quoted;
|
|
|
|
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return (simple_quoted == 1 + (double_quoted == 1) * 2);
|
|
|
|
}
|