aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-06-18 17:36:52 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-06-18 17:36:52 +0000
commit55d8e28ac565dbc5aecfd860a4d3fe6a7ac99c72 (patch)
tree7f64e9408bf7c65f4315b5f4fe84842d45fe00bd /man_term.c
parent6def9e6849d2a7530ac499cd2b141353134283ac (diff)
downloadmandoc-55d8e28ac565dbc5aecfd860a4d3fe6a7ac99c72.tar.gz
mandoc-55d8e28ac565dbc5aecfd860a4d3fe6a7ac99c72.tar.zst
mandoc-55d8e28ac565dbc5aecfd860a4d3fe6a7ac99c72.zip
Allow RS/RE blocks to nest. This requires first the syntax tree to
accomodate for the fix, then for the front-ends. -T[x]html accepted the syntax tree natively, but -Tascii had to use relative offsets. It's quite a simple fix. From a TODO by {dcoppa,dsoares}@openbsd.
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/man_term.c b/man_term.c
index 38ceeabd..8184fc23 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.109 2011/05/17 14:38:34 kristaps Exp $ */
+/* $Id: man_term.c,v 1.110 2011/06/18 17:36:52 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -791,13 +791,12 @@ post_SH(DECL_ARGS)
}
}
-
/* ARGSUSED */
static int
pre_RS(DECL_ARGS)
{
- const struct man_node *nn;
- int ival;
+ int ival;
+ size_t sz;
switch (n->type) {
case (MAN_BLOCK):
@@ -809,40 +808,44 @@ pre_RS(DECL_ARGS)
break;
}
- if (NULL == (nn = n->parent->head->child)) {
- mt->offset = mt->lmargin + term_len(p, INDENT);
- p->offset = mt->offset;
- return(1);
- }
+ sz = term_len(p, INDENT);
- if ((ival = a2width(p, nn->string)) < 0)
- return(1);
+ if (NULL != (n = n->parent->head->child))
+ if ((ival = a2width(p, n->string)) >= 0)
+ sz = (size_t)ival;
- mt->offset = term_len(p, INDENT) + (size_t)ival;
+ mt->offset += sz;
p->offset = mt->offset;
return(1);
}
-
/* ARGSUSED */
static void
post_RS(DECL_ARGS)
{
+ int ival;
+ size_t sz;
switch (n->type) {
case (MAN_BLOCK):
- mt->offset = mt->lmargin = term_len(p, INDENT);
- break;
+ return;
case (MAN_HEAD):
- break;
+ return;
default:
term_newln(p);
- p->offset = term_len(p, INDENT);
break;
}
-}
+ sz = term_len(p, INDENT);
+
+ if (NULL != (n = n->parent->head->child))
+ if ((ival = a2width(p, n->string)) >= 0)
+ sz = (size_t)ival;
+
+ mt->offset = mt->offset < sz ? 0 : mt->offset - sz;
+ p->offset = mt->offset;
+}
static void
print_man_node(DECL_ARGS)