=================================================================== RCS file: /cvs/mandoc/man_term.c,v retrieving revision 1.77 retrieving revision 1.83 diff -u -p -r1.77 -r1.83 --- mandoc/man_term.c 2010/06/25 18:53:14 1.77 +++ mandoc/man_term.c 2010/07/22 23:03:15 1.83 @@ -1,6 +1,6 @@ -/* $Id: man_term.c,v 1.77 2010/06/25 18:53:14 kristaps Exp $ */ +/* $Id: man_term.c,v 1.83 2010/07/22 23:03:15 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -92,9 +92,9 @@ static int pre_RS(DECL_ARGS); static int pre_SH(DECL_ARGS); static int pre_SS(DECL_ARGS); static int pre_TP(DECL_ARGS); -static int pre_br(DECL_ARGS); static int pre_fi(DECL_ARGS); static int pre_ign(DECL_ARGS); +static int pre_in(DECL_ARGS); static int pre_nf(DECL_ARGS); static int pre_sp(DECL_ARGS); @@ -106,7 +106,7 @@ static void post_SS(DECL_ARGS); static void post_TP(DECL_ARGS); static const struct termact termacts[MAN_MAX] = { - { pre_br, NULL, MAN_NOTEXT }, /* br */ + { pre_sp, NULL, MAN_NOTEXT }, /* br */ { NULL, NULL, 0 }, /* TH */ { pre_SH, post_SH, 0 }, /* SH */ { pre_SS, post_SS, 0 }, /* SS */ @@ -142,6 +142,7 @@ static const struct termact termacts[MAN_MAX] = { { pre_nf, NULL, 0 }, /* Vb */ { pre_fi, NULL, 0 }, /* Ve */ { pre_ign, NULL, 0 }, /* AT */ + { pre_in, NULL, MAN_NOTEXT }, /* in */ }; @@ -252,6 +253,7 @@ static int pre_fi(DECL_ARGS) { + term_newln(p); mt->fl &= ~MANT_LITERAL; return(1); } @@ -262,6 +264,7 @@ static int pre_nf(DECL_ARGS) { + term_newln(p); mt->fl |= MANT_LITERAL; return(MAN_Vb != n->tok); } @@ -353,28 +356,65 @@ pre_B(DECL_ARGS) /* ARGSUSED */ static int -pre_sp(DECL_ARGS) +pre_in(DECL_ARGS) { - size_t i, len; + int len, less; + size_t v; + const char *cp; - len = n->child ? - a2height(p, n->child->string) : term_len(p, 1); + term_newln(p); - if (0 == len) - term_newln(p); - for (i = 0; i <= len; i++) - term_vspace(p); + if (NULL == n->child) { + p->offset = mt->offset; + return(0); + } + cp = n->child->string; + less = 0; + + if ('-' == *cp) + less = -1; + else if ('+' == *cp) + less = 1; + else + cp--; + + if ((len = a2width(p, ++cp)) < 0) + return(0); + + v = (size_t)len; + + if (less < 0) + p->offset -= p->offset > v ? v : p->offset; + else if (less > 0) + p->offset += v; + else + p->offset = v; + return(0); } /* ARGSUSED */ static int -pre_br(DECL_ARGS) +pre_sp(DECL_ARGS) { + size_t i, len; - term_newln(p); + switch (n->tok) { + case (MAN_br): + len = 0; + break; + default: + len = n->child ? a2height(p, n->child->string) : 1; + break; + } + + if (0 == len) + term_newln(p); + for (i = 0; i < len; i++) + term_vspace(p); + return(0); }