-/* $Id: tree.c,v 1.58 2014/10/10 15:26:29 schwarze Exp $ */
+/* $Id: tree.c,v 1.62 2015/02/05 00:14:13 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
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
size_t argc;
struct mdoc_argv *argv;
+ if (n == NULL)
+ return;
+
argv = NULL;
argc = 0;
t = p = NULL;
t = "text";
break;
case MDOC_TBL:
- /* FALLTHROUGH */
+ break;
case MDOC_EQN:
+ t = "eqn";
break;
default:
abort();
}
break;
case MDOC_TBL:
- /* FALLTHROUGH */
+ break;
case MDOC_EQN:
+ p = "EQ";
break;
case MDOC_ROOT:
p = "root";
if (n->span) {
assert(NULL == p && NULL == t);
print_span(n->span, indent);
- } else if (n->eqn) {
- assert(NULL == p && NULL == t);
- print_box(n->eqn->root, indent);
} else {
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
printf("%s (%s)", p, t);
putchar(' ');
if (MDOC_LINE & n->flags)
putchar('*');
- printf("%d:%d", n->line, n->pos + 1);
- if (n->lastline != n->line)
- printf("-%d", n->lastline);
- putchar('\n');
+ printf("%d:%d\n", n->line, n->pos + 1);
}
+ if (n->eqn)
+ 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);
}
const char *p, *t;
int i;
+ if (n == NULL)
+ return;
+
t = p = NULL;
switch (n->type) {
case MAN_BODY:
t = "block-body";
break;
- case MAN_TAIL:
- t = "block-tail";
- break;
case MAN_TBL:
- /* FALLTHROUGH */
+ break;
case MAN_EQN:
+ t = "eqn";
break;
default:
abort();
/* FALLTHROUGH */
case MAN_HEAD:
/* FALLTHROUGH */
- case MAN_TAIL:
- /* FALLTHROUGH */
case MAN_BODY:
p = man_macronames[n->tok];
break;
p = "root";
break;
case MAN_TBL:
- /* FALLTHROUGH */
+ break;
case MAN_EQN:
+ p = "EQ";
break;
default:
abort();
if (n->span) {
assert(NULL == p && NULL == t);
print_span(n->span, indent);
- } else if (n->eqn) {
- assert(NULL == p && NULL == t);
- print_box(n->eqn->root, indent);
} else {
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
printf("%s (%s) ", p, t);
if (MAN_LINE & n->flags)
putchar('*');
printf("%d:%d\n", n->line, n->pos + 1);
}
+ if (n->eqn)
+ 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);
}
if (NULL == ep)
return;
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
t = NULL;
switch (ep->type) {
printf(" args=%zu", ep->args);
putchar('\n');
- print_box(ep->first, indent + 1);
+ print_box(ep->first, indent + 4);
print_box(ep->next, indent);
}
int i;
for (i = 0; i < indent; i++)
- putchar('\t');
+ putchar(' ');
switch (sp->pos) {
case TBL_SPAN_HORIZ: