summaryrefslogtreecommitdiffstats
path: root/src/s_lpipes.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-10-21 21:11:51 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-10-21 21:11:51 +0200
commit754cc63f327eb7fa40bf1b780d75da0a1482d3be (patch)
tree53a540a7b1ba88b5af435c5a27afd7df4349d43b /src/s_lpipes.c
parentAdd new file (diff)
download42-minishell-754cc63f327eb7fa40bf1b780d75da0a1482d3be.tar.gz
42-minishell-754cc63f327eb7fa40bf1b780d75da0a1482d3be.tar.bz2
42-minishell-754cc63f327eb7fa40bf1b780d75da0a1482d3be.tar.xz
42-minishell-754cc63f327eb7fa40bf1b780d75da0a1482d3be.tar.zst
42-minishell-754cc63f327eb7fa40bf1b780d75da0a1482d3be.zip
Mostly works, || issues
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);
}