summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-09-04 19:01:52 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-09-04 19:01:52 +0000
commit8602ef022ba97685524bab84712ad686cd05b20e (patch)
tree68f879dc053e8cd622fba425bf024d152f20a12f /mdoc_term.c
parentf6865c5cc81f43ad947eb8f69efe22d17360f0d7 (diff)
downloadmandoc-8602ef022ba97685524bab84712ad686cd05b20e.tar.gz
Properly handle -mdoc %A in all outputs. This has two-author entires
separated by only "and" while two or more are with ", and" for the last author. Also remove relevant TODO and add regression tests.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 55d5d1e8..ff8d47aa 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -92,6 +92,7 @@ static void termp_sh_post(DECL_ARGS);
static void termp_sq_post(DECL_ARGS);
static void termp_ss_post(DECL_ARGS);
+static int termp__a_pre(DECL_ARGS);
static int termp_an_pre(DECL_ARGS);
static int termp_ap_pre(DECL_ARGS);
static int termp_aq_pre(DECL_ARGS);
@@ -178,7 +179,7 @@ static const struct termact termacts[MDOC_MAX] = {
{ termp_under_pre, NULL }, /* Va */
{ termp_vt_pre, NULL }, /* Vt */
{ termp_xr_pre, NULL }, /* Xr */
- { NULL, termp____post }, /* %A */
+ { termp__a_pre, termp____post }, /* %A */
{ termp_under_pre, termp____post }, /* %B */
{ NULL, termp____post }, /* %D */
{ termp_under_pre, termp____post }, /* %I */
@@ -1079,6 +1080,19 @@ termp_fl_pre(DECL_ARGS)
/* ARGSUSED */
static int
+termp__a_pre(DECL_ARGS)
+{
+
+ if (n->prev && MDOC__A == n->prev->tok)
+ if (NULL == n->next || MDOC__A != n->next->tok)
+ term_word(p, "and");
+
+ return(1);
+}
+
+
+/* ARGSUSED */
+static int
termp_an_pre(DECL_ARGS)
{
@@ -2098,6 +2112,16 @@ static void
termp____post(DECL_ARGS)
{
+ /*
+ * Handle lists of authors. In general, print each followed by
+ * a comma. Don't print the comma if there are only two
+ * authors.
+ */
+ if (MDOC__A == n->tok && n->next && MDOC__A == n->next->tok)
+ if (NULL == n->next->next || MDOC__A != n->next->next->tok)
+ if (NULL == n->prev || MDOC__A != n->prev->tok)
+ return;
+
/* TODO: %U. */
p->flags |= TERMP_NOSPACE;