=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.204 retrieving revision 1.207 diff -u -p -r1.204 -r1.207 --- mandoc/term.c 2012/07/10 15:35:41 1.204 +++ mandoc/term.c 2013/05/29 15:17:52 1.207 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.204 2012/07/10 15:35:41 schwarze Exp $ */ +/* $Id: term.c,v 1.207 2013/05/29 15:17:52 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011, 2012 Ingo Schwarze @@ -106,6 +106,7 @@ void term_flushln(struct termp *p) { int i; /* current input position in p->buf */ + int ntab; /* number of tabs to prepend */ size_t vis; /* current visual position on output */ size_t vbl; /* number of blanks to prepend to output */ size_t vend; /* end of word visual position on output */ @@ -144,10 +145,12 @@ term_flushln(struct termp *p) * Handle literal tab characters: collapse all * subsequent tabs into a single huge set of spaces. */ + ntab = 0; while (i < p->col && '\t' == p->buf[i]) { vend = (vis / p->tabwidth + 1) * p->tabwidth; vbl += vend - vis; vis = vend; + ntab++; i++; } @@ -192,6 +195,11 @@ term_flushln(struct termp *p) } else vbl = p->offset; + /* use pending tabs on the new line */ + + if (0 < ntab) + vbl += ntab * p->tabwidth; + /* Remove the p->overstep width. */ bp += (size_t)p->overstep; @@ -368,7 +376,7 @@ void term_fontpopq(struct termp *p, const void *key) { - while (p->fonti >= 0 && key != &p->fontq[p->fonti]) + while (p->fonti >= 0 && key < (void *)(p->fontq + p->fonti)) p->fonti--; assert(p->fonti >= 0); } @@ -398,14 +406,14 @@ term_word(struct termp *p, const char *word) if ( ! (TERMP_NOSPACE & p->flags)) { if ( ! (TERMP_KEEP & p->flags)) { - if (TERMP_PREKEEP & p->flags) - p->flags |= TERMP_KEEP; bufferc(p, ' '); if (TERMP_SENTENCE & p->flags) bufferc(p, ' '); } else bufferc(p, ASCII_NBRSP); } + if (TERMP_PREKEEP & p->flags) + p->flags |= TERMP_KEEP; if ( ! (p->flags & TERMP_NONOSPACE)) p->flags &= ~TERMP_NOSPACE;