diff --git a/include/parsing.h b/include/parsing.h index 416120c..06990fd 100644 --- a/include/parsing.h +++ b/include/parsing.h @@ -6,7 +6,7 @@ /* By: mmoussou +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/18 20:14:15 by adjoly #+# #+# */ -/* Updated: 2024/07/04 16:50:24 by adjoly ### ########.fr */ +/* Updated: 2024/07/20 16:52:51 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,7 @@ # include "libft.h" -typedef enum s_redirection_sign +typedef enum s_redir_sign { INFILE, HEREDOC, diff --git a/src/parsing/get_cmd_list.c b/src/parsing/get_cmd_list.c index f399a7f..be14e35 100644 --- a/src/parsing/get_cmd_list.c +++ b/src/parsing/get_cmd_list.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/31 12:47:13 by adjoly #+# #+# */ -/* Updated: 2024/07/13 14:08:31 by adjoly ### ########.fr */ +/* Updated: 2024/07/20 17:11:41 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,8 @@ t_list *make_lst(t_list *tmp) cmd_list = malloc(sizeof(t_list)); get_list2(&cmd_list); cmd_list->next = NULL; - cmd_list->content = get_redir_fd(tmp->content); + cmd_list->content = get_redir_fd(tmp->content, \ + ((t_token *)tmp->content)->redirection); return (cmd_list); } @@ -40,7 +41,8 @@ t_list *get_cmd_list(t_list *list) tmp = tmp->next; while (tmp) { - ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content))); + ft_lstadd_back(&cmd_list, ft_lstnew(get_redir_fd(tmp->content, \ + ((t_token *)tmp->content)->redirection))); if (!ft_lstlast(cmd_list)->content) { ft_lstclear(&cmd_list, &free_cmd); diff --git a/src/parsing/get_redir_fd.c b/src/parsing/get_redir_fd.c index a0fa0ba..4689742 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/14 15:11:26 by adjoly ### ########.fr */ +/* Updated: 2024/07/20 17:16:57 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,17 +18,16 @@ #include #include "libft.h" -t_cmd *get_redir_fd(void *content) +t_cmd *get_redir_fd(void *content, t_list *tmp) { - t_list *tmp; t_redir_sign sign[2]; t_cmd *cmd; - tmp = ((t_token *)content)->redirection; - cmd = NULL; sign[0] = INFILE; sign[1] = OUTFILE; cmd = ft_calloc(sizeof(t_cmd), 1); + if (!cmd) + return (NULL); while (tmp) { open_redir((t_redirection *)tmp->content, cmd, sign); diff --git a/src/parsing/split_cmd.c b/src/parsing/split_cmd.c index 8f4e464..798f094 100644 --- a/src/parsing/split_cmd.c +++ b/src/parsing/split_cmd.c @@ -6,7 +6,7 @@ /* By: mmoussou argv = NULL; + cmd->cmd = NULL; + return (cmd); + } cmd->cmd = ft_strdup(*split); if (!cmd->cmd) - return (NULL); + return (cmd); cmd->argv = split; return (cmd); }