aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tree.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-02-03 18:37:59 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-02-03 18:37:59 +0000
commitdad3f5fc59c880f22cf4466047c31f280b9f8cc8 (patch)
tree3be00c8b70dd3f7d41ea2dbcb630fedfef24ecf1 /tree.c
parent11a1855aacfa2e86de660d1fd1da9c80708ad89b (diff)
downloadmandoc-dad3f5fc59c880f22cf4466047c31f280b9f8cc8.tar.gz
mandoc-dad3f5fc59c880f22cf4466047c31f280b9f8cc8.tar.zst
mandoc-dad3f5fc59c880f22cf4466047c31f280b9f8cc8.zip
reduce indentation for better readability
Diffstat (limited to 'tree.c')
-rw-r--r--tree.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/tree.c b/tree.c
index 4753219c..43934bbf 100644
--- a/tree.c
+++ b/tree.c
@@ -1,7 +1,7 @@
-/* $Id: tree.c,v 1.60 2014/11/28 05:51:32 schwarze Exp $ */
+/* $Id: tree.c,v 1.61 2015/02/03 18:37:59 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -40,14 +40,14 @@ void
tree_mdoc(void *arg, const struct mdoc *mdoc)
{
- print_mdoc(mdoc_node(mdoc), 0);
+ print_mdoc(mdoc_node(mdoc)->child, 0);
}
void
tree_man(void *arg, const struct man *man)
{
- print_man(man_node(man), 0);
+ print_man(man_node(man)->child, 0);
}
static void
@@ -58,6 +58,9 @@ print_mdoc(const struct mdoc_node *n, int indent)
size_t argc;
struct mdoc_argv *argv;
+ if (n == NULL)
+ return;
+
argv = NULL;
argc = 0;
t = p = NULL;
@@ -142,7 +145,7 @@ print_mdoc(const struct mdoc_node *n, int indent)
print_span(n->span, indent);
} else {
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
printf("%s (%s)", p, t);
@@ -166,9 +169,10 @@ print_mdoc(const struct mdoc_node *n, int indent)
}
if (n->eqn)
- print_box(n->eqn->root->first, indent + 1);
+ print_box(n->eqn->root->first, indent + 4);
if (n->child)
- print_mdoc(n->child, indent + 1);
+ print_mdoc(n->child, indent +
+ (n->type == MDOC_BLOCK ? 2 : 4));
if (n->next)
print_mdoc(n->next, indent);
}
@@ -179,6 +183,9 @@ print_man(const struct man_node *n, int indent)
const char *p, *t;
int i;
+ if (n == NULL)
+ return;
+
t = p = NULL;
switch (n->type) {
@@ -241,7 +248,7 @@ print_man(const struct man_node *n, int indent)
print_span(n->span, indent);
} else {
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
printf("%s (%s) ", p, t);
if (MAN_LINE & n->flags)
putchar('*');
@@ -249,9 +256,10 @@ print_man(const struct man_node *n, int indent)
}
if (n->eqn)
- print_box(n->eqn->root->first, indent + 1);
+ print_box(n->eqn->root->first, indent + 4);
if (n->child)
- print_man(n->child, indent + 1);
+ print_man(n->child, indent +
+ (n->type == MAN_BLOCK ? 2 : 4));
if (n->next)
print_man(n->next, indent);
}
@@ -270,7 +278,7 @@ print_box(const struct eqn_box *ep, int indent)
if (NULL == ep)
return;
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
t = NULL;
switch (ep->type) {
@@ -318,7 +326,7 @@ print_box(const struct eqn_box *ep, int indent)
printf(" args=%zu", ep->args);
putchar('\n');
- print_box(ep->first, indent + 1);
+ print_box(ep->first, indent + 4);
print_box(ep->next, indent);
}
@@ -329,7 +337,7 @@ print_span(const struct tbl_span *sp, int indent)
int i;
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
switch (sp->pos) {
case TBL_SPAN_HORIZ: