From 6f58bb20b3b1201faeebd764beacd7694bd9e648 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Sat, 18 Mar 2017 19:00:46 +0100 Subject: [PATCH] heredoc ok --- 42sh/includes/minishell.h | 3 +-- 42sh/src/exec/ast_free.c | 10 +--------- 42sh/src/exec/redir_free.c | 11 ++++++----- 42sh/src/parser/heredoc_parser.c | 2 +- 42sh/src/parser/parser_destroy.c | 4 ++-- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index ad6603ad..c478145d 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/03/17 23:20:13 by ariard ### ########.fr */ +/* Updated: 2017/03/18 18:42:58 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -51,7 +51,6 @@ struct s_data t_comp *comp; t_exec exec; t_jobc jobc; - t_list *heredoc_queue; char **local_var; t_list *lst_func; }; diff --git a/42sh/src/exec/ast_free.c b/42sh/src/exec/ast_free.c index 1b31af40..54f30952 100644 --- a/42sh/src/exec/ast_free.c +++ b/42sh/src/exec/ast_free.c @@ -6,20 +6,12 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */ -/* Updated: 2017/03/18 17:34:46 by ariard ### ########.fr */ +/* Updated: 2017/03/18 18:17:20 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -void read_redir(void *data) -{ - t_redir *redir; - - redir = data; - DG("file : [%s]", redir->word); -} - void ast_free(void *data, size_t content_size) { t_astnode *node; diff --git a/42sh/src/exec/redir_free.c b/42sh/src/exec/redir_free.c index 121e9171..09665cd9 100644 --- a/42sh/src/exec/redir_free.c +++ b/42sh/src/exec/redir_free.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/03 18:12:57 by ariard #+# #+# */ -/* Updated: 2017/03/18 17:27:56 by ariard ### ########.fr */ +/* Updated: 2017/03/18 18:59:57 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,9 +18,10 @@ void redir_free(void *data, size_t content_size) (void)content_size; redir = data; - if (redir->type == TK_GREAT || redir->type == TK_LESS || redir->type == TK_DGREAT) - { - ft_strdel(&redir->word); - } + ft_strdel(&redir->word); + if (redir->type == TK_DLESS) + ft_strdel(&redir->heredoc_data); + redir->type = 0; + redir->n = 0; free(redir); } diff --git a/42sh/src/parser/heredoc_parser.c b/42sh/src/parser/heredoc_parser.c index 1800740c..01c20bd0 100644 --- a/42sh/src/parser/heredoc_parser.c +++ b/42sh/src/parser/heredoc_parser.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 16:21:05 by ariard #+# #+# */ -/* Updated: 2017/03/17 18:42:58 by ariard ### ########.fr */ +/* Updated: 2017/03/18 19:00:17 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/parser_destroy.c b/42sh/src/parser/parser_destroy.c index e9064ce0..02b4bf6e 100644 --- a/42sh/src/parser/parser_destroy.c +++ b/42sh/src/parser/parser_destroy.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/16 19:30:17 by ariard #+# #+# */ -/* Updated: 2017/03/17 17:55:38 by ariard ### ########.fr */ +/* Updated: 2017/03/18 18:45:22 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,7 +16,7 @@ void parser_destroy(t_parser *parser) { parser->state = SUCCESS; ft_lstdel(&parser->stack, &ft_lst_cfree); - ft_lstdel(&data_singleton()->parser.heredoc_queue, &ft_lst_cfree); + ft_lstdel(&parser->heredoc_queue, &ft_lst_cfree); free(parser->new_sym); parser->new_sym = NULL; }