diff --git a/42sh/Makefile b/42sh/Makefile index 7f741ccd..1efb305d 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -29,289 +29,292 @@ INC_DIR = includes/ OBJ_DIR = objs/ SRC_BASE = \ -completion/c_pathsolver.c\ -completion/c_init.c\ -completion/c_printer.c\ -completion/c_find_binary.c\ -completion/c_find_env.c\ -completion/c_clear.c\ -completion/c_parser.c\ -completion/c_arrow.c\ -completion/c_sizing.c\ -completion/completion.c\ -completion/c_match_glob.c\ -completion/c_find_files.c\ -completion/c_terminal.c\ -completion/c_output.c\ -completion/c_misc.c\ -completion/c_match.c\ -completion/c_match_update.c\ -completion/c_find_abspath.c\ -history/surch_in_history.c\ -history/history_parsing_toolz_2.c\ -history/history_parsing_toolz.c\ -history/list_toolz.c\ -history/add_str_in_history.c\ -history/history_parsing.c\ -history/history.c\ -job_control/pprint_while.c\ -job_control/mark_job_as_running.c\ -job_control/pprint_case.c\ -job_control/job_notify_new.c\ -job_control/sigint_handler.c\ -job_control/job_update_status.c\ -job_control/job_format_head.c\ -job_control/job_is_completed.c\ -job_control/job_wait.c\ -job_control/sigtstp_handler.c\ -job_control/job_free.c\ -job_control/pprint_for.c\ -job_control/pprint_if.c\ -job_control/job_hup_all.c\ -job_control/put_job_in_foreground.c\ -job_control/job_is_stopped.c\ -job_control/process_free.c\ -job_control/sigttin_handler.c\ -job_control/sigttou_handler.c\ -job_control/builtin_jobs.c\ -job_control/process_cmp_pid.c\ -job_control/pprint_subshell.c\ -job_control/job_remove.c\ -job_control/builtin_bg.c\ -job_control/job_run.c\ -job_control/has_stopped_job.c\ -job_control/pprint_cmd.c\ -job_control/job_cmp_id.c\ -job_control/pprint_brace.c\ -job_control/job_addprocess.c\ -job_control/job_update_id.c\ -job_control/do_job_notification.c\ -job_control/job_getrank.c\ -job_control/has_running_job.c\ -job_control/process_format.c\ -job_control/job_getprocess.c\ -job_control/job_notify_change.c\ -job_control/job_format.c\ -job_control/put_job_in_background.c\ -job_control/pprint_until.c\ -job_control/pprint_function.c\ -job_control/builtin_fg.c\ -job_control/sigchld_handler.c\ -parser/tree_func_free.c\ -parser/parser_destroy.c\ -parser/tree_wrapper.c\ -parser/pop_stack.c\ -parser/add_cmd.c\ -parser/parser_init.c\ -parser/aggregate_sym.c\ -parser/redir_init.c\ -parser/do_parser_routine.c\ -parser/stack_init.c\ -parser/add_number.c\ -parser/add_func.c\ -parser/add_loop.c\ -parser/read_stack.c\ -parser/push_stack.c\ -parser/add_sep.c\ -parser/ft_parse.c\ -parser/add_condition.c\ -parser/produce_sym.c\ -parser/heredoc_parser.c\ -parser/add_case.c\ -parser/sym_free.c\ -parser/add_subshell.c\ -parser/build_tree.c\ -parser/eval_sym.c\ -parser/error_syntax.c\ -parser/add_bang.c\ -parser/add_redir.c\ -main/data_exit.c\ -main/ft_putast.c\ -main/main.c\ -main/shell_reset.c\ -main/data_singleton.c\ -main/data_init.c\ -main/shell_init.c\ -line_editing/lib_line_editing/toolz_termcaps.c\ -line_editing/lib_line_editing/tool_line_2.c\ -line_editing/lib_line_editing/tool_line.c\ -line_editing/lib_line_editing/toolz.c\ -line_editing/lib_line_editing/toolz_parseur.c\ -line_editing/lib_line_editing/ft_nb_line.c\ -line_editing/lib_line_editing/toolz2.c\ -line_editing/resize.c\ -line_editing/control_features.c\ -line_editing/print_del_completion/queue.c\ -line_editing/print_del_completion/completion.c\ -line_editing/print_del_completion/print_and_del.c\ -line_editing/get_key.c\ -line_editing/ft_prompt.c\ -line_editing/readline.c\ -line_editing/move_term/move_up_and_down.c\ -line_editing/move_term/home_end.c\ -line_editing/move_term/move_to_word.c\ -line_editing/move_term/move_left_and_right.c\ -line_editing/init_line/init_termcaps.c\ -line_editing/init_line/init_history.c\ -line_editing/init_line/init_line.c\ -line_editing/copy_cut_paste/underline_home.c\ -line_editing/copy_cut_paste/underline_down.c\ -line_editing/copy_cut_paste/underline_end.c\ -line_editing/copy_cut_paste/underline_reset.c\ -line_editing/copy_cut_paste/underline_function.c\ -line_editing/copy_cut_paste/copy_cut_paste.c\ -line_editing/copy_cut_paste/underline_right.c\ -line_editing/copy_cut_paste/underline_up.c\ -line_editing/copy_cut_paste/underline_left.c\ -glob/expand_home.c\ -glob/expand_bquote.c\ -glob/dir_glob.c\ -glob/ft_strsplit_esc.c\ -glob/expand_var.c\ -glob/glob.c\ -glob/word_is_assignment.c\ -glob/match_pattern.c\ -glob/lib_perso/ft_ld_front.c\ -glob/lib_perso/ft_ld_new.c\ -glob/lib_perso/ft_ld_size.c\ -glob/lib_perso/ft_tablen.c\ -glob/lib_perso/ft_ld_pushfront.c\ -glob/lib_perso/ft_ld_swap.c\ -glob/lib_perso/ft_ld_order.c\ -glob/lib_perso/ft_strsubf.c\ -glob/lib_perso/ft_ld_reverse.c\ -glob/lib_perso/ft_ld_to_tab.c\ -glob/lib_perso/ft_tabdel.c\ -glob/lib_perso/ft_strjoinf.c\ -glob/lib_perso/ft_ld_del.c\ -glob/lib_perso/ft_ld_back.c\ -glob/lib_perso/ft_memrealloc.c\ -glob/lib_perso/ft_ld_copy.c\ -glob/lib_perso/ft_ld_pushback.c\ -glob/lib_perso/ft_ld_clear.c\ -glob/expand_brace.c\ -glob/tab_esc_copy.c\ -glob/ft_strsplit_spe.c\ -glob/esc_print.c\ -glob/expand_esc.c\ -glob/is_char_esc.c\ -glob/command_getoutput.c\ -glob/gen_tab_esc.c\ -lexer/lexer_delim.c\ -lexer/lexer_paren.c\ -lexer/get_state_redir.c\ -lexer/lexer_quote.c\ -lexer/lexer_dquote.c\ -lexer/token_free.c\ -lexer/token_cmp_type.c\ -lexer/lexer_sep.c\ -lexer/lexer_heredoc.c\ -lexer/token_init.c\ -lexer/lexer_less.c\ -lexer/insert_newline.c\ -lexer/get_lexer_stack2.c\ -lexer/lexer_init.c\ -lexer/keep_last_type.c\ -lexer/isrw_delim.c\ -lexer/lexer_lex.c\ -lexer/lexer_destroy.c\ -lexer/lexer_word.c\ -lexer/lexer_newline.c\ -lexer/get_lexer_stack.c\ -lexer/lexer_great.c\ -lexer/lexer_curly_braces.c\ -lexer/lexer_end.c\ -lexer/get_reserved_words.c\ -lexer/do_lexer_routine.c\ -lexer/token_append.c\ -lexer/get_state_global.c\ -lexer/lexer_bquote.c\ -lexer/lexer_default.c\ -lexer/token_print.c\ -lexer/lexer_backslash.c\ -lexer/lexer_number.c\ -builtin/builtin_func.c\ +builtin/bt_env_opt.c\ +builtin/bt_read_get.c\ +builtin/bt_read_term.c\ +builtin/builtin_cd.c\ +builtin/builtin_echo.c\ +builtin/builtin_env.c\ +builtin/builtin_exit.c\ builtin/builtin_export.c\ -builtin/builtin_unsetenv.c\ +builtin/builtin_func.c\ +builtin/builtin_hash.c\ +builtin/builtin_history.c\ +builtin/builtin_math.c\ +builtin/builtin_read.c\ builtin/builtin_setenv.c\ builtin/builtin_unset.c\ -builtin/builtin_math.c\ -builtin/bt_read_term.c\ -builtin/builtin_echo.c\ -builtin/builtin_hash.c\ -builtin/bt_env_opt.c\ -builtin/builtin_exit.c\ -builtin/builtin_cd.c\ -builtin/builtin_read.c\ +builtin/builtin_unsetenv.c\ builtin/is_builtin.c\ -builtin/bt_read_get.c\ -builtin/builtin_history.c\ -builtin/builtin_env.c\ -exec/pset_brace.c\ -exec/pset_if.c\ -exec/pfree_func.c\ -exec/plaunch_subshell.c\ -exec/pset_case.c\ +completion/c_arrow.c\ +completion/c_clear.c\ +completion/c_find_abspath.c\ +completion/c_find_binary.c\ +completion/c_find_env.c\ +completion/c_find_files.c\ +completion/c_init.c\ +completion/c_match.c\ +completion/c_match_glob.c\ +completion/c_match_update.c\ +completion/c_misc.c\ +completion/c_output.c\ +completion/c_parser.c\ +completion/c_pathsolver.c\ +completion/c_printer.c\ +completion/c_sizing.c\ +completion/c_terminal.c\ +completion/completion.c\ +exec/ast_free.c\ +exec/bad_fd.c\ exec/exec_ampersand.c\ exec/exec_and_if.c\ -exec/exec_var.c\ +exec/exec_bang.c\ exec/exec_case_branch.c\ -exec/redirect_greatand.c\ +exec/exec_destroy.c\ +exec/exec_elif.c\ +exec/exec_else.c\ +exec/exec_func.c\ +exec/exec_init.c\ +exec/exec_leaf.c\ +exec/exec_or_if.c\ +exec/exec_pipe.c\ +exec/exec_popfds.c\ +exec/exec_pushfds.c\ +exec/exec_semi.c\ +exec/exec_var.c\ +exec/fd_is_valid.c\ +exec/ft_exec.c\ +exec/ft_findexec.c\ +exec/is_function.c\ +exec/mark_process_status.c\ +exec/node_copy.c\ +exec/pfree_cmd.c\ +exec/pfree_cond.c\ +exec/pfree_func.c\ +exec/pfree_list.c\ +exec/pfree_subshell.c\ +exec/plaunch_brace.c\ +exec/plaunch_builtin.c\ +exec/plaunch_case.c\ +exec/plaunch_empty.c\ +exec/plaunch_file.c\ +exec/plaunch_for.c\ +exec/plaunch_function.c\ +exec/plaunch_if.c\ +exec/plaunch_subshell.c\ +exec/plaunch_until.c\ +exec/plaunch_while.c\ +exec/process_launch.c\ +exec/process_redirect.c\ +exec/process_set.c\ +exec/process_setgroup.c\ +exec/process_setsig.c\ +exec/pset_brace.c\ +exec/pset_case.c\ +exec/pset_cmd.c\ +exec/pset_for.c\ +exec/pset_if.c\ +exec/pset_subshell.c\ +exec/pset_until.c\ +exec/pset_while.c\ exec/redir_copy.c\ exec/redir_free.c\ -exec/token_to_argv.c\ -exec/exec_pipe.c\ -exec/pfree_cond.c\ -exec/pset_for.c\ -exec/pset_until.c\ -exec/exec_func.c\ -exec/exec_or_if.c\ -exec/node_copy.c\ -exec/pfree_list.c\ -exec/redirect_dless.c\ -exec/exec_bang.c\ exec/redirect_dgreat.c\ -exec/mark_process_status.c\ -exec/plaunch_for.c\ -exec/is_function.c\ -exec/pset_while.c\ -exec/exec_else.c\ -exec/ast_free.c\ -exec/exec_semi.c\ -exec/plaunch_while.c\ -exec/bad_fd.c\ -exec/exec_leaf.c\ -exec/plaunch_if.c\ -exec/plaunch_case.c\ -exec/process_redirect.c\ -exec/process_setgroup.c\ -exec/ft_exec.c\ -exec/set_exitstatus.c\ -exec/plaunch_brace.c\ -exec/plaunch_empty.c\ +exec/redirect_dless.c\ exec/redirect_great.c\ -exec/process_set.c\ -exec/exec_reset.c\ -exec/plaunch_until.c\ -exec/pset_cmd.c\ -exec/redirect_lessand.c\ -exec/ft_findexec.c\ +exec/redirect_greatand.c\ exec/redirect_less.c\ -exec/pset_subshell.c\ -exec/fd_is_valid.c\ -exec/exec_elif.c\ -exec/plaunch_builtin.c\ -exec/pfree_subshell.c\ -exec/plaunch_file.c\ -exec/process_setsig.c\ -exec/plaunch_function.c\ -exec/process_launch.c\ -exec/pfree_cmd.c\ +exec/redirect_lessand.c\ +exec/set_exitstatus.c\ +exec/token_to_argv.c\ +glob/command_getoutput.c\ +glob/dir_glob.c\ +glob/esc_print.c\ +glob/expand_bquote.c\ +glob/expand_brace.c\ +glob/expand_esc.c\ +glob/expand_home.c\ +glob/expand_var.c\ +glob/ft_strsplit_esc.c\ +glob/ft_strsplit_spe.c\ +glob/gen_tab_esc.c\ +glob/glob.c\ +glob/is_char_esc.c\ +glob/lib_perso/ft_ld_back.c\ +glob/lib_perso/ft_ld_clear.c\ +glob/lib_perso/ft_ld_copy.c\ +glob/lib_perso/ft_ld_del.c\ +glob/lib_perso/ft_ld_front.c\ +glob/lib_perso/ft_ld_new.c\ +glob/lib_perso/ft_ld_order.c\ +glob/lib_perso/ft_ld_pushback.c\ +glob/lib_perso/ft_ld_pushfront.c\ +glob/lib_perso/ft_ld_reverse.c\ +glob/lib_perso/ft_ld_size.c\ +glob/lib_perso/ft_ld_swap.c\ +glob/lib_perso/ft_ld_to_tab.c\ +glob/lib_perso/ft_memrealloc.c\ +glob/lib_perso/ft_strjoinf.c\ +glob/lib_perso/ft_strsubf.c\ +glob/lib_perso/ft_tabdel.c\ +glob/lib_perso/ft_tablen.c\ +glob/match_pattern.c\ +glob/tab_esc_copy.c\ +glob/word_is_assignment.c\ hash_table/ft_add_hash.c\ -hash_table/is_hash.c\ hash_table/hash.c\ hash_table/hash_free.c\ -hash_table/hash_str.c +hash_table/hash_str.c\ +hash_table/is_hash.c\ +history/add_str_in_history.c\ +history/history.c\ +history/history_parsing.c\ +history/history_parsing_toolz.c\ +history/history_parsing_toolz_2.c\ +history/list_toolz.c\ +history/surch_in_history.c\ +job_control/builtin_bg.c\ +job_control/builtin_fg.c\ +job_control/builtin_jobs.c\ +job_control/do_job_notification.c\ +job_control/has_running_job.c\ +job_control/has_stopped_job.c\ +job_control/job_addprocess.c\ +job_control/job_cmp_id.c\ +job_control/job_format.c\ +job_control/job_format_head.c\ +job_control/job_free.c\ +job_control/job_getprocess.c\ +job_control/job_getrank.c\ +job_control/job_hup_all.c\ +job_control/job_is_completed.c\ +job_control/job_is_stopped.c\ +job_control/job_notify_change.c\ +job_control/job_notify_new.c\ +job_control/job_remove.c\ +job_control/job_run.c\ +job_control/job_update_id.c\ +job_control/job_update_status.c\ +job_control/job_wait.c\ +job_control/mark_job_as_running.c\ +job_control/pprint_brace.c\ +job_control/pprint_case.c\ +job_control/pprint_cmd.c\ +job_control/pprint_for.c\ +job_control/pprint_function.c\ +job_control/pprint_if.c\ +job_control/pprint_subshell.c\ +job_control/pprint_until.c\ +job_control/pprint_while.c\ +job_control/process_cmp_pid.c\ +job_control/process_format.c\ +job_control/process_free.c\ +job_control/put_job_in_background.c\ +job_control/put_job_in_foreground.c\ +job_control/sigchld_handler.c\ +job_control/sigint_handler.c\ +job_control/sigtstp_handler.c\ +job_control/sigttin_handler.c\ +job_control/sigttou_handler.c\ +lexer/do_lexer_routine.c\ +lexer/get_lexer_stack.c\ +lexer/get_lexer_stack2.c\ +lexer/get_reserved_words.c\ +lexer/get_state_global.c\ +lexer/get_state_redir.c\ +lexer/insert_newline.c\ +lexer/isrw_delim.c\ +lexer/keep_last_type.c\ +lexer/lexer_backslash.c\ +lexer/lexer_bquote.c\ +lexer/lexer_curly_braces.c\ +lexer/lexer_default.c\ +lexer/lexer_delim.c\ +lexer/lexer_destroy.c\ +lexer/lexer_dquote.c\ +lexer/lexer_end.c\ +lexer/lexer_great.c\ +lexer/lexer_heredoc.c\ +lexer/lexer_init.c\ +lexer/lexer_less.c\ +lexer/lexer_lex.c\ +lexer/lexer_newline.c\ +lexer/lexer_number.c\ +lexer/lexer_paren.c\ +lexer/lexer_quote.c\ +lexer/lexer_sep.c\ +lexer/lexer_word.c\ +lexer/token_append.c\ +lexer/token_cmp_type.c\ +lexer/token_free.c\ +lexer/token_init.c\ +lexer/token_print.c\ +line_editing/control_features.c\ +line_editing/copy_cut_paste/copy_cut_paste.c\ +line_editing/copy_cut_paste/underline_down.c\ +line_editing/copy_cut_paste/underline_end.c\ +line_editing/copy_cut_paste/underline_function.c\ +line_editing/copy_cut_paste/underline_home.c\ +line_editing/copy_cut_paste/underline_left.c\ +line_editing/copy_cut_paste/underline_reset.c\ +line_editing/copy_cut_paste/underline_right.c\ +line_editing/copy_cut_paste/underline_up.c\ +line_editing/ft_prompt.c\ +line_editing/get_key.c\ +line_editing/init_line/init_history.c\ +line_editing/init_line/init_line.c\ +line_editing/init_line/init_termcaps.c\ +line_editing/lib_line_editing/ft_nb_line.c\ +line_editing/lib_line_editing/tool_line.c\ +line_editing/lib_line_editing/tool_line_2.c\ +line_editing/lib_line_editing/toolz.c\ +line_editing/lib_line_editing/toolz2.c\ +line_editing/lib_line_editing/toolz_parseur.c\ +line_editing/lib_line_editing/toolz_termcaps.c\ +line_editing/move_term/home_end.c\ +line_editing/move_term/move_left_and_right.c\ +line_editing/move_term/move_to_word.c\ +line_editing/move_term/move_up_and_down.c\ +line_editing/print_del_completion/completion.c\ +line_editing/print_del_completion/print_and_del.c\ +line_editing/print_del_completion/queue.c\ +line_editing/readline.c\ +line_editing/resize.c\ +main/data_exit.c\ +main/data_init.c\ +main/data_singleton.c\ +main/ft_putast.c\ +main/main.c\ +main/shell_init.c\ +main/shell_reset.c\ +parser/add_bang.c\ +parser/add_case.c\ +parser/add_cmd.c\ +parser/add_condition.c\ +parser/add_func.c\ +parser/add_loop.c\ +parser/add_number.c\ +parser/add_redir.c\ +parser/add_sep.c\ +parser/add_subshell.c\ +parser/aggregate_sym.c\ +parser/build_tree.c\ +parser/do_parser_routine.c\ +parser/error_syntax.c\ +parser/eval_sym.c\ +parser/ft_parse.c\ +parser/heredoc_parser.c\ +parser/parser_destroy.c\ +parser/parser_init.c\ +parser/pop_stack.c\ +parser/produce_sym.c\ +parser/push_stack.c\ +parser/read_stack.c\ +parser/redir_init.c\ +parser/stack_init.c\ +parser/sym_free.c\ +parser/tree_func_free.c\ +parser/tree_wrapper.c SRCS = $(addprefix $(SRC_DIR), $(SRC_BASE)) OBJS = $(addprefix $(OBJ_DIR), $(SRC_BASE:.c=.o)) diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index b14e1d2d..c2445149 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/03/24 20:07:48 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:39:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -139,8 +139,8 @@ struct s_exec int control_count; }; -int exec_reset(void); -int exec_destroy(void); +int exec_init(t_exec *exec); +int exec_destroy(t_exec *exec); int exec_pushfds(); int exec_popfds(); int process_fork(t_process *p); diff --git a/42sh/libft/includes/libft.h b/42sh/libft/includes/libft.h index dbecfc8c..96b3f0c3 100644 --- a/42sh/libft/includes/libft.h +++ b/42sh/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2017/03/25 01:56:46 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:12:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/lst/ft_lst_print.c b/42sh/libft/src/lst/ft_lst_print.c index 94e5f315..0ff1d1a6 100644 --- a/42sh/libft/src/lst/ft_lst_print.c +++ b/42sh/libft/src/lst/ft_lst_print.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:27 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:25:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/lst/ft_lstdel.c b/42sh/libft/src/lst/ft_lstdel.c index ecebf830..f60ae2d0 100644 --- a/42sh/libft/src/lst/ft_lstdel.c +++ b/42sh/libft/src/lst/ft_lstdel.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 15:18:57 by jhalford #+# #+# */ -/* Updated: 2016/12/05 13:39:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:33:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,9 +14,8 @@ void ft_lstdel(t_list **alst, void (*del)(void *, size_t)) { - if (alst && *alst && del) - { - ft_lstdel(&(*alst)->next, del); - ft_lstdelone(alst, del); - } + if (!(alst || *alst || del)) + return ; + ft_lstdel(&(*alst)->next, del); + ft_lstdelone(alst, del); } diff --git a/42sh/libft/src/lst/ft_lstdelone.c b/42sh/libft/src/lst/ft_lstdelone.c index d9743a95..e550e0f3 100644 --- a/42sh/libft/src/lst/ft_lstdelone.c +++ b/42sh/libft/src/lst/ft_lstdelone.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/05 13:39:33 by jhalford #+# #+# */ -/* Updated: 2017/03/18 17:17:50 by ariard ### ########.fr */ +/* Updated: 2017/03/26 21:24:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/lst/pop.c b/42sh/libft/src/lst/pop.c index df3be22e..9e7d713d 100644 --- a/42sh/libft/src/lst/pop.c +++ b/42sh/libft/src/lst/pop.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:09:56 by jhalford #+# #+# */ -/* Updated: 2017/03/24 20:05:13 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:25:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,10 +17,11 @@ int pop(t_list **lst) t_list *top; int item; + if (!(lst || *lst)) + return (0); top = *lst; item = top ? *(int*)top->content : 0; - if (lst && *lst) - *lst = (*lst)->next; + *lst = (*lst)->next; ft_lstdelone(&top, ft_lst_cfree); return (item); } diff --git a/42sh/src/exec/exec_reset.c b/42sh/src/exec/exec_destroy.c similarity index 53% rename from 42sh/src/exec/exec_reset.c rename to 42sh/src/exec/exec_destroy.c index 0e55431e..bbbdace0 100644 --- a/42sh/src/exec/exec_reset.c +++ b/42sh/src/exec/exec_destroy.c @@ -6,75 +6,23 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */ -/* Updated: 2017/03/24 23:29:00 by ariard ### ########.fr */ +/* Updated: 2017/03/26 21:40:16 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -int exec_reset_job(t_job *job) -{ - job->id = 0; - job->pgid = 0; - job->attrs = 0; - job->first_process = NULL; - tcgetattr(STDIN, &job->tmodes); - return (0); -} - -int exec_pushfds(void) -{ - int i; - t_exec *exec; - - exec = &data_singleton()->exec; - i = -1; - while (++i < 10) - push(&(exec->fd_save[i]), fcntl(i, F_DUPFD_CLOEXEC, 10)); - return (0); -} - -int exec_popfds(void) -{ - int i; - t_exec *exec; - - exec = &data_singleton()->exec; - i = -1; - while (++i < 10) - pop(&exec->fd_save[i]); - return (0); -} - -int exec_reset(void) +int exec_destroy(t_exec *exec) { t_jobc *jobc; - t_exec *exec; - - exec = &data_singleton()->exec; - jobc = &data_singleton()->jobc; - exec_pushfds(); - exec->op_stack = NULL; - exec->fdin = STDIN; - exec->attrs = 0; - exec_reset_job(&exec->job); - jobc->first_job = NULL; - jobc->current_id = 1; - return (0); -} - -int exec_destroy(void) -{ int i; - t_jobc *jobc; - t_exec *exec; - exec = &data_singleton()->exec; jobc = &data_singleton()->jobc; ft_lstdel(&exec->op_stack, ft_lst_cfree); ft_lstdel(&jobc->first_job, job_free); i = -1; while (++i < 10) ft_lstdel(&exec->fd_save[i], ft_lst_cfree); + exec_init(exec); return (0); } diff --git a/42sh/src/exec/exec_init.c b/42sh/src/exec/exec_init.c new file mode 100644 index 00000000..59c30110 --- /dev/null +++ b/42sh/src/exec/exec_init.c @@ -0,0 +1,42 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exec_init.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/26 21:28:09 by jhalford #+# #+# */ +/* Updated: 2017/03/26 21:40:15 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int job_init(t_job *job) +{ + job->id = 0; + job->pgid = 0; + job->attrs = 0; + job->first_process = NULL; + tcgetattr(STDIN, &job->tmodes); + return (0); +} + +int exec_init(t_exec *exec) +{ + t_jobc *jobc; + int i; + + jobc = &data_singleton()->jobc; + i = -1; + while (++i < 10) + exec->fd_save[i] = NULL; + exec_pushfds(); + exec->op_stack = NULL; + exec->fdin = STDIN; + exec->attrs = 0; + job_init(&exec->job); + jobc->first_job = NULL; + jobc->current_id = 1; + return (0); +} diff --git a/42sh/src/exec/exec_popfds.c b/42sh/src/exec/exec_popfds.c new file mode 100644 index 00000000..39d8c6a1 --- /dev/null +++ b/42sh/src/exec/exec_popfds.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exec_popfds.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/26 21:31:05 by jhalford #+# #+# */ +/* Updated: 2017/03/26 21:31:24 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int exec_popfds(void) +{ + int i; + t_exec *exec; + + exec = &data_singleton()->exec; + i = -1; + while (++i < 10) + pop(&exec->fd_save[i]); + return (0); +} diff --git a/42sh/src/exec/exec_pushfds.c b/42sh/src/exec/exec_pushfds.c new file mode 100644 index 00000000..7f156b1b --- /dev/null +++ b/42sh/src/exec/exec_pushfds.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* exec_pushfds.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/26 21:31:46 by jhalford #+# #+# */ +/* Updated: 2017/03/26 21:34:27 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "minishell.h" + +int exec_pushfds(void) +{ + int i; + t_exec *exec; + + exec = &data_singleton()->exec; + i = -1; + while (++i < 10) + push(&(exec->fd_save[i]), fcntl(i, F_DUPFD_CLOEXEC, 10)); + return (0); +} diff --git a/42sh/src/exec/process_launch.c b/42sh/src/exec/process_launch.c index 5a0b711b..14d5c134 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/24 20:02:54 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:39:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,8 +26,7 @@ int process_fork(t_process *p) exit(1); process_setgroup(p, 0); process_setsig(); - exec_destroy(); - exec_reset(); + exec_destroy(&data_singleton()->exec); data_singleton()->opts &= ~SH_INTERACTIVE; data_singleton()->opts &= ~SH_OPTS_JOBC; exit(p->map.launch(p)); diff --git a/42sh/src/main/data_exit.c b/42sh/src/main/data_exit.c index d8911c0f..d1bb2df3 100644 --- a/42sh/src/main/data_exit.c +++ b/42sh/src/main/data_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 18:07:50 by jhalford #+# #+# */ -/* Updated: 2017/03/25 20:27:32 by jhalford ### ########.fr */ +/* Updated: 2017/03/26 21:40:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,13 +19,13 @@ void data_exit(void) data = data_singleton(); ft_strdel(&data->line.input); ft_strdel(&data->binary); - /* exec_popfds(); */ + exec_popfds(); ft_sstrfree(data->env); ft_sstrfree(data->local_var); ft_sstrfree(data->argv); lexer_destroy(&data->lexer); parser_destroy(&data->parser); - exec_destroy(); + exec_destroy(&data->exec); ft_lstdel(&data->lst_func, &tree_func_free); ft_save_termios(-1); ft_free_hash_table(); diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 4b0a771c..07e91e6a 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/24 17:12:51 by wescande ### ########.fr */ +/* Updated: 2017/03/26 21:40:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -82,8 +82,8 @@ int data_init(int ac, char **av, char **env) return (-1); data->comp = NULL; data->opts = SH_INTERACTIVE | SH_OPTS_JOBC; - exec_reset(); data->lst_func = NULL; + exec_init(&data->exec); lexer_init(&data->lexer); parser_init(&data->parser); if ((term_name = ft_getenv(data->env, "TERM")) == NULL) diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index e7f55e88..a86c1fa2 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/25 20:12:37 by ariard ### ########.fr */ +/* Updated: 2017/03/26 21:37:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,7 +79,8 @@ int main(int ac, char **av, char **env) ret = handle_instruction(&token, &ast); lexer_destroy(&data->lexer); parser_destroy(&data->parser); - ft_lstdel(&data_singleton()->exec.op_stack, &ft_lst_cfree); + exec_destroy(&data->exec); + /* ft_lstdel(&data_singleton()->exec.op_stack, &ft_lst_cfree); */ ft_lstdel(&token, &token_free); btree_del(&ast, &ast_free); if (ret == 1) diff --git a/42sh/src/parser/parser_init.c b/42sh/src/parser/parser_init.c index 8f86e68c..e31e0e19 100644 --- a/42sh/src/parser/parser_init.c +++ b/42sh/src/parser/parser_init.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/21 16:14:04 by ariard #+# #+# */ -/* Updated: 2017/03/16 22:13:39 by ariard ### ########.fr */ +/* Updated: 2017/03/26 21:36:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/push_stack.c b/42sh/src/parser/push_stack.c index 3ab774c2..7f74703e 100644 --- a/42sh/src/parser/push_stack.c +++ b/42sh/src/parser/push_stack.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 16:48:30 by ariard #+# #+# */ -/* Updated: 2017/03/18 19:15:39 by ariard ### ########.fr */ +/* Updated: 2017/03/26 21:35:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/stack_init.c b/42sh/src/parser/stack_init.c index a9ae3199..391ffce8 100644 --- a/42sh/src/parser/stack_init.c +++ b/42sh/src/parser/stack_init.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/16 20:31:32 by ariard #+# #+# */ -/* Updated: 2017/03/17 18:24:46 by ariard ### ########.fr */ +/* Updated: 2017/03/26 21:37:19 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,8 @@ int stack_init(t_parser *parser) { - ft_lstdel(&parser->stack, NULL); + ft_lstdel(&parser->stack, ft_lst_cfree); + /* parser->stack = NULL; */ push_stack(&parser->stack, TERMINUS); push_stack(&parser->stack, LINEBREAK); if (!parser->new_sym && !(parser->new_sym = ft_memalloc(sizeof(t_sym))))