diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-06-15 00:57:07 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-06-15 00:57:07 +0000 |
commit | d7afce2789fd8229b8f6c1287edd1741a3765705 (patch) | |
tree | 12876a54e4841e62f8fb997a3a0f1d83d42f64bd /usr.bin/mandoc | |
parent | 8a7e073ca27b9e1be1b6d24148ae05302d0df734 (diff) |
sync to 1.7.16: avoid trailing space in output
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/term.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index 5363d045f45..e8d9dce1ae6 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.2 2009/06/14 23:00:57 schwarze Exp $ */ +/* $Id: term.c,v 1.3 2009/06/15 00:57:06 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -272,22 +272,20 @@ term_flushln(struct termp *p) vis = p->rmargin - p->offset; } - /* - * Write out the word and a trailing space. Omit the - * space if we're the last word in the line or beyond - * our breakpoint. + /* + * Prepend a space if we're not already at the beginning + * of the line, then the word. */ + if (0 < vis++) + putchar(' '); + for ( ; i < (int)p->col; i++) { if (' ' == p->buf[i]) break; putchar(p->buf[i]); } vis += vsz; - if (i < (int)p->col && vis <= bp) { - putchar(' '); - vis++; - } } /* @@ -295,7 +293,7 @@ term_flushln(struct termp *p) * cause a newline and offset at the right margin. */ - if ((TERMP_NOBREAK & p->flags) && vis >= maxvis) { + if ((TERMP_NOBREAK & p->flags) && vis > maxvis) { if ( ! (TERMP_NONOBREAK & p->flags)) { putchar('\n'); for (i = 0; i < (int)p->rmargin; i++) @@ -312,7 +310,7 @@ term_flushln(struct termp *p) if (p->flags & TERMP_NOBREAK) { if ( ! (TERMP_NONOBREAK & p->flags)) - for ( ; vis < maxvis; vis++) + for ( ; vis <= maxvis; vis++) putchar(' '); } else putchar('\n'); |