From b0dececf1fdb59a6d332e0e0460c3fd7dd8b5297 Mon Sep 17 00:00:00 2001 From: "ariard@student.42.fr" Date: Tue, 31 Jan 2017 22:52:36 +0100 Subject: [PATCH] loop_del --- 42sh/file2 | 1 - 42sh/file3 | 0 42sh/includes/exec.h | 3 ++- 42sh/includes/lexer.h | 2 +- 42sh/src/exec/ast_free.c | 2 +- 42sh/src/exec/exec_while.c | 11 ++++------- 42sh/src/exec/loop_del.c | 27 +++++++++++++++++++++++++++ 42sh/src/lexer/ft_tokenize.c | 2 +- 42sh/src/lexer/lexer_do.c | 2 +- 42sh/src/lexer/lexer_done.c | 2 +- 42sh/src/lexer/lexer_list.c | 2 +- 42sh/src/main/ft_print_all_ast.c | 9 ++++++--- 42sh/src/main/shell_script.c | 2 +- 42sh/src/parser/.ft_parse.c.swn | Bin 0 -> 12288 bytes 42sh/src/parser/ft_parse.c | 2 +- 15 files changed, 47 insertions(+), 20 deletions(-) delete mode 100644 42sh/file2 delete mode 100644 42sh/file3 create mode 100644 42sh/src/exec/loop_del.c create mode 100644 42sh/src/parser/.ft_parse.c.swn diff --git a/42sh/file2 b/42sh/file2 deleted file mode 100644 index ce09b016..00000000 --- a/42sh/file2 +++ /dev/null @@ -1 +0,0 @@ -/Users/ariard/Projects/42sh diff --git a/42sh/file3 b/42sh/file3 deleted file mode 100644 index e69de29b..00000000 diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index 00305b5d..f6b22c1e 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: 2017/01/31 19:34:10 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:38:56 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -106,5 +106,6 @@ void set_exitstatus(int status); void ast_free(void *data, size_t content_size); int loop_exec(t_list *list_ast); +int loop_del(t_list *list_ast); #endif diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 2872c1f1..bd6c40ea 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: 2017/01/31 21:55:48 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:14:11 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/ast_free.c b/42sh/src/exec/ast_free.c index 12e06dba..29a7f0e1 100644 --- a/42sh/src/exec/ast_free.c +++ b/42sh/src/exec/ast_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */ -/* Updated: 2017/01/31 18:49:37 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:35:31 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_while.c b/42sh/src/exec/exec_while.c index 75285598..0892a0d9 100644 --- a/42sh/src/exec/exec_while.c +++ b/42sh/src/exec/exec_while.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/30 17:33:53 by ariard #+# #+# */ -/* Updated: 2017/01/31 20:45:41 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:52:11 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,7 +23,6 @@ int exec_while(t_btree **ast) node = ((*ast)->left)->item; DG("test command data '%s'", node->data.str); test_commands = shell_get_ast(node->data.str); -// ft_print_all_ast(*test_commands); node = ((*ast)->right)->item; DG("consequent command data '%s'", node->data.str); @@ -32,15 +31,13 @@ int exec_while(t_btree **ast) p = &data_singleton()->exec.process; p->script |= SCRIPT_LOOP; -// ft_print_all_ast(consequent_commands); + test = 10; while (test--) loop_exec(*consequent_commands); -// del tree (test_commands); -// del tree (test_commands); - p->script &= 0; - + loop_del(*consequent_commands); + p->script &= 0; btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/loop_del.c b/42sh/src/exec/loop_del.c new file mode 100644 index 00000000..dc9614d7 --- /dev/null +++ b/42sh/src/exec/loop_del.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* loop_del.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ariard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/31 22:39:20 by ariard #+# #+# */ +/* Updated: 2017/01/31 22:51:56 by ariard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "exec.h" + +int loop_del(t_list *list_ast) +{ + t_list *temp; + + while (list_ast) + { + btree_del((t_btree **)list_ast->content, &ast_free); + temp = list_ast; + list_ast = list_ast->next; + ft_lstdelone(&temp, NULL); + } + return (0); +} diff --git a/42sh/src/lexer/ft_tokenize.c b/42sh/src/lexer/ft_tokenize.c index 4e09ed79..51ef8fc6 100644 --- a/42sh/src/lexer/ft_tokenize.c +++ b/42sh/src/lexer/ft_tokenize.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */ -/* Updated: 2017/01/31 21:08:54 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:52:22 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_do.c b/42sh/src/lexer/lexer_do.c index f6c20aeb..ce34feca 100644 --- a/42sh/src/lexer/lexer_do.c +++ b/42sh/src/lexer/lexer_do.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 00:48:48 by ariard #+# #+# */ -/* Updated: 2017/01/31 21:57:33 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:14:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_done.c b/42sh/src/lexer/lexer_done.c index 19705849..daa57f81 100644 --- a/42sh/src/lexer/lexer_done.c +++ b/42sh/src/lexer/lexer_done.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/31 20:49:09 by ariard #+# #+# */ -/* Updated: 2017/01/31 21:57:46 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:14:28 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_list.c b/42sh/src/lexer/lexer_list.c index 0ff80acd..4012135f 100644 --- a/42sh/src/lexer/lexer_list.c +++ b/42sh/src/lexer/lexer_list.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 00:55:33 by ariard #+# #+# */ -/* Updated: 2017/01/31 22:05:36 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:14:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/ft_print_all_ast.c b/42sh/src/main/ft_print_all_ast.c index 84d2ada8..55003400 100644 --- a/42sh/src/main/ft_print_all_ast.c +++ b/42sh/src/main/ft_print_all_ast.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/30 19:23:49 by ariard #+# #+# */ -/* Updated: 2017/01/30 22:11:21 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:52:06 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,8 +20,11 @@ void ft_print_all_ast(t_list *lst_ast) tmp = lst_ast; while (tmp) { - ast = tmp->content; - btree_print(STDBUG, *ast, &ft_putast); + if (tmp->content) + { + ast = tmp->content; + btree_print(STDBUG, *ast, &ft_putast); + } tmp = tmp->next; } } diff --git a/42sh/src/main/shell_script.c b/42sh/src/main/shell_script.c index 2ec9a76c..3c5971b4 100644 --- a/42sh/src/main/shell_script.c +++ b/42sh/src/main/shell_script.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/22 23:06:34 by ariard #+# #+# */ -/* Updated: 2017/01/31 21:55:11 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:21:14 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/.ft_parse.c.swn b/42sh/src/parser/.ft_parse.c.swn new file mode 100644 index 0000000000000000000000000000000000000000..1b104c55853f350931c778f1c199294dcf8d8268 GIT binary patch literal 12288 zcmeI2!Ef7C9LL|dumBwhE@%Sr)=0xix;V~SR@|*>M*@wOrd88W1}esNoW`x^M9;2D zDFqJf3Y7pB{cML)Mnx}^o~uv%^ZUKu_r3RZ zUN3nYm6scfbh=z2xE>?q!@D27^4Y;t40=VIv^d84oC;21JVKMfOOzKbil;#`}9FVE}zEa@%#T=yoS#oCFFH52EIB& z$Tm0&z8fRtP4F!E=@CM1g7?7?48V1;2ByJT@aw~b{0MG=Pr!S?1`D77PJ>?_BIJAU zCHNHF1TL_^8^8e1fTzJ3@Mn&Y-@$L-HuxF*0KNs^fDgbrcoj6jli)7a_XoHIz5pMC zKDZ7#parghS-`!R0rHX#NC%_?(gEp!bl|W92PDVrV262BsT5{N4$nEKR6-Pnqsd$@ zrxZ7%^L^|!XT97jD6ZoNhUo_rH2m-blOaCu`T>`NSdS{BC1~B}qadN68@)ntW)OkV zbG)un6bjj*U~gzcG#G5#o?+b>8oZ%UC=jl++jm@hbdWHOF^Xb#$snG+t3(rZ-m(Wh zB``JuX4|w_;M3)EI+qkdp4*|I6H2^6mv>W&hzl2Hoxr|h&rTDWX3@B|&}gRJ!}lvv?atNqLcQ5cs{EY| zzi+#)=|nszIdntQZxwNw%FjMasp_~%r%?je+>^^zVv#6ffuf@!~FM7k~{ X5%CMP|4Z +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */ -/* Updated: 2017/01/31 18:38:01 by ariard ### ########.fr */ +/* Updated: 2017/01/31 22:15:59 by ariard ### ########.fr */ /* */ /* ************************************************************************** */