leaks
This commit is contained in:
@@ -60,7 +60,7 @@ static int ifremove_quote(char **str)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void read_hereinput(char *limiter)
|
||||
void read_hereinput(char *limiter, t_node *lst, t_msh *msh)
|
||||
{
|
||||
char buf[100000];
|
||||
char c;
|
||||
@@ -75,6 +75,8 @@ void read_hereinput(char *limiter)
|
||||
{
|
||||
ft_fprintf(2, "\n");
|
||||
ft_fprintf(1, "%s\n", limiter);
|
||||
free_linked_list(lst);
|
||||
free_msh(msh);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
while (r && c != '\n' && c != '\0')
|
||||
@@ -87,6 +89,8 @@ void read_hereinput(char *limiter)
|
||||
if (ft_strncmp(buf, limiter, ft_strlen(limiter)) == 0)
|
||||
{
|
||||
ft_fprintf(1, "%s\n", buf);
|
||||
free_msh(msh);
|
||||
free_linked_list(lst);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
buf[i++] = '\n';
|
||||
@@ -94,7 +98,7 @@ void read_hereinput(char *limiter)
|
||||
ft_fprintf(1, "%s", buf);
|
||||
}
|
||||
|
||||
void parse_heredoc(char *limiter)
|
||||
void parse_heredoc(char *limiter, t_node *lst, t_msh *msh)
|
||||
{
|
||||
int fd;
|
||||
pid_t pid;
|
||||
@@ -107,7 +111,7 @@ void parse_heredoc(char *limiter)
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
close(fd);
|
||||
while (1)
|
||||
read_hereinput(limiter);
|
||||
read_hereinput(limiter, lst, msh);
|
||||
}
|
||||
else if (pid > 0)
|
||||
{
|
||||
@@ -122,14 +126,14 @@ void parse_heredoc(char *limiter)
|
||||
}
|
||||
}
|
||||
|
||||
void create_heredoc(t_node *lst)
|
||||
void create_heredoc(t_node *lst, t_msh *msh)
|
||||
{
|
||||
while (lst)
|
||||
{
|
||||
if (lst->pressision == HEREDOC && lst->next && lst->next->pressision)
|
||||
{
|
||||
lst = lst->next;
|
||||
parse_heredoc(lst->val);
|
||||
parse_heredoc(lst->val, lst, msh);
|
||||
}
|
||||
lst = lst->next;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ t_ast_n *parser(char *input, t_msh *msh)
|
||||
lst = tokenize(input);
|
||||
if (!lst)
|
||||
return (NULL);
|
||||
create_heredoc(lst);
|
||||
create_heredoc(lst, msh);
|
||||
if (DEBUG)
|
||||
{
|
||||
dio = drawio_init(DIO_PATH);
|
||||
|
||||
@@ -32,15 +32,15 @@ int add_node_back(t_node **head, char *val, t_token token, t_pres pres)
|
||||
{
|
||||
t_node *tmp;
|
||||
|
||||
tmp = *head;
|
||||
if (!val)
|
||||
return (0);
|
||||
if (!head || !(*head))
|
||||
{
|
||||
(*head) = create_node(val, token);
|
||||
*head = create_node(val, token);
|
||||
(*head)->pressision = pres;
|
||||
return (1);
|
||||
}
|
||||
tmp = *head;
|
||||
while (tmp->next != NULL)
|
||||
tmp = tmp->next;
|
||||
tmp->next = create_node(val, token);
|
||||
|
||||
@@ -26,7 +26,7 @@ static t_node *tokenize_base(char *str)
|
||||
while (tab[i])
|
||||
{
|
||||
if (!add_node_back(&head, tab[i], 0, 0))
|
||||
return (free(tab), NULL);
|
||||
return (free_tab(tab), NULL);
|
||||
i++;
|
||||
}
|
||||
free_tab(tab);
|
||||
@@ -116,12 +116,16 @@ t_node *tokenize(char *str)
|
||||
head = tokenize_base(str);
|
||||
if (!head)
|
||||
return (NULL);
|
||||
debug_token_list(head, "tokenizer");
|
||||
if (!trim_nodes(head))
|
||||
return (NULL);
|
||||
debug_token_list(head, "tokenizer");
|
||||
if (!unstick_nodes(head))
|
||||
return (NULL);
|
||||
debug_token_list(head, "tokenizer");
|
||||
stick_quote_node(head, 39);
|
||||
stick_quote_node(head, '"');
|
||||
debug_token_list(head, "tokenizer");
|
||||
set_token(head);
|
||||
del_void_nodes(&head);
|
||||
debug_token_list(head, "tokenizer");
|
||||
|
||||
Reference in New Issue
Block a user