summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2015-01-07 12:19:17 +0000
committerschwarze <schwarze@openbsd.org>2015-01-07 12:19:17 +0000
commitc65a03d48f9671c8e33b3dc03289fe45decbbcb1 (patch)
treedb590e6c739c308d9465bd937c1c333bc59d05cf
parentRelax configuration list parsing to allow multi-line blocks for tls, (diff)
downloadwireguard-openbsd-c65a03d48f9671c8e33b3dc03289fe45decbbcb1.tar.xz
wireguard-openbsd-c65a03d48f9671c8e33b3dc03289fe45decbbcb1.zip
Bugfix: When the invocation of a user-defined macro follows a roff
conditional request on the same input line, don't skip the first few bytes of its content.
-rw-r--r--regress/usr.bin/mandoc/roff/de/Makefile4
-rw-r--r--regress/usr.bin/mandoc/roff/de/cond.in13
-rw-r--r--regress/usr.bin/mandoc/roff/de/cond.out_ascii9
-rw-r--r--usr.bin/mandoc/roff.c3
4 files changed, 26 insertions, 3 deletions
diff --git a/regress/usr.bin/mandoc/roff/de/Makefile b/regress/usr.bin/mandoc/roff/de/Makefile
index 9e48a3be0f9..82a43f78885 100644
--- a/regress/usr.bin/mandoc/roff/de/Makefile
+++ b/regress/usr.bin/mandoc/roff/de/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.7 2015/01/01 09:06:39 schwarze Exp $
+# $OpenBSD: Makefile,v 1.8 2015/01/07 12:19:17 schwarze Exp $
-REGRESS_TARGETS = append escname factorial indir startde TH Dd
+REGRESS_TARGETS = append cond escname factorial indir startde TH Dd
LINT_TARGETS = escname indir
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/de/cond.in b/regress/usr.bin/mandoc/roff/de/cond.in
new file mode 100644
index 00000000000..057ad3a090b
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/de/cond.in
@@ -0,0 +1,13 @@
+.Dd January 7, 2015
+.Dt DE-COND 1
+.Os OpenBSD
+.Sh NAME
+.Nm de-cond
+.Nd conditional execution of a user-defined macro
+.Sh DESCRIPTION
+.de mym
+This is the text printed by the macro.
+..
+preceding text
+.if n .mym
+following text
diff --git a/regress/usr.bin/mandoc/roff/de/cond.out_ascii b/regress/usr.bin/mandoc/roff/de/cond.out_ascii
new file mode 100644
index 00000000000..2f946407a4c
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/de/cond.out_ascii
@@ -0,0 +1,9 @@
+DE-COND(1) General Commands Manual DE-COND(1)
+
+NNAAMMEE
+ ddee--ccoonndd - conditional execution of a user-defined macro
+
+DDEESSCCRRIIPPTTIIOONN
+ preceding text This is the text printed by the macro. following text
+
+OpenBSD January 7, 2015 OpenBSD
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index d7d1ff61ca9..356326e5316 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.119 2015/01/01 19:28:29 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.120 2015/01/07 12:19:17 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -2167,6 +2167,7 @@ roff_userdef(ROFF_ARGS)
buf->buf = n1;
if (buf->sz == 0)
buf->sz = strlen(buf->buf) + 1;
+ *offs = 0;
return(buf->sz > 1 && buf->buf[buf->sz - 2] == '\n' ?
ROFF_REPARSE : ROFF_APPEND);