From 47a68b82e0463f5dfd4bd8a9c4b32b4c5fbcb610 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Mon, 22 Jul 2024 15:07:59 +0200 Subject: Fix errors and make the parser work --- src/parse_cmd.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/parse_cmd.c') diff --git a/src/parse_cmd.c b/src/parse_cmd.c index 4fa2bc2..0173caa 100644 --- a/src/parse_cmd.c +++ b/src/parse_cmd.c @@ -6,7 +6,7 @@ /* By: dkaiser next != NULL) { if (cur->type == REDIR_TOKEN && cur->next->type == STRING_TOKEN) { if (cur->content.redir_type & (INPUT_FILE | INPUT_LIMITER)) - { - result[0].type = cur->content.redir_type; - result[0].specifier = cur->next->content.string; - } + idx = 0; else if (cur->content.redir_type & (OUTPUT_APPEND | OUTPUT_OVERRIDE)) - { - result[1].type = cur->content.redir_type; - result[1].specifier = cur->next->content.string; - } + idx = 1; + set_redir(&result[idx], cur->content.redir_type, + cur->next->content.string); cur = cur->next; free_token_and_connect(cur->previous); if (cur->next != NULL) @@ -170,3 +167,9 @@ static char **collect_args(t_token **tokens) result[i] = NULL; return (result); } + +static void set_redir(t_redirection *redir, int type, char *specifier) +{ + redir->type = type; + redir->specifier = specifier; +} -- cgit v1.2.3