googd redir
This commit is contained in:
parent
975a271bc9
commit
b90a17f2fa
21 changed files with 46 additions and 90 deletions
|
|
@ -6,7 +6,7 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||
# Updated: 2017/03/01 16:42:16 by ariard ### ########.fr #
|
||||
# Updated: 2017/03/03 14:36:32 by ariard ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -62,10 +62,14 @@ exec/ast_free.c\
|
|||
exec/bad_fd.c\
|
||||
exec/exec_ampersand.c\
|
||||
exec/exec_and_if.c\
|
||||
exec/exec_case.c\
|
||||
exec/exec_case_branch.c\
|
||||
exec/exec_command.c\
|
||||
exec/exec_default.c\
|
||||
exec/exec_elif.c\
|
||||
exec/exec_else.c\
|
||||
exec/exec_for.c\
|
||||
exec/exec_func.c\
|
||||
exec/exec_if.c\
|
||||
exec/exec_less.c\
|
||||
exec/exec_or_if.c\
|
||||
|
|
@ -73,11 +77,8 @@ exec/exec_pipe.c\
|
|||
exec/exec_redir.c\
|
||||
exec/exec_semi.c\
|
||||
exec/exec_until.c\
|
||||
exec/exec_while.c\
|
||||
exec/exec_var.c\
|
||||
exec/exec_for.c\
|
||||
exec/exec_case.c\
|
||||
exec/exec_case_branch.c\
|
||||
exec/exec_while.c\
|
||||
exec/fd_is_valid.c\
|
||||
exec/ft_exec.c\
|
||||
exec/ft_findexec.c\
|
||||
|
|
@ -174,9 +175,11 @@ lexer/get_reserved_words.c\
|
|||
lexer/get_state_global.c\
|
||||
lexer/get_state_redir.c\
|
||||
lexer/insert_newline.c\
|
||||
lexer/lexer_assignement_word.c\
|
||||
lexer/lexer_backslash.c\
|
||||
lexer/lexer_bquote.c\
|
||||
lexer/lexer_comment.c\
|
||||
lexer/lexer_curly_brackets.c\
|
||||
lexer/lexer_default.c\
|
||||
lexer/lexer_delim.c\
|
||||
lexer/lexer_dless.c\
|
||||
|
|
@ -191,8 +194,6 @@ lexer/lexer_lex.c\
|
|||
lexer/lexer_newline.c\
|
||||
lexer/lexer_number.c\
|
||||
lexer/lexer_paren.c\
|
||||
lexer/lexer_curly_brackets.c\
|
||||
lexer/lexer_assignement_word.c\
|
||||
lexer/lexer_quote.c\
|
||||
lexer/lexer_sep.c\
|
||||
lexer/lexer_word.c\
|
||||
|
|
@ -228,15 +229,14 @@ main/shell_exit.c\
|
|||
main/shell_get_avdata.c\
|
||||
main/shell_get_opts.c\
|
||||
main/shell_init.c\
|
||||
parser/add_cmd.c\
|
||||
parser/add_subshell.c\
|
||||
parser/add_condition.c\
|
||||
parser/add_loop.c\
|
||||
parser/add_sep.c\
|
||||
parser/add_case.c\
|
||||
parser/add_cmd.c\
|
||||
parser/add_condition.c\
|
||||
parser/add_func.c\
|
||||
parser/add_loop.c\
|
||||
parser/add_redir.c\
|
||||
parser/add_pipe.c\
|
||||
parser/add_sep.c\
|
||||
parser/add_subshell.c\
|
||||
parser/aggregate_sym.c\
|
||||
parser/build_tree.c\
|
||||
parser/error_syntax.c\
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/02 20:36:25 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:33:49 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ enum e_sym
|
|||
FUNC_NAME,
|
||||
CLOSE_LIST,
|
||||
REDIR,
|
||||
JOB,
|
||||
CMD,
|
||||
ALL = 200,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit bfc8ca207ab4d39f0140322c0f1d368137304a3c
|
||||
Subproject commit 8f6e64fa9b4ac1dd3e3d5200fb93471ddfeedd40
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/02 20:39:36 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:34:25 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,8 +17,8 @@ char *ft_putast(void *nodein)
|
|||
t_astnode *node;
|
||||
node = nodein;
|
||||
|
||||
if (node->type == JOB)
|
||||
return ("JOB");
|
||||
if (node->type == CMD)
|
||||
return ("CMD");
|
||||
if (node->type == REDIR)
|
||||
return ("REDIR");
|
||||
if (node->type == CLOSE_LIST)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:53:48 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:33:19 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,8 +16,6 @@ int add_cmd(t_btree **ast, t_list **lst)
|
|||
{
|
||||
t_token *token;
|
||||
t_astnode *node;
|
||||
t_cmd *cmd;
|
||||
t_redir *redir;
|
||||
char **my_tab;
|
||||
|
||||
if ((token = (*lst)->content)->type == TK_IN || token->type == TK_PAREN_OPEN)
|
||||
|
|
@ -47,31 +45,19 @@ int add_cmd(t_btree **ast, t_list **lst)
|
|||
else if (isfunc(ast, lst))
|
||||
return (add_func_cmd(ast, lst));
|
||||
else if ((node = (*ast)->item)->type != TK_DO && node->type != TK_THEN
|
||||
&& node->type != TK_PAREN_CLOSE && node->type != JOB
|
||||
&& node->type != TK_PAREN_CLOSE && node->type != CMD
|
||||
&& node->type != REDIR)
|
||||
return (add_cmd(&(*ast)->right, lst));
|
||||
my_tab = NULL;
|
||||
node = (*ast)->item;
|
||||
node->type = JOB;
|
||||
node->type = CMD;
|
||||
if (token->type == TK_WORD || token->type == TK_ASSIGNEMENT_WORD)
|
||||
{
|
||||
DG("add data");
|
||||
my_tab = ft_sstradd(my_tab, token->data);
|
||||
my_tab = ft_sstradd(my_tab, (char *)token->esc);
|
||||
my_tab = ft_sstradd(my_tab, (char *)token->esc2);
|
||||
if (!node->data.cmds)
|
||||
{
|
||||
DG("new cmd");
|
||||
cmd = ft_memalloc(sizeof(cmd));
|
||||
ft_ld_new(&cmd->token, my_tab);
|
||||
redir = ft_memalloc(sizeof(redir));
|
||||
ft_lsteadd(&cmd->redir, ft_lstnew(redir, sizeof(redir)));
|
||||
ft_lsteadd(&node->data.cmds, ft_lstnew(&cmd, sizeof(t_ld)));
|
||||
}
|
||||
else
|
||||
cmd = ft_lstlast(node->data.cmds)->content;
|
||||
DG("again");
|
||||
ft_ld_pushback(&cmd->token, my_tab);
|
||||
ft_ld_pushback(&node->data.cmd.token, my_tab);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/19 18:12:52 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:40:59 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:21 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/24 23:43:07 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:41:01 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:25 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/17 22:17:14 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:41:02 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:27 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
#include "parser.h"
|
||||
|
||||
int add_pipe(t_btree **ast, t_list **lst)
|
||||
{
|
||||
t_astnode *node;
|
||||
t_cmd *cmd;
|
||||
|
||||
(void)lst;
|
||||
node = (*ast)->item;
|
||||
ft_lsteadd(&node->data.cmds, ft_lstnew(&cmd, sizeof(cmd)));
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 22:01:51 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:35:14 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ int isdir_sep(t_btree **ast, t_list **list)
|
|||
if (*ast)
|
||||
{
|
||||
node = (*ast)->item;
|
||||
if (node->type == JOB
|
||||
if (node->type == CMD
|
||||
&& (token->type == TK_LESS || token->type == TK_GREAT
|
||||
|| token->type == TK_GREATAND || token->type == TK_LESSAND
|
||||
|| token->type == TK_DLESS || token->type == TK_DGREAT))
|
||||
|
|
@ -47,7 +47,7 @@ int isdir_word(t_btree **ast, t_list **list)
|
|||
{
|
||||
node = (*ast)->item;
|
||||
if (token->type == TK_WORD && node->type == REDIR)
|
||||
return ((node->type = JOB));
|
||||
return ((node->type = CMD));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -57,19 +57,17 @@ int add_redir_word(t_btree **ast, t_list **lst)
|
|||
t_astnode *node;
|
||||
t_token *token;
|
||||
t_redir *redir;
|
||||
t_cmd *cmd;
|
||||
|
||||
token = (*lst)->content;
|
||||
node = (*ast)->item;
|
||||
cmd = (ft_lstlast(node->data.cmds))->content;
|
||||
if (cmd->redir)
|
||||
if (node->data.cmd.redir)
|
||||
{
|
||||
DG("add file");
|
||||
redir = (ft_lstlast(cmd->redir))->content;
|
||||
redir = (ft_lstlast(node->data.cmd.redir))->content;
|
||||
if (redir->type == TK_DLESS)
|
||||
redir->word.word = NULL;
|
||||
// else if (ft_stris((char *)token->data, &ft_isdigit))
|
||||
// redir->word.fd = ft_atoi(token->data);
|
||||
else if (ft_stris((char *)token->data, &ft_isdigit))
|
||||
redir->word.fd = ft_atoi(token->data);
|
||||
else
|
||||
redir->word.word = token->data;
|
||||
}
|
||||
|
|
@ -81,7 +79,6 @@ int add_redir_type(t_btree **ast, t_list **lst)
|
|||
t_astnode *node;
|
||||
t_token *token;
|
||||
t_redir *redir;
|
||||
t_cmd *cmd;
|
||||
|
||||
DG("add redir");
|
||||
if (!*ast)
|
||||
|
|
@ -91,21 +88,6 @@ int add_redir_type(t_btree **ast, t_list **lst)
|
|||
node->type = REDIR;
|
||||
redir = ft_memalloc(sizeof(redir));
|
||||
redir->type = token->type;
|
||||
if (!node->data.cmds)
|
||||
{
|
||||
cmd = ft_memalloc(sizeof(cmd));
|
||||
cmd->token = NULL;
|
||||
cmd->redir = NULL;
|
||||
node->data.cmds = ft_lstnew(&cmd, sizeof(cmd));
|
||||
}
|
||||
cmd = ft_lstlast(node->data.cmds)->content;
|
||||
DG("still");
|
||||
if (!cmd->redir)
|
||||
cmd->redir = ft_lstnew(redir, sizeof(redir));
|
||||
else
|
||||
{
|
||||
DG("flag");
|
||||
ft_lsteadd(&cmd->redir, ft_lstnew(redir, sizeof(redir)));
|
||||
}
|
||||
ft_lsteadd(&node->data.cmd.redir, ft_lstnew(redir, sizeof(redir)));
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:41:07 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:40 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/24 18:41:50 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:41:11 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:44 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 17:39:18 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:41:13 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:46 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:41:15 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:35:40 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
t_treematch g_treematch[] =
|
||||
{
|
||||
{TK_WORD, &add_cmd},
|
||||
{TK_PIPE, &add_pipe},
|
||||
{TK_PIPE, &add_sep},
|
||||
{TK_SEMI, &add_sep},
|
||||
{TK_GREAT, &add_cmd},
|
||||
{TK_LESS, &add_cmd},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 20:15:35 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/01 16:53:53 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:27:52 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/21 16:14:04 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:40:37 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:28:00 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 19:12:44 by ariard #+# #+# */
|
||||
/* Updated: 2017/02/15 19:52:42 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:28:02 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 17:58:34 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:40:41 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:28:05 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 16:48:30 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:40:45 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:28:09 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 15:32:10 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:40:47 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:28:12 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 18:57:44 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/02 21:40:48 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/03 14:28:14 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue