This commit is contained in:
Loic Deridder
2025-02-12 14:10:12 +01:00
parent 3ac1625f5a
commit 78c3fd452a
2 changed files with 14 additions and 9 deletions

View File

@@ -31,6 +31,13 @@ const char *translate_state(t_state state)
return (out);
}
static void else_case(t_dio_node *txt)
{
txt->cmd = ft_calloc(1, 1);
txt->args = ft_calloc(1, 1);
txt->files = ft_calloc(1, 1);
}
t_dio_node get_cmd_txt(t_ast_n *node)
{
t_dio_node txt;
@@ -39,8 +46,10 @@ t_dio_node get_cmd_txt(t_ast_n *node)
txt.st = translate_state(node->state);
if (node->state == _CMD)
{
if (node->cmd)
txt.cmd = ft_sprintf("%s%s", NL, node->cmd);
if (txt.cmd)
else
txt.cmd = ft_strdup(NL);
txt.cmd = replace_left_red(txt.cmd);
if (node->args && node->args[0])
args = ft_tabstr(node->args);
@@ -51,10 +60,6 @@ t_dio_node get_cmd_txt(t_ast_n *node)
txt.files = ft_sprintf("redir: UNCHECKED\n");
}
else
{
txt.cmd = ft_calloc(1, 1);
txt.args = ft_calloc(1, 1);
txt.files = ft_calloc(1, 1);
}
else_case(&txt);
return (txt);
}

View File

@@ -24,7 +24,7 @@ char *get_node_txt(t_ast_n *node)
else
subsh = ft_strdup("");
out = ft_sprintf("%s%s%s%s%s", txt.st, txt.cmd, txt.args, subsh, txt.files);
free(txt.cmd);
ft_free(&txt.cmd);
free(txt.args);
free(txt.files);
free(subsh);