mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
cmdlist debug: implement debug func (STUB)
I need to actually parse some cmdlists for this to have any meaning further
This commit is contained in:
parent
40c5164eef
commit
5379ad34f2
5 changed files with 62 additions and 17 deletions
1
Makefile
1
Makefile
|
|
@ -33,6 +33,7 @@ srcs = \
|
||||||
src/parser/cmdgroup/cmdgroup.c \
|
src/parser/cmdgroup/cmdgroup.c \
|
||||||
src/parser/cmdlist/cmdlist.c \
|
src/parser/cmdlist/cmdlist.c \
|
||||||
src/parser/cmdlist/cmdlist_builder.c \
|
src/parser/cmdlist/cmdlist_builder.c \
|
||||||
|
src/parser/cmdlist/cmdlist_debug.c \
|
||||||
src/parser/cmdlist/cmdlist_item.c \
|
src/parser/cmdlist/cmdlist_item.c \
|
||||||
src/parser/cmdlist/operator.c \
|
src/parser/cmdlist/operator.c \
|
||||||
src/parser/matchers/blank.c \
|
src/parser/matchers/blank.c \
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
|
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/18 15:32:01 by khais ### ########.fr */
|
/* Updated: 2025/03/18 15:54:18 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -36,6 +36,8 @@ void cmdgroup_destroy(t_cmdgroup *cmd)
|
||||||
|
|
||||||
void cmdgroup_debug(t_cmdgroup *cmd, t_buffer **leader, bool is_last)
|
void cmdgroup_debug(t_cmdgroup *cmd, t_buffer **leader, bool is_last)
|
||||||
{
|
{
|
||||||
|
if (cmd == NULL)
|
||||||
|
return ;
|
||||||
indent(leader, is_last);
|
indent(leader, is_last);
|
||||||
ft_printf("%s\n", "t_cmdgroup");
|
ft_printf("%s\n", "t_cmdgroup");
|
||||||
cmdlist_debug(&cmd->item, leader, false);
|
cmdlist_debug(&cmd->item, leader, false);
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,15 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/24 17:49:46 by khais #+# #+# */
|
/* Created: 2025/02/24 17:49:46 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/18 15:31:31 by khais ### ########.fr */
|
/* Updated: 2025/03/18 15:52:43 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "cmdlist.h"
|
#include "cmdlist.h"
|
||||||
#include "../../treedrawing.h"
|
|
||||||
#include "cmdlist_item.h"
|
#include "cmdlist_item.h"
|
||||||
#include "cmdlist_builder.h"
|
#include "cmdlist_builder.h"
|
||||||
#include "cmdlist_item_type.h"
|
#include "cmdlist_item_type.h"
|
||||||
#include "operator.h"
|
#include "operator.h"
|
||||||
#include "libft.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
@ -117,11 +115,3 @@ void cmdlist_destroy(t_cmdlist *cmd)
|
||||||
free(cmd->operators);
|
free(cmd->operators);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdlist_debug(t_cmdlist *cmd, t_buffer **leader, bool is_last)
|
|
||||||
{
|
|
||||||
indent(leader, is_last);
|
|
||||||
ft_printf("%s\n", "t_cmdlist");
|
|
||||||
(void)cmd; // TODO
|
|
||||||
dedent(leader, is_last);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
52
src/parser/cmdlist/cmdlist_debug.c
Normal file
52
src/parser/cmdlist/cmdlist_debug.c
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* cmdlist_debug.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/18 15:52:28 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/18 15:52:45 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "cmdlist.h"
|
||||||
|
#include "../../treedrawing.h"
|
||||||
|
#include "libft.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); */
|
||||||
|
dedent(leader, is_last);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmdlist_debug(t_cmdlist *cmd, t_buffer **leader, bool is_last)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
bool last;
|
||||||
|
|
||||||
|
if (cmd == NULL)
|
||||||
|
return ;
|
||||||
|
indent(leader, is_last);
|
||||||
|
ft_printf("%s\n", "t_cmdlist");
|
||||||
|
i = 0;
|
||||||
|
last = false;
|
||||||
|
if (cmd->num_cmds == 0)
|
||||||
|
last = true;
|
||||||
|
indent(leader, last);
|
||||||
|
ft_printf("num_cmds = %d\n", cmd->num_cmds);
|
||||||
|
dedent(leader, last);
|
||||||
|
while (i < cmd->num_cmds)
|
||||||
|
{
|
||||||
|
if (i == cmd->num_cmds - 1)
|
||||||
|
last = true;
|
||||||
|
cmdlist_array_debug(cmd, i, leader, last);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
dedent(leader, is_last);
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/18 12:24:25 by khais #+# #+# */
|
/* Created: 2025/03/18 12:24:25 by khais #+# #+# */
|
||||||
/* Updated: 2025/03/18 15:24:40 by khais ### ########.fr */
|
/* Updated: 2025/03/18 15:46:36 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue