mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
tree debug: implement rest of tree debug
This is a big commit, sorry!
This commit is contained in:
parent
76b2b8ec7f
commit
1f03cbbedb
16 changed files with 190 additions and 159 deletions
1
Makefile
1
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 \
|
||||
|
|
|
|||
136
report.txt
136
report.txt
|
|
@ -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)
|
||||
[36m14,15d13[0m
|
||||
[31m< │ │ │ ├─ t_redir_type = REDIR_INPUT[0m
|
||||
[31m< │ │ │ ╰─ marker = [in][0m
|
||||
[36m18,19d15[0m
|
||||
[31m< │ │ ├─ t_redir_type = REDIR_OUTPUT[0m
|
||||
[31m< │ │ ╰─ marker = [out][0m
|
||||
++++ 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)
|
||||
[36m1,33c1[0m
|
||||
[31m< ╰─ t_cmdgroup[0m
|
||||
[31m< ├─ t_cmdlist[0m
|
||||
[31m< │ ├─ num_cmds = 1[0m
|
||||
[31m< │ ╰─ cmd[0][0m
|
||||
[31m< │ ├─ t_cmdlist_item[0m
|
||||
[31m< │ │ ╰─ t_pipeline[0m
|
||||
[31m< │ │ ├─ num_cmd = 1[0m
|
||||
[31m< │ │ ╰─ cmd[0][0m
|
||||
[31m< │ │ ╰─ t_simple_cmd[0m
|
||||
[31m< │ │ ├─ words = [echo][hello][0m
|
||||
[31m< │ │ ╰─ t_redir_list[0m
|
||||
[31m< │ │ ├─ redirection[0][0m
|
||||
[31m< │ │ │ ╰─ t_redirection[0m
|
||||
[31m< │ │ │ ├─ t_redir_type = REDIR_HERE_DOC[0m
|
||||
[31m< │ │ │ ╰─ marker = [HERE_DOC][0m
|
||||
[31m< │ │ ├─ redirection[1][0m
|
||||
[31m< │ │ │ ╰─ t_redirection[0m
|
||||
[31m< │ │ │ ├─ t_redir_type = REDIR_OUTPUT[0m
|
||||
[31m< │ │ │ ╰─ marker = [outfile][0m
|
||||
[31m< │ │ ├─ redirection[2][0m
|
||||
[31m< │ │ │ ╰─ t_redirection[0m
|
||||
[31m< │ │ │ ├─ t_redir_type = REDIR_INPUT[0m
|
||||
[31m< │ │ │ ╰─ marker = [infile][0m
|
||||
[31m< │ │ ├─ redirection[3][0m
|
||||
[31m< │ │ │ ╰─ t_redirection[0m
|
||||
[31m< │ │ │ ├─ t_redir_type = REDIR_INPUT[0m
|
||||
[31m< │ │ │ ╰─ marker = [infile2][0m
|
||||
[31m< │ │ ╰─ redirection[4][0m
|
||||
[31m< │ │ ╰─ t_redirection[0m
|
||||
[31m< │ │ ├─ t_redir_type = REDIR_APPEND[0m
|
||||
[31m< │ │ ╰─ marker = [append][0m
|
||||
[31m< │ ╰─ t_operator = END[0m
|
||||
[31m< ╰─ (no redirections)[0m
|
||||
---
|
||||
[32m> [0m
|
||||
++++ Run this to debug:
|
||||
echo 'echo << HERE_DOC hello>outfile < infile < infile2 >> append' | ./minishell
|
||||
|
|
@ -6,22 +6,29 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,16 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <stdbool.h>
|
||||
|
||||
/*
|
||||
** 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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <stdbool.h>
|
||||
|
||||
/*
|
||||
|
|
@ -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
|
||||
|
|
|
|||
56
src/parser/pipeline/pipeline_debug.c
Normal file
56
src/parser/pipeline/pipeline_debug.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* pipeline_debug.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
@ -6,12 +6,14 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <stdbool.h>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <stdbool.h>
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue