temp
This commit is contained in:
parent
8da0e0a036
commit
24752c9d08
@ -28,6 +28,7 @@ t_list *parser_get_commands(t_minishell *minishell)
|
||||
token = (t_token *) current->content;
|
||||
command = parser_command_new(ft_strdup(token->value));
|
||||
command->args = parser_get_arguments(current, minishell);
|
||||
command->redirect_in = parser_get_input_redirects(current);
|
||||
ft_lstadd_back(&command_list, ft_lstnew(command));
|
||||
while (current && ((t_token *)current->content)->type < 3)
|
||||
current = current->next;
|
||||
|
||||
39
src/parser/parser_get_input_redirects.c
Normal file
39
src/parser/parser_get_input_redirects.c
Normal file
@ -0,0 +1,39 @@
|
||||
# include "minishell.h"
|
||||
|
||||
static int valid_def(t_list *list, t_token *token)
|
||||
{
|
||||
t_token *next;
|
||||
|
||||
if (!list->next)
|
||||
return (0);
|
||||
next = (t_token *)list->next->content;
|
||||
if (!next)
|
||||
return (0);
|
||||
return ((token->type == T_REDIRECT_IN || token->type == T_HEREDOC) && next->type < 3);
|
||||
}
|
||||
|
||||
static t_redirect *redirect_new()
|
||||
{
|
||||
t_redirect *result;
|
||||
}
|
||||
|
||||
void parser_get_input_redirects(t_list *list)
|
||||
{
|
||||
t_list *current;
|
||||
t_list *redirects;
|
||||
t_token *token;
|
||||
|
||||
redirects = NULL;
|
||||
current = list;
|
||||
while (current)
|
||||
{
|
||||
token = (t_token *)current->content;
|
||||
if (valid_def(current, token))
|
||||
{
|
||||
ft_lstaddfront(&redirects, ft_lstnew());
|
||||
}
|
||||
else
|
||||
break ;
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user