diff --git a/srcs/check_syntax.c b/srcs/check_syntax.c index 6beef4e..87b3c96 100644 --- a/srcs/check_syntax.c +++ b/srcs/check_syntax.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/24 14:50:15 by tomoron #+# #+# */ -/* Updated: 2024/04/25 13:50:46 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 14:39:48 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -32,7 +32,7 @@ int check_parens_syntax(t_cmd *cmd, t_cmd *last, t_env *env) } tmp = check_cmds_syntax(parsed_cmd, env); if (tmp) - print_syntax_error_bonus(tmp); + print_syntax_error_bonus(tmp, 0); free_cmd(parsed_cmd); return (tmp == 0); } diff --git a/srcs/check_syntax_utils.c b/srcs/check_syntax_utils.c index fd81b3a..81a52ca 100644 --- a/srcs/check_syntax_utils.c +++ b/srcs/check_syntax_utils.c @@ -6,14 +6,15 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/24 14:54:53 by tomoron #+# #+# */ -/* Updated: 2024/04/25 13:51:03 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 14:41:58 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -void print_syntax_error_bonus(t_cmd *cmd) +void print_syntax_error_bonus(t_cmd *cmd,t_cmd *cmds) { + free_cmd(cmds); if (cmd->cmd_type == CMD || cmd->cmd_type == PAREN) return ; ft_printf_fd(2, "minishell : syntax error near unexpected token `"); diff --git a/srcs/exec_bonus.c b/srcs/exec_bonus.c index c3b7113..d35fafb 100755 --- a/srcs/exec_bonus.c +++ b/srcs/exec_bonus.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 13:50:14 by tomoron #+# #+# */ -/* Updated: 2024/04/26 13:14:42 by marde-vr ### ########.fr */ +/* Updated: 2024/04/26 14:37:53 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,11 +20,11 @@ void exec_command_bonus(t_msh *msh, char *cmd_str) if (!cmd_str) return ; cmds = parsing_bonus(cmd_str); + free(cmd_str); tmp = check_cmds_syntax(cmds, msh->env); if (tmp) { - print_syntax_error_bonus(tmp); - free_cmd(cmds); + print_syntax_error_bonus(tmp, cmds); return ; } msh->cmds_head = cmds; diff --git a/srcs/main.c b/srcs/main.c index 589dd30..92c2b63 100755 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/02 21:59:20 by tomoron #+# #+# */ -/* Updated: 2024/04/26 11:08:22 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 14:22:59 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -128,7 +128,6 @@ int main(int argc, char **argv, char **envp) free(prompt); add_history(commands); exec_command_bonus(msh, commands); - free(commands); } printf("exit\n"); ft_exit(msh, g_return_code); diff --git a/srcs/minishell.h b/srcs/minishell.h index 9391e8a..435cc19 100755 --- a/srcs/minishell.h +++ b/srcs/minishell.h @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/02/04 17:31:38 by tomoron #+# #+# */ -/* Updated: 2024/04/25 18:54:09 by marde-vr ### ########.fr */ +/* Updated: 2024/04/26 14:41:02 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -103,7 +103,7 @@ void handle_here_doc(t_msh *msh, char *eof); int get_in_type(t_msh *msh, t_cmd *t_strt, t_cmd *tokens, int here_doc); void signal_handler_interactive(int signum); int get_token_len(char *cmd, t_env *env); -void print_syntax_error_bonus(t_cmd *cmd); +void print_syntax_error_bonus(t_cmd *cmd, t_cmd *cmds); void signal_handler_here_doc(int signum); t_token *parsing_syntax_error(t_token *res); int file_access(t_msh *msh, int *found); @@ -125,14 +125,12 @@ void ft_exit(t_msh *msh, int exit_code); char **split_paths_from_env(t_env *env); int add_return_code_to_str(char *res); void parse_var(t_msh *msh, char *line); -void print_parsed_token(t_token *cmd);//debug int get_var_name_len(char *command); void handle_minishellrc(t_msh *msh); t_cmd *check_cmds_syntax(t_cmd *cmds, t_env *env); char *get_tmp_file_name(t_msh *msh); int get_args_count(t_token *cmds); char **env_to_char_tab(t_env *env); -void print_parsed_cmd(t_cmd *cmd);//debug int first_is_in_type(t_cmd *cmd); void print_msh_struct(t_msh *msh); int contains_newline(char *str); diff --git a/srcs/parsing_bonus.c b/srcs/parsing_bonus.c index 7180ba6..cd79a68 100755 --- a/srcs/parsing_bonus.c +++ b/srcs/parsing_bonus.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/27 14:40:44 by tomoron #+# #+# */ -/* Updated: 2024/04/24 14:53:19 by tomoron ### ########.fr */ +/* Updated: 2024/04/26 14:32:51 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/srcs/pipe.c b/srcs/pipe.c index e919032..d68fefe 100755 --- a/srcs/pipe.c +++ b/srcs/pipe.c @@ -6,7 +6,7 @@ /* By: marde-vr +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/05 18:17:25 by marde-vr #+# #+# */ -/* Updated: 2024/04/26 10:49:45 by marde-vr ### ########.fr */ +/* Updated: 2024/04/26 14:43:52 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -50,7 +50,6 @@ void handle_parenthesis(t_msh *msh) msh->out_fd = 0; msh->locked_return_code = 0; exec_command_bonus(msh, command); - free(command); ft_exit(msh, g_return_code); }