-/* $Id: tree.c,v 1.26 2011/01/01 13:54:58 kristaps Exp $ */
+/* $Id: tree.c,v 1.31 2011/01/03 13:59:21 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
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 *, int);
/* ARGSUSED */
size_t argc, sz;
char **params;
struct mdoc_argv *argv;
- const struct tbl_dat *dp;
argv = NULL;
argc = sz = 0;
/* NOTREACHED */
}
- for (i = 0; i < indent; i++)
- 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(' ');
- }
+ print_span(n->span, indent);
} else {
+ for (i = 0; i < indent; i++)
+ putchar('\t');
+
printf("%s (%s)", p, t);
for (i = 0; i < (int)argc; i++) {
{
const char *p, *t;
int i;
- const struct tbl_dat *dp;
switch (n->type) {
case (MAN_ROOT):
/* NOTREACHED */
}
- for (i = 0; i < indent; i++)
- 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
+ print_span(n->span, indent);
+ } else {
+ for (i = 0; i < indent; i++)
+ putchar('\t');
printf("%s (%s) %d:%d", p, t, n->line, n->pos);
+ }
putchar('\n');
if (n->next)
print_man(n->next, indent);
}
+
+static void
+print_span(const struct tbl_span *sp, int indent)
+{
+ const struct tbl_dat *dp;
+ int i;
+
+ for (i = 0; i < indent; i++)
+ putchar('\t');
+
+ 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%s]", dp->string, dp->layout ? "" : "*");
+ if (dp->next)
+ putchar(' ');
+ }
+}