From 754cc63f327eb7fa40bf1b780d75da0a1482d3be Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 21 Oct 2020 21:11:51 +0200 Subject: Mostly works, || issues --- src/s_lpipes.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/s_lpipes.c') diff --git a/src/s_lpipes.c b/src/s_lpipes.c index 23d0476..22ed2a5 100644 --- a/src/s_lpipes.c +++ b/src/s_lpipes.c @@ -10,11 +10,15 @@ /* */ /* ************************************************************************** */ -#include #include #include #include #include +#ifdef __linux__ +# include +#else +# include +#endif #include "s_com.h" #include "s_line.h" @@ -76,30 +80,24 @@ struct s_lpipes *s_lpipes_new(const char pipedword[], t_msh *msh) return (link); } -/* -** TODO: Dangerous '|' split -*/ - struct s_lpipes *s_split_pipes(const char word[], t_msh *msh) { struct s_lpipes *lpipes; size_t pos[256]; - size_t i; + char tmp[ARG_MAX]; + int16_t i; ft_bzero(pos, 256 * sizeof(size_t)); s_get_split_pos(pos, word); - - i = 0; - while (words[i] != NULL) + while (++i < 256) { - if ((lpipes = s_lpipes_new(words[i], msh)) == NULL) - { + s_set_tmp(tmp, pos, i, word); + if (((lpipes = s_lpipes_new(tmp, msh))) == NULL) return (NULL); - } s_lpipes_add_back(&msh->pipes, lpipes); - i++; + if (pos[i] == 0) + break ; } - ft_delwords(words); return (lpipes); } -- cgit v1.2.3