fix: quote verif is better
This commit is contained in:
@ -14,26 +14,32 @@
|
||||
|
||||
int ft_is_in_quote(const char *str, size_t n)
|
||||
{
|
||||
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] == '\'')
|
||||
{
|
||||
i++;
|
||||
while (str[i] != '\'' && str[i] != '\0')
|
||||
{
|
||||
if (i == n)
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (str[i] == '"')
|
||||
{
|
||||
if (simple_quoted == 0)
|
||||
double_quoted = !double_quoted;
|
||||
}
|
||||
else if (str[i] == '\'')
|
||||
{
|
||||
if (double_quoted == 0)
|
||||
simple_quoted = !simple_quoted;
|
||||
i++;
|
||||
while (str[i] != '"' && str[i] != '\0')
|
||||
{
|
||||
if (i == n)
|
||||
return (2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (simple_quoted + double_quoted * 2);
|
||||
return (0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user