debug: remove debug prints

This commit is contained in:
Khaïs COLIN 2025-03-04 13:20:50 +01:00 committed by Khaïs COLIN
parent 4bc6c1ab20
commit 14f7e523d3
6 changed files with 7 additions and 26 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);