Browse Source

[enh] new function to fill pipe data struct.

Moul 3 years ago
parent
commit
73cb28bd84
2 changed files with 12 additions and 8 deletions
  1. 11 8
      src/pipe_redir_parsing.c
  2. 1 0
      src/sh.h

+ 11 - 8
src/pipe_redir_parsing.c

@@ -14,18 +14,21 @@ void	fill_pipe_redir_data(t_e *e, t_pipe *p, t_pipe_redir **t)
 	while (p->cmd_pipe[++j] != NULL)
 	{
 		if (parse_double_redir(e, p->cmd_pipe[j], p, t) == 0)
-		{
-			t[p->i] = (t_pipe_redir*)malloc(sizeof(t_pipe_redir));
-			t[p->i]->itxt = p->cmd_pipe[j];
-			t[p->i]->ifd = 1;
-			t[p->i]->operator = "|";
-			t[p->i]->ofd = 0;
-			t[p->i++]->otxt = NULL;
-		}
+			pipe_creation(t, p, p->cmd_pipe[j]);
 	}
 	t[p->i] = NULL;
 }
 
+void	pipe_creation(t_pipe_redir **t, t_pipe *p, char *cmd)
+{
+	t[p->i] = (t_pipe_redir*)malloc(sizeof(t_pipe_redir));
+	t[p->i]->itxt = cmd;
+	t[p->i]->ifd = 1;
+	t[p->i]->operator = "|";
+	t[p->i]->ofd = 0;
+	t[p->i++]->otxt = NULL;
+}
+
 /*
 ** cat << end >> toto
 ** cat << end > toto

+ 1 - 0
src/sh.h

@@ -38,6 +38,7 @@ void	count_pipe_nbr(t_e *e, t_pipe *p, char *str);
 ** pipe_redir_parsing.c
 */
 void	fill_pipe_redir_data(t_e *e, t_pipe *p, t_pipe_redir **t);
+void	pipe_creation(t_pipe_redir **t, t_pipe *p, char *cmd);
 void	display_data(t_pipe_redir **t);
 int		parse_double_redir(t_e *e, char *str, t_pipe *p, t_pipe_redir **t);
 int		parse_redirection(t_e *e, t_pipe *p, char *str, t_pipe_redir **t);