single quote expander
This commit is contained in:
@@ -106,6 +106,30 @@ void expander_var(t_ast_n *node, int j)
|
|||||||
node->args[j] = new;
|
node->args[j] = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int in_squote(char *str, char *ch)
|
||||||
|
{
|
||||||
|
if (!ft_strchr(str, '\'') && !ft_strchr(str, '\"'))
|
||||||
|
return (0);
|
||||||
|
else if (ft_strchr(str, '\'') && !ft_strchr(str, '\"'))
|
||||||
|
{
|
||||||
|
if ((ch > ft_strchr(str, '\'')) && ch < ft_strrchr(str, '\''))
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
else if (!ft_strchr(str, '\'') && ft_strchr(str, '\"'))
|
||||||
|
return (0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ft_strchr(str, '\'') < ft_strchr(str, '\"'))
|
||||||
|
{
|
||||||
|
if ((ch > ft_strchr(str, '\'')) && ch < ft_strrchr(str, '\''))
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int expand_var(t_ast_n *node, int j)
|
int expand_var(t_ast_n *node, int j)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -113,7 +137,7 @@ int expand_var(t_ast_n *node, int j)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (node->args[j][i])
|
while (node->args[j][i])
|
||||||
{
|
{
|
||||||
if (node->args[j][i] == '$')
|
if (node->args[j][i] == '$' && !in_squote(node->args[j], &node->args[j][i]))
|
||||||
return (expander_var(node, j), 1);
|
return (expander_var(node, j), 1);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ int ifremove_quote(t_ast_n *node, int j)
|
|||||||
c = '\'';
|
c = '\'';
|
||||||
else
|
else
|
||||||
c = '\"';
|
c = '\"';
|
||||||
if (c && (ft_strchr(node->args[j], c) && ft_strrchr(node->args[j], c)))
|
if (c && (ft_strchr(node->args[j], c) != ft_strrchr(node->args[j], c)))
|
||||||
remove_quote(node, j, c);
|
remove_quote(node, j, c);
|
||||||
if (c)
|
if (c)
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user