summaryrefslogtreecommitdiffstats
path: root/man_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-03-22 05:59:32 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-03-22 05:59:32 +0000
commit32cbe85d8ce6eee87446621fa65138ae97b24bb8 (patch)
treeef7a96e354ccaf6e84ec022230ad8840df8ef74d /man_term.c
parent1f06d7b1d7dc62d0276312c7c411ee4ed3b842f8 (diff)
downloadmandoc-32cbe85d8ce6eee87446621fa65138ae97b24bb8.tar.gz
Accomodate (libman) for next-line macros followed by non-text macros `na', `sp', and `br'.
Based on a patch by Ingo Schwarze.
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c79
1 files changed, 43 insertions, 36 deletions
diff --git a/man_term.c b/man_term.c
index 139ec436..45bcf5d3 100644
--- a/man_term.c
+++ b/man_term.c
@@ -65,6 +65,8 @@ struct mtermp {
struct termact {
int (*pre)(DECL_ARGS);
void (*post)(DECL_ARGS);
+ int flags;
+#define MAN_NOTEXT (1 << 0) /* Never has text children. */
};
static int a2width(const struct man_node *);
@@ -105,38 +107,38 @@ static void post_SS(DECL_ARGS);
static void post_TP(DECL_ARGS);
static const struct termact termacts[MAN_MAX] = {
- { pre_br, NULL }, /* br */
- { NULL, NULL }, /* TH */
- { pre_SH, post_SH }, /* SH */
- { pre_SS, post_SS }, /* SS */
- { pre_TP, post_TP }, /* TP */
- { pre_PP, NULL }, /* LP */
- { pre_PP, NULL }, /* PP */
- { pre_PP, NULL }, /* P */
- { pre_IP, post_IP }, /* IP */
- { pre_HP, post_HP }, /* HP */
- { NULL, NULL }, /* SM */
- { pre_B, NULL }, /* SB */
- { pre_BI, NULL }, /* BI */
- { pre_BI, NULL }, /* IB */
- { pre_RB, NULL }, /* BR */
- { pre_RB, NULL }, /* RB */
- { NULL, NULL }, /* R */
- { pre_B, NULL }, /* B */
- { pre_I, NULL }, /* I */
- { pre_RI, NULL }, /* IR */
- { pre_RI, NULL }, /* RI */
- { NULL, NULL }, /* na */
- { pre_I, NULL }, /* i */
- { pre_sp, NULL }, /* sp */
- { pre_nf, NULL }, /* nf */
- { pre_fi, NULL }, /* fi */
- { NULL, NULL }, /* r */
- { NULL, NULL }, /* RE */
- { pre_RS, post_RS }, /* RS */
- { pre_ign, NULL }, /* DT */
- { pre_ign, NULL }, /* UC */
- { pre_ign, NULL }, /* PD */
+ { pre_br, NULL, MAN_NOTEXT }, /* br */
+ { NULL, NULL, 0 }, /* TH */
+ { pre_SH, post_SH, 0 }, /* SH */
+ { pre_SS, post_SS, 0 }, /* SS */
+ { pre_TP, post_TP, 0 }, /* TP */
+ { pre_PP, NULL, 0 }, /* LP */
+ { pre_PP, NULL, 0 }, /* PP */
+ { pre_PP, NULL, 0 }, /* P */
+ { pre_IP, post_IP, 0 }, /* IP */
+ { pre_HP, post_HP, 0 }, /* HP */
+ { NULL, NULL, 0 }, /* SM */
+ { pre_B, NULL, 0 }, /* SB */
+ { pre_BI, NULL, 0 }, /* BI */
+ { pre_BI, NULL, 0 }, /* IB */
+ { pre_RB, NULL, 0 }, /* BR */
+ { pre_RB, NULL, 0 }, /* RB */
+ { NULL, NULL, 0 }, /* R */
+ { pre_B, NULL, 0 }, /* B */
+ { pre_I, NULL, 0 }, /* I */
+ { pre_RI, NULL, 0 }, /* IR */
+ { pre_RI, NULL, 0 }, /* RI */
+ { NULL, NULL, MAN_NOTEXT }, /* na */
+ { pre_I, NULL, 0 }, /* i */
+ { pre_sp, NULL, MAN_NOTEXT }, /* sp */
+ { pre_nf, NULL, 0 }, /* nf */
+ { pre_fi, NULL, 0 }, /* fi */
+ { NULL, NULL, 0 }, /* r */
+ { NULL, NULL, 0 }, /* RE */
+ { pre_RS, post_RS, 0 }, /* RS */
+ { pre_ign, NULL, 0 }, /* DT */
+ { pre_ign, NULL, 0 }, /* UC */
+ { pre_ign, NULL, 0 }, /* PD */
};
@@ -574,10 +576,13 @@ pre_TP(DECL_ARGS)
/* Calculate offset. */
- if (NULL != (nn = n->parent->head->child))
- if (NULL != nn->next)
+ if (NULL != (nn = n->parent->head->child)) {
+ while (nn && MAN_TEXT != nn->type)
+ nn = nn->next;
+ if (nn && nn->next)
if ((ival = a2width(nn)) >= 0)
len = (size_t)ival;
+ }
switch (n->type) {
case (MAN_HEAD):
@@ -803,7 +808,8 @@ print_man_node(DECL_ARGS)
}
break;
default:
- term_fontrepl(p, TERMFONT_NONE);
+ if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+ term_fontrepl(p, TERMFONT_NONE);
if (termacts[n->tok].pre)
c = (*termacts[n->tok].pre)(p, mt, n, m);
break;
@@ -815,7 +821,8 @@ print_man_node(DECL_ARGS)
if (MAN_TEXT != n->type) {
if (termacts[n->tok].post)
(*termacts[n->tok].post)(p, mt, n, m);
- term_fontrepl(p, TERMFONT_NONE);
+ if ( ! (MAN_NOTEXT & termacts[n->tok].flags))
+ term_fontrepl(p, TERMFONT_NONE);
}
}