From 64ab5424221e72e61015c877ca16080a90071245 Mon Sep 17 00:00:00 2001 From: Adam Joly Date: Tue, 30 Jul 2024 19:04:42 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20Error?= =?UTF-8?q?=20when=20in=20or=20out=20not=20valid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libft/include/libft.h | 4 ++-- src/parsing/get_redir_fd.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libft/include/libft.h b/libft/include/libft.h index 7d7b2cd..d5df8e9 100644 --- a/libft/include/libft.h +++ b/libft/include/libft.h @@ -6,7 +6,7 @@ /* By: mmoussou // for macos compilation +# include // for macos compilation # include # include # include diff --git a/src/parsing/get_redir_fd.c b/src/parsing/get_redir_fd.c index 7b62d75..c9227f4 100644 --- a/src/parsing/get_redir_fd.c +++ b/src/parsing/get_redir_fd.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/30 10:48:41 by adjoly #+# #+# */ -/* Updated: 2024/07/30 17:17:13 by adjoly ### ########.fr */ +/* Updated: 2024/07/30 19:03:54 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,12 @@ #include #include "libft.h" +void parsing_msg(t_cmd *cmd) +{ + if (cmd->infile == -1 || cmd->outfile == -1) + send_error_parsing(ERROR_NO_FILE); +} + t_cmd *get_redir_fd(void *content, t_list *tmp) { t_redir_sign sign[2]; @@ -31,10 +37,9 @@ t_cmd *get_redir_fd(void *content, t_list *tmp) while (tmp) { open_redir((t_redirection *)tmp->content, cmd, sign); - if (cmd->infile >= -1 || cmd->outfile == -1) + if (cmd->infile <= -1 || cmd->outfile == -1) { - if (cmd->infile == -1 || cmd->outfile == -1) - send_error_parsing(ERROR_NO_FILE); + parsing_msg(cmd); free(cmd); return (NULL); }