diff --git a/42sh/src/builtin/is_builtin.c b/42sh/src/builtin/is_builtin.c index 4f43e139..7c2a8769 100644 --- a/42sh/src/builtin/is_builtin.c +++ b/42sh/src/builtin/is_builtin.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); } diff --git a/42sh/src/completion/c_match.c b/42sh/src/completion/c_match.c index 4df444b5..03b81a0b 100644 --- a/42sh/src/completion/c_match.c +++ b/42sh/src/completion/c_match.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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, '$')) diff --git a/42sh/src/exec/pfree_cond.c b/42sh/src/exec/pfree_cond.c index 7f330d3c..6bbb757d 100644 --- a/42sh/src/exec/pfree_cond.c +++ b/42sh/src/exec/pfree_cond.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); } diff --git a/42sh/src/exec/plaunch_case.c b/42sh/src/exec/plaunch_case.c index 753d221c..85806831 100644 --- a/42sh/src/exec/plaunch_case.c +++ b/42sh/src/exec/plaunch_case.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); diff --git a/42sh/src/exec/plaunch_function.c b/42sh/src/exec/plaunch_function.c index af12c567..87c7e34c 100644 --- a/42sh/src/exec/plaunch_function.c +++ b/42sh/src/exec/plaunch_function.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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, "?"))); } diff --git a/42sh/src/exec/process_launch.c b/42sh/src/exec/process_launch.c index 4a7c5825..4566bd1b 100644 --- a/42sh/src/exec/process_launch.c +++ b/42sh/src/exec/process_launch.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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; diff --git a/42sh/src/exec/process_redirect.c b/42sh/src/exec/process_redirect.c index b8ac4278..ce1025cc 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/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; diff --git a/42sh/src/exec/process_set.c b/42sh/src/exec/process_set.c index 15d7d29f..2c12279c 100644 --- a/42sh/src/exec/process_set.c +++ b/42sh/src/exec/process_set.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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) diff --git a/42sh/src/exec/redirect_dgreat.c b/42sh/src/exec/redirect_dgreat.c index 66fc6881..b1164f94 100644 --- a/42sh/src/exec/redirect_dgreat.c +++ b/42sh/src/exec/redirect_dgreat.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* redirect_dgreat.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); } diff --git a/42sh/src/exec/redirect_great.c b/42sh/src/exec/redirect_great.c index 24506564..49f59d8e 100644 --- a/42sh/src/exec/redirect_great.c +++ b/42sh/src/exec/redirect_great.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* redirect_great.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); } diff --git a/42sh/src/exec/set_exitstatus.c b/42sh/src/exec/set_exitstatus.c index c3f2e8e3..08e20c5a 100644 --- a/42sh/src/exec/set_exitstatus.c +++ b/42sh/src/exec/set_exitstatus.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* set_exitstatus.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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,10 +26,7 @@ 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); diff --git a/42sh/src/glob/command_getoutput.c b/42sh/src/glob/command_getoutput.c index f51688a7..471d0887 100644 --- a/42sh/src/glob/command_getoutput.c +++ b/42sh/src/glob/command_getoutput.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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", diff --git a/42sh/src/history/list_toolz.c b/42sh/src/history/list_toolz.c index bdf71e76..1c2008fa 100644 --- a/42sh/src/history/list_toolz.c +++ b/42sh/src/history/list_toolz.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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) diff --git a/42sh/src/job_control/process_free.c b/42sh/src/job_control/process_free.c index 8ffb939d..49e4d7fb 100644 --- a/42sh/src/job_control/process_free.c +++ b/42sh/src/job_control/process_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); - free(p); + if (content_size) + free(p); } diff --git a/42sh/src/lexer/isrw_delim.c b/42sh/src/lexer/isrw_delim.c index 5f191584..a7903f29 100644 --- a/42sh/src/lexer/isrw_delim.c +++ b/42sh/src/lexer/isrw_delim.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* istoken.c :+: :+: :+: */ +/* isrw_delim.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* 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 */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index f5f5a4d6..b9478e50 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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(); diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 0dc2c0f3..0def2805 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); diff --git a/42sh/src/parser/add_bang.c b/42sh/src/parser/add_bang.c index 6a6752fb..a4ca0eb6 100644 --- a/42sh/src/parser/add_bang.c +++ b/42sh/src/parser/add_bang.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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 diff --git a/42sh/src/parser/add_condition.c b/42sh/src/parser/add_condition.c index db5ea7de..65f4e323 100644 --- a/42sh/src/parser/add_condition.c +++ b/42sh/src/parser/add_condition.c @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* add_if.c :+: :+: :+: */ +/* add_condition.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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;