summaryrefslogtreecommitdiffstats
path: root/src/s_lpipes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/s_lpipes.c')
-rw-r--r--src/s_lpipes.c26
1 files changed, 12 insertions, 14 deletions
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 <cstddef>
#include <libft.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
+#ifdef __linux__
+# include <linux/limits.h>
+#else
+# include <limits.h>
+#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);
}