pipes in subsh in pipes error solved

This commit is contained in:
Nathan Lebrun
2025-02-12 20:13:39 +01:00
parent e60a03293e
commit e747b10ed5
2 changed files with 21 additions and 7 deletions

View File

@@ -33,7 +33,7 @@
# include "exec/exec.h"
# include "exec/expander.h"
# define DEBUG 0
# define DEBUG 1
# ifndef DIO_PATH
# define DIO_PATH "ast.xml"

View File

@@ -31,7 +31,17 @@ static void add_nodell(t_nodell **nodell, t_node *node)
tmp->next->next = NULL;
}
static t_node *get_node(t_node **lst, t_node *expected, int limiter)
static void update_subsh_l(int *shlvl, t_node *lst)
{
if (!lst)
return;
if (!ft_strncmp(")", lst->val, 1))
*shlvl = 0;
if (!ft_strncmp("(", lst->val, 1))
*shlvl = 1;
}
static t_node *get_node(t_node **lst, t_node *expected, int limiter, int *shlvl)
{
t_node *node;
@@ -41,9 +51,9 @@ static t_node *get_node(t_node **lst, t_node *expected, int limiter)
add_node_back(&node, (*lst)->val, (*lst)->token, (*lst)->pressision);
(*lst) = (*lst)->next;
}
while (limiter == -1 && (*lst) && ft_strncmp((*lst)->val, expected->val,
ft_strlen((*lst)->val)))
while (limiter == -1 && (*lst) && ( *shlvl == 1 || ft_strncmp((*lst)->val, expected->val, ft_strlen((*lst)->val))))
{
update_subsh_l(shlvl, *lst);
add_node_back(&node, (*lst)->val, (*lst)->token, (*lst)->pressision);
(*lst) = (*lst)->next;
}
@@ -56,20 +66,24 @@ t_nodell *cutll(t_node *lst, t_node *expected, size_t limiter)
t_node *node;
size_t i;
t_nodell *tmp;
int shlvl;
i = 0;
out = NULL;
shlvl = 0;
while (i <= limiter)
{
node = get_node(&lst, expected, limiter);
update_subsh_l(&shlvl, lst);
node = get_node(&lst, expected, limiter, &shlvl);
if (!node)
break ;
add_nodell(&out, node);
tmp = out;
while (tmp)
tmp = tmp->next;
if (lst && lst->next)
lst = lst->next;
if (!lst)
break;
lst = lst->next;
i++;
}
return (out);