aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tree.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-01 17:10:20 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-01 17:10:20 +0000
commitdbd5746117cfc008d44b2e9e53c8f76c8d92673d (patch)
tree400e153ac05f7aa95ec6164d5295afc836e3556f /tree.c
parent9ccd8b3e4376fa371cffa2cc59bb4e395f16bf6b (diff)
downloadmandoc-dbd5746117cfc008d44b2e9e53c8f76c8d92673d.tar.gz
mandoc-dbd5746117cfc008d44b2e9e53c8f76c8d92673d.tar.zst
mandoc-dbd5746117cfc008d44b2e9e53c8f76c8d92673d.zip
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.c60
1 files changed, 44 insertions, 16 deletions
diff --git a/tree.c b/tree.c
index 17d56843..d56eeaf6 100644
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-/* $Id: tree.c,v 1.27 2011/01/01 14:09:21 kristaps Exp $ */
+/* $Id: tree.c,v 1.28 2011/01/01 17:10:20 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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(' ');
+ }
+}