summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-01 13:54:58 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-01 13:54:58 +0000
commit88d1d7e475d216a18b657024cf3084f083eb33c9 (patch)
tree683a6d8547d02c8d4bd7034a4e9d3ecccc6a16ba
parenteaae29b74b1f45f13fc7edacce3631f05b0ba412 (diff)
downloadmandoc-88d1d7e475d216a18b657024cf3084f083eb33c9.tar.gz
Make -Ttree spit out table columns.
Add forgotten assignment of span to -man's TBL nodes.
-rw-r--r--man.c1
-rw-r--r--tree.c66
2 files changed, 48 insertions, 19 deletions
diff --git a/man.c b/man.c
index 61657041..683fd098 100644
--- a/man.c
+++ b/man.c
@@ -301,6 +301,7 @@ man_span_alloc(struct man *m, const struct tbl_span *span)
/* FIXME: grab from span */
n = man_node_alloc(0, 0, MAN_TBL, MAN_MAX);
+ n->span = span;
if ( ! man_node_append(m, n))
return(0);
diff --git a/tree.c b/tree.c
index 9eee5535..3dbbbd77 100644
--- a/tree.c
+++ b/tree.c
@@ -58,6 +58,7 @@ 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;
@@ -96,6 +97,8 @@ print_mdoc(const struct mdoc_node *n, int indent)
/* NOTREACHED */
}
+ p = NULL;
+
switch (n->type) {
case (MDOC_TEXT):
p = n->string;
@@ -124,7 +127,6 @@ print_mdoc(const struct mdoc_node *n, int indent)
}
break;
case (MDOC_TBL):
- p = "tbl";
break;
case (MDOC_ROOT):
p = "root";
@@ -135,23 +137,36 @@ print_mdoc(const struct mdoc_node *n, int indent)
}
for (i = 0; i < indent; i++)
- (void)printf(" ");
- (void)printf("%s (%s)", p, t);
-
- for (i = 0; i < (int)argc; i++) {
- (void)printf(" -%s", mdoc_argnames[argv[i].arg]);
- if (argv[i].sz > 0)
- (void)printf(" [");
- for (j = 0; j < (int)argv[i].sz; j++)
- (void)printf(" [%s]", argv[i].value[j]);
- if (argv[i].sz > 0)
- (void)printf(" ]");
- }
+ putchar('\t');
+
+ 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 {
+ printf("%s (%s)", p, t);
- for (i = 0; i < (int)sz; i++)
- (void)printf(" [%s]", params[i]);
+ for (i = 0; i < (int)argc; i++) {
+ printf(" -%s", mdoc_argnames[argv[i].arg]);
+ if (argv[i].sz > 0)
+ printf(" [");
+ for (j = 0; j < (int)argv[i].sz; j++)
+ printf(" [%s]", argv[i].value[j]);
+ if (argv[i].sz > 0)
+ printf(" ]");
+ }
+
+ for (i = 0; i < (int)sz; i++)
+ printf(" [%s]", params[i]);
- (void)printf(" %d:%d\n", n->line, n->pos);
+ printf(" %d:%d", n->line, n->pos);
+ }
+
+ putchar('\n');
if (n->child)
print_mdoc(n->child, indent + 1);
@@ -165,6 +180,7 @@ 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):
@@ -193,6 +209,8 @@ print_man(const struct man_node *n, int indent)
/* NOTREACHED */
}
+ p = NULL;
+
switch (n->type) {
case (MAN_TEXT):
p = n->string;
@@ -210,7 +228,6 @@ print_man(const struct man_node *n, int indent)
p = "root";
break;
case (MAN_TBL):
- p = "tbl";
break;
default:
abort();
@@ -218,8 +235,19 @@ print_man(const struct man_node *n, int indent)
}
for (i = 0; i < indent; i++)
- (void)printf(" ");
- (void)printf("%s (%s) %d:%d\n", p, t, n->line, n->pos);
+ putchar('\t');
+
+ if (n->span) {
+ assert(NULL == p);
+ for (dp = n->span->first; dp; dp = dp->next) {
+ printf("tbl: [%s]", dp->string);
+ if (dp->next)
+ putchar(' ');
+ }
+ } else
+ printf("%s (%s) %d:%d", p, t, n->line, n->pos);
+
+ putchar('\n');
if (n->child)
print_man(n->child, indent + 1);