summaryrefslogtreecommitdiffstatshomepage
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
commitf27e8dcec6089cf24702107e517e3c0c5950477d (patch)
tree820e7552a3bbb4dec58c8f24329f3bce76140c82 /man_term.c
parentb89219869bcc53798ee875bb243b8c4f60b23bda (diff)
downloadmandoc-f27e8dcec6089cf24702107e517e3c0c5950477d.tar.gz
mandoc-f27e8dcec6089cf24702107e517e3c0c5950477d.tar.zst
mandoc-f27e8dcec6089cf24702107e517e3c0c5950477d.zip
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.c81
1 files changed, 44 insertions, 37 deletions
diff --git a/man_term.c b/man_term.c
index f6df381c..0a012d04 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.55 2010/01/01 17:14:28 kristaps Exp $ */
+/* $Id: man_term.c,v 1.56 2010/03/22 05:59:32 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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);
}
}