summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-11-16 21:29:27 +0000
committerschwarze <schwarze@openbsd.org>2014-11-16 21:29:27 +0000
commit187f91aca4082bbd53b62aa18744e6f92479ce87 (patch)
tree8cec2eb1e0ff9f5cd4bb6eceab69c7fd04159616
parentMove some memory allocations/initialization and file reading to (diff)
downloadwireguard-openbsd-187f91aca4082bbd53b62aa18744e6f92479ce87.tar.xz
wireguard-openbsd-187f91aca4082bbd53b62aa18744e6f92479ce87.zip
When a line (in the sense of term_flushln()) contains white space only,
the `vbl' variable includes the left margin, but `vis' does not. Prevent a `vis' underflow that caused a bogus blank line. Bug reported by Carsten Kunze, found in less(1): .Bl -tag ... .It " "
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/tag.in4
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii4
-rw-r--r--usr.bin/mandoc/term.c6
3 files changed, 10 insertions, 4 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.in b/regress/usr.bin/mandoc/mdoc/Bl/tag.in
index a8ded58d901..649da804535 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/tag.in
+++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.in
@@ -1,4 +1,4 @@
-.Dd April 8, 2014
+.Dd November 16, 2014
.Dt BL-TAG 1
.Os OpenBSD
.Sh NAME
@@ -53,6 +53,8 @@ Trailing white space in the head:
b
.It "a "
b
+.It " "
+white space only
.It "a "
b
.El
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
index c8f15374f09..959b1c8a4b8 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
@@ -46,6 +46,8 @@ DDEESSCCRRIIPPTTIIOONN
a b
+ white space only
+
a b
Non-numeric width specification:
@@ -75,4 +77,4 @@ DDEESSCCRRIIPPTTIIOONN
second paragraph
-OpenBSD April 8, 2014 OpenBSD
+OpenBSD November 16, 2014 OpenBSD
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 8ff50bf20aa..add5ec877cc 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.94 2014/11/01 04:03:22 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.95 2014/11/16 21:29:27 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -252,8 +252,10 @@ term_flushln(struct termp *p)
* If there was trailing white space, it was not printed;
* so reset the cursor position accordingly.
*/
- if (vis)
+ if (vis > vbl)
vis -= vbl;
+ else
+ vis = 0;
p->col = 0;
p->overstep = 0;