aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-12 10:09:19 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-12 10:09:19 +0000
commit0b20ee1ae342d058c3e78b46ba69335c80addfda (patch)
tree2c6c3b2b5b2b24cce540a79d6cafcda7e6bce9b3 /mdoc_term.c
parent078ee5b9efa7e35cf66a131178415a512c4a33fe (diff)
downloadmandoc-0b20ee1ae342d058c3e78b46ba69335c80addfda.tar.gz
mandoc-0b20ee1ae342d058c3e78b46ba69335c80addfda.tar.zst
mandoc-0b20ee1ae342d058c3e78b46ba69335c80addfda.zip
Added enum mdoc_disp (similar to enum mdoc_list). Display types are now
only calculated once in mdoc_validate.c. Noted that `Bd -file xxx' is not supported: it now raises a fatal warning. This is noted in mdoc.7. Empty `Bd' now defaults to LIST_ragged, which is not quite what groff does, but close enough (gross just throws away the `Bd' and gets upset when it encounters an `Ed').
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c49
1 files changed, 7 insertions, 42 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 7b590ed7..f74be21a 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.146 2010/06/10 23:24:37 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.147 2010/06/12 10:09:19 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -60,7 +60,6 @@ static int arg_hasattr(int, const struct mdoc_node *);
static int arg_getattrs(const int *, int *, size_t,
const struct mdoc_node *);
static int arg_getattr(int, const struct mdoc_node *);
-static int arg_disptype(const struct mdoc_node *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
const struct mdoc_node *);
@@ -489,35 +488,6 @@ a2width(const struct mdoc_argv *arg, int pos)
}
-static int
-arg_disptype(const struct mdoc_node *n)
-{
- int i, len;
-
- assert(MDOC_BLOCK == n->type);
-
- len = (int)(n->args ? n->args->argc : 0);
-
- for (i = 0; i < len; i++)
- switch (n->args->argv[i].arg) {
- case (MDOC_Centred):
- /* FALLTHROUGH */
- case (MDOC_Ragged):
- /* FALLTHROUGH */
- case (MDOC_Filled):
- /* FALLTHROUGH */
- case (MDOC_Unfilled):
- /* FALLTHROUGH */
- case (MDOC_Literal):
- return(n->args->argv[i].arg);
- default:
- break;
- }
-
- return(-1);
-}
-
-
static size_t
a2offs(const struct mdoc_argv *arg)
{
@@ -1632,7 +1602,7 @@ static int
termp_bd_pre(DECL_ARGS)
{
size_t tabwidth;
- int i, type;
+ int i;
size_t rm, rmax;
const struct mdoc_node *nn;
@@ -1644,9 +1614,6 @@ termp_bd_pre(DECL_ARGS)
nn = n->parent;
- type = arg_disptype(nn);
- assert(-1 != type);
-
if (-1 != (i = arg_getattr(MDOC_Offset, nn)))
p->offset += a2offs(&nn->args->argv[i]);
@@ -1658,7 +1625,8 @@ termp_bd_pre(DECL_ARGS)
* lines are allowed.
*/
- if (MDOC_Literal != type && MDOC_Unfilled != type)
+ if (DISP_literal != n->data.disp &&
+ DISP_unfilled != n->data.disp)
return(1);
tabwidth = p->tabwidth;
@@ -1675,8 +1643,8 @@ termp_bd_pre(DECL_ARGS)
NULL == nn->next)
term_flushln(p);
}
- p->tabwidth = tabwidth;
+ p->tabwidth = tabwidth;
p->rmargin = rm;
p->maxrmargin = rmax;
return(0);
@@ -1687,19 +1655,16 @@ termp_bd_pre(DECL_ARGS)
static void
termp_bd_post(DECL_ARGS)
{
- int type;
size_t rm, rmax;
if (MDOC_BODY != n->type)
return;
- type = arg_disptype(n->parent);
- assert(-1 != type);
-
rm = p->rmargin;
rmax = p->maxrmargin;
- if (MDOC_Literal == type || MDOC_Unfilled == type)
+ if (DISP_literal == n->data.disp ||
+ DISP_unfilled == n->data.disp)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;