quote fix in syntax
This commit is contained in:
@@ -27,7 +27,7 @@ int is_redir(t_node *cpy);
|
|||||||
int is_basic_word(t_node *cpy);
|
int is_basic_word(t_node *cpy);
|
||||||
int syntax_err_mess(char *token_base, int selected);
|
int syntax_err_mess(char *token_base, int selected);
|
||||||
int check_unclosed(char *c, t_node *node);
|
int check_unclosed(char *c, t_node *node);
|
||||||
int check_unclosed_quote(char *c, t_node *node);
|
bool check_unclosed_quote(char *c, t_node *node);
|
||||||
|
|
||||||
int last_tok_redir(t_node *lst);
|
int last_tok_redir(t_node *lst);
|
||||||
int last_tok_subsh(t_node *lst);
|
int last_tok_subsh(t_node *lst);
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ int unclosed(t_node *head)
|
|||||||
{
|
{
|
||||||
if (check_unclosed("()", head) != 0)
|
if (check_unclosed("()", head) != 0)
|
||||||
return (syntax_err_mess("()", check_unclosed("()", head)));
|
return (syntax_err_mess("()", check_unclosed("()", head)));
|
||||||
if (check_unclosed_quote("\"", head) != 0)
|
if (check_unclosed_quote("\"", head))
|
||||||
return (syntax_err_mess("\"\"", 1));
|
return (syntax_err_mess("\"\"", 1));
|
||||||
if (check_unclosed_quote("'", head) != 0)
|
if (check_unclosed_quote("'", head))
|
||||||
return (syntax_err_mess("'", 1));
|
return (syntax_err_mess("'", 1));
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,23 +55,30 @@ int check_unclosed(char *c, t_node *node)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_unclosed_quote(char *c, t_node *node)
|
bool check_unclosed_quote(char *c, t_node *node)
|
||||||
{
|
{
|
||||||
t_node *cpy;
|
t_node *cpy;
|
||||||
int count;
|
int i;
|
||||||
int len;
|
bool closed;
|
||||||
|
bool in_other_quote;
|
||||||
|
|
||||||
|
closed = true;
|
||||||
|
in_other_quote = false;
|
||||||
cpy = node;
|
cpy = node;
|
||||||
count = 0;
|
|
||||||
while (cpy)
|
while (cpy)
|
||||||
{
|
{
|
||||||
len = ft_strlen(cpy->val);
|
i = 0;
|
||||||
if (len > 0 && cpy->val[0] == c[0])
|
while(cpy->val[i])
|
||||||
{
|
{
|
||||||
if (len == 1 || cpy->val[len - 1] != c[0])
|
if ((cpy->val[i] == '"' || cpy->val[i] == '\'') && cpy->val[i] != c[0] && closed)
|
||||||
count++;
|
in_other_quote = !in_other_quote;
|
||||||
|
if (cpy->val[i] == c[0] && !in_other_quote)
|
||||||
|
closed = !closed;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
cpy = cpy->next;
|
cpy = cpy->next;
|
||||||
}
|
}
|
||||||
return (count % 2);
|
if (!closed)
|
||||||
|
return (true);
|
||||||
|
return (false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user