=================================================================== RCS file: /cvs/mandoc/tree.c,v retrieving revision 1.74 retrieving revision 1.83 diff -u -p -r1.74 -r1.83 --- mandoc/tree.c 2017/04/24 23:06:18 1.74 +++ mandoc/tree.c 2018/12/30 00:49:56 1.83 @@ -1,7 +1,7 @@ -/* $Id: tree.c,v 1.74 2017/04/24 23:06:18 schwarze Exp $ */ +/* $Id: tree.c,v 1.83 2018/12/30 00:49:56 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,8 @@ #include "roff.h" #include "mdoc.h" #include "man.h" +#include "tbl.h" +#include "eqn.h" #include "main.h" static void print_box(const struct eqn_box *, int); @@ -39,18 +41,18 @@ static void print_span(const struct tbl_span *, int); void -tree_mdoc(void *arg, const struct roff_man *mdoc) +tree_mdoc(void *arg, const struct roff_meta *mdoc) { - print_meta(&mdoc->meta); + print_meta(mdoc); putchar('\n'); print_mdoc(mdoc->first->child, 0); } void -tree_man(void *arg, const struct roff_man *man) +tree_man(void *arg, const struct roff_meta *man) { - print_meta(&man->meta); - if (man->meta.hasbody == 0) + print_meta(man); + if (man->hasbody == 0) puts("body = empty"); putchar('\n'); print_man(man->first->child, 0); @@ -115,6 +117,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 +131,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 +208,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 +237,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 +260,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 +291,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)); @@ -313,10 +325,6 @@ print_box(const struct eqn_box *ep, int indent) t = NULL; switch (ep->type) { - case EQN_ROOT: - t = "eqn-root"; - break; - case EQN_LISTONE: case EQN_LIST: t = "eqn-list"; break; @@ -373,35 +381,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); }