wordlist: add a function to debug-print a wordlist

This commit is contained in:
Khaïs COLIN 2025-02-24 18:18:15 +01:00 committed by Khaïs COLIN
parent eb21f00156
commit 3b8b2c7a4a
4 changed files with 33 additions and 2 deletions

View file

@ -41,6 +41,7 @@ srcs = \
src/parser/simple_cmd/simple_cmd.c \
src/parser/worddesc/worddesc.c \
src/parser/wordlist/wordlist.c \
src/parser/wordlist/wordlist_debug.c \
src/parser/wordsplit/rule_utils.c \
src/parser/wordsplit/tokenizing_1_5.c \
src/parser/wordsplit/tokenizing_6_10.c \

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 17:07:01 by khais #+# #+# */
/* Updated: 2025/02/21 14:04:50 by khais ### ########.fr */
/* Updated: 2025/02/24 18:20:18 by khais ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 15:46:02 by khais #+# #+# */
/* Updated: 2025/02/21 14:00:19 by khais ### ########.fr */
/* Updated: 2025/02/24 18:14:37 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -39,5 +39,6 @@ void wordlist_destroy(t_wordlist *wordlist);
t_worddesc *wordlist_get(t_wordlist *wordlist, int idx);
t_wordlist *wordlist_push(t_wordlist *wordlist, t_worddesc *worddesc);
t_worddesc *wordlist_pop(t_wordlist **wordlist);
void wordlist_debug(t_wordlist *wordlist);
#endif

View file

@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* wordlist_debug.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/24 18:20:00 by khais #+# #+# */
/* Updated: 2025/02/24 18:20:09 by khais ### ########.fr */
/* */
/* ************************************************************************** */
#include "wordlist.h"
#include "libft.h"
/*
** Debug-print a wordlist
*/
void wordlist_debug(t_wordlist *wordlist)
{
if (wordlist == NULL)
ft_dprintf(STDERR_FILENO, "(empty wordlist)");
while (wordlist != NULL)
{
ft_dprintf(STDERR_FILENO, "[%s]", wordlist->word->word);
wordlist = wordlist->next;
}
ft_dprintf(STDERR_FILENO, "\n");
}