tree.c revision 371584c2eae4cf827fd406ba26c14f021adaaa70
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov/* $Id: tree.c,v 1.69 2015/10/12 00:08:16 schwarze Exp $ */
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov * Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * copyright notice and this permission notice appear in all copies.
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankov * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amorestatic void print_box(const struct eqn_box *, int);
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankovstatic void print_man(const struct roff_node *, int);
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankovstatic void print_mdoc(const struct roff_node *, int);
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amorestatic void print_span(const struct tbl_span *, int);
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankovtree_mdoc(void *arg, const struct roff_man *mdoc)
371584c2eae4cf827fd406ba26c14f021adaaa70Yuri Pankovprint_mdoc(const struct roff_node *n, int indent)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore const char *p, *t;
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore switch (n->type) {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore t = "body-end";
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore switch (n->type) {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore for (i = 0; i < indent; i++)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore for (i = 0; i < (int)argc; i++) {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore const char *p, *t;
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore switch (n->type) {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore switch (n->type) {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore for (i = 0; i < indent; i++)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amoreprint_box(const struct eqn_box *ep, int indent)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore const char *t;
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov static const char *posnames[] = {
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore for (i = 0; i < indent; i++)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore t = "eqn-root";
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore t = "eqn-list";
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore t = "eqn-expr";
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore t = "eqn-text";
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov t = "eqn-pile";
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore t = "eqn-matrix";
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov if (ep->expectargs != UINT_MAX && ep->expectargs != ep->args)
260e9a87725c090ba5835b1f9f0b62fa2f96036fYuri Pankov printf(" badargs=%zu(%zu)", ep->args, ep->expectargs);
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amoreprint_span(const struct tbl_span *sp, int indent)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore for (i = 0; i < indent; i++)
95c635efb7c3b86efc493e0447eaec7aecca3f0fGarrett D'Amore printf("[\"%s\"", dp->string ? dp->string : "");