mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
debug: remove debug prints
This commit is contained in:
parent
4bc6c1ab20
commit
14f7e523d3
6 changed files with 7 additions and 26 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* 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/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 ;
|
return ;
|
||||||
cmdlist_destroy(builder->cmdlist);
|
cmdlist_destroy(builder->cmdlist);
|
||||||
builder->cmdlist = NULL;
|
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);
|
wordlist_destroy(builder->current_wordlist);
|
||||||
builder->current_wordlist = NULL;
|
builder->current_wordlist = NULL;
|
||||||
ft_dprintf(STDERR_FILENO, "current wordlist has been freed: %p\n", builder->current_wordlist);
|
|
||||||
worddesc_destroy(builder->current_word);
|
worddesc_destroy(builder->current_word);
|
||||||
builder->current_word = NULL;
|
builder->current_word = NULL;
|
||||||
builder->error = true;
|
builder->error = true;
|
||||||
|
|
@ -68,15 +65,12 @@ static void cmdlist_builder_delimit(
|
||||||
t_cmdlist_builder *builder,
|
t_cmdlist_builder *builder,
|
||||||
t_wordlist **words)
|
t_wordlist **words)
|
||||||
{
|
{
|
||||||
ft_dprintf(STDERR_FILENO, "cmdlist delimit: ");
|
|
||||||
wordlist_debug(builder->current_wordlist);
|
wordlist_debug(builder->current_wordlist);
|
||||||
builder->cmdlist->pipelines[builder->idx]
|
builder->cmdlist->pipelines[builder->idx]
|
||||||
= pipeline_from_wordlist(builder->current_wordlist);
|
= pipeline_from_wordlist(builder->current_wordlist);
|
||||||
if (builder->cmdlist->pipelines[builder->idx] == NULL)
|
if (builder->cmdlist->pipelines[builder->idx] == NULL)
|
||||||
{
|
{
|
||||||
ft_perror("invalid pipeline");
|
|
||||||
cmdlist_builder_error(builder);
|
cmdlist_builder_error(builder);
|
||||||
ft_dprintf(STDERR_FILENO, "destroyed builder: %d\n", builder->error);
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
if (cmdlist_builder_at_last_pipeline(builder))
|
if (cmdlist_builder_at_last_pipeline(builder))
|
||||||
|
|
@ -98,23 +92,18 @@ t_cmdlist *cmdlist_from_wordlist(t_wordlist *words)
|
||||||
t_cmdlist_builder builder;
|
t_cmdlist_builder builder;
|
||||||
|
|
||||||
if (setup_cmdlist_builder(&builder, &words) == NULL)
|
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)
|
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)
|
if (match_op(builder.current_word->word) == OP_INVALID)
|
||||||
cmdlist_builder_next_word(&builder, &words);
|
cmdlist_builder_next_word(&builder, &words);
|
||||||
else
|
else
|
||||||
cmdlist_builder_delimit(&builder, &words);
|
cmdlist_builder_delimit(&builder, &words);
|
||||||
}
|
}
|
||||||
ft_dprintf(STDERR_FILENO, "cmdlist builder error: %d\n", builder.error);
|
|
||||||
if (builder.current_wordlist != NULL)
|
if (builder.current_wordlist != NULL)
|
||||||
cmdlist_builder_delimit(&builder, &words);
|
cmdlist_builder_delimit(&builder, &words);
|
||||||
if (builder.error == true)
|
if (builder.error == true)
|
||||||
{
|
|
||||||
ft_dprintf(STDERR_FILENO, "cmdlist: returning null\n");
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
|
||||||
return (builder.cmdlist);
|
return (builder.cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/26 13:51:18 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)
|
if (builder->cmdlist == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
builder->current_wordlist = NULL;
|
builder->current_wordlist = NULL;
|
||||||
ft_dprintf(STDERR_FILENO, "words before pop in setup: %p\n", *words);
|
|
||||||
builder->current_word = wordlist_pop(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;
|
builder->idx = 0;
|
||||||
return (builder);
|
return (builder);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/24 14:36:43 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);
|
return (builder_destroy(builder), ft_errno(FT_EUNEXPECTED_PIPE), NULL);
|
||||||
while (!eof(builder))
|
while (!eof(builder))
|
||||||
{
|
{
|
||||||
ft_dprintf(STDERR_FILENO, "pipeline parse: current word: [%s]\n", builder->current_word);
|
|
||||||
if (current_is_pipe(builder))
|
if (current_is_pipe(builder))
|
||||||
{
|
{
|
||||||
pipeline_delimit(builder);
|
pipeline_delimit(builder);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/13 17:20:36 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)
|
void worddesc_destroy(t_worddesc *worddesc)
|
||||||
{
|
{
|
||||||
ft_dprintf(STDERR_FILENO, "WORDDESC_destroy: %p\n", worddesc);
|
|
||||||
if (worddesc == NULL)
|
if (worddesc == NULL)
|
||||||
return ;
|
return ;
|
||||||
free(worddesc->word);
|
free(worddesc->word);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/13 17:07:01 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)
|
while (wordlist != NULL)
|
||||||
{
|
{
|
||||||
ft_dprintf(STDERR_FILENO, "wordlist_destroy: %p\n", wordlist);
|
|
||||||
worddesc_destroy(wordlist->word);
|
worddesc_destroy(wordlist->word);
|
||||||
prev = wordlist;
|
prev = wordlist;
|
||||||
wordlist = wordlist->next;
|
wordlist = wordlist->next;
|
||||||
|
|
@ -111,6 +110,5 @@ t_worddesc *wordlist_pop(t_wordlist **wordlist)
|
||||||
(*wordlist) = first->next;
|
(*wordlist) = first->next;
|
||||||
word = first->word;
|
word = first->word;
|
||||||
free(first);
|
free(first);
|
||||||
ft_dprintf(STDERR_FILENO, "freed a wordlist in wordlist_pop: %p\n", first);
|
|
||||||
return (word);
|
return (word);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/03 11:40:37 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)
|
int main(void)
|
||||||
{
|
{
|
||||||
t_wordlist *words = minishell_wordsplit("|");
|
t_wordlist *words = minishell_wordsplit("|");
|
||||||
ft_printf("FINISHED PARSING WORDS!\n");
|
|
||||||
t_cmdlist *cmd = cmdlist_from_wordlist(words);
|
t_cmdlist *cmd = cmdlist_from_wordlist(words);
|
||||||
assert(cmd == NULL);
|
assert(cmd == NULL);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue