diff --git a/42sh/fi b/42sh/fi new file mode 100644 index 00000000..7caa40de --- /dev/null +++ b/42sh/fi @@ -0,0 +1,16 @@ +42sh +Makefile +STDBUG +TESTSHELL +donovan_segaults_06-02 +fi +file +includes +libft +objs +parser_init.c +pdf +sample +src +test_framework.sh +update_makefile.sh diff --git a/42sh/file b/42sh/file index 614d43df..9bda8fd6 100644 --- a/42sh/file +++ b/42sh/file @@ -1,16 +1,15 @@ -total 576 --rwxr-xr-x 1 ariard 2016_paris 249036 Mar 5 17:14 42sh --rw-r--r-- 1 ariard 2016_paris 8133 Mar 5 16:46 Makefile --rw-r--r-- 1 ariard 2016_paris 16999 Mar 5 17:15 STDBUG -drwxr-xr-x 7 ariard 2016_paris 238 Mar 4 14:53 TESTSHELL --rw-r--r-- 1 ariard 2016_paris 4396 Mar 4 14:53 donovan_segaults_06-02 --rw-r--r-- 1 ariard 2016_paris 0 Mar 5 17:15 file -drwxr-xr-x 16 ariard 2016_paris 544 Mar 5 16:46 includes -drwxr-xr-x 12 ariard 2016_paris 408 Mar 5 16:50 libft -drwxr-xr-x 13 ariard 2016_paris 442 Mar 5 16:50 objs --rw-r--r-- 1 ariard 2016_paris 0 Mar 4 14:53 parser_init.c -drwxr-xr-x 6 ariard 2016_paris 204 Mar 4 14:53 pdf -drwxr-xr-x 29 ariard 2016_paris 986 Mar 4 14:53 sample -drwxr-xr-x 14 ariard 2016_paris 476 Mar 4 14:53 src --rwxr-xr-x 1 ariard 2016_paris 890 Mar 4 14:53 test_framework.sh --rwxr-xr-x 1 ariard 2016_paris 690 Mar 4 14:53 update_makefile.sh +42sh +Makefile +STDBUG +TESTSHELL +donovan_segaults_06-02 +file +includes +libft +objs +parser_init.c +pdf +sample +src +test_framework.sh +update_makefile.sh diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index bd2af6e5..49eb2ddc 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -125,7 +125,7 @@ int add_one_func(t_btree **ast, t_list **lst); int add_pipe(t_btree **ast, t_list **lst); int add_var(t_btree **ast, t_list **lst); int add_null(t_btree **ast, t_list **lst); -int add_ionumbr(t_btree **ast, t_list **lst); +int add_ionumber(t_btree **ast, t_list **lst); int isloop(t_btree **ast, t_list **lst); int isloop_condition(t_btree **ast, t_list **lst); @@ -158,7 +158,7 @@ extern t_distrostree g_distrostree[]; struct s_redir { - t_flag type; + t_type type; int n; char *word; /* int close; */ diff --git a/42sh/includes/types.h b/42sh/includes/types.h index bdf68621..68f377fc 100644 --- a/42sh/includes/types.h +++ b/42sh/includes/types.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ -/* Updated: 2017/03/04 19:50:36 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:31:28 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,7 +33,6 @@ typedef struct s_redir t_redir; typedef struct s_cmd t_cmd; typedef union u_astdata t_astdata; typedef union u_word t_word; -typedef long long t_type; typedef int t_condition; typedef struct s_job t_job; diff --git a/42sh/libft b/42sh/libft index 0270e365..318efc7c 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit 0270e3651474c1b20bb0d6873f5c6188ccf43897 +Subproject commit 318efc7cfb7b7cc9d3714fa19fd2be7382b6adec diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index ac516c54..fdf22068 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2017/03/05 15:42:36 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 15:03:36 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index 3cd63335..a56782fa 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/04 17:16:30 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:01:32 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index 8dd68e79..fc41d265 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:08:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 15:04:17 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/process_redirect.c b/42sh/src/exec/process_redirect.c index 35413937..2bb7f19d 100644 --- a/42sh/src/exec/process_redirect.c +++ b/42sh/src/exec/process_redirect.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */ -/* Updated: 2017/03/05 19:40:54 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 15:12:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,11 +33,14 @@ int process_redirect(t_process *p) while (redirs) { redir = redirs->content; + DG("redir type :%s", read_state(redir->type)); + DG("redir word : %s", redir->word); if (redir->n > 9) return (bad_fd(redir->n)); i = 0; while (g_redirmap[i].type) { + DG("process redirect"); if (g_redirmap[i].type == redir->type) { if ((g_redirmap[i].f)(redir)) diff --git a/42sh/src/exec/redirect_great.c b/42sh/src/exec/redirect_great.c index 8b9e2a9b..fee82964 100644 --- a/42sh/src/exec/redirect_great.c +++ b/42sh/src/exec/redirect_great.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */ -/* Updated: 2017/03/05 19:35:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/06 14:58:57 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,7 @@ int redirect_great(t_redir* redir) int fdnew; fdnew = redir->n; + DG("redir great"); if ((fdold = open(redir->word, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) { diff --git a/42sh/src/exec/redirect_less.c b/42sh/src/exec/redirect_less.c index 7942ce1a..c8df2f62 100644 --- a/42sh/src/exec/redirect_less.c +++ b/42sh/src/exec/redirect_less.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:11:13 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:05:40 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,7 @@ int redirect_less(t_redir *redir) int fdnew; fdnew = redir->n; + DG("redirect less"); if ((fdold = open(redir->word, O_RDONLY)) < 0) { ft_dprintf(2, "{red}%s: no such file or directory: %s{eoc}\n", diff --git a/42sh/src/parser/add_case.c b/42sh/src/parser/add_case.c index 077688d1..1a87f15f 100644 --- a/42sh/src/parser/add_case.c +++ b/42sh/src/parser/add_case.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/04 20:42:13 by ariard #+# #+# */ -/* Updated: 2017/03/05 17:30:19 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:11:04 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,7 +34,7 @@ int iscase_pattern(t_btree **ast, t_list **lst) t_astnode *node; t_token *token; - DG(" add pattern"); +// DG(" add pattern"); node = NULL; token = (*lst)->content; if (*ast) diff --git a/42sh/src/parser/add_cmd.c b/42sh/src/parser/add_cmd.c index f0bda953..8a1f255a 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/05 16:34:17 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:57:48 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,6 +27,7 @@ t_distrostree g_distrostree[] = {&iscase, &add_case_cmd}, {&issubshell, &add_subshell_cmd}, {&isfunc, &add_func_cmd}, + {&isionumber, &add_ionumber}, {&isnull, &add_null}, }; diff --git a/42sh/src/parser/add_number.c b/42sh/src/parser/add_number.c index 908cb6d5..7ed5d7de 100644 --- a/42sh/src/parser/add_number.c +++ b/42sh/src/parser/add_number.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 17:28:31 by ariard #+# #+# */ -/* Updated: 2017/03/05 18:19:26 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:56:00 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,6 +38,7 @@ int add_ionumber(t_btree **ast, t_list **lst) t_token *token; t_redir redir; + DG("add io_number"); if (!*ast) gen_node(ast); token = (*lst)->content; diff --git a/42sh/src/parser/add_redir.c b/42sh/src/parser/add_redir.c index 78cce0f4..ce91da7c 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/05 18:14:00 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:54:24 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -67,6 +67,8 @@ int add_redir_word(t_btree **ast, t_list **lst) { DG("add file"); redir = (ft_lstlast(node->data.cmd.redir))->content; + DG("now redir.type :%s", read_state(redir->type)); + DG("n is ? : %d", redir->n); if (redir->type == TK_DLESS) redir->word = NULL; else @@ -80,6 +82,7 @@ int add_redir_type(t_btree **ast, t_list **lst) t_astnode *node; t_token *token; t_redir redir; + t_redir *temp; if (!*ast) gen_node(ast); @@ -87,11 +90,17 @@ int add_redir_type(t_btree **ast, t_list **lst) node = (*ast)->item; if (!(node->type == TK_IO_NUMBER)) { + DG("add redir"); redir.n = (token->type == TK_LESS || token->type == TK_DLESS || token->type == TK_LESSAND) ? STDIN : STDOUT; + redir.type = token->type; ft_lsteadd(&node->data.cmd.redir, ft_lstnew(&redir, sizeof(redir))); } + else + { + temp = (ft_lstlast(node->data.cmd.redir))->content; + temp->type = token->type; + } node->type = REDIR; - redir.type = token->type; return (0); } diff --git a/42sh/src/parser/build_tree.c b/42sh/src/parser/build_tree.c index 0ebefed7..ff3a467b 100644 --- a/42sh/src/parser/build_tree.c +++ b/42sh/src/parser/build_tree.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 18:32:59 by ariard #+# #+# */ -/* Updated: 2017/03/05 15:04:14 by ariard ### ########.fr */ +/* Updated: 2017/03/06 15:55:07 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ t_treematch g_treematch[] = {TK_LESS, &add_cmd}, {TK_DGREAT, &add_cmd}, {TK_DLESS, &add_cmd}, + {TK_IO_NUMBER, &add_cmd}, {TK_OR_IF, &add_sep}, {TK_AND_IF, &add_sep}, {TK_AMP, &add_sep}, diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index 59c0d7b6..b959f9c5 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -37,7 +37,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser) while (*token) { produce_sym(&parser->stack, parser->new_sym, token); - DG("new sym %s", read_state(*parser->new_sym)); +// DG("new sym %s", read_state(*parser->new_sym)); if (eval_sym(&parser->stack, *parser->new_sym)) return ((parser->state = ERROR)); else @@ -52,7 +52,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser) else parser->state = UNDEFINED; build_tree(ast, token); -// btree_print(STDBUG, *ast, &ft_putast); + btree_print(STDBUG, *ast, &ft_putast); if ((end_instruction(&parser->stack) && !(*token)->next)) insert_linebreak(token); else diff --git a/42sh/yolo b/42sh/yolo new file mode 100644 index 00000000..e69de29b