=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.182 retrieving revision 1.184 diff -u -p -r1.182 -r1.184 --- mandoc/mdoc_term.c 2010/08/20 22:51:29 1.182 +++ mandoc/mdoc_term.c 2010/09/04 19:01:52 1.184 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.182 2010/08/20 22:51:29 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.184 2010/09/04 19:01:52 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -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 */ @@ -842,8 +843,6 @@ termp_it_pre(DECL_ARGS) if (MDOC_BODY == n->prev->type) p->flags |= TERMP_NOLPAD; - p->flags |= TERMP_IGNDELIM; - break; case (LIST_diag): if (MDOC_HEAD == n->type) @@ -1002,13 +1001,6 @@ termp_it_post(DECL_ARGS) p->flags &= ~TERMP_TWOSPACE; p->flags &= ~TERMP_NOLPAD; p->flags &= ~TERMP_HANG; - - /* - * TERMP_IGNDELIM is also set by `Pf', but it is safe - * to clear it here because `Pf' cannot contain `It'. - */ - - p->flags &= ~TERMP_IGNDELIM; } @@ -1088,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) { @@ -1813,10 +1818,6 @@ static void termp_pf_post(DECL_ARGS) { - /* - * XXX Resetting TERMP_IGNDELIM here is not safe - * because `Pf' can be used inside `Bl -column'. - */ p->flags &= ~TERMP_IGNDELIM; p->flags |= TERMP_NOSPACE; } @@ -2110,6 +2111,16 @@ termp_ap_pre(DECL_ARGS) 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. */