summaryrefslogtreecommitdiffstats
path: root/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-08-30 21:10:56 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-08-30 21:10:56 +0000
commitdfd27e6cd9c8f1f55ef0e659bcb6dd71d22a1057 (patch)
tree8855625e5277b24b040e4359f765e17da5ef659d /term.c
parent5c7a2c6bb5d2ce6ece31f59b674ba5fe68726fa7 (diff)
downloadmandoc-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.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/term.c b/term.c
index 0bd147cc..acda12f7 100644
--- a/term.c
+++ b/term.c
@@ -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) {