diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-10-10 12:19:25 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-10-10 12:19:25 +0000 |
commit | f50d4319685e3fbbff4c0871544a4aad054b35b3 (patch) | |
tree | 6ee2bcf5f017492ca33ed45df76e41335c3a5704 /tree.c | |
parent | 49d7281ce6b0994cd2dff338b2f098217baa219f (diff) | |
download | mandoc-f50d4319685e3fbbff4c0871544a4aad054b35b3.tar.gz mandoc-f50d4319685e3fbbff4c0871544a4aad054b35b3.tar.zst mandoc-f50d4319685e3fbbff4c0871544a4aad054b35b3.zip |
Make eqn(7) -Ttree output more useful:
* Reduce noise by not printing default attributes.
* Print missing "top" and "bottom" attributes.
* Print mnemonics, not code numbers for expression positions.
* Do not print unused "pile" attribute.
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 37 |
1 files changed, 28 insertions, 9 deletions
@@ -1,4 +1,4 @@ -/* $Id: tree.c,v 1.56 2014/10/10 08:44:24 kristaps Exp $ */ +/* $Id: tree.c,v 1.57 2014/10/10 12:19:25 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -265,6 +265,11 @@ print_box(const struct eqn_box *ep, int indent) int i; const char *t; + static const char *posnames[] = { + NULL, "sup", "subsup", "sub", + "to", "from", "fromto", + "over", "sqrt", NULL }; + if (NULL == ep) return; for (i = 0; i < indent; i++) @@ -293,14 +298,28 @@ print_box(const struct eqn_box *ep, int indent) break; } - assert(t); - printf("%s(size=%d, args=%zu(%zu), pos=%d, font=%d, pile=%d, l=\"%s\", r=\"%s\") %s\n", - t, EQN_DEFSIZE == ep->size ? 0 : ep->size, - ep->args, ep->expectargs, - ep->pos, ep->font, ep->pile, - ep->left ? ep->left : "", - ep->right ? ep->right : "", - ep->text ? ep->text : ""); + fputs(t, stdout); + if (ep->pos) + printf(" pos=%s", posnames[ep->pos]); + if (ep->left) + printf(" left=\"%s\"", ep->left); + if (ep->right) + printf(" right=\"%s\"", ep->right); + if (ep->top) + printf(" top=\"%s\"", ep->top); + if (ep->bottom) + printf(" bottom=\"%s\"", ep->bottom); + if (ep->text) + printf(" text=\"%s\"", ep->text); + if (ep->font) + printf(" font=%d", ep->font); + if (ep->size != EQN_DEFSIZE) + printf(" size=%d", ep->size); + if (ep->expectargs != UINT_MAX && ep->expectargs != ep->args) + printf(" badargs=%zu(%zu)", ep->args, ep->expectargs); + else if (ep->args) + printf(" args=%zu", ep->args); + putchar('\n'); print_box(ep->first, indent + 1); print_box(ep->next, indent); |