From 8b33185add356fb6df2e7ada7b1b4b04aadcd108 Mon Sep 17 00:00:00 2001 From: Quinten Date: Sun, 23 Feb 2025 13:14:48 +0100 Subject: [PATCH] readability --- inc/redirect.h | 2 ++ src/redirect/redirect_get_inputs.c | 2 +- src/redirect/redirect_get_outputs.c | 2 +- src/redirect/redirect_valid_type.c | 8 +++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/inc/redirect.h b/inc/redirect.h index 98a86e3..5cffd36 100644 --- a/inc/redirect.h +++ b/inc/redirect.h @@ -19,4 +19,6 @@ t_list *redirect_get_inputs(t_list *list); t_list *redirect_get_outputs(t_list *list); int redirect_is_valid(t_list *lst, t_token *token); int redirect_token_type(t_token *token); +int redirect_is_delimiter(t_token *token); + #endif \ No newline at end of file diff --git a/src/redirect/redirect_get_inputs.c b/src/redirect/redirect_get_inputs.c index a44a6fe..b6e0828 100644 --- a/src/redirect/redirect_get_inputs.c +++ b/src/redirect/redirect_get_inputs.c @@ -23,7 +23,7 @@ t_list *redirect_get_inputs(t_list *list) while (current) { token = (t_token *)current->content; - if (token->type == T_PIPE || token->type == T_EOF) + if (redirect_is_delimiter(token)) break ; if (token->type != T_REDIRECT_IN && token->type != T_HEREDOC) { diff --git a/src/redirect/redirect_get_outputs.c b/src/redirect/redirect_get_outputs.c index 9383bf6..8daee58 100644 --- a/src/redirect/redirect_get_outputs.c +++ b/src/redirect/redirect_get_outputs.c @@ -23,7 +23,7 @@ t_list *redirect_get_outputs(t_list *list) while (current) { token = (t_token *)current->content; - if (token->type == T_PIPE || token->type == T_EOF) + if (redirect_is_delimiter(token)) break; if (token->type != T_REDIRECT_OUT && token->type != T_APPEND_OUT) { diff --git a/src/redirect/redirect_valid_type.c b/src/redirect/redirect_valid_type.c index 2df0a3d..2554d32 100644 --- a/src/redirect/redirect_valid_type.c +++ b/src/redirect/redirect_valid_type.c @@ -28,4 +28,10 @@ int redirect_is_valid(t_list *lst, t_token *token) if (!next) return (0); return (redirect_token_type(token) && next->type < 3); -} \ No newline at end of file +} + +int redirect_is_delimiter(t_token *token) +{ + return (token->type == T_PIPE || token->type == T_AND || + token->type == T_OR || token->type == T_EOF || token->type == T_ERROR); +} \ No newline at end of file