This commit is contained in:
gazhonsepaskwa
2025-02-10 16:00:49 +01:00
parent 48f4576179
commit a47d619f71
4 changed files with 12 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ char *ft_tabstr(char **tab)
char *out; char *out;
char *tmp; char *tmp;
if (!tab)
return (NULL);
i = -1; i = -1;
alloc_count = 0; alloc_count = 0;
while (tab[++i]) while (tab[++i])

View File

@@ -41,7 +41,10 @@ t_dio_node get_cmd_txt(t_ast_n *node)
{ {
txt.cmd = ft_sprintf("%s%s", NL, node->cmd); txt.cmd = ft_sprintf("%s%s", NL, node->cmd);
txt.cmd = replace_left_red(txt.cmd); txt.cmd = replace_left_red(txt.cmd);
args = ft_tabstr(node->args); if (node->args && node->args[0])
args = ft_tabstr(node->args);
else
args = ft_strdup("");
txt.args = ft_sprintf("%s%s%s", NL, args, NL); txt.args = ft_sprintf("%s%s%s", NL, args, NL);
free(args); free(args);
txt.files = ft_sprintf("redir: UNCHECKED\n"); txt.files = ft_sprintf("redir: UNCHECKED\n");

View File

@@ -13,7 +13,7 @@ void read_hereinput(char *limiter)
r = read(0, &c, 1); r = read(0, &c, 1);
if (r == 0) if (r == 0)
{ {
ft_fprintf (2, "etdsttdt\n"); ft_fprintf (2, "\n");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
while (r && c != '\n' && c != '\0') while (r && c != '\n' && c != '\0')

View File

@@ -152,19 +152,19 @@ t_node *tokenize(char *str)
head = tokenize_base(str); head = tokenize_base(str);
if (!head) if (!head)
return (NULL); return (NULL);
debug_token_list(head, "tokenize_base"); // debug_token_list(head, "tokenize_base");
if (!trim_nodes(head)) if (!trim_nodes(head))
return (NULL); return (NULL);
debug_token_list(head, "trim_nodes"); // debug_token_list(head, "trim_nodes");
if (!unstick_nodes(head)) if (!unstick_nodes(head))
return (NULL); return (NULL);
debug_token_list(head, "unstick_nodes"); // debug_token_list(head, "unstick_nodes");
stick_quote_node(head, 39); stick_quote_node(head, 39);
stick_quote_node(head, '"'); stick_quote_node(head, '"');
debug_token_list(head, "stick quote node"); // debug_token_list(head, "stick quote node");
if (!trim_nodes(head)) if (!trim_nodes(head))
return (NULL); return (NULL);
debug_token_list(head, "trim_nodes"); // debug_token_list(head, "trim_nodes");
set_token(head); set_token(head);
del_void_nodes(&head); del_void_nodes(&head);
debug_token_list(head, "tokenizer"); debug_token_list(head, "tokenizer");