Make ft_parse_tree_print comply with the Norm
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 21 Jun 2024 11:09:19 +0000 (13:09 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 21 Jun 2024 11:09:19 +0000 (13:09 +0200)
ft_parse/ft_parse_tree_print.c

index 28ba3c843880f1a33625b046e5f5c1a3c99ee2b6..eab297d7cf35538c2ad7cce36db475e11673458d 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <marvin@42.fr>                    +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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       */
 /*                                                                            */
 /* ************************************************************************** */
 
 
 #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)
        {