diff options
Diffstat (limited to '')
-rw-r--r-- | src/s_lpipes.c | 33 | ||||
-rw-r--r-- | src/s_lpipes.h | 6 |
2 files changed, 19 insertions, 20 deletions
diff --git a/src/s_lpipes.c b/src/s_lpipes.c index 04320b8..7e2261a 100644 --- a/src/s_lpipes.c +++ b/src/s_lpipes.c @@ -19,21 +19,19 @@ #include "s_lpipes.h" #include "s_struct.h" -struct s_lpipes - *s_lpipes_last(struct s_lpipes *lpipes) +struct s_lpipes *s_lpipes_last(struct s_lpipes *lpipes) { while (lpipes->next != NULL) lpipes = lpipes->next; return (lpipes); } -void - s_lpipes_add_back(struct s_lpipes **alpipes, +void s_lpipes_add_back(struct s_lpipes **alpipes, struct s_lpipes *new) { struct s_lpipes *tmp; - if (!*alpipes) + if (*alpipes == NULL) *alpipes = new; else { @@ -42,16 +40,15 @@ void } } -void - s_lpipes_clear(struct s_lpipes **lpipes) +void s_lpipes_clear(struct s_lpipes **lpipes) { - struct s_lpipes *tmp; struct s_lpipes *renext; + struct s_lpipes *tmp; - if (!lpipes) + if (lpipes == NULL) return ; tmp = *lpipes; - while (tmp) + while (tmp != NULL) { renext = tmp->next; s_com_destroy(&tmp->com); @@ -61,8 +58,7 @@ void *lpipes = NULL; } -struct s_lpipes - *s_lpipes_new(const char pipedword[], t_msh *msh) +struct s_lpipes *s_lpipes_new(const char pipedword[], t_msh *msh) { struct s_lpipes *link; @@ -77,19 +73,22 @@ struct s_lpipes return (link); } -struct s_lpipes - *s_split_pipes(const char word[], t_msh *msh) +/* +** TODO: Dangerous '|' split +*/ + +struct s_lpipes *s_split_pipes(const char word[], t_msh *msh) { struct s_lpipes *lpipes; char **words; size_t i; - if (!(words = ft_split(word, '|'))) + if ((words = ft_split(word, '|')) == NULL) return (NULL); i = 0; - while (words[i]) + while (words[i] != NULL) { - if (!(lpipes = s_lpipes_new(words[i], msh))) + if ((lpipes = s_lpipes_new(words[i], msh)) == NULL) { return (NULL); } diff --git a/src/s_lpipes.h b/src/s_lpipes.h index e2b3f40..edc559a 100644 --- a/src/s_lpipes.h +++ b/src/s_lpipes.h @@ -10,10 +10,10 @@ /* */ /* ************************************************************************** */ -#ifndef S_LPIPES_H -#define S_LPIPES_H +#ifndef FT_S_LPIPES_H +# define FT_S_LPIPES_H -#include "s_struct.h" +# include "s_struct.h" struct s_lpipes *s_lpipes_last(struct s_lpipes *lpipes); void s_lpipes_add_back(struct s_lpipes **alpipes, |