mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
implement tree debug for redirections
This commit is contained in:
parent
88ed66e138
commit
9fb4e13420
5 changed files with 49 additions and 8 deletions
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/21 14:40:02 by khais #+# #+# */
|
||||
/* Updated: 2025/03/21 14:40:07 by khais ### ########.fr */
|
||||
/* Created: 2025/02/13 17:20:36 by khais #+# #+# */
|
||||
/* Updated: 2025/03/27 13:57:29 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#include "libft.h"
|
||||
#include "libft/libft.h"
|
||||
#include <stdlib.h>
|
||||
#include "../../treedrawing.h"
|
||||
|
||||
/*
|
||||
** allocate a new worddesc with given flags, marker, and word.
|
||||
|
|
@ -71,3 +72,13 @@ t_worddesc *worddesc_copy(t_worddesc *worddesc)
|
|||
return (free(out), NULL);
|
||||
return (out);
|
||||
}
|
||||
|
||||
void worddesc_debug(t_worddesc *worddesc, t_buffer *leader, bool is_last)
|
||||
{
|
||||
indent(leader, is_last);
|
||||
if (worddesc == NULL)
|
||||
ft_printf("%s\n", "(nil)");
|
||||
else
|
||||
ft_printf("[%s]\n", worddesc->word);
|
||||
dedent(leader, is_last);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,16 +3,19 @@
|
|||
/* ::: :::::::: */
|
||||
/* worddesc.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: jguelen <jguelen@student.42.fr> +#+ +:+ +#+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 15:47:58 by khais #+# #+# */
|
||||
/* Updated: 2025/03/21 10:09:06 by jguelen ### ########.fr */
|
||||
/* Created: 2025/03/27 13:57:44 by khais #+# #+# */
|
||||
/* Updated: 2025/03/27 13:57:49 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef WORDDESC_H
|
||||
# define WORDDESC_H
|
||||
|
||||
# include "../../buffer/buffer.h"
|
||||
# include <stdbool.h>
|
||||
|
||||
/* Possible values for the `flags' field of a WORD_DESC. */
|
||||
# define W_HASDOLLAR 0b1 /* Dollar sign present. */
|
||||
# define W_QUOTED 0b10 /* Some form of quote character is present. */
|
||||
|
|
@ -58,5 +61,7 @@ typedef struct s_worddesc
|
|||
t_worddesc *worddesc_create(char *word, char flags, char *marker);
|
||||
void worddesc_destroy(t_worddesc *worddesc);
|
||||
t_worddesc *worddesc_copy(t_worddesc *worddesc);
|
||||
void worddesc_debug(t_worddesc *worddesc, t_buffer *leader,
|
||||
bool is_last);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 14:26:26 by khais #+# #+# */
|
||||
/* Updated: 2025/03/19 14:38:10 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/19 16:58:50 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -54,5 +54,9 @@ void redirection_debug(t_redirection *redirection, t_buffer *leader,
|
|||
return ;
|
||||
}
|
||||
ft_printf("%s\n", "t_redirection");
|
||||
redir_type_debug(redirection->type, leader, false);
|
||||
indent(leader, true);
|
||||
ft_printf("%s = [%s]\n", "marker", redirection->marker->word);
|
||||
dedent(leader, true);
|
||||
dedent(leader, is_last);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 14:56:29 by khais #+# #+# */
|
||||
/* Updated: 2025/03/10 16:51:39 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/19 16:59:14 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "redirection_type.h"
|
||||
#include "libft.h"
|
||||
#include "../../treedrawing.h"
|
||||
|
||||
t_redir_type redir_type_from_worddesc(t_worddesc *word)
|
||||
{
|
||||
|
|
@ -25,3 +26,19 @@ t_redir_type redir_type_from_worddesc(t_worddesc *word)
|
|||
return (REDIR_APPEND);
|
||||
return (REDIR_INVALID);
|
||||
}
|
||||
|
||||
void redir_type_debug(t_redir_type type, t_buffer *leader,
|
||||
bool is_last)
|
||||
{
|
||||
indent(leader, is_last);
|
||||
ft_printf("t_redir_type = ");
|
||||
if (type == REDIR_OUTPUT)
|
||||
ft_printf("%s\n", "REDIR_OUTPUT");
|
||||
if (type == REDIR_INPUT)
|
||||
ft_printf("%s\n", "REDIR_INPUT");
|
||||
if (type == REDIR_HERE_DOC)
|
||||
ft_printf("%s\n", "REDIR_HERE_DOC");
|
||||
if (type == REDIR_APPEND)
|
||||
ft_printf("%s\n", "REDIR_APPEND");
|
||||
dedent(leader, is_last);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 14:37:12 by khais #+# #+# */
|
||||
/* Updated: 2025/03/07 14:56:07 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/19 16:52:09 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,6 +14,8 @@
|
|||
# define REDIRECTION_TYPE_H
|
||||
|
||||
# include "../../parser/worddesc/worddesc.h"
|
||||
# include "../../buffer/buffer.h"
|
||||
# include <stdbool.h>
|
||||
|
||||
/*
|
||||
** Type of redirection.
|
||||
|
|
@ -33,5 +35,7 @@ typedef enum e_redirection_type
|
|||
} t_redir_type;
|
||||
|
||||
t_redir_type redir_type_from_worddesc(t_worddesc *word);
|
||||
void redir_type_debug(t_redir_type type, t_buffer *leader,
|
||||
bool is_last);
|
||||
|
||||
#endif // REDIRECTION_TYPE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue