=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.56 retrieving revision 1.58 diff -u -p -r1.56 -r1.58 --- mandoc/mdoc_term.c 2009/07/21 15:39:04 1.56 +++ mandoc/mdoc_term.c 2009/07/23 08:36:32 1.58 @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.56 2009/07/21 15:39:04 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.58 2009/07/23 08:36:32 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -66,7 +66,7 @@ const int ttypes[TTYPE_NMAX] = { TERMP_UNDER, /* TTYPE_FUNC_ARG */ TERMP_UNDER, /* TTYPE_LINK */ TERMP_BOLD, /* TTYPE_SSECTION */ - 0, /* TTYPE_FILE */ + TERMP_UNDER, /* TTYPE_FILE */ TERMP_UNDER, /* TTYPE_EMPH */ TERMP_BOLD, /* TTYPE_CONFIG */ TERMP_BOLD, /* TTYPE_CMD */ @@ -155,6 +155,7 @@ static int termp_nd_pre(DECL_ARGS); static int termp_nm_pre(DECL_ARGS); static int termp_ns_pre(DECL_ARGS); static int termp_op_pre(DECL_ARGS); +static int termp_pa_pre(DECL_ARGS); static int termp_pf_pre(DECL_ARGS); static int termp_pp_pre(DECL_ARGS); static int termp_pq_pre(DECL_ARGS); @@ -210,7 +211,7 @@ static const struct termact termacts[MDOC_MAX] = { { termp_nm_pre, NULL }, /* Nm */ { termp_op_pre, termp_op_post }, /* Op */ { NULL, NULL }, /* Ot */ - { NULL, NULL }, /* Pa */ + { termp_pa_pre, NULL }, /* Pa */ { termp_rv_pre, NULL }, /* Rv */ { NULL, NULL }, /* St */ { termp_va_pre, NULL }, /* Va */ @@ -781,11 +782,27 @@ termp_it_pre(DECL_ARGS) case (MDOC_Column): if (MDOC_BODY == node->type) break; - for (i = 0, n = node->prev; n; n = n->prev, i++) + /* + * Work around groff's column handling. The offset is + * equal to the sum of all widths leading to the current + * column (plus the -offset value). If this column + * exceeds the stated number of columns, the width is + * set as 0, else it's the stated column width (later + * the 0 will be adjusted to default 10 or, if in the + * last column case, set to stretch to the margin). + */ + for (i = 0, n = node->prev; n && n && + i < (int)bl->args[vals[2]].argv->sz; + n = n->prev, i++) offset += arg_width (&bl->args->argv[vals[2]], i); - assert(i < (int)bl->args->argv[vals[2]].sz); - width = arg_width(&bl->args->argv[vals[2]], i); + + /* Whether exceeds maximum column. */ + if (i < (int)bl->args[vals[2]].argv->sz) + width = arg_width(&bl->args->argv[vals[2]], i); + else + width = 0; + if (vals[1] >= 0) offset += arg_offset(&bl->args->argv[vals[1]]); break; @@ -1729,6 +1746,16 @@ termp_sq_post(DECL_ARGS) return; p->flags |= TERMP_NOSPACE; term_word(p, "\\(aq"); +} + + +/* ARGSUSED */ +static int +termp_pa_pre(DECL_ARGS) +{ + + pair->flag |= ttypes[TTYPE_FILE]; + return(1); }