From: Dominik Kaiser Date: Tue, 17 Sep 2024 17:49:29 +0000 (+0200) Subject: Banish the cosmic horror X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=4765148b87b6c095aae1b32b023d5815356584c3;p=42%2Fminishell.git Banish the cosmic horror --- diff --git a/src/collect_redirs.c b/src/collect_redirs.c index 8917c78..9ac1605 100644 --- a/src/collect_redirs.c +++ b/src/collect_redirs.c @@ -6,7 +6,7 @@ /* By: dkaiser next != NULL) { if (cur->type == REDIR_TOKEN && cur->next->type == STRING_TOKEN) - { - cur = collect_redir(tokens, result, cur); - *tokens = (t_token *)(((unsigned long)*tokens) & (~0 - * (!cur->previous && !cur->next->next))); - } + collect_and_check_redir(tokens, result, &cur); else if (cur->type == REDIR_TOKEN) return (free(result), NULL); else @@ -46,6 +44,19 @@ t_redirection *collect_redirs(t_token **tokens) return (result); } +static void collect_and_check_redir(t_token **tokens, t_redirection *result, + t_token **cur) +{ + int is_redir_only; + + is_redir_only = 0; + if ((*cur)->previous == NULL && (*cur)->next->next == NULL) + is_redir_only = 1; + *cur = collect_redir(tokens, result, *cur); + if (is_redir_only) + *tokens = NULL; +} + static t_token *collect_redir(t_token **tokens, t_redirection *result, t_token *cur) {