From 4a46f6db577150a7e1b8b4bbb2c6e89e397b6c32 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 13 Mar 2017 14:13:33 +0100 Subject: [PATCH 1/3] heredoc fix --- 42sh/includes/job_control.h | 2 +- 42sh/includes/parser.h | 2 +- 42sh/src/exec/exec_leaf.c | 5 +++-- 42sh/src/exec/ft_exec.c | 2 +- 42sh/src/exec/launch_file.c | 6 +++--- 42sh/src/exec/launch_process.c | 2 +- 42sh/src/exec/launch_subshell.c | 6 +++--- 42sh/src/exec/process_redirect.c | 7 ++++--- 42sh/src/exec/process_setgroup.c | 7 +++++-- 42sh/src/exec/redir_copy.c | 3 ++- 42sh/src/exec/redirect_dless.c | 3 ++- 42sh/src/exec/set_process.c | 2 +- 42sh/src/job-control/job_wait.c | 2 +- 42sh/src/job-control/put_job_in_foreground.c | 3 ++- 42sh/src/main/main.c | 4 ++-- 42sh/src/parser/add_redir.c | 2 +- 42sh/src/parser/heredoc_parser.c | 5 +++-- 42sh/src/parser/read_stack.c | 20 +++++++++----------- 18 files changed, 45 insertions(+), 38 deletions(-) diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 32d1156a..e3b6293f 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2017/03/11 16:06:07 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 13:52:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 5ae9561a..c132a271 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -154,7 +154,7 @@ int join_ast(t_btree **ast, t_btree **new_node); int gen_node(t_btree **ast); int superflous_token(t_btree **ast, t_list **list); -int ft_show_heredoc_data(t_btree **ast); +int ft_show_heredoc_data(t_astnode *node); struct s_distrostree { diff --git a/42sh/src/exec/exec_leaf.c b/42sh/src/exec/exec_leaf.c index c367c141..60f95158 100644 --- a/42sh/src/exec/exec_leaf.c +++ b/42sh/src/exec/exec_leaf.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ -/* Updated: 2017/03/11 18:32:51 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:13:02 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,13 +22,14 @@ int exec_leaf(t_btree **ast) return (1); if (!(launch_process(&p))) { - /* DG("forked pid=[%i], name=[%s]", p.pid, p.data.cmd.av[0]); */ + DG("forked pid=[%i], name=[%s]", p.pid, p.data.cmd.av[0]); job_addprocess(&p); /* DG("[IS_BG->%i]", JOB_IS_BG(job->attrs)); */ if (IS_PIPEEND(p)) { if (JOB_IS_FG(job->attrs)) put_job_in_foreground(job, 0); + DG("job->pgid RESET (end of pipe)"); job->pgid = 0; } } diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index 4d5e0762..9ed829d3 100644 --- a/42sh/src/exec/ft_exec.c +++ b/42sh/src/exec/ft_exec.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ -/* Updated: 2017/03/10 15:45:12 by ariard ### ########.fr */ +/* Updated: 2017/03/13 14:03:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_file.c b/42sh/src/exec/launch_file.c index 3a005fa9..86d96c83 100644 --- a/42sh/src/exec/launch_file.c +++ b/42sh/src/exec/launch_file.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ -/* Updated: 2017/03/11 18:16:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 13:28:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,10 +22,10 @@ int launch_file(t_process *p) /* data_singleton()->opts &= ~SH_INTERACTIVE; */ /* data_singleton()->opts &= ~SH_OPTS_JOBC; */ /* DG("fork! [%s]", p->data.cmd.av[0]); */ - process_setgroup(p, 0); - process_setsig(); if (process_redirect(p)) exit (1); + process_setgroup(p, 0); + process_setsig(); exec_reset(); if (!p->data.cmd.path) { diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index 57bb96dd..ce74fee7 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/03/11 17:59:03 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:12:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_subshell.c b/42sh/src/exec/launch_subshell.c index cc7cd24d..087f2e73 100644 --- a/42sh/src/exec/launch_subshell.c +++ b/42sh/src/exec/launch_subshell.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 00:11:44 by wescande #+# #+# */ -/* Updated: 2017/03/11 18:09:35 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 13:27:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,10 +36,10 @@ int launch_subshell(t_process *p) { data_singleton()->opts &= ~SH_INTERACTIVE; data_singleton()->opts &= ~SH_OPTS_JOBC; - process_setgroup(p, 0); - process_setsig(); if (process_redirect(p)) exit (1); + process_setgroup(p, 0); + process_setsig(); exec_reset(); exit(do_subshell(p)); } diff --git a/42sh/src/exec/process_redirect.c b/42sh/src/exec/process_redirect.c index ddceb6af..b433aa4d 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/11 19:44:31 by ariard ### ########.fr */ +/* Updated: 2017/03/13 14:01:23 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,8 +33,9 @@ int process_redirect(t_process *p) while (redirs) { redir = redirs->content; - DG("redirs content : %p", redirs->content); -// DG("redir.type [%li]", redir->type); + /* DG("redirs content : %p", redirs->content); */ + DG("redir @ %p", redir); + DG("redir.type [%li]", redir->type); DG("redir.word [%s]", redir->word); DG("redir.n [%i]", redir->n); if (redir->n > 9) diff --git a/42sh/src/exec/process_setgroup.c b/42sh/src/exec/process_setgroup.c index 35b83760..21577578 100644 --- a/42sh/src/exec/process_setgroup.c +++ b/42sh/src/exec/process_setgroup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:48:10 by jhalford #+# #+# */ -/* Updated: 2017/03/11 16:07:43 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 13:37:03 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,7 +25,10 @@ int process_setgroup(t_process *p, pid_t pid) return (0); DG("setpgid(%i, %i)", pid, j->pgid); if (setpgid(pid, j->pgid) == -1) - ft_dprintf(2, "{red}%s: internal setpgid() error{eoc}\n", SHELL_NAME); + { + ft_dprintf(2, "{red}%s: internal setpgid() errno=%i{eoc}\n", SHELL_NAME, errno); + perror(""); + } if (pid == 0 && JOB_IS_FG(j->attrs)) { DG("tcsetpgrp[%i]", j->pgid); diff --git a/42sh/src/exec/redir_copy.c b/42sh/src/exec/redir_copy.c index 3dea51e4..092d4150 100644 --- a/42sh/src/exec/redir_copy.c +++ b/42sh/src/exec/redir_copy.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 00:02:58 by ariard #+# #+# */ -/* Updated: 2017/03/08 11:53:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:13:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,5 +24,6 @@ void *redir_copy(void *data) new->type = old->type; new->n = old->n; new->word = ft_strdup(old->word); + new->heredoc_data = ft_strdup(old->heredoc_data); return (new); } diff --git a/42sh/src/exec/redirect_dless.c b/42sh/src/exec/redirect_dless.c index 5fb50aa9..5bcd3aa3 100644 --- a/42sh/src/exec/redirect_dless.c +++ b/42sh/src/exec/redirect_dless.c @@ -18,7 +18,8 @@ int redirect_dless(t_redir *redir) pipe(fds); str = redir->heredoc_data; - DG("[%s] && adr %p", str, redir); + DG("[%s] && adr %p", str, str); + DG("redir @ %p", redir); write(fds[PIPE_WRITE], str, ft_strlen(str)); close(fds[PIPE_WRITE]); dup2(fds[PIPE_READ], 0); diff --git a/42sh/src/exec/set_process.c b/42sh/src/exec/set_process.c index 2be25490..ea0e07fb 100644 --- a/42sh/src/exec/set_process.c +++ b/42sh/src/exec/set_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/11 17:49:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:13:25 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/job_wait.c b/42sh/src/job-control/job_wait.c index d4f63cd6..15305beb 100644 --- a/42sh/src/job-control/job_wait.c +++ b/42sh/src/job-control/job_wait.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */ -/* Updated: 2017/03/11 16:00:09 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 13:22:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index d2e9479b..726d899e 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ -/* Updated: 2017/03/11 18:22:21 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:03:43 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,6 +26,7 @@ int put_job_in_foreground(t_job *j, int cont) if (kill(-j->pgid, SIGCONT) < 0) DG("kill(SIGCONT) failed"); } + /* if (SH_IS_INTERACTIVE(data_singleton()->opts)) */ job_wait(j->id); job_remove(j->id); if (SH_IS_INTERACTIVE(data_singleton()->opts)) diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 6635870a..7037580f 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/11 19:56:53 by ariard ### ########.fr */ +/* Updated: 2017/03/13 14:12:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,8 +70,8 @@ int handle_instruction(int fd) return (error_syntax(&token, &parser, &ast)); } } - /* ft_show_heredoc_data(&ast); */ btree_print(STDBUG, ast, &ft_putast); + /* ft_show_heredoc_data(ast->left->item); */ if (ft_exec(&ast)) return (1); instruction_free(&token, &parser, &ast); diff --git a/42sh/src/parser/add_redir.c b/42sh/src/parser/add_redir.c index 9737eea1..8f97f8db 100644 --- a/42sh/src/parser/add_redir.c +++ b/42sh/src/parser/add_redir.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/17 16:39:05 by ariard #+# #+# */ -/* Updated: 2017/03/11 19:57:02 by ariard ### ########.fr */ +/* Updated: 2017/03/13 13:06:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/heredoc_parser.c b/42sh/src/parser/heredoc_parser.c index ee34ac8c..31d3fd24 100644 --- a/42sh/src/parser/heredoc_parser.c +++ b/42sh/src/parser/heredoc_parser.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 16:21:05 by ariard #+# #+# */ -/* Updated: 2017/03/11 19:40:43 by ariard ### ########.fr */ +/* Updated: 2017/03/13 14:01:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,8 @@ int pop_heredoc(t_list **lst) temp2 = temp->next; // free(temp); data_singleton()->heredoc_queue = temp2; - DG("data is %s et adr %p", head->heredoc_data, temp); + DG("data is %s et adr %p", head->heredoc_data, head->heredoc_data); + DG("redir @ %p", head); } else { diff --git a/42sh/src/parser/read_stack.c b/42sh/src/parser/read_stack.c index b746dfa3..4d91117c 100644 --- a/42sh/src/parser/read_stack.c +++ b/42sh/src/parser/read_stack.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 15:32:10 by ariard #+# #+# */ -/* Updated: 2017/03/11 19:55:57 by ariard ### ########.fr */ +/* Updated: 2017/03/13 14:13:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -224,18 +224,16 @@ int ft_read_stack(t_sym *stack) } -int ft_show_heredoc_data(t_btree **ast) +int ft_show_heredoc_data(t_astnode *node) { - t_astnode *node; t_redir *redir; - if (*ast) - if ((*ast)->left) - { - node = ((*ast)->left)->item; - redir = (node->data.cmd.redir)->content; - if (redir->type == TK_DLESS) - DG("Show me heredoc data from node :%s", redir->heredoc_data); - } + if (node->type != CMD) + return (1); + redir = (node->data.cmd.redir)->content; + if (redir->type != TK_DLESS) + return (1); + DG("heredoc_data=[%s] @ %p", redir->heredoc_data, redir->heredoc_data); + DG("redir @ %p", redir); return (0); } From bfb7c13e9478eecec2e0ec18bf26fa508adee3f9 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 13 Mar 2017 14:29:23 +0100 Subject: [PATCH 2/3] fix historique --- 42sh/src/exec/exec_leaf.c | 2 +- 42sh/src/exec/launch_while.c | 2 +- 42sh/src/exec/redir_copy.c | 2 +- 42sh/src/exec/set_process.c | 2 +- 42sh/src/history/add_str_in_history.c | 3 ++- 42sh/src/main/main.c | 5 +++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/42sh/src/exec/exec_leaf.c b/42sh/src/exec/exec_leaf.c index 60f95158..44704e32 100644 --- a/42sh/src/exec/exec_leaf.c +++ b/42sh/src/exec/exec_leaf.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ -/* Updated: 2017/03/13 14:13:02 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:21:27 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_while.c b/42sh/src/exec/launch_while.c index 81f49a83..7dfafe7d 100644 --- a/42sh/src/exec/launch_while.c +++ b/42sh/src/exec/launch_while.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 17:20:53 by wescande #+# #+# */ -/* Updated: 2017/03/11 17:45:18 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:18:07 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redir_copy.c b/42sh/src/exec/redir_copy.c index 092d4150..055efcd4 100644 --- a/42sh/src/exec/redir_copy.c +++ b/42sh/src/exec/redir_copy.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 00:02:58 by ariard #+# #+# */ -/* Updated: 2017/03/13 14:13:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:20:56 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/set_process.c b/42sh/src/exec/set_process.c index ea0e07fb..4461fc05 100644 --- a/42sh/src/exec/set_process.c +++ b/42sh/src/exec/set_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/13 14:13:25 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:18:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/history/add_str_in_history.c b/42sh/src/history/add_str_in_history.c index 333f5225..65b7fe8d 100644 --- a/42sh/src/history/add_str_in_history.c +++ b/42sh/src/history/add_str_in_history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/14 11:27:03 by gwojda #+# #+# */ -/* Updated: 2017/03/10 12:59:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:23:03 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ void ft_add_in_history_file(char *str) char **hist; i = 0; + /* DG("gonna add [%s] in history"); */ hist = ft_strsplit(str, '\n'); if (!(home = ft_getenv(data_singleton()->env, "HOME"))) return ; diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 7037580f..f36d7962 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/13 14:12:55 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:23:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,7 +75,8 @@ int handle_instruction(int fd) if (ft_exec(&ast)) return (1); instruction_free(&token, &parser, &ast); - ft_add_str_in_history(lexer.str); + if (SH_IS_INTERACTIVE(data_singleton()->opts)) + ft_add_str_in_history(lexer.str); return (0); } From 163c93c0c2078ba21106b244bf4bfb3634086933 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Mon, 13 Mar 2017 14:48:40 +0100 Subject: [PATCH 3/3] issue #81, probleme de protection free historique, p-e resolu #77 aussi --- 42sh/includes/job_control.h | 2 +- 42sh/src/builtin/builtin_exit.c | 2 +- 42sh/src/exec/exec_leaf.c | 2 +- 42sh/src/exec/launch_process.c | 2 +- 42sh/src/history/add_str_in_history.c | 3 +-- 42sh/src/history/list_toolz.c | 6 +++--- 42sh/src/line-editing/readline.c | 10 +++------- 42sh/src/main/main.c | 10 ++++------ 42sh/src/parser/error_syntax.c | 2 +- 9 files changed, 16 insertions(+), 23 deletions(-) diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index e3b6293f..00985ade 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2017/03/13 13:52:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:29:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index ea146188..f00c59da 100644 --- a/42sh/src/builtin/builtin_exit.c +++ b/42sh/src/builtin/builtin_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ -/* Updated: 2017/03/09 15:14:37 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:47:29 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_leaf.c b/42sh/src/exec/exec_leaf.c index 44704e32..de370722 100644 --- a/42sh/src/exec/exec_leaf.c +++ b/42sh/src/exec/exec_leaf.c @@ -6,7 +6,7 @@ /* By: wescande +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ -/* Updated: 2017/03/13 14:21:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:37:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index ce74fee7..3d6a30ed 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/03/13 14:12:52 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:43:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/history/add_str_in_history.c b/42sh/src/history/add_str_in_history.c index 65b7fe8d..0a8c95ee 100644 --- a/42sh/src/history/add_str_in_history.c +++ b/42sh/src/history/add_str_in_history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/14 11:27:03 by gwojda #+# #+# */ -/* Updated: 2017/03/13 14:23:03 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:30:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,6 @@ void ft_add_in_history_file(char *str) char **hist; i = 0; - /* DG("gonna add [%s] in history"); */ hist = ft_strsplit(str, '\n'); if (!(home = ft_getenv(data_singleton()->env, "HOME"))) return ; diff --git a/42sh/src/history/list_toolz.c b/42sh/src/history/list_toolz.c index b3b17fb1..a12fd6a8 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/09 11:21:06 by gwojda ### ########.fr */ +/* Updated: 2017/03/13 14:47:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,13 +16,13 @@ void free_history_list(t_list_history *head) { t_list_history *prev; - free(head->prev); + if (!head) + return ; while (head) { ft_strdel(&head->str); prev = head; head = head->next; - free(prev); } } diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index 5c75131c..a30d7d38 100644 --- a/42sh/src/line-editing/readline.c +++ b/42sh/src/line-editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/10 15:48:30 by gwojda ### ########.fr */ +/* Updated: 2017/03/13 14:43:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,15 +15,11 @@ int readline(int fd, int prompt, char **input) { if (!SH_IS_INTERACTIVE(data_singleton()->opts)) - { - if (get_next_line(fd, input) == 0) - return (1); - return (0); - } + return (get_next_line(fd, input) == 0); readline_init(prompt); *input = ft_read_stdin(); if (STR) - ft_current_str(STR, POS); + ft_current_str(STR, POS); ft_putchar('\n'); if (!prompt) *input = ft_history_parsing(); diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index f36d7962..d186be71 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/13 14:23:21 by jhalford ### ########.fr */ +/* Updated: 2017/03/13 14:47:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,11 +31,13 @@ int handle_instruction(int fd) if ((ret = readline(fd, get_lexer_stack(lexer) || parser.state == UNDEFINED || lexer.state == HEREDOC, &str))) { + DG("readline trap"); if (ret == -1) return (-1); return (parser.state == UNDEFINED ? error_eof(&token, &parser, &ast) : 1); } + DG("INPUT STRING IS [%s]", str); if (lexer.state == HEREDOC) { ft_strappend(&lexer.str, (char[]){'\n', 0}); @@ -71,7 +73,6 @@ int handle_instruction(int fd) } } btree_print(STDBUG, ast, &ft_putast); - /* ft_show_heredoc_data(ast->left->item); */ if (ft_exec(&ast)) return (1); instruction_free(&token, &parser, &ast); @@ -124,11 +125,8 @@ int main(int ac, char **av) } DG("JOBC is %s, fd=[%i]", SH_HAS_JOBC(data_singleton()->opts)?"ON":"OFF", fd); while (handle_instruction(fd) == 0) - { -// lexer_clean; -// parser_clean; ; - } + DG("gonna exit"); builtin_exit(NULL, NULL, NULL); return (0); } diff --git a/42sh/src/parser/error_syntax.c b/42sh/src/parser/error_syntax.c index 6165e443..f74ae423 100644 --- a/42sh/src/parser/error_syntax.c +++ b/42sh/src/parser/error_syntax.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:15:35 by ariard #+# #+# */ -/* Updated: 2017/03/11 16:10:56 by ariard ### ########.fr */ +/* Updated: 2017/03/13 14:41:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */