=================================================================== RCS file: /cvs/mandoc/tree.c,v retrieving revision 1.76 retrieving revision 1.81 diff -u -p -r1.76 -r1.81 --- mandoc/tree.c 2017/07/07 19:39:30 1.76 +++ mandoc/tree.c 2018/12/12 21:54:35 1.81 @@ -1,7 +1,7 @@ -/* $Id: tree.c,v 1.76 2017/07/07 19:39:30 schwarze Exp $ */ +/* $Id: tree.c,v 1.81 2018/12/12 21:54:35 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2011, 2014 Kristaps Dzonsons - * Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze + * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -29,6 +29,7 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "tbl.h" #include "main.h" static void print_box(const struct eqn_box *, int); @@ -115,6 +116,9 @@ print_mdoc(const struct roff_node *n, int indent) case ROFFT_TEXT: t = "text"; break; + case ROFFT_COMMENT: + t = "comment"; + break; case ROFFT_TBL: break; case ROFFT_EQN: @@ -126,6 +130,7 @@ print_mdoc(const struct roff_node *n, int indent) switch (n->type) { case ROFFT_TEXT: + case ROFFT_COMMENT: p = n->string; break; case ROFFT_BODY: @@ -202,7 +207,7 @@ print_mdoc(const struct roff_node *n, int indent) } if (n->eqn) - print_box(n->eqn->root->first, indent + 4); + print_box(n->eqn->first, indent + 4); if (n->child) print_mdoc(n->child, indent + (n->type == ROFFT_BLOCK ? 2 : 4)); @@ -231,6 +236,9 @@ print_man(const struct roff_node *n, int indent) case ROFFT_TEXT: t = "text"; break; + case ROFFT_COMMENT: + t = "comment"; + break; case ROFFT_BLOCK: t = "block"; break; @@ -251,6 +259,7 @@ print_man(const struct roff_node *n, int indent) switch (n->type) { case ROFFT_TEXT: + case ROFFT_COMMENT: p = n->string; break; case ROFFT_ELEM: @@ -281,13 +290,15 @@ print_man(const struct roff_node *n, int indent) if (NODE_LINE & n->flags) putchar('*'); printf("%d:%d", n->line, n->pos + 1); + if (NODE_DELIMC & n->flags) + putchar(')'); if (NODE_EOS & n->flags) putchar('.'); putchar('\n'); } if (n->eqn) - print_box(n->eqn->root->first, indent + 4); + print_box(n->eqn->first, indent + 4); if (n->child) print_man(n->child, indent + (n->type == ROFFT_BLOCK ? 2 : 4)); @@ -369,35 +380,41 @@ print_span(const struct tbl_span *sp, int indent) switch (sp->pos) { case TBL_SPAN_HORIZ: putchar('-'); - return; + putchar(' '); + break; case TBL_SPAN_DHORIZ: putchar('='); - return; + putchar(' '); + break; default: + for (dp = sp->first; dp; dp = dp->next) { + switch (dp->pos) { + case TBL_DATA_HORIZ: + case TBL_DATA_NHORIZ: + putchar('-'); + putchar(' '); + continue; + case TBL_DATA_DHORIZ: + case TBL_DATA_NDHORIZ: + putchar('='); + putchar(' '); + continue; + default: + break; + } + printf("[\"%s\"", dp->string ? dp->string : ""); + if (dp->hspans) + printf(">%d", dp->hspans); + if (dp->vspans) + printf("v%d", dp->vspans); + if (dp->layout == NULL) + putchar('*'); + else if (dp->layout->pos == TBL_CELL_DOWN) + putchar('^'); + putchar(']'); + putchar(' '); + } break; } - - for (dp = sp->first; dp; dp = dp->next) { - switch (dp->pos) { - case TBL_DATA_HORIZ: - case TBL_DATA_NHORIZ: - putchar('-'); - continue; - case TBL_DATA_DHORIZ: - case TBL_DATA_NDHORIZ: - putchar('='); - continue; - default: - break; - } - printf("[\"%s\"", dp->string ? dp->string : ""); - if (dp->spans) - printf("(%d)", dp->spans); - if (NULL == dp->layout) - putchar('*'); - putchar(']'); - putchar(' '); - } - printf("(tbl) %d:1\n", sp->line); }