fix: quote verif is better
This commit is contained in:
parent
08261b1921
commit
ee3d535393
@ -24,8 +24,10 @@ static char *ft_spacer_after(const char *str)
|
||||
i = 1;
|
||||
while (out[i] != '\0')
|
||||
{
|
||||
while (ft_is_in_quote(out, i))
|
||||
while (ft_is_in_quote(out, i - 1))
|
||||
i++;
|
||||
if (out[i] == '\0')
|
||||
break ;
|
||||
if (ft_is_in("><|", out[i - 1]))
|
||||
{
|
||||
while (out[i] == out[i - 1])
|
||||
@ -56,6 +58,8 @@ static char *ft_spacer_before(const char *str)
|
||||
{
|
||||
while (ft_is_in_quote(out, i))
|
||||
i++;
|
||||
if (out[i] == '\0')
|
||||
break ;
|
||||
if (ft_is_in("><|", out[i + 1]))
|
||||
{
|
||||
while (out[i] == ' ')
|
||||
@ -83,6 +87,8 @@ static void ft_space_simplifier(char *str)
|
||||
{
|
||||
if (ft_is_in_quote(str, i))
|
||||
i++;
|
||||
if (str[i] != '\0')
|
||||
break ;
|
||||
y = 0;
|
||||
while (str[y + i] == ' ')
|
||||
y++;
|
||||
|
@ -84,7 +84,7 @@ static int ft_special_char_dub(const char *str)
|
||||
}
|
||||
i = i + y;
|
||||
}
|
||||
else
|
||||
else if (str[i] != '\0')
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
|
@ -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] == '\'')
|
||||
i++;
|
||||
while (str[i] != '"' && str[i] != '\0')
|
||||
{
|
||||
if (double_quoted == 0)
|
||||
simple_quoted = !simple_quoted;
|
||||
if (i == n)
|
||||
return (2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (simple_quoted + double_quoted * 2);
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user