readability

This commit is contained in:
Quinten 2025-02-23 13:14:48 +01:00
parent e13eff0669
commit 8b33185add
4 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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);
}
}
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);
}