Merge branch 'pda' of github.com:jzck/42sh into pda
This commit is contained in:
commit
b3e03c71c7
29 changed files with 97 additions and 52 deletions
|
|
@ -58,7 +58,6 @@ completion/c_rematch.c\
|
|||
completion/c_sizing.c\
|
||||
completion/c_terminal.c\
|
||||
completion/completion.c\
|
||||
exec/ast_copy.c\
|
||||
exec/ast_free.c\
|
||||
exec/bad_fd.c\
|
||||
exec/error_badidentifier.c\
|
||||
|
|
@ -96,6 +95,8 @@ exec/process_setexec.c\
|
|||
exec/process_setgroup.c\
|
||||
exec/process_setsig.c\
|
||||
exec/redir_free.c\
|
||||
exec/redir_copy.c\
|
||||
exec/node_copy.c\
|
||||
exec/redirect_dgreat.c\
|
||||
exec/redirect_dless.c\
|
||||
exec/redirect_great.c\
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 02:38:42 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 03:05:38 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -176,7 +176,9 @@ char *ft_findexec(char *path, char *file);
|
|||
void set_exitstatus(int status, int override);
|
||||
|
||||
void ast_free(void *data, size_t content_size);
|
||||
t_btree *ast_copy(t_btree *tree);
|
||||
void *node_copy(void *data);
|
||||
void *redir_copy(void *data);
|
||||
|
||||
void redir_free(void *data, size_t content_size);
|
||||
|
||||
char **token_to_argv(t_ld *ld, int do_match);
|
||||
|
|
|
|||
6
42sh/laurier.sh
Normal file
6
42sh/laurier.sh
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
read -p "Quel est ton login ?" login
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "Tu es le meilleur codeur de l'ecole $login"
|
||||
sleep 1
|
||||
done
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/07 18:34:27 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/08 00:59:53 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/06 20:42:20 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/04 18:16:38 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/08 02:09:21 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 00:21:22 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 01:48:55 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
36
42sh/src/exec/node_copy.c
Normal file
36
42sh/src/exec/node_copy.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ast_copy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 20:44:42 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/08 01:00:05 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void *node_copy(void *data)
|
||||
{
|
||||
t_astnode *new;
|
||||
t_astnode *old;
|
||||
|
||||
if (!data)
|
||||
return (NULL);
|
||||
old = data;
|
||||
ft_bzero((void *)&new, sizeof(t_astdata));
|
||||
new->nest = old->nest;
|
||||
new->full = old->full;
|
||||
new->type = old->type;
|
||||
new->pattern = old->pattern;
|
||||
if (old->type == CMD || old->type == TK_ASSIGNEMENT_WORD)
|
||||
{
|
||||
new->data.cmd.redir = ft_lstdup(&old->data.cmd.redir, &redir_copy);
|
||||
new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
|
||||
}
|
||||
if (old->type == TK_FOR || old->type == TK_PAREN_OPEN || old->type == TK_CASE)
|
||||
new->data.cmd.wordlist = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
|
||||
return (new);
|
||||
}
|
||||
|
|
@ -1,25 +1,28 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ast_copy.c :+: :+: :+: */
|
||||
/* redir_copy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 20:44:42 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/07 21:25:15 by wescande ### ########.fr */
|
||||
/* Created: 2017/03/08 00:02:58 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/08 00:41:57 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
t_btree *ast_copy(t_btree *tree)
|
||||
void *redir_copy(void *data)
|
||||
{
|
||||
t_btree *node;
|
||||
t_redir *old;
|
||||
t_redir *new;
|
||||
|
||||
if (!tree)
|
||||
if (!data)
|
||||
return (NULL);
|
||||
node = btree_create_node(tree->item, tree->content_size);
|
||||
node->left = ast_copy(tree->left);
|
||||
node->right = ast_copy(tree->right);
|
||||
return (node);
|
||||
}
|
||||
old = data;
|
||||
ft_bzero((void *)&new, sizeof(t_astdata));
|
||||
new->type = old->type;
|
||||
new->n = old->n;
|
||||
new->word = ft_strdup(old->word);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 20:36:04 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/07 22:01:20 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 01:49:48 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ int set_process_case(t_process *p, t_btree *ast, t_cmd *cmd)
|
|||
{
|
||||
(void)cmd;
|
||||
p->data.d_case.list_word = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.wordlist, tab_esc_copy);
|
||||
p->data.d_case.content = ast_copy(ast->right);
|
||||
p->data.d_case.content = btree_map(ast->right, &node_copy);
|
||||
p->type = PROCESS_CASE;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 19:38:05 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/07 22:00:34 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 01:50:33 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ int set_process_for(t_process *p, t_btree *ast, t_cmd *cmd)
|
|||
{
|
||||
(void)cmd;
|
||||
p->data.d_for.list_word = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.wordlist, tab_esc_copy);
|
||||
p->data.d_for.content = ast_copy(ast->right);
|
||||
p->data.d_for.content = btree_map(ast->right, &node_copy);
|
||||
p->type = PROCESS_FOR;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 19:19:50 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/07 21:59:44 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 01:51:09 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
int set_process_if(t_process *p, t_btree *ast, t_cmd *cmd)
|
||||
{
|
||||
(void)cmd;
|
||||
p->data.d_if.condition = ast_copy(ast->left);
|
||||
p->data.d_if.content = ast_copy(ast->right);
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/08 00:02:01 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/08 00:14:44 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 01:52:45 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
int set_process_subshell(t_process *p, t_btree *ast, t_cmd *cmd)
|
||||
{
|
||||
(void)cmd;
|
||||
p->data.subshell.content = ast_copy(ast->right);
|
||||
p->data.subshell.content = btree_map(ast->right, &node_copy);
|
||||
p->type = PROCESS_SUBSHELL;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 22:22:24 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/08 02:35:27 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 03:06:03 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
int set_process_until(t_process *p, t_btree *ast, t_cmd *cmd)
|
||||
{
|
||||
(void)cmd;
|
||||
p->data.d_until.condition = ast_copy(ast->left);
|
||||
p->data.d_until.content = ast_copy(ast->right);
|
||||
p->data.d_while.condition = btree_map(ast->left, &node_copy);
|
||||
p->data.d_while.content = btree_map(ast->right, &node_copy);
|
||||
p->type = PROCESS_UNTIL;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 19:38:10 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/07 21:57:55 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 01:51:38 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,8 +15,8 @@
|
|||
int set_process_while(t_process *p, t_btree *ast, t_cmd *cmd)
|
||||
{
|
||||
(void)cmd;
|
||||
p->data.d_while.condition = ast_copy(ast->left);
|
||||
p->data.d_while.content = ast_copy(ast->right);
|
||||
p->data.d_while.condition = btree_map(ast->left, &node_copy);
|
||||
p->data.d_while.content = btree_map(ast->right, &node_copy);
|
||||
p->type = PROCESS_WHILE;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 19:42:23 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/07 21:21:30 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 00:58:50 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 00:36:12 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 02:03:58 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 02:38:47 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/08 03:07:01 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/07 19:40:52 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 20:26:36 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
#include "lexer.h"
|
||||
|
||||
int lexer_sep(t_list **alst, t_lexer *lexer)
|
||||
{
|
||||
|
|
@ -37,11 +37,8 @@ int lexer_sep(t_list **alst, t_lexer *lexer)
|
|||
token->type = cn == '&' ? TK_AND_IF : TK_AMP;
|
||||
else if (c == '|')
|
||||
token->type = cn == '|' ? TK_OR_IF : TK_PIPE;
|
||||
else if (c == '!')
|
||||
token->type = TK_BANG;
|
||||
token->type = (c == ';') ? TK_SEMI : token->type;
|
||||
token->type = (c == ';') && (cn == ';') ? TK_DSEMI : token->type;
|
||||
// c est ici que ca bug, ca marche plus les bitwise sur des enums
|
||||
lexer->pos += 1 + (token->type & (TK_AND_IF | TK_OR_IF | TK_DSEMI) ? 1 : 0);
|
||||
return (lexer_lex(&(*alst)->next, lexer));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/05 14:57:19 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 23:35:32 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ int instruction_free(t_list **token, t_parser *parser, t_btree **ast)
|
|||
ft_lstdel(&parser->stack, NULL);
|
||||
btree_del(ast, &ast_free);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/07 16:41:02 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/07 21:53:23 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/04 20:42:13 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/07 19:32:45 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:46:00 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/19 18:12:52 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/05 15:32:49 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:46:10 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/06 19:06:03 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:46:20 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/06 15:54:24 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:46:46 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/04 21:43:00 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:46:57 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/05 15:34:12 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:46:36 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/03 15:08:16 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/07 14:40:21 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 22:47:38 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/06 19:01:18 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/08 00:02:46 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue