skip parentesis fix

This commit is contained in:
gazhonsepaskwa
2025-02-14 11:00:37 +01:00
parent 93b69e815f
commit 459862d0a5
3 changed files with 18 additions and 13 deletions

View File

@@ -29,10 +29,10 @@ $(LIBFT): $(LIBFT_SRCS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
@$(CC) $(WFLAGS) -MMD -MP -I$(INCDIR) -D DIO_PATH="\"$(HOME)/ast.xml\"" -c $< -o $@ $(LINK)
@$(CC) $(WFLAGS) -gdwarf-4 -MMD -MP -I$(INCDIR) -D DIO_PATH="\"$(HOME)/ast.xml\"" -c $< -o $@ $(LINK)
$(NAME): $(LIBFT) $(OBJS)
@$(CC) $(WFLAGS) $(OBJS) $(LIBFT) -D DIO_PATH="\"$(HOME)/ast.xml\"" -o $(NAME) $(LINK)
@$(CC) $(WFLAGS) -gdwarf-4 $(OBJS) $(LIBFT) -D DIO_PATH="\"$(HOME)/ast.xml\"" -o $(NAME) $(LINK)
@echo "$(CYAN)Build completed: $(NAME)$(RESET)"
clean:

View File

@@ -20,6 +20,7 @@ t_node *remove_parentheses(t_node *lst)
char *str;
out = NULL;
str = NULL;
it = lst;
it = it->next;
deepness = 1;
@@ -36,7 +37,7 @@ t_node *remove_parentheses(t_node *lst)
free(str);
it = it->next;
}
free(str);
// ft_free(&str);
return (out);
}

View File

@@ -6,7 +6,7 @@
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/31 17:14:26 by nalebrun #+# #+# */
/* Updated: 2025/02/07 17:56:02 by nalebrun ### ########.fr */
/* Updated: 2025/02/14 10:59:00 by nalebrun ### ########.fr */
/* */
/* ************************************************************************** */
@@ -28,12 +28,11 @@ static int last_tok_redir(t_node *lst)
{
while (lst)
{
if ((lst->next == NULL
|| lst->next->pressision == D_RED_R
if ((lst->next == NULL || lst->next->pressision == D_RED_R
|| lst->next->pressision == RED_R
|| lst->next->pressision == RED_L
|| lst->next->pressision == HEREDOC)
&& !ft_strncmp(lst->val, ")", 1))
|| lst->next->pressision == HEREDOC) && !ft_strncmp(lst->val,
")", 1))
return (1);
lst = lst->next;
}
@@ -44,12 +43,16 @@ static void skip_parentheses(t_node **lst)
{
if (!ft_strncmp((*lst)->val, "(", 1))
{
while ((*lst)->next && ft_strncmp((*lst)->next->val, ")", 1))
(*lst) = (*lst)->next;
while (*lst && ft_strncmp((*lst)->val, ")", 1))
{
if (!ft_strncmp((*lst)->val, "(", 1))
skip_parentheses(&(*lst)->next);
*lst = (*lst)->next;
skip_parentheses(lst);
else
(*lst) = (*lst)->next;
}
if (*lst)
(*lst) = (*lst)->next;
}
}
@@ -58,8 +61,9 @@ static t_node *find_token(char *tok, t_node *lst)
while (lst)
{
skip_parentheses(&lst);
if (!ft_strncmp(lst->val, tok, ft_strlen(tok)))
if (lst && !ft_strncmp(lst->val, tok, ft_strlen(tok)))
return (lst);
if (lst)
lst = lst->next;
}
return (NULL);