diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-08-30 21:10:56 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-08-30 21:10:56 +0000 |
commit | dfd27e6cd9c8f1f55ef0e659bcb6dd71d22a1057 (patch) | |
tree | 8855625e5277b24b040e4359f765e17da5ef659d /term.c | |
parent | 5c7a2c6bb5d2ce6ece31f59b674ba5fe68726fa7 (diff) | |
download | mandoc-dfd27e6cd9c8f1f55ef0e659bcb6dd71d22a1057.tar.gz |
Drop leading, internal, and trailing blank characters in \o (overstrike)
escape sequences; that's cleaner for all output modes, and it's required
to prevent the PostScript/PDF formatter from dying on assertions.
Bug found by jsg@ with afl.
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -499,6 +499,9 @@ term_word(struct termp *p, const char *word) p->flags |= TERMP_BACKBEFORE; } } + /* Trim trailing backspace/blank pair. */ + if (p->col > 2 && p->buf[p->col - 1] == ' ') + p->col -= 2; continue; default: continue; @@ -561,7 +564,10 @@ encode1(struct termp *p, int c) p->fontq[p->fonti] : TERMFONT_NONE; if (p->flags & TERMP_BACKBEFORE) { - p->buf[p->col++] = 8; + if (p->buf[p->col - 1] == ' ') + p->col--; + else + p->buf[p->col++] = 8; p->flags &= ~TERMP_BACKBEFORE; } if (TERMFONT_UNDER == f || TERMFONT_BI == f) { |