From 14f7e523d316218ba0ea735cbbfa297cced6e99b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Tue, 4 Mar 2025 13:20:50 +0100 Subject: [PATCH] debug: remove debug prints --- src/parser/command_list/command_list.c | 15 ++------------- src/parser/command_list/command_list_builder.c | 5 +---- src/parser/pipeline/pipeline_parse.c | 3 +-- src/parser/worddesc/worddesc.c | 3 +-- src/parser/wordlist/wordlist.c | 4 +--- tests/cmdlist_use_after_free.c | 3 +-- 6 files changed, 7 insertions(+), 26 deletions(-) diff --git a/src/parser/command_list/command_list.c b/src/parser/command_list/command_list.c index 9e16d78..ba8b778 100644 --- a/src/parser/command_list/command_list.c +++ b/src/parser/command_list/command_list.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/24 17:49:46 by khais #+# #+# */ -/* Updated: 2025/03/04 12:41:51 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:48:37 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,11 +47,8 @@ static void cmdlist_builder_error(t_cmdlist_builder *builder) return ; cmdlist_destroy(builder->cmdlist); builder->cmdlist = NULL; - ft_dprintf(STDERR_FILENO, "current wordlist: %p\n", builder->current_wordlist); - ft_dprintf(STDERR_FILENO, "current wordlist->word: %p\n", builder->current_wordlist->word); wordlist_destroy(builder->current_wordlist); builder->current_wordlist = NULL; - ft_dprintf(STDERR_FILENO, "current wordlist has been freed: %p\n", builder->current_wordlist); worddesc_destroy(builder->current_word); builder->current_word = NULL; builder->error = true; @@ -68,15 +65,12 @@ static void cmdlist_builder_delimit( t_cmdlist_builder *builder, t_wordlist **words) { - ft_dprintf(STDERR_FILENO, "cmdlist delimit: "); wordlist_debug(builder->current_wordlist); builder->cmdlist->pipelines[builder->idx] = pipeline_from_wordlist(builder->current_wordlist); if (builder->cmdlist->pipelines[builder->idx] == NULL) { - ft_perror("invalid pipeline"); cmdlist_builder_error(builder); - ft_dprintf(STDERR_FILENO, "destroyed builder: %d\n", builder->error); return ; } if (cmdlist_builder_at_last_pipeline(builder)) @@ -98,23 +92,18 @@ t_cmdlist *cmdlist_from_wordlist(t_wordlist *words) t_cmdlist_builder builder; if (setup_cmdlist_builder(&builder, &words) == NULL) - return (ft_dprintf(STDERR_FILENO, "cmdlist: error during setup\n"), NULL); + return (NULL); while (builder.error == false && builder.current_word != NULL) { - ft_dprintf(STDERR_FILENO, "current word: %s\n", builder.current_word->word); if (match_op(builder.current_word->word) == OP_INVALID) cmdlist_builder_next_word(&builder, &words); else cmdlist_builder_delimit(&builder, &words); } - ft_dprintf(STDERR_FILENO, "cmdlist builder error: %d\n", builder.error); if (builder.current_wordlist != NULL) cmdlist_builder_delimit(&builder, &words); if (builder.error == true) - { - ft_dprintf(STDERR_FILENO, "cmdlist: returning null\n"); return (NULL); - } return (builder.cmdlist); } diff --git a/src/parser/command_list/command_list_builder.c b/src/parser/command_list/command_list_builder.c index 716e277..9de52d4 100644 --- a/src/parser/command_list/command_list_builder.c +++ b/src/parser/command_list/command_list_builder.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/26 13:51:18 by khais #+# #+# */ -/* Updated: 2025/02/26 17:02:05 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:19:51 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -78,10 +78,7 @@ t_cmdlist_builder *setup_cmdlist_builder( if (builder->cmdlist == NULL) return (NULL); builder->current_wordlist = NULL; - ft_dprintf(STDERR_FILENO, "words before pop in setup: %p\n", *words); builder->current_word = wordlist_pop(words); - ft_dprintf(STDERR_FILENO, "builder->current_word after pop in setup: %p\n", builder->current_word); - ft_dprintf(STDERR_FILENO, "words after pop in setup: %p\n", *words); builder->idx = 0; return (builder); } diff --git a/src/parser/pipeline/pipeline_parse.c b/src/parser/pipeline/pipeline_parse.c index 49d1188..6829041 100644 --- a/src/parser/pipeline/pipeline_parse.c +++ b/src/parser/pipeline/pipeline_parse.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/24 14:36:43 by khais #+# #+# */ -/* Updated: 2025/03/04 12:21:38 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:19:46 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -107,7 +107,6 @@ t_pipeline *pipeline_parse_wordlist(t_pipeline_builder *builder) return (builder_destroy(builder), ft_errno(FT_EUNEXPECTED_PIPE), NULL); while (!eof(builder)) { - ft_dprintf(STDERR_FILENO, "pipeline parse: current word: [%s]\n", builder->current_word); if (current_is_pipe(builder)) { pipeline_delimit(builder); diff --git a/src/parser/worddesc/worddesc.c b/src/parser/worddesc/worddesc.c index 08ab9f3..6058601 100644 --- a/src/parser/worddesc/worddesc.c +++ b/src/parser/worddesc/worddesc.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/13 17:20:36 by khais #+# #+# */ -/* Updated: 2025/03/09 12:35:55 by khais ### ########.fr */ +/* Updated: 2025/03/09 12:36:22 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,7 +45,6 @@ t_worddesc *worddesc_create(char *word, char flags, char *marker) */ void worddesc_destroy(t_worddesc *worddesc) { - ft_dprintf(STDERR_FILENO, "WORDDESC_destroy: %p\n", worddesc); if (worddesc == NULL) return ; free(worddesc->word); diff --git a/src/parser/wordlist/wordlist.c b/src/parser/wordlist/wordlist.c index bd46138..57fdc06 100644 --- a/src/parser/wordlist/wordlist.c +++ b/src/parser/wordlist/wordlist.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/02/13 17:07:01 by khais #+# #+# */ -/* Updated: 2025/02/26 16:57:59 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:20:47 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,7 +43,6 @@ void wordlist_destroy(t_wordlist *wordlist) while (wordlist != NULL) { - ft_dprintf(STDERR_FILENO, "wordlist_destroy: %p\n", wordlist); worddesc_destroy(wordlist->word); prev = wordlist; wordlist = wordlist->next; @@ -111,6 +110,5 @@ t_worddesc *wordlist_pop(t_wordlist **wordlist) (*wordlist) = first->next; word = first->word; free(first); - ft_dprintf(STDERR_FILENO, "freed a wordlist in wordlist_pop: %p\n", first); return (word); } diff --git a/tests/cmdlist_use_after_free.c b/tests/cmdlist_use_after_free.c index bc65e31..3f9462a 100644 --- a/tests/cmdlist_use_after_free.c +++ b/tests/cmdlist_use_after_free.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/03 11:40:37 by khais #+# #+# */ -/* Updated: 2025/03/03 13:09:12 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:27:54 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,6 @@ int main(void) { t_wordlist *words = minishell_wordsplit("|"); - ft_printf("FINISHED PARSING WORDS!\n"); t_cmdlist *cmd = cmdlist_from_wordlist(words); assert(cmd == NULL); return (0);