From 8ee4fc18cbc96b68048bad5eca3cc320947ad09e Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Fri, 21 Jun 2024 13:09:19 +0200 Subject: [PATCH] Make ft_parse_tree_print comply with the Norm --- ft_parse/ft_parse_tree_print.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ft_parse/ft_parse_tree_print.c b/ft_parse/ft_parse_tree_print.c index 28ba3c8..eab297d 100644 --- a/ft_parse/ft_parse_tree_print.c +++ b/ft_parse/ft_parse_tree_print.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/21 09:51:43 by ljiriste #+# #+# */ -/* Updated: 2024/06/21 11:07:45 by ljiriste ### ########.fr */ +/* Updated: 2024/06/21 13:09:00 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,10 +15,13 @@ #define MAX_WIDTH 80 -static void print_last_at_depth(t_parse_tree_node *node, size_t depth, char branches[MAX_WIDTH]); -static void print_node_at_depth(t_parse_tree_node *node, size_t depth, char branches[MAX_WIDTH]); +static void print_last_at_depth(t_parse_tree_node *node, + size_t depth, char branches[MAX_WIDTH]); +static void print_node_at_depth(t_parse_tree_node *node, + size_t depth, char branches[MAX_WIDTH]); -static void print_children_at_depth(t_parse_tree_node *node, size_t depth, char branches[MAX_WIDTH]) +static void print_children_at_depth(t_parse_tree_node *node, + size_t depth, char branches[MAX_WIDTH]) { size_t i; @@ -30,18 +33,21 @@ static void print_children_at_depth(t_parse_tree_node *node, size_t depth, char i = 0; while (i + 1 < node->children.size) { - print_node_at_depth(ft_vec_access(&node->children, i), depth + 1, branches); + print_node_at_depth(ft_vec_access(&node->children, i), + depth + 1, branches); ++i; } if (i < node->children.size) - print_last_at_depth(ft_vec_access(&node->children, i), depth + 1, branches); + print_last_at_depth(ft_vec_access(&node->children, i), + depth + 1, branches); if (depth > 0) branches[ft_strlen(branches) - 1] = '\0'; branches[ft_strlen(branches) - 1] = '\0'; return ; } -static void print_last_at_depth(t_parse_tree_node *node, size_t depth, char branches[MAX_WIDTH]) +static void print_last_at_depth(t_parse_tree_node *node, + size_t depth, char branches[MAX_WIDTH]) { if (!node) { @@ -54,7 +60,8 @@ static void print_last_at_depth(t_parse_tree_node *node, size_t depth, char bran print_children_at_depth(node, depth, branches); } -static void print_node_at_depth(t_parse_tree_node *node, size_t depth, char branches[MAX_WIDTH]) +static void print_node_at_depth(t_parse_tree_node *node, + size_t depth, char branches[MAX_WIDTH]) { if (!node) { -- 2.30.2