diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-01 17:10:20 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-01-01 17:10:20 +0000 |
commit | 34ce24843b2a8171fe592d29a7ef15c8322b18c5 (patch) | |
tree | dabb531c21d174bdea12196c0fc93edb4b0753ea /tree.c | |
parent | 3592c989529bee1adce043bede9fbc1902993301 (diff) | |
download | mandoc-34ce24843b2a8171fe592d29a7ef15c8322b18c5.tar.gz |
Make some bit-flags into enums as they should be. Make printing of -Ttree
tables a little bit smarter.
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 58 |
1 files changed, 43 insertions, 15 deletions
@@ -30,6 +30,7 @@ static void print_mdoc(const struct mdoc_node *, int); static void print_man(const struct man_node *, int); +static void print_span(const struct tbl_span *); /* ARGSUSED */ @@ -58,7 +59,6 @@ print_mdoc(const struct mdoc_node *n, int indent) size_t argc, sz; char **params; struct mdoc_argv *argv; - const struct tbl_dat *dp; argv = NULL; argc = sz = 0; @@ -141,12 +141,7 @@ print_mdoc(const struct mdoc_node *n, int indent) if (n->span) { assert(NULL == p); - printf("tbl: "); - for (dp = n->span->first; dp; dp = dp->next) { - printf("[%s]", dp->string); - if (dp->next) - putchar(' '); - } + print_span(n->span); } else { printf("%s (%s)", p, t); @@ -180,7 +175,6 @@ print_man(const struct man_node *n, int indent) { const char *p, *t; int i; - const struct tbl_dat *dp; switch (n->type) { case (MAN_ROOT): @@ -239,13 +233,8 @@ print_man(const struct man_node *n, int indent) if (n->span) { assert(NULL == p); - printf("tbl: "); - for (dp = n->span->first; dp; dp = dp->next) { - printf("[%s]", dp->string); - if (dp->next) - putchar(' '); - } - } else + print_span(n->span); + } else printf("%s (%s) %d:%d", p, t, n->line, n->pos); putchar('\n'); @@ -255,3 +244,42 @@ print_man(const struct man_node *n, int indent) if (n->next) print_man(n->next, indent); } + +static void +print_span(const struct tbl_span *sp) +{ + const struct tbl_dat *dp; + + printf("tbl: "); + + switch (sp->pos) { + case (TBL_SPAN_HORIZ): + putchar('-'); + return; + case (TBL_SPAN_DHORIZ): + putchar('='); + return; + default: + break; + } + + for (dp = sp->first; dp; dp = dp->next) { + switch (dp->pos) { + case (TBL_DATA_HORIZ): + /* FALLTHROUGH */ + case (TBL_DATA_NHORIZ): + putchar('-'); + continue; + case (TBL_DATA_DHORIZ): + /* FALLTHROUGH */ + case (TBL_DATA_NDHORIZ): + putchar('='); + continue; + default: + break; + } + printf("[%s]", dp->string); + if (dp->next) + putchar(' '); + } +} |