From 1b0bdf49f16badf24d9b0c44bb5228bcafde6fe4 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 30 Aug 2015 21:10:56 +0000 Subject: 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. --- term.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'term.c') 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 * Copyright (c) 2010-2015 Ingo Schwarze @@ -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) { -- cgit v1.2.3-56-ge451