aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit1b0bdf49f16badf24d9b0c44bb5228bcafde6fe4 (patch)
treec3e9315c80dbf90451a73130cd544e78068290f4 /term.c
parent3e2ccabb99fdf7207092e29697a26a5045ab784d (diff)
downloadmandoc-1b0bdf49f16badf24d9b0c44bb5228bcafde6fe4.tar.gz
mandoc-1b0bdf49f16badf24d9b0c44bb5228bcafde6fe4.tar.zst
mandoc-1b0bdf49f16badf24d9b0c44bb5228bcafde6fe4.zip
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.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/term.c b/term.c
index 79d116a3..7070d09b 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.248 2015/04/29 18:35:00 schwarze Exp $ */
+/* $Id: term.c,v 1.249 2015/08/30 21:10:56 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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) {