=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.151 retrieving revision 1.153 diff -u -p -r1.151 -r1.153 --- mandoc/term.c 2010/06/27 01:26:20 1.151 +++ mandoc/term.c 2010/06/28 22:46:21 1.153 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.151 2010/06/27 01:26:20 schwarze Exp $ */ +/* $Id: term.c,v 1.153 2010/06/28 22:46:21 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -133,9 +133,10 @@ term_flushln(struct termp *p) size_t vbl; /* number of blanks to prepend to output */ size_t vend; /* end of word visual position on output */ size_t bp; /* visual right border position */ - int j; /* temporary loop index */ - int jhy; /* last hyphen before line overflow */ - size_t maxvis, mmax; + int j; /* temporary loop index for p->buf */ + int jhy; /* last hyph before overflow w/r/t j */ + size_t maxvis; /* output position of visible boundary */ + size_t mmax; /* used in calculating bp */ /* * First, establish the maximum columns of "visible" content. @@ -194,9 +195,11 @@ term_flushln(struct termp *p) if (vend > vis && vend < bp && ASCII_HYPH == p->buf[j]) jhy = j; - vend++; - } else - vend--; + vend += (*p->width)(p, p->buf[j]); + } else { + assert(j); + vend -= (*p->width)(p, p->buf[j - 1]); + } } /* @@ -236,13 +239,13 @@ term_flushln(struct termp *p) break; if (' ' == p->buf[i]) { while (' ' == p->buf[i]) { - vbl++; + vbl += (*p->width)(p, p->buf[i]); i++; } break; } if (ASCII_NBRSP == p->buf[i]) { - vbl++; + vbl += (*p->width)(p, ' '); continue; } @@ -257,12 +260,13 @@ term_flushln(struct termp *p) vbl = 0; } - if (ASCII_HYPH == p->buf[i]) + if (ASCII_HYPH == p->buf[i]) { (*p->letter)(p, '-'); - else + p->viscol += (*p->width)(p, '-'); + } else { (*p->letter)(p, p->buf[i]); - - p->viscol += 1; + p->viscol += (*p->width)(p, p->buf[i]); + } } vend += vbl; vis = vend; @@ -280,7 +284,7 @@ term_flushln(struct termp *p) if (TERMP_HANG & p->flags) { /* We need one blank after the tag. */ p->overstep = /* LINTED */ - vis - maxvis + 1; + vis - maxvis + (*p->width)(p, ' '); /* * Behave exactly the same way as groff: @@ -304,7 +308,7 @@ term_flushln(struct termp *p) /* Right-pad. */ if (maxvis > vis + /* LINTED */ - ((TERMP_TWOSPACE & p->flags) ? 1 : 0)) { + ((TERMP_TWOSPACE & p->flags) ? (*p->width)(p, ' ') : 0)) { p->viscol += maxvis - vis; (*p->advance)(p, maxvis - vis); vis += (maxvis - vis);