diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-08 19:32:40 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-08 19:32:40 +0200 |
commit | d742075e1af0c063ef9677f157263c0d45253f73 (patch) | |
tree | 656be50d447b90308647a253e3ba6ba75a751b13 /src/s_line.c | |
parent | Update (diff) | |
download | 42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.gz 42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.bz2 42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.xz 42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.tar.zst 42-minishell-d742075e1af0c063ef9677f157263c0d45253f73.zip |
Rework in progress
Diffstat (limited to 'src/s_line.c')
-rw-r--r-- | src/s_line.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/s_line.c b/src/s_line.c index ae0ec07..b198fff 100644 --- a/src/s_line.c +++ b/src/s_line.c @@ -14,26 +14,30 @@ #include <stdlib.h> #include <stdint.h> +#include "d_define.h" #include "p_line.h" #include "s_com.h" #include "s_struct.h" -t_line - *s_line_last(t_line *line) +t_line_block + *s_line_last(t_line_block *line) { while (line->next != NULL) + { line = line->next; + } return (line); } void - s_line_add_back(t_line **aline, - t_line *new) + s_line_add_back(t_line_block **aline, t_line_block *new) { - t_line *tmp; + t_line_block *tmp; - if (!*aline) + if (*aline == NULL) + { *aline = new; + } else { tmp = s_line_last(*aline); @@ -42,45 +46,43 @@ void } void - s_line_clear(t_line **line) + s_line_clear(t_line_block **line) { - t_line *tmp; - t_line *renext; + t_line_block *tmp; + t_line_block *renext; - if (!line) + if (line == NULL) + { return ; + } tmp = *line; while (tmp != NULL) { renext = tmp->next; - if (tmp->com != NULL) - { - s_com_destroy(&tmp->com); - } ft_memdel((void*)&tmp); tmp = renext; } *line = NULL; } -t_line - *s_line_new(const char word[], - t_msh *msh) +t_line_block + *s_line_new(const char word[], uint8_t nextif) { - t_line *link; + t_line_block *link; - if ((link = (t_line*)malloc(sizeof(t_line))) == NULL) + if ((link = (t_line_block*)malloc(sizeof(t_line_block))) == NULL) return (NULL); - link->nextif = 0; - link->com = NULL; - link->pipes = NULL; + link->lblock[0] = C_NUL; + link->nextif = nextif; link->next = NULL; if (word == NULL) { link->next = NULL; return (link); } - if ((link->com = s_com_new(word, msh)) == NULL) - return (NULL); + else + { + ft_strlcpy(link->lblock, word, 4096); + } return (link); } |