summaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-25 12:27:37 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-25 12:27:37 +0000
commita017287dafe633c9f23e9990989b55dea239344c (patch)
treeb376c10c00c43d91aebb5492af1ae2a91a9baa6a /term.c
parent3da36abba778bbb6f652585d4c8d476dcee854a4 (diff)
downloadmandoc-a017287dafe633c9f23e9990989b55dea239344c.tar.gz
mandoc-a017287dafe633c9f23e9990989b55dea239344c.tar.zst
mandoc-a017287dafe633c9f23e9990989b55dea239344c.zip
Some offsets built into termpair.
Diffstat (limited to 'term.c')
-rw-r--r--term.c62
1 files changed, 26 insertions, 36 deletions
diff --git a/term.c b/term.c
index db9261e4..c69210d6 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.18 2009/02/25 12:09:20 kristaps Exp $ */
+/* $Id: term.c,v 1.19 2009/02/25 12:27:37 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -654,25 +654,6 @@ termp_op_post(DECL_ARGS)
/* ARGSUSED */
-static void
-termp_sh_post(DECL_ARGS)
-{
-
- switch (node->type) {
- case (MDOC_HEAD):
- newln(p);
- break;
- case (MDOC_BODY):
- newln(p);
- p->offset = 0;
- break;
- default:
- break;
- }
-}
-
-
-/* ARGSUSED */
static int
termp_xr_pre(DECL_ARGS)
{
@@ -765,6 +746,25 @@ termp_sh_pre(DECL_ARGS)
/* ARGSUSED */
+static void
+termp_sh_post(DECL_ARGS)
+{
+
+ switch (node->type) {
+ case (MDOC_HEAD):
+ newln(p);
+ break;
+ case (MDOC_BODY):
+ newln(p);
+ p->offset = 0;
+ break;
+ default:
+ break;
+ }
+}
+
+
+/* ARGSUSED */
static int
termp_op_pre(DECL_ARGS)
{
@@ -809,7 +809,7 @@ termp_d1_pre(DECL_ARGS)
if (MDOC_BODY != node->type)
return(1);
newln(p);
- p->offset += INDENT;
+ p->offset += (pair->offset = INDENT);
return(1);
}
@@ -822,7 +822,7 @@ termp_d1_post(DECL_ARGS)
if (MDOC_BODY != node->type)
return;
newln(p);
- p->offset -= INDENT;
+ p->offset -= pair->offset;
}
@@ -988,7 +988,8 @@ termp_bd_pre(DECL_ARGS)
i = arg_getattr(MDOC_Offset, bl->argc, bl->argv);
if (-1 != i) {
assert(1 == bl->argv[i].sz);
- p->offset += arg_offset(&bl->argv[i]);
+ pair->offset = arg_offset(&bl->argv[i]);
+ p->offset += pair->offset;
}
if ( ! arg_hasattr(MDOC_Literal, bl->argc, bl->argv))
@@ -1015,20 +1016,9 @@ termp_bd_pre(DECL_ARGS)
static void
termp_bd_post(DECL_ARGS)
{
- int i;
- const struct mdoc_block *bl;
-
- if (MDOC_BODY != node->type)
- return;
-
- assert(MDOC_BLOCK == node->parent->type);
- bl = &node->parent->data.block;
- i = arg_getattr(MDOC_Offset, bl->argc, bl->argv);
- if (-1 != i) {
- assert(1 == bl->argv[i].sz);
- p->offset -= arg_offset(&bl->argv[i]);
- }
+ if (MDOC_BODY == node->type)
+ p->offset -= pair->offset;
}