summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-03-08 16:20:01 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-03-08 16:20:01 +0000
commit50e76ea0549aa7b11814b996d49a468508286302 (patch)
tree9ca312689db9e72192e183d4978465792667b5a3
parent9ecbecb55d38cad3fc3f4a7340a796445940de39 (diff)
In .nf mode, use the MAN_LINE flag to detect input line breaks
instead of the man_node line member. This is required to preserve line breaks contained in user-defined macros called in .nf mode. Found in a code audit triggered by fixing a similar issue in .TP.
-rw-r--r--regress/usr.bin/mandoc/man/nf/Makefile4
-rw-r--r--regress/usr.bin/mandoc/man/nf/userdef.in21
-rw-r--r--regress/usr.bin/mandoc/man/nf/userdef.out_ascii19
-rw-r--r--usr.bin/mandoc/man_term.c4
4 files changed, 44 insertions, 4 deletions
diff --git a/regress/usr.bin/mandoc/man/nf/Makefile b/regress/usr.bin/mandoc/man/nf/Makefile
index 0b8694a7ca5..b8f84c157b9 100644
--- a/regress/usr.bin/mandoc/man/nf/Makefile
+++ b/regress/usr.bin/mandoc/man/nf/Makefile
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.4 2012/07/10 17:05:16 schwarze Exp $
+# $OpenBSD: Makefile,v 1.5 2014/03/08 16:20:00 schwarze Exp $
-REGRESS_TARGETS = indent args vert
+REGRESS_TARGETS = indent args vert userdef
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/nf/userdef.in b/regress/usr.bin/mandoc/man/nf/userdef.in
new file mode 100644
index 00000000000..9342246985f
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/nf/userdef.in
@@ -0,0 +1,21 @@
+.TH NF-USERDEF 1 "March 8, 2014" OpenBSD
+.SH NAME
+nf-userdef \- setting unfilled mode via user-defined macros
+.SH DESCRIPTION
+filled
+text
+.nf
+unfilled
+text
+.fi
+filled
+text
+.de MYBLOCK
+.nf
+unfilled
+text
+.fi
+filled
+text
+..
+.MYBLOCK
diff --git a/regress/usr.bin/mandoc/man/nf/userdef.out_ascii b/regress/usr.bin/mandoc/man/nf/userdef.out_ascii
new file mode 100644
index 00000000000..4a8b35cf799
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/nf/userdef.out_ascii
@@ -0,0 +1,19 @@
+NF-USERDEF(1) OpenBSD Reference Manual NF-USERDEF(1)
+
+
+
+NNAAMMEE
+ nf-userdef - setting unfilled mode via user-defined macros
+
+DDEESSCCRRIIPPTTIIOONN
+ filled text
+ unfilled
+ text
+ filled text
+ unfilled
+ text
+ filled text
+
+
+
+OpenBSD March 8, 2014 NF-USERDEF(1)
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 79cc9d2030a..a4faaa3ad84 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.95 2014/03/08 15:50:21 schwarze Exp $ */
+/* $Id: man_term.c,v 1.96 2014/03/08 16:19:59 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1041,7 +1041,7 @@ out:
* more specific than this.
*/
if (MANT_LITERAL & mt->fl && ! (TERMP_NOBREAK & p->flags) &&
- (NULL == n->next || n->next->line > n->line)) {
+ (NULL == n->next || MAN_LINE & n->next->flags)) {
rm = p->rmargin;
rmax = p->maxrmargin;
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;