diff --git a/include/parser.h b/include/parser.h index 60cba1d..b89c2a2 100644 --- a/include/parser.h +++ b/include/parser.h @@ -6,7 +6,7 @@ /* By: sede-san type == TOKEN_WORD) { ft_lstadd_back(&args, ft_lstnew(ft_strdup(token->value))); - command->argc++; + (*command)->argc++; arg = arg->next; if (arg != NULL) token = (t_token *)arg->content; } *tokens = arg; - command->argv = args_to_array(args, command->argc); + (*command)->argv = args_to_array(args, (*command)->argc); ft_lstclear_nodes(&args); } void redirection_add( t_list **tokens, t_token *token, - t_command *command + t_command **command ) { t_redirection *redirection; @@ -268,7 +268,11 @@ void redirection_add( redirection = redirection_new(tokens); if (redirection == NULL) + { + command_clear(*command); + *command = NULL; return ; + } redirection_tokens = ft_lstnew(redirection); if (redirection_tokens == NULL) { @@ -276,9 +280,9 @@ void redirection_add( return (malloc_error()); } if (token->type == TOKEN_HEREDOC) - ft_lstadd_back(&command->heredocs, redirection_tokens); + ft_lstadd_back(&(*command)->heredocs, redirection_tokens); else - ft_lstadd_back(&command->redirections, redirection_tokens); + ft_lstadd_back(&(*command)->redirections, redirection_tokens); } /**