diff --git a/src/executing/simple_cmd/simple_cmd_execute_debug.c b/src/executing/simple_cmd/simple_cmd_execute_debug.c index e775d9e..6d8a9bd 100644 --- a/src/executing/simple_cmd/simple_cmd_execute_debug.c +++ b/src/executing/simple_cmd/simple_cmd_execute_debug.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/10 15:36:26 by khais #+# #+# */ -/* Updated: 2025/04/15 15:34:44 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:05:49 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ void simple_cmd_execute_debug(t_simple_cmd *cmd, t_minishell *app) { if (app->debug) { - ft_printf("about to execute\n"); + ft_dprintf(STDERR_FILENO, "about to execute\n"); simple_cmd_root_debug(cmd); } } @@ -27,7 +27,7 @@ void simple_cmd_post_process_debug(t_simple_cmd *cmd, t_minishell *app) { if (app->debug) { - ft_printf("about to post-process\n"); + ft_dprintf(STDERR_FILENO, "about to post-process\n"); simple_cmd_root_debug(cmd); } } diff --git a/src/parser/cmd/cmd_debug.c b/src/parser/cmd/cmd_debug.c index 6b6e361..d183474 100644 --- a/src/parser/cmd/cmd_debug.c +++ b/src/parser/cmd/cmd_debug.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/09 16:53:27 by khais #+# #+# */ -/* Updated: 2025/04/17 12:24:52 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:05:34 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,20 +21,20 @@ static void cmd_type_debug(t_cmd_type type, t_buffer *leader, bool is_last) { indent(leader, is_last); - ft_printf("t_cmd_type = "); + ft_dprintf(STDERR_FILENO, "t_cmd_type = "); if (type == FT_CONNECTION) - ft_printf("FT_CONNECTION\n"); + ft_dprintf(STDERR_FILENO, "FT_CONNECTION\n"); if (type == FT_GROUP) - ft_printf("FT_GROUP\n"); + ft_dprintf(STDERR_FILENO, "FT_GROUP\n"); if (type == FT_SIMPLE) - ft_printf("FT_SIMPLE\n"); + ft_dprintf(STDERR_FILENO, "FT_SIMPLE\n"); dedent(leader, is_last); } static void cmd_value_debug(t_cmd *cmd, t_buffer *leader, bool is_last) { indent(leader, is_last); - ft_printf("value\n"); + ft_dprintf(STDERR_FILENO, "value\n"); if (cmd->type == FT_CONNECTION) connec_cmd_debug(cmd->value.connection, leader, true); if (cmd->type == FT_GROUP) @@ -48,16 +48,16 @@ void cmd_debug(t_cmd *cmd, t_buffer *leader, bool is_last) { indent(leader, is_last); if (cmd == NULL) - ft_printf("t_cmd = NULL\n"); + ft_dprintf(STDERR_FILENO, "t_cmd = NULL\n"); else { - ft_printf("t_cmd\n"); + ft_dprintf(STDERR_FILENO, "t_cmd\n"); cmd_type_debug(cmd->type, leader, false); indent(leader, false); - ft_printf("flags = %d\n", cmd->flags); + ft_dprintf(STDERR_FILENO, "flags = %d\n", cmd->flags); dedent(leader, false); indent(leader, false); - ft_printf("line = %d\n", cmd->line); + ft_dprintf(STDERR_FILENO, "line = %d\n", cmd->line); dedent(leader, false); cmd_value_debug(cmd, leader, true); } diff --git a/src/parser/connec_cmd/connec_cmd_debug.c b/src/parser/connec_cmd/connec_cmd_debug.c index cd3d433..9a6c693 100644 --- a/src/parser/connec_cmd/connec_cmd_debug.c +++ b/src/parser/connec_cmd/connec_cmd_debug.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/09 17:47:18 by khais #+# #+# */ -/* Updated: 2025/04/09 17:49:02 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:04:50 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,13 +19,13 @@ static void connector_debug(t_connector connector, t_buffer *leader, bool is_last) { indent(leader, is_last); - ft_printf("t_connector = "); + ft_dprintf(STDERR_FILENO, "t_connector = "); if (connector == FT_PIPE) - ft_printf("FT_PIPE\n"); + ft_dprintf(STDERR_FILENO, "FT_PIPE\n"); if (connector == FT_AND) - ft_printf("FT_AND\n"); + ft_dprintf(STDERR_FILENO, "FT_AND\n"); if (connector == FT_OR) - ft_printf("FT_OR\n"); + ft_dprintf(STDERR_FILENO, "FT_OR\n"); dedent(leader, is_last); } @@ -33,16 +33,16 @@ void connec_cmd_debug(t_connec_cmd *cmd, t_buffer *leader, bool is_last) { indent(leader, is_last); if (cmd == NULL) - ft_printf("t_connec_cmd = NULL\n"); + ft_dprintf(STDERR_FILENO, "t_connec_cmd = NULL\n"); else { - ft_printf("t_connec_cmd\n"); + ft_dprintf(STDERR_FILENO, "t_connec_cmd\n"); indent(leader, false); - ft_printf("first\n"); + ft_dprintf(STDERR_FILENO, "first\n"); cmd_debug(cmd->first, leader, true); dedent(leader, false); indent(leader, false); - ft_printf("second\n"); + ft_dprintf(STDERR_FILENO, "second\n"); cmd_debug(cmd->second, leader, true); dedent(leader, false); connector_debug(cmd->connector, leader, true); diff --git a/src/parser/group_cmd/group_cmd_debug.c b/src/parser/group_cmd/group_cmd_debug.c index 83af892..cec715e 100644 --- a/src/parser/group_cmd/group_cmd_debug.c +++ b/src/parser/group_cmd/group_cmd_debug.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/09 17:43:56 by khais #+# #+# */ -/* Updated: 2025/04/25 17:49:38 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:04:58 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,13 +19,13 @@ void group_cmd_debug(t_group_cmd *cmd, t_buffer *leader, bool is_last) { indent(leader, is_last); - ft_printf("t_group_cmd\n"); + ft_dprintf(STDERR_FILENO, "t_group_cmd\n"); indent(leader, false); - ft_printf("cmd\n"); + ft_dprintf(STDERR_FILENO, "cmd\n"); cmd_debug(cmd->cmd, leader, true); dedent(leader, false); indent(leader, true); - ft_printf("redirect\n"); + ft_dprintf(STDERR_FILENO, "redirect\n"); redirect_debug(cmd->redirects, leader, true); dedent(leader, true); dedent(leader, is_last); diff --git a/src/parser/redirect/redirect_debug.c b/src/parser/redirect/redirect_debug.c index 07b2a03..e638894 100644 --- a/src/parser/redirect/redirect_debug.c +++ b/src/parser/redirect/redirect_debug.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/09 15:07:58 by khais #+# #+# */ -/* Updated: 2025/04/24 13:30:44 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:12:54 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,15 +18,16 @@ static void redir_type_debug(t_redir_type type, t_buffer *leader, bool is_last) { indent(leader, is_last); if (type == FT_INVALID_REDIR) - ft_printf("redir_type = %s\n", "FT_INVALID_REDIR"); + ft_dprintf(STDERR_FILENO, "redir_type = %s\n", "FT_INVALID_REDIR"); if (type == FT_OUTPUT_TRUNC_REDIR) - ft_printf("redir_type = %s\n", "FT_OUTPUT_TRUNC_REDIR"); + ft_dprintf(STDERR_FILENO, "redir_type = %s\n", "FT_OUTPUT_TRUNC_REDIR"); if (type == FT_OUTPUT_APPEND_REDIR) - ft_printf("redir_type = %s\n", "FT_OUTPUT_APPEND_REDIR"); + ft_dprintf(STDERR_FILENO, "redir_type = %s\n", + "FT_OUTPUT_APPEND_REDIR"); if (type == FT_INPUT_REDIR) - ft_printf("redir_type = %s\n", "FT_INPUT_REDIR"); + ft_dprintf(STDERR_FILENO, "redir_type = %s\n", "FT_INPUT_REDIR"); if (type == FT_HEREDOC) - ft_printf("redir_type = %s\n", "FT_HEREDOC"); + ft_dprintf(STDERR_FILENO, "redir_type = %s\n", "FT_HEREDOC"); dedent(leader, is_last); } @@ -34,11 +35,11 @@ static void redirectee_debug(t_redirectee redirectee, t_buffer *leader, bool is_last, bool is_here_doc) { indent(leader, is_last); - ft_printf("t_redirectee\n"); + ft_dprintf(STDERR_FILENO, "t_redirectee\n"); if (is_here_doc) { indent(leader, false); - ft_printf("dest = %d\n", redirectee.dest); + ft_dprintf(STDERR_FILENO, "dest = %d\n", redirectee.dest); dedent(leader, false); } else @@ -52,24 +53,24 @@ static void single_redirect_debug(t_redirect *redirect, t_buffer *leader, if (redirect == NULL) return ; indent(leader, is_last); - ft_printf("t_redirect\n"); + ft_dprintf(STDERR_FILENO, "t_redirect\n"); redir_type_debug(redirect->type, leader, false); indent(leader, false); - ft_printf("source = %d\n", redirect->source); + ft_dprintf(STDERR_FILENO, "source = %d\n", redirect->source); dedent(leader, false); indent(leader, false); - ft_printf("open_flags = %d\n", redirect->open_flags); + ft_dprintf(STDERR_FILENO, "open_flags = %d\n", redirect->open_flags); dedent(leader, false); indent(leader, false); - ft_printf("c_flags = %d\n", redirect->c_flags); + ft_dprintf(STDERR_FILENO, "c_flags = %d\n", redirect->c_flags); dedent(leader, false); redirectee_debug(redirect->redirectee, leader, false, redirect->type == FT_HEREDOC); indent(leader, false); - ft_printf("c_flags = [%s]\n", redirect->here_doc_eof); + ft_dprintf(STDERR_FILENO, "c_flags = [%s]\n", redirect->here_doc_eof); dedent(leader, false); indent(leader, true); - ft_printf("here_doc_eof = [%s]\n", redirect->here_doc_eof); + ft_dprintf(STDERR_FILENO, "here_doc_eof = [%s]\n", redirect->here_doc_eof); dedent(leader, true); dedent(leader, is_last); } @@ -80,15 +81,15 @@ void redirect_debug(t_redirect *redirect, t_buffer *leader, bool is_last) indent(leader, is_last); if (redirect == NULL) - ft_printf("redirections = (empty redir list)\n"); + ft_dprintf(STDERR_FILENO, "redirections = (empty redir list)\n"); else { - ft_printf("redirections\n"); + ft_dprintf(STDERR_FILENO, "redirections\n"); i = 0; while (redirect != NULL) { indent(leader, redirect->next == NULL); - ft_printf("redirections[%d]\n", i); + ft_dprintf(STDERR_FILENO, "redirections[%d]\n", i); single_redirect_debug(redirect, leader, true); dedent(leader, redirect->next == NULL); redirect = redirect->next; diff --git a/src/parser/simple_cmd/simple_cmd.c b/src/parser/simple_cmd/simple_cmd.c index 65d90e5..3a5a878 100644 --- a/src/parser/simple_cmd/simple_cmd.c +++ b/src/parser/simple_cmd/simple_cmd.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/21 12:30:07 by khais #+# #+# */ -/* Updated: 2025/04/15 14:47:13 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:09:43 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,9 +46,9 @@ 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"); + ft_dprintf(STDERR_FILENO, "%s\n", "t_simple_cmd"); indent(leader, false); - ft_printf("line = %d\n", cmd->line); + ft_dprintf(STDERR_FILENO, "line = %d\n", cmd->line); dedent(leader, false); wordlist_debug(cmd->words, leader, false); redirect_debug(cmd->redirections, leader, true); diff --git a/src/parser/worddesc/worddesc_debug.c b/src/parser/worddesc/worddesc_debug.c index abfd17b..cc07784 100644 --- a/src/parser/worddesc/worddesc_debug.c +++ b/src/parser/worddesc/worddesc_debug.c @@ -6,10 +6,11 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/18 09:19:54 by khais #+# #+# */ -/* Updated: 2025/04/18 09:20:21 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:14:20 by khais ### ########.fr */ /* */ /* ************************************************************************** */ +#include #include "worddesc.h" #include "../../treedrawing.h" #include "libft.h" @@ -17,28 +18,29 @@ static void token_type_debug(t_token_type type, t_buffer *leader, bool is_last) { indent(leader, is_last); + ft_dprintf(STDERR_FILENO, "t_token_type = "); if (type == NOT_TOKEN) - ft_printf("t_token_type = %s\n", "NOT_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "NOT_TOKEN"); if (type == WORD_TOKEN) - ft_printf("t_token_type = %s\n", "WORD_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "WORD_TOKEN"); if (type == OPEN_PARENTH_TOKEN) - ft_printf("t_token_type = %s\n", "OPEN_PARENTH_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "OPEN_PARENTH_TOKEN"); if (type == CLOSE_PARENTH_TOKEN) - ft_printf("t_token_type = %s\n", "CLOSE_PARENTH_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "CLOSE_PARENTH_TOKEN"); if (type == PIPE_TOKEN) - ft_printf("t_token_type = %s\n", "PIPE_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "PIPE_TOKEN"); if (type == OR_TOKEN) - ft_printf("t_token_type = %s\n", "OR_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "OR_TOKEN"); if (type == AND_TOKEN) - ft_printf("t_token_type = %s\n", "AND_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "AND_TOKEN"); if (type == OUT_TRUNC_REDIR_TOKEN) - ft_printf("t_token_type = %s\n", "OUT_TRUNC_REDIR_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "OUT_TRUNC_REDIR_TOKEN"); if (type == OUT_APPEND_REDIR_TOKEN) - ft_printf("t_token_type = %s\n", "OUT_APPEND_REDIR_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "OUT_APPEND_REDIR_TOKEN"); if (type == IN_REDIR_TOKEN) - ft_printf("t_token_type = %s\n", "IN_REDIR_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "IN_REDIR_TOKEN"); if (type == HERE_DOC_REDIR_TOKEN) - ft_printf("t_token_type = %s\n", "HERE_DOC_REDIR_TOKEN"); + ft_dprintf(STDERR_FILENO, "%s\n", "HERE_DOC_REDIR_TOKEN"); dedent(leader, is_last); } @@ -46,18 +48,18 @@ void worddesc_debug(t_worddesc *worddesc, t_buffer *leader, bool is_last) { indent(leader, is_last); if (worddesc == NULL) - ft_printf("(null worddesc)\n"); + ft_dprintf(STDERR_FILENO, "(null worddesc)\n"); else { - ft_printf("t_worddesc\n"); + ft_dprintf(STDERR_FILENO, "t_worddesc\n"); indent(leader, false); - ft_printf("word = [%s]\n", worddesc->word); + ft_dprintf(STDERR_FILENO, "word = [%s]\n", worddesc->word); dedent(leader, false); indent(leader, false); - ft_printf("marker = [%s]\n", worddesc->marker); + ft_dprintf(STDERR_FILENO, "marker = [%s]\n", worddesc->marker); dedent(leader, false); indent(leader, false); - ft_printf("flags = %d\n", worddesc->flags); + ft_dprintf(STDERR_FILENO, "flags = %d\n", worddesc->flags); dedent(leader, false); token_type_debug(worddesc->token_type, leader, true); } diff --git a/src/parser/wordlist/wordlist_debug.c b/src/parser/wordlist/wordlist_debug.c index ac458b1..a7524fd 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/04/16 15:10:13 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:05:20 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,10 +21,10 @@ void wordlist_debug(t_wordlist *wordlist, t_buffer *leader, bool is_last) { indent(leader, is_last); if (wordlist == NULL) - ft_printf("t_wordlist = (empty wordlist)\n"); + ft_dprintf(STDERR_FILENO, "t_wordlist = (empty wordlist)\n"); else { - ft_printf("t_wordlist\n"); + ft_dprintf(STDERR_FILENO, "t_wordlist\n"); while (wordlist != NULL) { worddesc_debug(wordlist->word, leader, wordlist->next == NULL); diff --git a/src/treedrawing.c b/src/treedrawing.c index 6dff6ab..be77519 100644 --- a/src/treedrawing.c +++ b/src/treedrawing.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/18 15:24:50 by khais #+# #+# */ -/* Updated: 2025/03/19 14:00:35 by khais ### ########.fr */ +/* Updated: 2025/04/29 13:16:44 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,15 +15,15 @@ void indent(t_buffer *leader, bool is_last) { - ft_printf("%s", leader->buffer); + ft_dprintf(STDERR_FILENO, "%s", leader->buffer); if (is_last) { - ft_printf("%s", CORNER); + ft_dprintf(STDERR_FILENO, "%s", CORNER); ft_buffer_push_buf(leader, SPACE, ft_strlen(SPACE)); } else { - ft_printf("%s", CROSS); + ft_dprintf(STDERR_FILENO, "%s", CROSS); ft_buffer_push_buf(leader, VERTICAL, ft_strlen(VERTICAL)); } }