modifs historique delim

This commit is contained in:
Antoine Riard 2017-03-20 19:14:16 +01:00
commit f72e8dbe3c
19 changed files with 33 additions and 54 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
/* Updated: 2017/03/18 00:53:53 by wescande ### ########.fr */
/* Updated: 2017/03/20 18:14:20 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,10 +41,7 @@ t_execf *is_builtin(t_process *p)
while (g_builtin[++i].name)
{
if (ft_strcmp(g_builtin[i].name, p->data.cmd.av[0]) == 0)
{
DG();
return (g_builtin[i].f);
}
}
return (NULL);
}

View file

@ -6,7 +6,7 @@
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
/* Updated: 2017/03/20 14:41:04 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:14:35 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -63,7 +63,6 @@ int c_matching(t_data *s, t_comp *c)
char *current_word;
current_word = c_current_words(c);
DG("current_word = %s", current_word);
if (ft_strchr(c->rcmd, '/'))
c_seek_abs_path(c, current_word);
else if (ft_strchr(c->rcmd, '$'))

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 02:26:31 by wescande #+# #+# */
/* Updated: 2017/03/20 19:12:13 by ariard ### ########.fr */
/* Updated: 2017/03/20 19:13:40 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,5 +16,6 @@ int pfree_cond(t_process *p)
{
btree_del(&p->data.d_while.condition, &ast_free);
btree_del(&p->data.d_while.content, &ast_free);
btree_del(&p->data.d_while.condition, &ast_free);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:02:23 by wescande #+# #+# */
/* Updated: 2017/03/20 15:50:14 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:15:17 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,7 +16,6 @@ int plaunch_case(t_process *p)
{
t_exec *exec;
DG("exec case");
exec = &data_singleton()->exec;
exec->attrs &= ~EXEC_CASE_BRANCH;
exec->case_pattern = token_to_argv(p->data.d_case.token, 1);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 03:23:59 by wescande #+# #+# */
/* Updated: 2017/03/20 15:50:21 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:15:21 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,6 @@
int plaunch_function(t_process *p)
{
DG("do function");
ft_exec(&p->data.function.content);
return (ft_atoi(ft_getenv(data_singleton()->env, "?")));
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:58:12 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:41:25 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,6 +58,7 @@ int process_launch(t_process *p)
if (!(pid = do_the_fork_if_i_have_to(p)))
{
process_resetfds(p);
process_free(p, 0);
return (1);
}
p->pid = pid;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 16:04:18 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:57:02 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:38:13 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,7 +26,7 @@ t_itof g_redirmap[] =
static void process_close(int fd1, int fd2)
{
if (fd1 != fd2)
close(fd1);
dup2_close(fd1, fd2);
}
int process_redirect(t_process *p)
@ -36,7 +36,8 @@ int process_redirect(t_process *p)
int i;
redirs = p->redirs;
process_close(p->to_close, STDIN);
if (p->to_close != STDIN)
close(p->to_close);
while (redirs)
{
redir = redirs->content;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/20 17:07:01 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:50:44 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -50,6 +50,7 @@ int process_set(t_process *p, t_btree *ast)
int op;
int fds[2];
ft_bzero(p, sizeof(t_process));
exec = &data_singleton()->exec;
op = pop(&exec->op_stack);
if ((EXEC_IS_AND_IF(exec->attrs)

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* redirect_dgreat.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */
/* Updated: 2017/03/05 18:10:36 by ariard ### ########.fr */
/* Updated: 2017/03/20 18:15:39 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,10 +20,7 @@ int redirect_dgreat(t_redir *redir)
fdnew = redir->n;
if ((fdold = open(redir->word,
O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
{
DG("open errno=%i", errno);
exit(1);
}
dup2(fdold, fdnew);
return (0);
}

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* redirect_great.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */
/* Updated: 2017/03/20 12:38:41 by jhalford ### ########.fr */
/* Updated: 2017/03/20 18:15:43 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,10 +20,7 @@ int redirect_great(t_redir *redir)
fdnew = redir->n;
if ((fdold = open(redir->word,
O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
{
DG("open errno=%i", errno);
exit(1);
}
dup2(fdold, fdnew);
return (0);
}

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */
/* set_exitstatus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/20 15:35:33 by jhalford ### ########.fr */
/* Updated: 2017/03/20 18:15:50 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,11 +26,8 @@ void set_exitstatus(int status, int override)
else if (WIFSIGNALED(status))
exitval = 128 + WTERMSIG(status);
else
{
DG("%s: process was not exited nor signaled.", SHELL_NAME);
return ;
}
}
astatus = ft_itoa(exitval);
builtin_setenv("setenv", (char*[]){"setenv", "?", astatus, 0}, NULL);
ft_strdel(&astatus);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/14 19:44:25 by wescande #+# #+# */
/* Updated: 2017/03/20 15:10:40 by wescande ### ########.fr */
/* Updated: 2017/03/20 18:16:20 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -63,7 +63,6 @@ static void execute_command(char *const av[], char **env)
data->opts &= ~SH_INTERACTIVE;
data->opts &= ~SH_OPTS_JOBC;
command = manage_command(av);
DG("command is %s", command);
if (do_lexer_routine(&token, command))
{
ft_dprintf(2, "{red}%s: syntax error in command substitution{eoc}\n",

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */
/* Updated: 2017/03/16 12:10:14 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:16:45 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,7 +18,6 @@ void free_history_list(t_list_history *head)
if (!head)
return ;
DG("free hist");
if (head->next)
free(head->next);
while (head)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
/* Updated: 2017/03/20 12:55:37 by jhalford ### ########.fr */
/* Updated: 2017/03/20 18:58:03 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,5 +21,6 @@ void process_free(void *content, size_t content_size)
if (p->map.free)
(p->map.free)(p);
ft_lstdel(&p->redirs, redir_free);
if (content_size)
free(p);
}

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* istoken.c :+: :+: :+: */
/* isrw_delim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 15:54:23 by ariard #+# #+# */
/* Updated: 2017/03/20 19:11:47 by ariard ### ########.fr */
/* Created: 2017/03/20 19:12:50 by ariard #+# #+# */
/* Updated: 2017/03/20 19:12:51 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
/* Updated: 2017/03/20 14:46:44 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:12:18 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -65,10 +65,8 @@ int main(int ac, char **av)
g_argv = av;
setlocale(LC_ALL, "");
DG("{inv}{bol}{gre}start of shell{eoc}");
if (shell_init(ac, av) != 0)
return (1);
DG("JOBC is %s", SH_HAS_JOBC(data_singleton()->opts) ? "ON" : "OFF");
token = NULL;
ast = NULL;
data = data_singleton();

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/20 14:54:28 by gwojda ### ########.fr */
/* Updated: 2017/03/20 18:12:27 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -100,22 +100,17 @@ int shell_init(int ac, char **av)
t_data *data;
data = data_singleton();
DG();
if (data_init(ac, av) < 0)
return (-1);
DG();
if (cliopts_get(av, g_opts, data))
{
usage();
return (ft_perror());
}
DG();
if (!isatty(STDIN) || *data->av_data)
data->opts &= ~(SH_INTERACTIVE | SH_OPTS_JOBC);
DG();
if ((data->fd = get_input_fd(data)) < 0)
return (-1);
DG();
if (SH_IS_INTERACTIVE(data->opts) && interactive_settings() < 0)
return (-1);
return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/10 14:57:45 by ariard #+# #+# */
/* Updated: 2017/03/13 20:36:01 by ariard ### ########.fr */
/* Updated: 2017/03/20 18:11:11 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -55,7 +55,6 @@ int add_bang(t_btree **ast, t_list **lst)
t_astnode *node;
t_token *token;
DG("add bang");
token = (*lst)->content;
node = (*ast)->item;
if ((token->type == TK_CASE || token->type == TK_WHILE

View file

@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* add_if.c :+: :+: :+: */
/* add_condition.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/10 17:06:16 by ariard #+# #+# */
/* Updated: 2017/03/13 20:46:40 by ariard ### ########.fr */
/* Updated: 2017/03/20 18:11:18 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -88,7 +88,6 @@ int add_if(t_btree **ast, t_list **lst)
t_token *token;
t_astnode *node;
DG("add if");
token = (*lst)->content;
node = (*ast)->item;
node->type = TK_IF;