From c56c17992552256b55134ead16c3e16164fd2e67 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 23 Aug 2018 14:29:38 +0000 Subject: Implement the roff(7) .shift and .return requests, for example used by groff_hdtbl(7) and groff_mom(7). Also correctly interpolate arguments during nested macro execution even after .shift and .return, implemented using a stack of argument arrays. Note that only read.c, but not roff.c can detect the end of a macro execution, and the existence of .shift implies that arguments cannot be interpolated up front, so unfortunately, this includes a partial revert of roff.c rev. 1.337, moving argument interpolation back into the function roff_res(). --- regress/roff/return/Makefile | 6 ++++++ regress/roff/return/basic.in | 23 +++++++++++++++++++++++ regress/roff/return/basic.out_ascii | 15 +++++++++++++++ regress/roff/return/basic.out_lint | 3 +++ 4 files changed, 47 insertions(+) create mode 100644 regress/roff/return/Makefile create mode 100644 regress/roff/return/basic.in create mode 100644 regress/roff/return/basic.out_ascii create mode 100644 regress/roff/return/basic.out_lint (limited to 'regress/roff/return') diff --git a/regress/roff/return/Makefile b/regress/roff/return/Makefile new file mode 100644 index 00000000..f7d510f7 --- /dev/null +++ b/regress/roff/return/Makefile @@ -0,0 +1,6 @@ +# $OpenBSD: Makefile,v 1.1 2018/08/23 14:16:12 schwarze Exp $ + +REGRESS_TARGETS = basic +LINT_TARGETS = basic + +.include diff --git a/regress/roff/return/basic.in b/regress/roff/return/basic.in new file mode 100644 index 00000000..f0a777c1 --- /dev/null +++ b/regress/roff/return/basic.in @@ -0,0 +1,23 @@ +.\" $OpenBSD: basic.in,v 1.1 2018/08/23 14:16:12 schwarze Exp $ +.Dd $Mdocdate: August 23 2018 $ +.Dt RETURN-BASIC 1 +.Os +.Sh NAME +.Nm return-basic +.Nd the return request +.Sh DESCRIPTION +return before macro +.return +.Pp +.de mymacro +text from macro (\\n(.$ argument: "\\$1"), +.return +not printed, +.. +.mymacro myarg +\n(.$ arguments after return: "\$1", +.Pp +return after macro +.return +.Pp +final text diff --git a/regress/roff/return/basic.out_ascii b/regress/roff/return/basic.out_ascii new file mode 100644 index 00000000..25f66744 --- /dev/null +++ b/regress/roff/return/basic.out_ascii @@ -0,0 +1,15 @@ +RETURN-BASIC(1) General Commands Manual RETURN-BASIC(1) + +NNAAMMEE + rreettuurrnn--bbaassiicc - the return request + +DDEESSCCRRIIPPTTIIOONN + return before macro + + text from macro (1 argument: "myarg"), 0 arguments after return: "", + + return after macro + + final text + +OpenBSD August 23, 2018 OpenBSD diff --git a/regress/roff/return/basic.out_lint b/regress/roff/return/basic.out_lint new file mode 100644 index 00000000..f4b15bac --- /dev/null +++ b/regress/roff/return/basic.out_lint @@ -0,0 +1,3 @@ +mandoc: basic.in:10:2: ERROR: ignoring request outside macro: return +mandoc: basic.in:18:32: ERROR: using macro argument outside macro: \$1 +mandoc: basic.in:21:2: ERROR: ignoring request outside macro: return -- cgit v1.2.3-56-ge451