summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-09-21 13:24:32 +0000
committerschwarze <schwarze@openbsd.org>2015-09-21 13:24:32 +0000
commitb8d4b727c8513fb54d4b36451201b475866b4b76 (patch)
tree4e03ccef7032500ac6429ea17992cde45279f662
parentremove vestigial bits of sha-0 and md2 from openssl(1) (diff)
downloadwireguard-openbsd-b8d4b727c8513fb54d4b36451201b475866b4b76.tar.xz
wireguard-openbsd-b8d4b727c8513fb54d4b36451201b475866b4b76.zip
Trailing whitespace is significant when determining the width of a tag
in mdoc(7) .Bl -tag and man(7) .TP, but not in man(7) .IP. Quirk reported by Jan Stary <hans at stare dot cz> on ports@.
-rw-r--r--regress/usr.bin/mandoc/man/IP/spacing.in14
-rw-r--r--regress/usr.bin/mandoc/man/IP/spacing.out_ascii14
-rw-r--r--regress/usr.bin/mandoc/man/TP/Makefile4
-rw-r--r--regress/usr.bin/mandoc/man/TP/spacing.in42
-rw-r--r--regress/usr.bin/mandoc/man/TP/spacing.out_ascii43
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/tag.in18
-rw-r--r--regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii20
-rw-r--r--usr.bin/mandoc/man_term.c6
-rw-r--r--usr.bin/mandoc/mdoc_term.c6
-rw-r--r--usr.bin/mandoc/term.c8
-rw-r--r--usr.bin/mandoc/term.h15
11 files changed, 162 insertions, 28 deletions
diff --git a/regress/usr.bin/mandoc/man/IP/spacing.in b/regress/usr.bin/mandoc/man/IP/spacing.in
index 02a92925f85..e1239b5b0b1 100644
--- a/regress/usr.bin/mandoc/man/IP/spacing.in
+++ b/regress/usr.bin/mandoc/man/IP/spacing.in
@@ -1,4 +1,4 @@
-.TH IP-SPACING 1 "February 5, 2011" OpenBSD
+.TH IP-SPACING 1 "September 21, 2015" OpenBSD
.SH NAME
IP-spacing \- spacing in indentend paragraphs
.SH DESCRIPTION
@@ -16,4 +16,16 @@ Indented text.
.IP "a much longer tag"
Indented text.
.LP
+Tags with trailing space:
+.IP "tag "
+Three plus one makes four.
+.IP "tag "
+Three plus two makes five.
+.IP "tag "
+Three plus three makes six.
+.IP "tag "
+Three plus four makes seven.
+.IP "tag "
+Three plus five makes eight.
+.LP
Normal text.
diff --git a/regress/usr.bin/mandoc/man/IP/spacing.out_ascii b/regress/usr.bin/mandoc/man/IP/spacing.out_ascii
index c9427446ec5..0aeb8291bc7 100644
--- a/regress/usr.bin/mandoc/man/IP/spacing.out_ascii
+++ b/regress/usr.bin/mandoc/man/IP/spacing.out_ascii
@@ -22,8 +22,20 @@ DDEESSCCRRIIPPTTIIOONN
a much longer tag
Indented text.
+ Tags with trailing space:
+
+ tag Three plus one makes four.
+
+ tag Three plus two makes five.
+
+ tag Three plus three makes six.
+
+ tag Three plus four makes seven.
+
+ tag Three plus five makes eight.
+
Normal text.
-OpenBSD February 5, 2011 IP-SPACING(1)
+OpenBSD September 21, 2015 IP-SPACING(1)
diff --git a/regress/usr.bin/mandoc/man/TP/Makefile b/regress/usr.bin/mandoc/man/TP/Makefile
index b6cbebd79ba..b867ba635a5 100644
--- a/regress/usr.bin/mandoc/man/TP/Makefile
+++ b/regress/usr.bin/mandoc/man/TP/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.11 2015/09/04 21:24:26 schwarze Exp $
+# $OpenBSD: Makefile,v 1.12 2015/09/21 13:24:32 schwarze Exp $
REGRESS_TARGETS = badarg broken double eof fill literal longhead
-REGRESS_TARGETS += macrotag manyargs sameline width
+REGRESS_TARGETS += macrotag manyargs sameline spacing width
LINT_TARGETS = broken double eof
diff --git a/regress/usr.bin/mandoc/man/TP/spacing.in b/regress/usr.bin/mandoc/man/TP/spacing.in
new file mode 100644
index 00000000000..71c788aa658
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TP/spacing.in
@@ -0,0 +1,42 @@
+.TH TP-SPACING 1 "September 21, 2015" OpenBSD
+.SH NAME
+TP-spacing \- spacing in tagged paragraphs
+.SH DESCRIPTION
+Normal text.
+.TP
+tag
+Indented text.
+.TP
+four
+Indented text.
+.TP
+ffive
+Indented text.
+.TP
+sixsix
+Indented text.
+.TP
+seseven
+Indented text.
+.TP
+a much longer tag
+Indented text.
+.LP
+Tags with trailing space:
+.TP
+tag\ \&
+Three plus one makes four.
+.TP
+tag\ \ \&
+Three plus two makes five.
+.TP
+tag\ \ \ \&
+Three plus three makes six.
+.TP
+tag\ \ \ \ \ \&
+Three plus four makes seven.
+.TP
+tag\ \ \ \ \ \ \&
+Three plus five makes eight.
+.LP
+Normal text.
diff --git a/regress/usr.bin/mandoc/man/TP/spacing.out_ascii b/regress/usr.bin/mandoc/man/TP/spacing.out_ascii
new file mode 100644
index 00000000000..247b25f903f
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TP/spacing.out_ascii
@@ -0,0 +1,43 @@
+TP-SPACING(1) General Commands Manual TP-SPACING(1)
+
+
+
+NNAAMMEE
+ TP-spacing - spacing in tagged paragraphs
+
+DDEESSCCRRIIPPTTIIOONN
+ Normal text.
+
+ tag Indented text.
+
+ four Indented text.
+
+ ffive Indented text.
+
+ sixsix Indented text.
+
+ seseven
+ Indented text.
+
+ a much longer tag
+ Indented text.
+
+ Tags with trailing space:
+
+ tag Three plus one makes four.
+
+ tag Three plus two makes five.
+
+ tag Three plus three makes six.
+
+ tag
+ Three plus four makes seven.
+
+ tag
+ Three plus five makes eight.
+
+ Normal text.
+
+
+
+OpenBSD September 21, 2015 TP-SPACING(1)
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.in b/regress/usr.bin/mandoc/mdoc/Bl/tag.in
index ee2d1b46d70..b5bfe8094cd 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/tag.in
+++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.in
@@ -1,4 +1,4 @@
-.Dd December 25, 2014
+.Dd September 21, 2015
.Dt BL-TAG 1
.Os OpenBSD
.Sh NAME
@@ -86,13 +86,21 @@ text text
Trailing white space in the head:
.Bl -tag -width 5n
.It "a"
-b
+none
.It "a "
-b
+one
+.It "a "
+two
+.It "a "
+three
+.It "a "
+four
+.It "a "
+five
+.It "a "
+six
.It " "
white space only
-.It "a "
-b
.El
.Pp
Non-numeric width specification:
diff --git a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
index a112c5b8729..4280111e89e 100644
--- a/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
+++ b/regress/usr.bin/mandoc/mdoc/Bl/tag.out_ascii
@@ -76,13 +76,23 @@ DDEESSCCRRIIPPTTIIOONN
Trailing white space in the head:
- a b
+ a none
- a b
+ a one
- white space only
+ a two
+
+ a three
+
+ a four
- a b
+ a
+ five
+
+ a
+ six
+
+ white space only
Non-numeric width specification:
@@ -111,4 +121,4 @@ DDEESSCCRRIIPPTTIIOONN
second paragraph
-OpenBSD December 25, 2014 OpenBSD
+OpenBSD September 21, 2015 OpenBSD
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 028a92dcea2..1fca9ac7e9d 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.136 2015/04/19 19:43:50 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.137 2015/09/21 13:24:32 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -669,7 +669,7 @@ pre_TP(DECL_ARGS)
switch (n->type) {
case ROFFT_HEAD:
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRTRSP;
p->trailspace = 1;
break;
case ROFFT_BODY:
@@ -721,7 +721,7 @@ pre_TP(DECL_ARGS)
p->offset = mt->offset + len;
p->rmargin = p->maxrmargin;
p->trailspace = 0;
- p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP);
break;
default:
break;
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 3ab4c2130ec..0cf99564659 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.224 2015/09/14 12:57:30 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.225 2015/09/21 13:24:32 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -800,7 +800,7 @@ termp_it_pre(DECL_ARGS)
if (n->type != ROFFT_HEAD)
break;
- p->flags |= TERMP_NOBREAK | TERMP_BRIND;
+ p->flags |= TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND;
p->trailspace = 2;
if (NULL == n->next || NULL == n->next->child)
@@ -972,7 +972,7 @@ termp_it_post(DECL_ARGS)
* has munged them in the meanwhile.
*/
- p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRTRSP | TERMP_BRIND |
TERMP_DANGLE | TERMP_HANG);
p->trailspace = 0;
}
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index a7ba3f2498b..9b972d5fde0 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.109 2015/08/30 21:10:40 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.110 2015/09/21 13:24:32 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -76,6 +76,8 @@ term_end(struct termp *p)
* the next column. However, if less than p->trailspace blanks,
* which can be 0, 1, or 2, remain to the right margin, the line
* will be broken.
+ * - TERMP_BRTRSP: Consider trailing whitespace significant
+ * when deciding whether the chunk fits or not.
* - TERMP_BRIND: If the chunk does not fit and the output line has
* to be broken, start the next line at the right margin instead
* of at the offset. Used together with TERMP_NOBREAK for the tags
@@ -289,6 +291,10 @@ term_flushln(struct termp *p)
} else if (TERMP_DANGLE & p->flags)
return;
+ /* Trailing whitespace is significant in some columns. */
+ if (vis && vbl && (TERMP_BRTRSP & p->flags))
+ vis += vbl;
+
/* If the column was overrun, break the line. */
if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) {
(*p->endline)(p);
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index fd2d6d9d673..7e59a3bd618 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.h,v 1.59 2015/07/17 22:35:36 schwarze Exp $ */
+/* $OpenBSD: term.h,v 1.60 2015/09/21 13:24:32 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,12 +77,13 @@ struct termp {
#define TERMP_BACKAFTER (1 << 6) /* Back up after next character. */
#define TERMP_BACKBEFORE (1 << 7) /* Back up before next character. */
#define TERMP_NOBREAK (1 << 8) /* See term_flushln(). */
-#define TERMP_BRIND (1 << 9) /* See term_flushln(). */
-#define TERMP_DANGLE (1 << 10) /* See term_flushln(). */
-#define TERMP_HANG (1 << 11) /* See term_flushln(). */
-#define TERMP_NOSPLIT (1 << 12) /* Do not break line before .An. */
-#define TERMP_SPLIT (1 << 13) /* Break line before .An. */
-#define TERMP_NONEWLINE (1 << 14) /* No line break in nofill mode. */
+#define TERMP_BRTRSP (1 << 9) /* See term_flushln(). */
+#define TERMP_BRIND (1 << 10) /* See term_flushln(). */
+#define TERMP_DANGLE (1 << 11) /* See term_flushln(). */
+#define TERMP_HANG (1 << 12) /* See term_flushln(). */
+#define TERMP_NOSPLIT (1 << 13) /* Do not break line before .An. */
+#define TERMP_SPLIT (1 << 14) /* Break line before .An. */
+#define TERMP_NONEWLINE (1 << 15) /* No line break in nofill mode. */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
const struct mchars *symtab; /* Character table. */