permet de compiler

This commit is contained in:
wescande 2017-03-07 21:25:40 +01:00
parent 8c2103fa1b
commit bac6e9d6d8
34 changed files with 90 additions and 75 deletions

View file

@ -58,6 +58,7 @@ 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\

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/03/07 20:55:11 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:08:54 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,7 @@
# define EXEC_H
# include <sys/stat.h>
# include "minishell.h"
# define PIPE_READ 0
# define PIPE_WRITE 1
@ -146,8 +147,6 @@ int exec_var(t_btree **ast);
int exec_case_branch(t_btree **ast);
int exec_math(t_btree **ast);
int launch_process(t_process *p);
int set_process(t_process *p, t_btree *ast);
int process_setexec(t_process *p);
int process_setgroup(t_process *p, pid_t pid);
void process_setsig(void);
@ -175,15 +174,25 @@ void redir_free(void *data, size_t content_size);
char **token_to_argv(t_ld *ld, int do_match);
# include <sys/stat.h>
int add_new_job(t_job *job);
int error_badidentifier(char *name);
/*
** Mapping pour launch les process
*/
int launch_process(t_process *p);
int launch_if(t_process *p);
int launch_while(t_process *p);
int launch_for(t_process *p);
int launch_case(t_process *p);
int launch_file(t_process *p);
int launch_builtin(t_process *p);
/*
** Mapping pour set les process
*/
int set_process(t_process *p, t_btree *ast);
int set_process_map(t_process *p, t_btree *ast, t_cmd *cmd);
int set_process_cmd(t_process *p, t_btree *ast, t_cmd *cmd);
#endif

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
/* Updated: 2017/03/07 18:38:08 by jhalford ### ########.fr */
/* Updated: 2017/03/07 21:13:31 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@
# include <fcntl.h>
# include <errno.h>
# include "libft.h"
# include "../libft/includes/libft.h"
# include "types.h"
# include "lexer.h"
# include "parser.h"

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:44:42 by wescande #+# #+# */
/* Updated: 2017/03/07 20:50:43 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:25:15 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec.h"
#include "minishell.h"
t_btree *ast_copy(t_btree *tree)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:02:23 by wescande #+# #+# */
/* Updated: 2017/03/07 20:38:19 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:02:46 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec.h"
#include "minishell.h"
/*
int exec_case(t_btree **ast)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:34:43 by wescande #+# #+# */
/* Updated: 2017/03/07 19:00:56 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:02:18 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec.h"
#include "minishell.h"
static int do_for(t_process *p)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:26:53 by wescande #+# #+# */
/* Updated: 2017/03/07 18:36:02 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:03:04 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec.h"
#include "minishell.h"
static int do_if(t_process *p)
{

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */
/* Updated: 2017/03/07 20:58:52 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:07:33 by wescande ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,13 +6,13 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/06 15:12:23 by ariard ### ########.fr */
/* Updated: 2017/03/07 21:04:38 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
t_redirmap g_redirmap[] =
t_itof g_redirmap[] =
{
{TK_LESS, redirect_less},
{TK_GREAT, redirect_great},
@ -38,10 +38,10 @@ int process_redirect(t_process *p)
if (redir->n > 9)
return (bad_fd(redir->n));
i = 0;
while (g_redirmap[i].type)
while (g_redirmap[i].id)
{
DG("process redirect");
if (g_redirmap[i].type == redir->type)
if (g_redirmap[i].id == redir->type)
{
if ((g_redirmap[i].f)(redir))
return (1);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/07 15:34:31 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:12:02 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,7 @@ int set_process(t_process *p, t_btree *ast)
p->redirs = ft_lstmap(cmd->redir, ft_id);
if (set_process_map(p, ast, cmd))
return (1);
if (exec->control_count)
p->attrs |= PROCESS_CONTROL;
// if (exec->control_count)
// p->attrs |= PROCESS_CONTROL;
return (0);
}

View file

@ -6,14 +6,15 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:36:04 by wescande #+# #+# */
/* Updated: 2017/03/07 20:51:41 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:14:19 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec.h"
#include "minishell.h"
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);
return (0);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:06:05 by wescande #+# #+# */
/* Updated: 2017/03/07 15:50:51 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:12:31 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,7 @@
int set_process_cmd(t_process *p, t_btree *ast, t_cmd *cmd)
{
(void)ast;
if (!(p->data.cmd.av = token_to_argv(cmd->token, 1)))
return (1);
process_setexec(p);

View file

@ -6,14 +6,15 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:38:05 by wescande #+# #+# */
/* Updated: 2017/03/07 20:51:57 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:14:33 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "exec.h"
#include "minishell.h"
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);
return (0);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:19:50 by wescande #+# #+# */
/* Updated: 2017/03/07 20:35:16 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:10:47 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,8 @@
int set_process_if(t_process *p, t_btree *ast, t_cmd *cmd)
{
p->data.d_if.condition = btree_map(ast->left, ast_copy);
p->data.d_if.content = btree_map(ast->right, ast_copy);
(void)cmd;
p->data.d_if.condition = ast_copy(ast->left);
p->data.d_if.content = ast_copy(ast->right);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:38:10 by wescande #+# #+# */
/* Updated: 2017/03/07 20:51:24 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:11:38 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,7 @@
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);
return (0);

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:04:40 by wescande #+# #+# */
/* Updated: 2017/03/07 20:07:31 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:14:55 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
char **gen_tab(const char *pat,
const unsigned char *esc,

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 19:56:49 by wescande #+# #+# */
/* Updated: 2017/01/05 14:17:11 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:18:59 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_ld_clear(t_ld **ld, void (*del)())
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:42:23 by wescande #+# #+# */
/* Updated: 2017/03/07 20:29:28 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:21:30 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
t_ld *ft_ld_copy(t_ld *src, void *(*f)(void *elem))
{
@ -21,9 +21,9 @@ t_ld *ft_ld_copy(t_ld *src, void *(*f)(void *elem))
while (src)
{
content = (*f)(src->content);
ft_ld_pushfront(dst, content);
ft_ld_pushfront(&dst, content);
src = src->next;
}
ft_ld_reverse(dst);
ft_ld_reverse(&dst);
return (dst);
}

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 15:54:53 by wescande #+# #+# */
/* Updated: 2017/01/05 14:17:18 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:17:50 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_ld_del(t_ld **ld, void (*del)())
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 18:17:34 by wescande #+# #+# */
/* Updated: 2017/02/03 14:38:19 by ariard ### ########.fr */
/* Updated: 2017/03/07 21:17:20 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_ld_new(t_ld **alst, void *content)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/24 19:20:45 by wescande #+# #+# */
/* Updated: 2017/01/24 19:40:54 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:19:13 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
t_ld *ft_ld_order(t_ld *ld, int (*f)(), void (*del)())
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/16 15:59:38 by wescande #+# #+# */
/* Updated: 2017/02/17 23:33:37 by ariard ### ########.fr */
/* Updated: 2017/03/07 21:17:28 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_ld_pushback(t_ld **alst, void *content)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 18:32:40 by wescande #+# #+# */
/* Updated: 2017/01/05 14:17:46 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:15:42 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_ld_pushfront(t_ld **alst, void *content)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 14:16:04 by wescande #+# #+# */
/* Updated: 2017/01/05 14:17:53 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:20:35 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_ld_reverse(t_ld **lst)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 18:33:48 by wescande #+# #+# */
/* Updated: 2017/02/03 14:38:07 by ariard ### ########.fr */
/* Updated: 2017/03/07 21:19:26 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
size_t ft_ld_size(t_ld *ld)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:17:00 by wescande #+# #+# */
/* Updated: 2017/01/05 16:22:12 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:20:05 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
char **ft_ld_to_tab(t_ld *ld)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/05 13:44:36 by wescande #+# #+# */
/* Updated: 2017/02/09 17:01:01 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:19:39 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void *ft_memrealloc(void *ptr, size_t old_s, size_t new_s)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/05 13:33:24 by wescande #+# #+# */
/* Updated: 2017/01/24 16:53:13 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:19:55 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
char *ft_strjoinf(char *s1, char *s2, int state)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/15 17:20:08 by wescande #+# #+# */
/* Updated: 2017/02/07 13:01:55 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:20:19 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
char *ft_strsubf(char *s, unsigned int start, size_t len, short int mode)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/04 16:29:54 by wescande #+# #+# */
/* Updated: 2017/02/02 14:22:46 by jhalford ### ########.fr */
/* Updated: 2017/03/07 21:18:08 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
void ft_tabdel(char ***mytab)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/28 16:54:07 by wescande #+# #+# */
/* Updated: 2016/12/28 16:55:46 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:18:23 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "minishell.h"
int ft_tablen(char **mytab)
{

View file

@ -6,11 +6,11 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 18:59:11 by wescande #+# #+# */
/* Updated: 2017/03/07 18:59:38 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:20:53 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "glob.h"
#include "minishell.h"
int word_is_assignment(char **content)
{

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */
/* Updated: 2017/03/07 14:46:12 by wescande ### ########.fr */
/* Updated: 2017/03/07 21:24:17 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -42,7 +42,7 @@ static void process_format_com_long(t_list **plist)
t_process *p;
p = (*plist)->content;
if (p->attrs & PROCESS_CONTROL)
/* if (p->attrs & PROCESS_CONTROL)
ft_putstr("script");
else if (p->attrs & PROCESS_SUBSHELL)
{
@ -50,7 +50,7 @@ static void process_format_com_long(t_list **plist)
// ft_putstr(p->data.cmd.av[2]);
ft_putstr(" )");
}
else
else*/
ft_sstrprint(p->data.cmd.av, ' ');
if ((*plist)->next)
ft_putstr(" |");
@ -72,7 +72,7 @@ static void process_format_com_short(t_list **plist, t_flag state)
p->attrs &= ~PROCESS_STATE_MASK;
p->attrs &= ~PROCESS_RUNNING;
}
if (p->attrs & PROCESS_CONTROL)
/* if (p->attrs & PROCESS_CONTROL)
ft_putstr("script");
else if (p->attrs & PROCESS_SUBSHELL)
{
@ -80,7 +80,7 @@ static void process_format_com_short(t_list **plist, t_flag state)
ft_putstr(p->data.cmd.av[2]);
ft_putstr(" )");
}
else
else*/
ft_sstrprint(p->data.cmd.av, ' ');
if ((*plist)->next)
ft_putstr(" | ");

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:58:34 by ariard #+# #+# */
/* Updated: 2017/03/07 18:47:55 by ariard ### ########.fr */
/* Updated: 2017/03/07 21:24:40 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -60,7 +60,7 @@ t_prodmatch g_prodmatch[] =
{TK_ASSIGNEMENT_WORD, TK_BANG, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, SEPARATOR_OP, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, NEWLINE_LIST, CMD_PREFIX},
{TK_NAME, TK_BAMG, FNAME},
{TK_NAME, TK_BANG, FNAME},
{TK_NAME, LINEBREAK, FNAME},
{TK_NAME, TK_PAREN_OPEN, FNAME},
{TK_NAME, TK_LBRACE, FNAME},