From d24633c9e61a761c5d65b5e3a8e47101f90e3069 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 5 Dec 2016 13:15:50 +0100 Subject: [PATCH] execution functions changes: they now take reference of nodes, they now delete nodes after operations (suffix). --- 42sh/includes/exec.h | 24 ++++++++++-------- 42sh/includes/lexer.h | 30 ++++++++++++---------- 42sh/includes/minishell.h | 2 +- 42sh/includes/parser.h | 3 ++- 42sh/src/exec/ast_free.c | 31 +++++++++++++++++++++++ 42sh/src/exec/exec_and_if.c | 11 ++++---- 42sh/src/exec/exec_command.c | 7 ++--- 42sh/src/exec/exec_dgreat.c | 9 ++++--- 42sh/src/exec/exec_great.c | 9 ++++--- 42sh/src/exec/exec_less.c | 9 ++++--- 42sh/src/exec/exec_or_if.c | 11 ++++---- 42sh/src/exec/exec_pipe.c | 9 ++++--- 42sh/src/exec/exec_semi.c | 9 ++++--- 42sh/src/exec/ft_exec.c | 8 +++--- 42sh/src/lexer/token_cmp_type.c | 2 +- 42sh/src/lexer/token_free.c | 2 +- 42sh/src/lexer/token_print.c | 10 ++++++-- 42sh/src/line-editing/ft_interactive_sh.c | 4 +-- 42sh/src/main/ft_putast2.c | 2 +- 42sh/src/main/main.c | 7 +++-- 42sh/src/parser/ft_parse.c | 2 +- 42sh/src/parser/parse_great.c | 4 +-- 42sh/src/parser/parse_less.c | 2 +- 23 files changed, 127 insertions(+), 80 deletions(-) create mode 100644 42sh/src/exec/ast_free.c diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 3159300f..28568d41 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:30:31 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:22:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,22 +22,22 @@ typedef struct s_execfunc t_execfunc; struct s_execfunc { t_type type; - int (*f)(t_btree *ast, t_data *data); + int (*f)(t_btree **ast, t_data *data); }; extern t_execfunc g_execfunc[]; -int ft_exec(t_btree *ast, t_data *data); +int ft_exec(t_btree **ast, t_data *data); -int exec_semi(t_btree *ast, t_data *data); -int exec_or_if(t_btree *ast, t_data *data); -int exec_and_if(t_btree *ast, t_data *data); -int exec_pipe(t_btree *ast, t_data *data); +int exec_semi(t_btree **ast, t_data *data); +int exec_or_if(t_btree **ast, t_data *data); +int exec_and_if(t_btree **ast, t_data *data); +int exec_pipe(t_btree **ast, t_data *data); -int exec_less(t_btree *ast, t_data *data); -int exec_great(t_btree *ast, t_data *data); -int exec_dgreat(t_btree *ast, t_data *data); -int exec_command(t_btree *ast, t_data *data); +int exec_less(t_btree **ast, t_data *data); +int exec_great(t_btree **ast, t_data *data); +int exec_dgreat(t_btree **ast, t_data *data); +int exec_command(t_btree **ast, t_data *data); void fd_redirect(t_data *data); void fd_reset(t_data *data); @@ -45,4 +45,6 @@ void fd_reset(t_data *data); int ft_cmd_process(char **argv, t_data *data); int ft_cmd_exec(char *execpath, char **argv, t_data *data); +void ast_free(void *data, size_t content_size); + #endif diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index b52d4bd6..891d756d 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2016/12/01 18:01:14 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 13:14:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,19 +15,21 @@ # include "minishell.h" -# define TK_LESS 0x00000001 -# define TK_GREAT 0x00000002 -# define TK_DLESS 0x00000004 -# define TK_DGREAT 0x00000008 -# define TK_LESSAND 0x00000010 -# define TK_GREATAND 0x00000020 -# define TK_SEMI 0x00000040 -# define TK_PIPE 0x00000080 -# define TK_AND_IF 0x00000100 -# define TK_OR_IF 0x00000200 -# define TK_AMP 0x00000400 -# define TK_WORD 0x00100000 -# define TK_COMMAND 0x00200000 +typedef long long t_type; + +# define TK_LESS 1 << 0 +# define TK_GREAT 1 << 1 +# define TK_DLESS 1 << 2 +# define TK_DGREAT 1 << 3 +# define TK_LESSAND 1 << 4 +# define TK_GREATAND 1 << 5 +# define TK_SEMI 1 << 6 +# define TK_PIPE 1 << 7 +# define TK_AND_IF 1 << 8 +# define TK_OR_IF 1 << 9 +# define TK_AMP 1 << 10 +# define TK_WORD 1 << 11 +# define TK_COMMAND 1 << 12 # define TK_REDIR (0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20) diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index 27a63214..9d20c3f1 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: 2016/12/03 15:27:13 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:32:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 79b606dd..ce4b8458 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:08:15 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:33:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,6 +20,7 @@ typedef struct s_astnode t_astnode; typedef struct s_redir t_redir; typedef union u_astdata t_astdata; typedef union u_word t_word; +typedef long long t_type; struct s_parser { diff --git a/42sh/src/exec/ast_free.c b/42sh/src/exec/ast_free.c new file mode 100644 index 00000000..47babd94 --- /dev/null +++ b/42sh/src/exec/ast_free.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ast_free.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */ +/* Updated: 2016/12/05 12:07:38 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +void ast_free(void *data, size_t content_size) +{ + t_astnode *node; + + (void)content_size; + node = data; + if (node->type == TK_COMMAND) + { + if (node->data.sstr) + ft_sstrfree(node->data.sstr); + } + else if (node->type == TK_LESS || node->type == TK_GREAT || node->type == TK_DGREAT) + { + ft_printf("gonna del word of redirection at %p\n", node->data.redir.word.word); + ft_strdel(&node->data.redir.word.word); + } +} diff --git a/42sh/src/exec/exec_and_if.c b/42sh/src/exec/exec_and_if.c index c1e1f426..4858321d 100644 --- a/42sh/src/exec/exec_and_if.c +++ b/42sh/src/exec/exec_and_if.c @@ -6,13 +6,13 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 20:52:28 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:22:12 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:17:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_and_if(t_btree *ast, t_data *data) +int exec_and_if(t_btree **ast, t_data *data) { if (data->exec.aol_status == NULL || (data->exec.aol_search == TK_AND_IF @@ -20,14 +20,15 @@ int exec_and_if(t_btree *ast, t_data *data) || (data->exec.aol_search == TK_OR_IF && *data->exec.aol_status != '0')) { - ft_exec(ast->left, data); + ft_exec(&(*ast)->left, data); data->exec.aol_status = ft_getenv(data->env, "?"); } data->exec.aol_search = TK_AND_IF; if (*data->exec.aol_status == '0' - || ((t_astnode*)ast->right->item)->type != TK_COMMAND) - ft_exec(ast->right, data); + || ((t_astnode*)(*ast)->right->item)->type != TK_COMMAND) + ft_exec(&(*ast)->right, data); data->exec.aol_status = NULL; data->exec.aol_search = 0; + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index 0f055cdb..119b6159 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,17 +6,18 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2016/12/03 11:56:11 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:12:31 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_command(t_btree *ast, t_data *data) +int exec_command(t_btree **ast, t_data *data) { t_astnode *node; - node = ast->item; + node = (*ast)->item; ft_cmd_process(node->data.sstr, data); + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_dgreat.c b/42sh/src/exec/exec_dgreat.c index 0439372f..a338c59d 100644 --- a/42sh/src/exec/exec_dgreat.c +++ b/42sh/src/exec/exec_dgreat.c @@ -6,21 +6,22 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:15:13 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:22:33 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:13:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_dgreat(t_btree *ast, t_data *data) +int exec_dgreat(t_btree **ast, t_data *data) { t_astnode *node; int fd; - node = ast->item; + node = (*ast)->item; fd = open(node->data.redir.word.word, O_WRONLY | O_APPEND | O_CREAT, 0644); data->exec.fdout = fd; - ft_exec(ast->left, data); + ft_exec(&(*ast)->left, data); data->exec.fdout = STDOUT; + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_great.c b/42sh/src/exec/exec_great.c index a971889a..996283e3 100644 --- a/42sh/src/exec/exec_great.c +++ b/42sh/src/exec/exec_great.c @@ -6,21 +6,22 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:27:51 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:22:43 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:13:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_great(t_btree *ast, t_data *data) +int exec_great(t_btree **ast, t_data *data) { t_astnode *node; int fd; - node = ast->item; + node = (*ast)->item; fd = open(node->data.redir.word.word, O_WRONLY | O_TRUNC | O_CREAT, 0644); data->exec.fdout = fd; - ft_exec(ast->left, data); + ft_exec(&(*ast)->left, data); data->exec.fdout = STDOUT; + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_less.c b/42sh/src/exec/exec_less.c index 7b3a8472..63dd4dbf 100644 --- a/42sh/src/exec/exec_less.c +++ b/42sh/src/exec/exec_less.c @@ -6,21 +6,22 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:27:08 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:22:51 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:12:59 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_less(t_btree *ast, t_data *data) +int exec_less(t_btree **ast, t_data *data) { t_astnode *node; int fd; - node = ast->item; + node = (*ast)->item; fd = open(node->data.redir.word.word, O_RDONLY); data->exec.fdin = fd; - ft_exec(ast->left, data); + ft_exec(&(*ast)->left, data); data->exec.fdin = STDIN; + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_or_if.c b/42sh/src/exec/exec_or_if.c index 511ad838..4410039c 100644 --- a/42sh/src/exec/exec_or_if.c +++ b/42sh/src/exec/exec_or_if.c @@ -6,13 +6,13 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 21:06:17 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:23:28 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:17:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_or_if(t_btree *ast, t_data *data) +int exec_or_if(t_btree **ast, t_data *data) { if (data->exec.aol_status == NULL || (data->exec.aol_search == TK_AND_IF @@ -20,14 +20,15 @@ int exec_or_if(t_btree *ast, t_data *data) || (data->exec.aol_search == TK_OR_IF && *data->exec.aol_status != '0')) { - ft_exec(ast->left, data); + ft_exec(&(*ast)->left, data); data->exec.aol_status = ft_getenv(data->env, "?"); } data->exec.aol_search = TK_OR_IF; if (*data->exec.aol_status != '0' - || ((t_astnode*)ast->right->item)->type != TK_COMMAND) - ft_exec(ast->right, data); + || ((t_astnode*)(*ast)->right->item)->type != TK_COMMAND) + ft_exec(&(*ast)->right, data); data->exec.aol_status = NULL; data->exec.aol_search = 0; + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_pipe.c b/42sh/src/exec/exec_pipe.c index 9162a9e4..31e03ef1 100644 --- a/42sh/src/exec/exec_pipe.c +++ b/42sh/src/exec/exec_pipe.c @@ -6,28 +6,29 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 21:13:23 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:23:49 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:14:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_pipe(t_btree *ast, t_data *data) +int exec_pipe(t_btree **ast, t_data *data) { int fds[2]; pipe(fds); ft_dprintf(2, "pipe %i->%i\n", fds[PIPE_WRITE], fds[PIPE_READ]); data->exec.fdout = fds[PIPE_WRITE]; - ft_exec(ast->left, data); + ft_exec(&(*ast)->left, data); if (data->exec.fdout != STDOUT) close(data->exec.fdout); data->exec.fdout = STDOUT; data->exec.fdin = fds[PIPE_READ]; - ft_exec(ast->right, data); + ft_exec(&(*ast)->right, data); close(fds[PIPE_WRITE]); close(fds[PIPE_READ]); data->exec.fdin = STDIN; data->exec.fdout = STDOUT; + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_semi.c b/42sh/src/exec/exec_semi.c index e75061ba..39b7d484 100644 --- a/42sh/src/exec/exec_semi.c +++ b/42sh/src/exec/exec_semi.c @@ -6,15 +6,16 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 20:52:05 by jhalford #+# #+# */ -/* Updated: 2016/11/30 20:52:09 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:14:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "exec.h" -int exec_semi(t_btree *ast, t_data *data) +int exec_semi(t_btree **ast, t_data *data) { - ft_exec(ast->left, data); - ft_exec(ast->right, data); + ft_exec(&(*ast)->left, data); + ft_exec(&(*ast)->right, data); + btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index e39d0da8..c67eaf9a 100644 --- a/42sh/src/exec/ft_exec.c +++ b/42sh/src/exec/ft_exec.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:25:00 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:18:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,14 +25,14 @@ t_execfunc g_execfunc[] = {0, 0}, }; -int ft_exec(t_btree *ast, t_data *data) +int ft_exec(t_btree **ast, t_data *data) { t_astnode *item; int i; i = 0; - item = ast->item; - if (!ast) + item = (*ast)->item; + if (!*ast) return (0); while (g_execfunc[i].type) { diff --git a/42sh/src/lexer/token_cmp_type.c b/42sh/src/lexer/token_cmp_type.c index 43f80c0d..b7e204f3 100644 --- a/42sh/src/lexer/token_cmp_type.c +++ b/42sh/src/lexer/token_cmp_type.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 17:08:55 by jhalford #+# #+# */ -/* Updated: 2016/11/30 17:52:00 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:29:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/token_free.c b/42sh/src/lexer/token_free.c index d987dfd3..05ecb6e4 100644 --- a/42sh/src/lexer/token_free.c +++ b/42sh/src/lexer/token_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:07:30 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:07:30 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 11:53:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/token_print.c b/42sh/src/lexer/token_print.c index aa5e1108..c62f83d5 100644 --- a/42sh/src/lexer/token_print.c +++ b/42sh/src/lexer/token_print.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:08:14 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:50:03 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,11 +15,17 @@ void token_print(t_list *lst) { t_token *token; + int i; + t_type type; while (lst) { + i = 1; token = lst->content; - ft_dprintf(2, "%#010llx: '%s'\n", token->type, token->data); + type = token->type; + while (type >> (i++ + 2)) + ; + ft_dprintf(2, "%02i '%s'\n", i, token->data); lst = lst->next; } } diff --git a/42sh/src/line-editing/ft_interactive_sh.c b/42sh/src/line-editing/ft_interactive_sh.c index b82f4750..b9a8c453 100644 --- a/42sh/src/line-editing/ft_interactive_sh.c +++ b/42sh/src/line-editing/ft_interactive_sh.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:14:12 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:37:29 by jhalford ### ########.fr */ +/* Updated: 2016/12/03 17:03:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,7 @@ t_stof g_keys[] = { {FT_KEY_C_K, NULL}, - {FT_KEY_TAB, NULL}, + {FT_KEY_TAB, &ft_key_default}, {FT_KEY_C_H, &ft_line_start}, {FT_KEY_C_L, &ft_line_end}, {FT_KEY_C_U, &ft_clear_line}, diff --git a/42sh/src/main/ft_putast2.c b/42sh/src/main/ft_putast2.c index 4d23eb88..b73e0e55 100644 --- a/42sh/src/main/ft_putast2.c +++ b/42sh/src/main/ft_putast2.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */ -/* Updated: 2016/12/01 16:44:24 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:35:35 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index a1ded8ed..7579feab 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 21:13:34 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:33:21 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:11:27 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ int main(void) t_btree *ast; token = NULL; + ast = NULL; if (data_init(&data)) return (1); if (signal(SIGINT, sig_handler) == SIG_ERR) @@ -34,14 +35,12 @@ int main(void) if (!token) continue ; token_print(token); - ast = NULL; if (ft_parse(&ast, &token)) return (1); btree_print(STDERR, ast, &ft_putast); /* ft_dprintf(STDERR, "\n--- INFIX BREAKDOWN ---\n"); */ /* btree_apply_infix(ast, &ft_putast2); */ - /* ft_lstdel(&token, &token_free); */ - if (ft_exec(ast, &data)) + if (ft_exec(&ast, &data)) return (1); } return (0); diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index 3793b5ea..c2645ed7 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */ -/* Updated: 2016/12/03 13:50:36 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:33:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/parse_great.c b/42sh/src/parser/parse_great.c index 9081a02e..ac191c30 100644 --- a/42sh/src/parser/parse_great.c +++ b/42sh/src/parser/parse_great.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */ -/* Updated: 2016/12/03 13:32:06 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 12:12:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,10 +28,8 @@ int parse_great(t_btree **ast, t_list **start, t_list **lst) return (1); node->data.redir.n = ft_atoi(tok->data); node->data.redir.word.word = ft_strdup(next_tok->data); - ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free); ft_lst_delif(start, (*lst)->next->content, &ft_addrcmp, &token_free); - ft_parse(&(*ast)->left, start); return (0); } diff --git a/42sh/src/parser/parse_less.c b/42sh/src/parser/parse_less.c index 5efd74b8..b1da5d1f 100644 --- a/42sh/src/parser/parse_less.c +++ b/42sh/src/parser/parse_less.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */ -/* Updated: 2016/12/01 16:36:44 by jhalford ### ########.fr */ +/* Updated: 2016/12/05 11:58:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */