diff --git a/42sh/a b/42sh/a new file mode 100644 index 00000000..e69de29b diff --git a/42sh/b b/42sh/b new file mode 100644 index 00000000..e69de29b diff --git a/42sh/c b/42sh/c new file mode 100644 index 00000000..31842517 --- /dev/null +++ b/42sh/c @@ -0,0 +1,25 @@ +total 800 +drwxr-xr-x 24 ariard 2016_paris 816 Mar 15 02:11 . +-rw-r--r-- 1 ariard 2016_paris 51102 Mar 15 02:11 STDBUG +-rw-r--r-- 1 ariard 2016_paris 0 Mar 15 02:11 a +-rw-r--r-- 1 ariard 2016_paris 0 Mar 15 02:11 b +-rw-r--r-- 1 ariard 2016_paris 0 Mar 15 02:11 c +drwxr-xr-x 17 ariard 2016_paris 578 Mar 15 02:10 .git +-rwxr-xr-x 1 ariard 2016_paris 299668 Mar 15 02:10 42sh +drwxr-xr-x 16 ariard 2016_paris 544 Mar 15 02:05 includes +drwxr-xr-x 12 ariard 2016_paris 408 Mar 15 02:05 libft +drwxr-xr-x 13 ariard 2016_paris 442 Mar 15 02:05 objs +-rw-r--r-- 1 ariard 2016_paris 9190 Mar 14 22:49 Makefile +-rw-r--r-- 1 ariard 2016_paris 113 Mar 14 12:49 main.c +drwxr-xr-x 11 ariard 2016_paris 374 Mar 14 11:00 .. +-rw-r--r-- 1 ariard 2016_paris 195 Mar 13 14:07 .gitignore +drwxr-xr-x 7 ariard 2016_paris 238 Mar 8 23:22 TESTSHELL +drwxr-xr-x 30 ariard 2016_paris 1020 Mar 8 23:22 sample +-rwxr-xr-x 1 ariard 2016_paris 890 Mar 8 23:22 test_framework.sh +drwxr-xr-x 13 ariard 2016_paris 442 Mar 7 19:42 src +-rw-r--r-- 1 ariard 2016_paris 75 Mar 4 14:53 .gitmodules +-rw-r--r-- 1 ariard 2016_paris 4241 Mar 4 14:53 .tags +-rw-r--r-- 1 ariard 2016_paris 92 Mar 4 14:53 .valgrind.supp +-rw-r--r-- 1 ariard 2016_paris 4396 Mar 4 14:53 donovan_segaults_06-02 +drwxr-xr-x 6 ariard 2016_paris 204 Mar 4 14:53 pdf +-rwxr-xr-x 1 ariard 2016_paris 690 Mar 4 14:53 update_makefile.sh diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 03ab84b7..2f07a512 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -104,7 +104,6 @@ int add_cmd(t_btree **ast, t_list **lst); int add_file(t_btree **ast, t_list **lst); int add_loop_cmd(t_btree **ast, t_list **lst); int add_loop_sep(t_btree **ast, t_list **lst); -int add_loop_condition(t_btree **ast, t_list **lst); int add_condition_cmd(t_btree **ast, t_list **lst); int add_condition_sep(t_btree **ast, t_list **lst); int add_branch(t_btree **ast, t_list **lst); @@ -127,7 +126,6 @@ int add_bang_sep(t_btree **ast, t_list **lst); int add_if(t_btree **ast, t_list **lst); int isloop(t_btree **ast, t_list **lst); -int isloop_condition(t_btree **ast, t_list **lst); int iscase(t_btree **ast, t_list **lst); int iscase_pattern(t_btree **ast, t_list **lst); int iscase_branch(t_btree **ast, t_list **lst); @@ -169,7 +167,6 @@ struct s_cmd { t_list *redir; t_ld *token; - t_ld *wordlist; }; union u_astdata diff --git a/42sh/src/exec/exec_elif.c b/42sh/src/exec/exec_elif.c index c4a5fa4a..f3742225 100644 --- a/42sh/src/exec/exec_elif.c +++ b/42sh/src/exec/exec_elif.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 18:08:53 by ariard #+# #+# */ -/* Updated: 2017/03/04 17:45:29 by ariard ### ########.fr */ +/* Updated: 2017/03/15 02:04:57 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_leaf.c b/42sh/src/exec/exec_leaf.c index 4707ff05..e26f54d4 100644 --- a/42sh/src/exec/exec_leaf.c +++ b/42sh/src/exec/exec_leaf.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ -/* Updated: 2017/03/15 01:50:11 by ariard ### ########.fr */ +/* Updated: 2017/03/15 02:04:30 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index c6424172..1f4a97ae 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: 2017/03/15 01:53:18 by ariard ### ########.fr */ +/* Updated: 2017/03/15 02:04:38 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/pfree_cond.c b/42sh/src/exec/pfree_cond.c index 57168280..2dae0996 100644 --- a/42sh/src/exec/pfree_cond.c +++ b/42sh/src/exec/pfree_cond.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 02:26:31 by wescande #+# #+# */ -/* Updated: 2017/03/13 22:31:32 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 02:04:14 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,6 @@ int pfree_cond(t_process *p) { - btree_del(&p->data.d_while.condition, &ast_free); btree_del(&p->data.d_while.content, &ast_free); return (0); } diff --git a/42sh/src/exec/plaunch_if.c b/42sh/src/exec/plaunch_if.c index a6208223..3efe9b9e 100644 --- a/42sh/src/exec/plaunch_if.c +++ b/42sh/src/exec/plaunch_if.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:26:53 by wescande #+# #+# */ -/* Updated: 2017/03/13 20:28:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 02:04:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,12 +18,7 @@ static int do_if(t_process *p) exec = &data_singleton()->exec; exec->attrs &= ~EXEC_IF_BRANCH; - ft_exec(&p->data.d_if.condition); - if (!(ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0"))) - { - exec->attrs |= EXEC_IF_BRANCH; - ft_exec(&p->data.d_if.content); - } + ft_exec(&p->data.d_if.content); return (ft_atoi(ft_getenv(data_singleton()->env, "?"))); } diff --git a/42sh/src/exec/pset_if.c b/42sh/src/exec/pset_if.c index 31440d0d..5d29ef80 100644 --- a/42sh/src/exec/pset_if.c +++ b/42sh/src/exec/pset_if.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 19:19:50 by wescande #+# #+# */ -/* Updated: 2017/03/13 20:31:21 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 02:03:19 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,6 @@ int pset_if(t_process *p, t_btree *ast) { - p->data.d_if.condition = btree_map(ast->left, &node_copy); p->data.d_if.content = btree_map(ast->right, &node_copy); p->type = PROCESS_IF; return (0); diff --git a/42sh/src/parser/add_cmd.c b/42sh/src/parser/add_cmd.c index ed1afa72..a9bbf035 100644 --- a/42sh/src/parser/add_cmd.c +++ b/42sh/src/parser/add_cmd.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 20:49:15 by ariard #+# #+# */ -/* Updated: 2017/03/15 01:35:15 by ariard ### ########.fr */ +/* Updated: 2017/03/15 02:10:08 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,8 +15,6 @@ t_distrostree g_distrostree[] = { {&superflous_token, &add_null}, - {&isdir_sep, &add_redir_type}, - {&isdir_word, &add_redir_word}, {&isloop, &add_loop_cmd}, {&iscondition_branch, &add_branch}, {&iscondition, &add_condition_cmd}, @@ -27,6 +25,8 @@ t_distrostree g_distrostree[] = {&isfunc, &add_func_cmd}, {&isionumber, &add_ionumber}, {&isbang, &add_bang}, + {&isdir_sep, &add_redir_type}, + {&isdir_word, &add_redir_word}, {&isnull, &add_null}, }; diff --git a/42sh/src/parser/add_loop.c b/42sh/src/parser/add_loop.c index 4b2713bc..94cadf15 100644 --- a/42sh/src/parser/add_loop.c +++ b/42sh/src/parser/add_loop.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/17 22:17:14 by ariard #+# #+# */ -/* Updated: 2017/03/15 01:45:34 by ariard ### ########.fr */ +/* Updated: 2017/03/15 01:59:52 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,8 @@ int isloop(t_btree **ast, t_list **lst) if (node->type == TK_FOR && (token->type == TK_NEWLINE || token->type == TK_SEMI) && node->pattern == 0) return (1); - if (node->type == TK_FOR && (token->type == TK_WORD || token->type == TK_NAME) - && node->pattern == 0) + if (node->type == TK_FOR && (token->type == TK_WORD + || token->type == TK_NAME) && node->pattern == 0) return (0); if ((node->type == TK_NEWLINE || node->type == TK_SEMI || node->type == TK_AMP || node->type == TK_PIPE) @@ -39,23 +39,6 @@ int isloop(t_btree **ast, t_list **lst) return (0); } -int isloop_condition(t_btree **ast, t_list **lst) -{ - t_astnode *node; - t_token *token; - - node = NULL; - token = (*lst)->content; - if (*ast) - { - node = (*ast)->item; - if (node->type == TK_FOR && (token->type == TK_WORD - || token->type == TK_NAME) && node->pattern == 0) - return (1); - } - return (0); -} - int add_loop_cmd(t_btree **ast, t_list **lst) { t_token *token; @@ -101,15 +84,3 @@ int add_loop_sep(t_btree **ast, t_list **lst) return (add_sep(&(*ast)->right, lst)); return (0); } - -int add_loop_condition(t_btree **ast, t_list **lst) -{ - t_astnode *node; - t_token *token; - - token = (*lst)->content; - node = (*ast)->item; - ft_ld_pushback(&node->data.cmd.wordlist, - gen_tab(token->data, token->esc, token->esc2, 1)); - return (0); -} diff --git a/42sh/src/parser/add_redir.c b/42sh/src/parser/add_redir.c index 4d5276ff..b4f9611a 100644 --- a/42sh/src/parser/add_redir.c +++ b/42sh/src/parser/add_redir.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/17 16:39:05 by ariard #+# #+# */ -/* Updated: 2017/03/13 22:39:30 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 02:09:54 by ariard ### ########.fr */ /* */ /* ************************************************************************** */