mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
debug, destroy all new types (also some code for testing it)
This commit is contained in:
parent
53693e171e
commit
d40b6c3586
18 changed files with 453 additions and 121 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
|
||||
/* Updated: 2025/04/14 14:52:24 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/14 15:10:28 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
#include "wordlist/wordlist.h"
|
||||
#include <unistd.h>
|
||||
#include "../executing/here_doc/here_doc.h"
|
||||
#include "cmd/cmd_destroy.h"
|
||||
|
||||
/*
|
||||
** NOTE: This file will temporarily include way more functions than allowed.
|
||||
|
|
@ -161,13 +162,13 @@ t_cmd *minishell_simple_parse(t_minishell *app, t_wordlist *tokens)
|
|||
redir = minishell_redir_parse(app, tokens);
|
||||
t_redirect_add_back(&simple->value.simple->redirections, redir);
|
||||
if (ft_errno_get() != FT_ESUCCESS)
|
||||
return (t_cmd_destroy(simple), NULL);
|
||||
return (cmd_destroy(simple), NULL);
|
||||
while (tokens && tokens->word->token_type == WORD_TOKEN)
|
||||
{
|
||||
simple->value.simple->words = wordlist_push(simple->value.simple->words,
|
||||
wordlist_pop(&tokens));
|
||||
if (!simple->value.simple->words)
|
||||
return (ft_errno(FT_EERRNO), t_cmd_destroy(simple), NULL);
|
||||
return (ft_errno(FT_EERRNO), cmd_destroy(simple), NULL);
|
||||
redir = minishell_redir_parse(app, tokens);
|
||||
t_redirect_add_back(&simple->value.simple->redirections, redir);
|
||||
}
|
||||
|
|
@ -213,17 +214,17 @@ t_cmd *minishell_group_or_smp_parse(t_minishell *app, t_wordlist *tokens)
|
|||
ft_errno(FT_EERRNO);
|
||||
if (tokens->word->token_type != CLOSE_PARENTH_TOKEN)
|
||||
parse_error(app, tokens->word);
|
||||
return (t_cmd_destroy(subtree), NULL);
|
||||
return (cmd_destroy(subtree), NULL);
|
||||
}
|
||||
worddesc_destroy(wordlist_pop(&tokens));
|
||||
group = ft_calloc(1, sizeof(t_cmd));
|
||||
if (!group)
|
||||
return (ft_errno(FT_ENOMEM), t_cmd_destroy(subtree), NULL);
|
||||
return (ft_errno(FT_ENOMEM), cmd_destroy(subtree), NULL);
|
||||
group->value.group->cmd = subtree;
|
||||
group->value.group->redirects = minishell_redir_parse(app, tokens);
|
||||
if (group->value.group->redirects == NULL
|
||||
&& ft_errno_get() != FT_ESUCCESS)
|
||||
return (t_cmd_destroy(group), NULL);
|
||||
return (cmd_destroy(group), NULL);
|
||||
return (group);
|
||||
}
|
||||
subtree = minishell_simple_parse(app, tokens);
|
||||
|
|
@ -263,16 +264,16 @@ static t_cmd *connec_reorient_subtree(t_cmd **list, t_cmd **subtree,
|
|||
if (!*list)
|
||||
{
|
||||
ft_errno(FT_ENOMEM);
|
||||
t_cmd_destroy(*subtree);
|
||||
t_cmd_destroy(*opt);
|
||||
cmd_destroy(*subtree);
|
||||
cmd_destroy(*opt);
|
||||
return (NULL);
|
||||
}
|
||||
(*list)->value.connection = ft_calloc(1, sizeof(t_connec_cmd));
|
||||
if (!(*list)->value.connection)
|
||||
{
|
||||
ft_errno(FT_ENOMEM);
|
||||
t_cmd_destroy(*subtree);
|
||||
t_cmd_destroy(*opt);
|
||||
cmd_destroy(*subtree);
|
||||
cmd_destroy(*opt);
|
||||
return (free(*list), NULL);
|
||||
}
|
||||
(*list)->type = FT_CONNECTION;
|
||||
|
|
@ -308,7 +309,7 @@ t_cmd *minishell_pipeline_parse(t_minishell *app, t_wordlist *tokens)
|
|||
opt = minishell_opt_pipeline_parse(app, tokens);
|
||||
}
|
||||
if (ft_errno_get() != FT_ESUCCESS)
|
||||
return (t_cmd_destroy(subtree), NULL);
|
||||
return (cmd_destroy(subtree), NULL);
|
||||
return (pipeline);
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +330,7 @@ t_cmd *minishell_cmds_parse(t_minishell *app, t_wordlist *tokens)
|
|||
return (NULL);
|
||||
opt = minishell_opt_cmds_parse(app, tokens, &connec);
|
||||
if (!opt && ft_errno_get() != FT_ESUCCESS)
|
||||
return (t_cmd_destroy(subtree), NULL);
|
||||
return (cmd_destroy(subtree), NULL);
|
||||
if (!opt)
|
||||
return (subtree);
|
||||
while (opt)
|
||||
|
|
@ -342,7 +343,7 @@ t_cmd *minishell_cmds_parse(t_minishell *app, t_wordlist *tokens)
|
|||
opt = minishell_opt_cmds_parse(app, tokens, &connec);
|
||||
}
|
||||
if (ft_errno_get() != FT_ESUCCESS)
|
||||
return (t_cmd_destroy(subtree), NULL);
|
||||
return (cmd_destroy(subtree), NULL);
|
||||
return (list);
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +373,7 @@ t_cmd *minishell_parse(t_minishell *app, char *command_line)
|
|||
{
|
||||
parse_error(app, tokens->word);
|
||||
wordlist_destroy(tokens);
|
||||
t_cmd_destroy(root_cmd);
|
||||
cmd_destroy(root_cmd);
|
||||
return (NULL);
|
||||
}
|
||||
return (root_cmd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue