From 1f03cbbedb6efabdf3161aea8faf25159d84adf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Wed, 19 Mar 2025 12:08:53 +0100 Subject: [PATCH] tree debug: implement rest of tree debug This is a big commit, sorry! --- Makefile | 1 + report.txt | 136 ------------------ src/parser/cmdlist/cmdlist_debug.c | 19 ++- src/parser/cmdlist/cmdlist_item.c | 23 ++- src/parser/cmdlist/cmdlist_item.h | 4 +- src/parser/cmdlist/operator.c | 17 ++- src/parser/cmdlist/operator.h | 7 +- src/parser/pipeline/pipeline.c | 2 +- src/parser/pipeline/pipeline.h | 5 +- src/parser/pipeline/pipeline_debug.c | 56 ++++++++ src/parser/simple_cmd/simple_cmd.c | 18 ++- src/parser/simple_cmd/simple_cmd.h | 6 +- src/parser/wordlist/wordlist_debug.c | 8 +- src/postprocess/redirections/redirection.c | 17 ++- src/postprocess/redirections/redirection.h | 6 +- .../redirections/redirection_list.c | 24 +++- 16 files changed, 190 insertions(+), 159 deletions(-) delete mode 100644 report.txt create mode 100644 src/parser/pipeline/pipeline_debug.c diff --git a/Makefile b/Makefile index c1c7655..645300e 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ srcs = \ src/parser/matchers/quote.c \ src/parser/pipeline/pipeline.c \ src/parser/pipeline/pipeline_parse.c \ + src/parser/pipeline/pipeline_debug.c \ src/parser/pipeline/pipeline_parse_baseops.c \ src/parser/remove_quotes/remove_quotes.c \ src/parser/simple_cmd/simple_cmd.c \ diff --git a/report.txt b/report.txt deleted file mode 100644 index f157d5d..0000000 --- a/report.txt +++ /dev/null @@ -1,136 +0,0 @@ -++++++++++++++++++++++++++++++++++++++++++++++++++++ -redirections are parsed -++++++++++++++++++++++++++++++++++++++++++++++++++++ -++++ Failed test: -echo hello < in hi > out -++++ Got output: - ╰─ t_cmdgroup - ├─ t_cmdlist - │ ├─ num_cmds = 1 - │ ╰─ cmd[0] - │ ├─ t_cmdlist_item - │ │ ╰─ t_pipeline - │ │ ├─ num_cmd = 1 - │ │ ╰─ cmd[0] - │ │ ╰─ t_simple_cmd - │ │ ├─ words = [echo][hello][hi] - │ │ ╰─ t_redir_list - │ │ ├─ redirection[0] - │ │ │ ╰─ t_redirection - │ │ │ ├─ t_redir_type = REDIR_INPUT - │ │ │ ╰─ marker = [in] - │ │ ╰─ redirection[1] - │ │ ╰─ t_redirection - │ │ ├─ t_redir_type = REDIR_OUTPUT - │ │ ╰─ marker = [out] - │ ╰─ t_operator = END - ╰─ (no redirections) -++++ But expected: - ╰─ t_cmdgroup - ├─ t_cmdlist - │ ├─ num_cmds = 1 - │ ╰─ cmd[0] - │ ├─ t_cmdlist_item - │ │ ╰─ t_pipeline - │ │ ├─ num_cmd = 1 - │ │ ╰─ cmd[0] - │ │ ╰─ t_simple_cmd - │ │ ├─ words = [echo][hello][hi] - │ │ ╰─ t_redir_list - │ │ ├─ redirection[0] - │ │ │ ╰─ t_redirection - │ │ ╰─ redirection[1] - │ │ ╰─ t_redirection - │ ╰─ t_operator = END - ╰─ (no redirections) -++++ Diff: -(red is got, green is expected) -14,15d13 -< │ │ │ ├─ t_redir_type = REDIR_INPUT -< │ │ │ ╰─ marker = [in] -18,19d15 -< │ │ ├─ t_redir_type = REDIR_OUTPUT -< │ │ ╰─ marker = [out] -++++ Run this to debug: -echo 'echo hello < in hi > out' | ./minishell -++++++++++++++++++++++++++++++++++++++++++++++++++++ -multiple redirections are parsed -++++++++++++++++++++++++++++++++++++++++++++++++++++ -++++ Failed test: -echo << HERE_DOC hello>outfile < infile < infile2 >> append -++++ Got output: - ╰─ t_cmdgroup - ├─ t_cmdlist - │ ├─ num_cmds = 1 - │ ╰─ cmd[0] - │ ├─ t_cmdlist_item - │ │ ╰─ t_pipeline - │ │ ├─ num_cmd = 1 - │ │ ╰─ cmd[0] - │ │ ╰─ t_simple_cmd - │ │ ├─ words = [echo][hello] - │ │ ╰─ t_redir_list - │ │ ├─ redirection[0] - │ │ │ ╰─ t_redirection - │ │ │ ├─ t_redir_type = REDIR_HERE_DOC - │ │ │ ╰─ marker = [HERE_DOC] - │ │ ├─ redirection[1] - │ │ │ ╰─ t_redirection - │ │ │ ├─ t_redir_type = REDIR_OUTPUT - │ │ │ ╰─ marker = [outfile] - │ │ ├─ redirection[2] - │ │ │ ╰─ t_redirection - │ │ │ ├─ t_redir_type = REDIR_INPUT - │ │ │ ╰─ marker = [infile] - │ │ ├─ redirection[3] - │ │ │ ╰─ t_redirection - │ │ │ ├─ t_redir_type = REDIR_INPUT - │ │ │ ╰─ marker = [infile2] - │ │ ╰─ redirection[4] - │ │ ╰─ t_redirection - │ │ ├─ t_redir_type = REDIR_APPEND - │ │ ╰─ marker = [append] - │ ╰─ t_operator = END - ╰─ (no redirections) -++++ But expected: - -++++ Diff: -(red is got, green is expected) -1,33c1 -< ╰─ t_cmdgroup -< ├─ t_cmdlist -< │ ├─ num_cmds = 1 -< │ ╰─ cmd[0] -< │ ├─ t_cmdlist_item -< │ │ ╰─ t_pipeline -< │ │ ├─ num_cmd = 1 -< │ │ ╰─ cmd[0] -< │ │ ╰─ t_simple_cmd -< │ │ ├─ words = [echo][hello] -< │ │ ╰─ t_redir_list -< │ │ ├─ redirection[0] -< │ │ │ ╰─ t_redirection -< │ │ │ ├─ t_redir_type = REDIR_HERE_DOC -< │ │ │ ╰─ marker = [HERE_DOC] -< │ │ ├─ redirection[1] -< │ │ │ ╰─ t_redirection -< │ │ │ ├─ t_redir_type = REDIR_OUTPUT -< │ │ │ ╰─ marker = [outfile] -< │ │ ├─ redirection[2] -< │ │ │ ╰─ t_redirection -< │ │ │ ├─ t_redir_type = REDIR_INPUT -< │ │ │ ╰─ marker = [infile] -< │ │ ├─ redirection[3] -< │ │ │ ╰─ t_redirection -< │ │ │ ├─ t_redir_type = REDIR_INPUT -< │ │ │ ╰─ marker = [infile2] -< │ │ ╰─ redirection[4] -< │ │ ╰─ t_redirection -< │ │ ├─ t_redir_type = REDIR_APPEND -< │ │ ╰─ marker = [append] -< │ ╰─ t_operator = END -< ╰─ (no redirections) ---- ->  -++++ Run this to debug: -echo 'echo << HERE_DOC hello>outfile < infile < infile2 >> append' | ./minishell diff --git a/src/parser/cmdlist/cmdlist_debug.c b/src/parser/cmdlist/cmdlist_debug.c index d2eaf11..6f50416 100644 --- a/src/parser/cmdlist/cmdlist_debug.c +++ b/src/parser/cmdlist/cmdlist_debug.c @@ -6,22 +6,29 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/18 15:52:28 by khais #+# #+# */ -/* Updated: 2025/03/19 12:12:20 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:43:39 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "cmdlist.h" #include "../../treedrawing.h" #include "libft.h" +#include "cmdlist_item.h" static void cmdlist_array_debug(t_cmdlist *cmd, int i, t_buffer *leader, bool is_last) { indent(leader, is_last); ft_printf("cmd[%d]\n", i); - (void)cmd; - /* cmdlist_item_debug(cmd->cmds[i], leader, false); */ - /* operator_debug(cmd->operators[i], leader, true); */ + cmdlist_item_debug(cmd->cmds[i], leader, false); + operator_debug(cmd->operators[i], leader, true); + dedent(leader, is_last); +} + +static void cmdlist_num_cmds_debug(int num_cmds, t_buffer *leader, bool is_last) +{ + indent(leader, is_last); + ft_printf("num_cmds = %d\n", num_cmds); dedent(leader, is_last); } @@ -38,9 +45,7 @@ void cmdlist_debug(t_cmdlist *cmd, t_buffer *leader, bool is_last) last = false; if (cmd->num_cmds == 0) last = true; - indent(leader, last); - ft_printf("num_cmds = %d\n", cmd->num_cmds); - dedent(leader, last); + cmdlist_num_cmds_debug(cmd->num_cmds, leader, last); while (i < cmd->num_cmds) { if (i == cmd->num_cmds - 1) diff --git a/src/parser/cmdlist/cmdlist_item.c b/src/parser/cmdlist/cmdlist_item.c index 5f37634..e320591 100644 --- a/src/parser/cmdlist/cmdlist_item.c +++ b/src/parser/cmdlist/cmdlist_item.c @@ -6,12 +6,14 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/18 13:02:02 by khais #+# #+# */ -/* Updated: 2025/03/18 15:03:13 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:11:27 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "cmdlist_item.h" +#include "cmdlist_item_type.h" #include "libft.h" +#include "../../treedrawing.h" void cmdlist_item_destroy(t_cmdlist_item *cmd) { @@ -34,3 +36,22 @@ t_cmdlist_item *cmdlist_item_create(void) item->type = TYPE_INVALID; return (item); } + +void cmdlist_item_debug(t_cmdlist_item *item, t_buffer *leader, bool is_last) +{ + if (item == NULL) + return ; + indent(leader, is_last); + ft_printf("%s\n", "t_cmdlist_item"); + if (item->type == TYPE_INVALID) + { + indent(leader, true); + ft_printf("%s\n", "type = INVALID"); + dedent(leader, true); + } + else if (item->type == TYPE_PIPELINE) + pipeline_debug(item->inner.pipeline, leader, true); + else if (item->type == TYPE_CMDGROUP) + cmdgroup_debug(item->inner.cmdgroup, leader, true); + dedent(leader, is_last); +} diff --git a/src/parser/cmdlist/cmdlist_item.h b/src/parser/cmdlist/cmdlist_item.h index d7dfa92..0bdb15d 100644 --- a/src/parser/cmdlist/cmdlist_item.h +++ b/src/parser/cmdlist/cmdlist_item.h @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/18 12:54:31 by khais #+# #+# */ -/* Updated: 2025/03/18 15:03:04 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:11:16 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,5 +28,7 @@ typedef struct s_cmdlist_item void cmdlist_item_destroy(t_cmdlist_item *cmd); t_cmdlist_item *cmdlist_item_create(void); +void cmdlist_item_debug(t_cmdlist_item *item, t_buffer *leader, + bool is_last); #endif // CMDLIST_ITEM_H diff --git a/src/parser/cmdlist/operator.c b/src/parser/cmdlist/operator.c index 5baf0eb..a2e7c40 100644 --- a/src/parser/cmdlist/operator.c +++ b/src/parser/cmdlist/operator.c @@ -6,12 +6,13 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/26 12:51:28 by khais #+# #+# */ -/* Updated: 2025/02/26 12:51:52 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:44:03 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "operator.h" #include "libft.h" +#include "../../treedrawing.h" /* ** Match a string to an operator @@ -26,3 +27,17 @@ t_operator match_op(char *op) return (OP_OR); return (OP_INVALID); } + +void operator_debug(t_operator op, t_buffer *leader, + bool is_last) +{ + indent(leader, is_last); + ft_printf("t_operator = "); + if (op == OP_AND) + ft_printf("%s\n", "AND"); + if (op == OP_OR) + ft_printf("%s\n", "OR"); + if (op == OP_END) + ft_printf("%s\n", "END"); + dedent(leader, is_last); +} diff --git a/src/parser/cmdlist/operator.h b/src/parser/cmdlist/operator.h index c3eff9f..16a04cd 100644 --- a/src/parser/cmdlist/operator.h +++ b/src/parser/cmdlist/operator.h @@ -6,13 +6,16 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/26 12:49:46 by khais #+# #+# */ -/* Updated: 2025/02/26 13:54:08 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:41:55 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef OPERATOR_H # define OPERATOR_H +# include "../../buffer/buffer.h" +# include + /* ** An operator used by a cmdlist */ @@ -37,5 +40,7 @@ typedef enum e_operator } t_operator; t_operator match_op(char *op); +void operator_debug(t_operator op, t_buffer *leader, + bool is_last); #endif // OPERATOR_H diff --git a/src/parser/pipeline/pipeline.c b/src/parser/pipeline/pipeline.c index 1d1880b..27cc562 100644 --- a/src/parser/pipeline/pipeline.c +++ b/src/parser/pipeline/pipeline.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 13:23:50 by khais #+# #+# */ -/* Updated: 2025/03/04 12:07:13 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:38:58 by khais ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/parser/pipeline/pipeline.h b/src/parser/pipeline/pipeline.h index 34ec836..71ed6b4 100644 --- a/src/parser/pipeline/pipeline.h +++ b/src/parser/pipeline/pipeline.h @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 13:19:51 by khais #+# #+# */ -/* Updated: 2025/03/03 13:36:43 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:40:08 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ # define PIPELINE_H # include "../simple_cmd/simple_cmd.h" +# include "../../buffer/buffer.h" # include /* @@ -94,5 +95,7 @@ typedef struct s_pipeline_builder t_pipeline *pipeline_from_wordlist(const t_wordlist *words); void pipeline_destroy(t_pipeline *pipeline); void builder_destroy(t_pipeline_builder *builder); +void pipeline_debug(t_pipeline *pipeline, t_buffer *leader, + bool is_last); #endif diff --git a/src/parser/pipeline/pipeline_debug.c b/src/parser/pipeline/pipeline_debug.c new file mode 100644 index 0000000..28bd0ab --- /dev/null +++ b/src/parser/pipeline/pipeline_debug.c @@ -0,0 +1,56 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pipeline_debug.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: khais +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/03/19 14:38:51 by khais #+# #+# */ +/* Updated: 2025/03/19 14:39:55 by khais ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include "../../treedrawing.h" +#include "pipeline.h" + +static void pipeline_num_cmds_debug(int num_cmds, t_buffer *leader, + bool is_last) +{ + indent(leader, is_last); + ft_printf("num_cmd = %d\n", num_cmds); + dedent(leader, is_last); +} + +static void pipeline_array_debug(t_pipeline *pipeline, + int i, t_buffer *leader, bool is_last) +{ + indent(leader, is_last); + ft_printf("cmd[%d]\n", i); + simple_cmd_debug(pipeline->cmds[i], leader, true); + dedent(leader, is_last); +} + +void pipeline_debug(t_pipeline *pipeline, t_buffer *leader, bool is_last) +{ + int i; + bool last; + + if (pipeline == NULL) + return ; + indent(leader, is_last); + ft_printf("%s\n", "t_pipeline"); + i = 0; + last = false; + if (pipeline->num_cmd == 0) + last = true; + pipeline_num_cmds_debug(pipeline->num_cmd, leader, last); + while (i < pipeline->num_cmd) + { + if (i == pipeline->num_cmd - 1) + last = true; + pipeline_array_debug(pipeline, i, leader, last); + i++; + } + dedent(leader, is_last); +} diff --git a/src/parser/simple_cmd/simple_cmd.c b/src/parser/simple_cmd/simple_cmd.c index 22597fa..670c60e 100644 --- a/src/parser/simple_cmd/simple_cmd.c +++ b/src/parser/simple_cmd/simple_cmd.c @@ -6,12 +6,14 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 12:30:07 by khais #+# #+# */ -/* Updated: 2025/02/21 12:51:07 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:28:36 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "simple_cmd.h" #include "libft.h" +#include "../../treedrawing.h" +#include "../../postprocess/redirections/redirection_list.h" /* ** parse a wordlist and yield a simple command. @@ -36,3 +38,17 @@ void simple_cmd_destroy(t_simple_cmd *cmd) wordlist_destroy(cmd->words); free(cmd); } + +void simple_cmd_debug(t_simple_cmd *cmd, t_buffer *leader, bool is_last) +{ + if (cmd == NULL) + return ; + indent(leader, is_last); + ft_printf("%s\n", "t_simple_cmd"); + indent(leader, false); + ft_printf("words = "); + wordlist_debug(cmd->words); + dedent(leader, false); + redir_list_debug(cmd->redirections, leader, true); + dedent(leader, is_last); +} diff --git a/src/parser/simple_cmd/simple_cmd.h b/src/parser/simple_cmd/simple_cmd.h index f3f01b5..bdd31ba 100644 --- a/src/parser/simple_cmd/simple_cmd.h +++ b/src/parser/simple_cmd/simple_cmd.h @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 12:24:57 by khais #+# #+# */ -/* Updated: 2025/03/07 13:12:12 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:38:27 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,8 @@ # define SIMPLE_CMD_H # include "../wordlist/wordlist.h" +# include "../../buffer/buffer.h" +# include typedef struct s_simple_cmd { @@ -23,5 +25,7 @@ typedef struct s_simple_cmd t_simple_cmd *simple_cmd_from_wordlist(t_wordlist *words); void simple_cmd_destroy(t_simple_cmd *cmd); +void simple_cmd_debug(t_simple_cmd *cmd, t_buffer *leader, + bool is_last); #endif diff --git a/src/parser/wordlist/wordlist_debug.c b/src/parser/wordlist/wordlist_debug.c index 7bce06e..73fae21 100644 --- a/src/parser/wordlist/wordlist_debug.c +++ b/src/parser/wordlist/wordlist_debug.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/24 18:20:00 by khais #+# #+# */ -/* Updated: 2025/03/19 12:09:56 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:35:24 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,11 +19,11 @@ void wordlist_debug(t_wordlist *wordlist) { if (wordlist == NULL) - ft_dprintf(STDERR_FILENO, "(empty wordlist)"); + ft_printf("(empty wordlist)"); while (wordlist != NULL) { - ft_dprintf(STDERR_FILENO, "[%s]", wordlist->word->word); + ft_printf("[%s]", wordlist->word->word); wordlist = wordlist->next; } - ft_dprintf(STDERR_FILENO, "\n"); + ft_printf("\n"); } diff --git a/src/postprocess/redirections/redirection.c b/src/postprocess/redirections/redirection.c index 7a5771e..b38dec2 100644 --- a/src/postprocess/redirections/redirection.c +++ b/src/postprocess/redirections/redirection.c @@ -6,12 +6,13 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 14:26:26 by khais #+# #+# */ -/* Updated: 2025/03/07 14:34:28 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:38:10 by khais ### ########.fr */ /* */ /* ************************************************************************** */ #include "redirection.h" #include "libft.h" +#include "../../treedrawing.h" /* ** create a new redirection, with the given data @@ -41,3 +42,17 @@ void redirection_destroy(t_redirection *redirection) worddesc_destroy(redirection->marker); free(redirection); } + +void redirection_debug(t_redirection *redirection, t_buffer *leader, + bool is_last) +{ + indent(leader, is_last); + if (redirection == NULL) + { + ft_printf("%s\n", "(no redirections)"); + dedent(leader, is_last); + return ; + } + ft_printf("%s\n", "t_redirection"); + dedent(leader, is_last); +} diff --git a/src/postprocess/redirections/redirection.h b/src/postprocess/redirections/redirection.h index fea537a..6e3c3df 100644 --- a/src/postprocess/redirections/redirection.h +++ b/src/postprocess/redirections/redirection.h @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 14:26:06 by khais #+# #+# */ -/* Updated: 2025/03/07 14:49:24 by khais ### ########.fr */ +/* Updated: 2025/03/19 14:37:20 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,8 @@ # include "../../parser/worddesc/worddesc.h" # include "redirection_type.h" +# include "../../buffer/buffer.h" +# include typedef struct s_redirection { @@ -28,5 +30,7 @@ typedef struct s_redirection t_redirection *redirection_create(t_redir_type type, t_worddesc *marker); void redirection_destroy(t_redirection *redirection); +void redirection_debug(t_redirection *redirection, t_buffer *leader, + bool is_last); #endif // REDIRECTION_BASICS_H diff --git a/src/postprocess/redirections/redirection_list.c b/src/postprocess/redirections/redirection_list.c index 19d3570..8af4d46 100644 --- a/src/postprocess/redirections/redirection_list.c +++ b/src/postprocess/redirections/redirection_list.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/07 14:29:53 by khais #+# #+# */ -/* Updated: 2025/03/19 12:10:48 by khais ### ########.fr */ +/* Updated: 2025/03/20 11:38:46 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,8 +69,28 @@ t_redir_list *redir_list_push(t_redir_list *lst, t_redirection *item) void redir_list_debug(t_redir_list *lst, t_buffer *leader, bool is_last) { + size_t i; + bool last; + + if (lst == NULL) + { + indent(leader, is_last); + ft_printf("%s\n", "(no redirections)"); + dedent(leader, is_last); + return ; + } indent(leader, is_last); ft_printf("%s\n", "t_redir_list"); - (void)lst; + i = 0; + while (lst != NULL) + { + last = lst->next == NULL; + indent(leader, last); + ft_printf("%s[%d]\n", "redirection", i); + redirection_debug(lst->redirection, leader, true); + dedent(leader, last); + lst = lst->next; + i++; + } dedent(leader, is_last); }