subsh correction
This commit is contained in:
@@ -17,7 +17,7 @@ char *ft_tabstr(char **tab)
|
|||||||
int i;
|
int i;
|
||||||
int alloc_count;
|
int alloc_count;
|
||||||
char *out;
|
char *out;
|
||||||
// char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
i = -1;
|
i = -1;
|
||||||
alloc_count = 0;
|
alloc_count = 0;
|
||||||
@@ -27,9 +27,9 @@ char *ft_tabstr(char **tab)
|
|||||||
out = tab[0];
|
out = tab[0];
|
||||||
while (tab[++i])
|
while (tab[++i])
|
||||||
{
|
{
|
||||||
// tmp = out;
|
tmp = out;
|
||||||
out = ft_sprintf("%s %s", out, tab[i]);
|
out = ft_sprintf("%s %s", out, tab[i]);
|
||||||
// free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,46 +12,28 @@
|
|||||||
|
|
||||||
#include "../../../includes/minishell.h"
|
#include "../../../includes/minishell.h"
|
||||||
|
|
||||||
static void remove_parentheses(t_node **lst)
|
t_node *remove_parentheses(t_node *lst)
|
||||||
{
|
{
|
||||||
t_node *tmp;
|
t_node *it;
|
||||||
t_node *cpy;
|
t_node *out;
|
||||||
|
|
||||||
if (!lst || !*lst || !(*lst)->next)
|
out = NULL;
|
||||||
return;
|
it = lst;
|
||||||
|
if (it->pressision == SUBSH_S)
|
||||||
tmp = *lst;
|
it = it->next;
|
||||||
*lst = (*lst)->next;
|
while (it->pressision != SUBSH_E)
|
||||||
free(tmp->val);
|
|
||||||
free(tmp);
|
|
||||||
cpy = *lst;
|
|
||||||
while (cpy->next && cpy->next->next)
|
|
||||||
cpy = cpy->next;
|
|
||||||
if (cpy->next)
|
|
||||||
{
|
{
|
||||||
free(cpy->next->val);
|
add_node_back(&out, ft_strdup(it->val), it->token, it->pressision);
|
||||||
free(cpy->next);
|
it = it->next;
|
||||||
cpy->next = NULL;
|
|
||||||
}
|
}
|
||||||
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_subsh(t_ast_n *parent, t_node *lst, t_msh *msh)
|
void create_subsh(t_ast_n *parent, t_node *lst, t_msh *msh)
|
||||||
{
|
{
|
||||||
t_node *cpy;
|
t_node *cpy;
|
||||||
|
t_node *cutted;
|
||||||
|
|
||||||
cpy = lst;
|
cutted = remove_parentheses(lst);
|
||||||
while (cpy)
|
parent->left = create_ast_n(cutted, parent, msh);
|
||||||
{
|
|
||||||
ft_printf("%s\n", cpy->val);
|
|
||||||
cpy = cpy->next;
|
|
||||||
}
|
|
||||||
remove_parentheses(&lst);
|
|
||||||
ft_printf("\n\n");
|
|
||||||
cpy = lst;
|
|
||||||
while (cpy)
|
|
||||||
{
|
|
||||||
ft_printf("%s\n", cpy->val);
|
|
||||||
cpy = cpy->next;
|
|
||||||
}
|
|
||||||
parent->left = create_ast_n(lst, parent, msh);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user