=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.258 retrieving revision 1.260 diff -u -p -r1.258 -r1.260 --- mandoc/term.c 2016/08/10 11:03:43 1.258 +++ mandoc/term.c 2017/05/07 17:31:45 1.260 @@ -1,7 +1,7 @@ -/* $Id: term.c,v 1.258 2016/08/10 11:03:43 schwarze Exp $ */ +/* $Id: term.c,v 1.260 2017/05/07 17:31:45 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010-2016 Ingo Schwarze + * Copyright (c) 2010-2017 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -141,8 +141,8 @@ term_flushln(struct termp *p) * 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; + while (i < p->col && p->buf[i] == '\t') { + vend = term_tab_next(vis); vbl += vend - vis; vis = vend; ntab++; @@ -192,18 +192,21 @@ term_flushln(struct termp *p) vend -= vis; (*p->endline)(p); p->viscol = 0; - if (TERMP_BRIND & p->flags) { - vbl = p->rmargin; - vend += p->rmargin; - vend -= p->offset; - } else - vbl = p->offset; - /* use pending tabs on the new line */ + /* Use pending tabs on the new line. */ - if (0 < ntab) - vbl += ntab * p->tabwidth; + vbl = 0; + while (ntab--) + vbl = term_tab_next(vbl); + /* Re-establish indentation. */ + + if (p->flags & TERMP_BRIND) { + vbl += p->rmargin; + vend += p->rmargin - p->offset; + } else + vbl += p->offset; + /* * Remove the p->overstep width. * Again, if p->overstep is negative, @@ -606,8 +609,20 @@ encode(struct termp *p, const char *word, size_t sz) if (ASCII_HYPH == word[i] || isgraph((unsigned char)word[i])) encode1(p, word[i]); - else + else { p->buf[p->col++] = word[i]; + + /* + * Postpone the effect of \z while handling + * an overstrike sequence from ascii_uc2str(). + */ + + if (word[i] == '\b' && + (p->flags & TERMP_BACKBEFORE)) { + p->flags &= ~TERMP_BACKBEFORE; + p->flags |= TERMP_BACKAFTER; + } + } } }