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/shift/bad.in | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 regress/roff/shift/bad.in (limited to 'regress/roff/shift/bad.in') diff --git a/regress/roff/shift/bad.in b/regress/roff/shift/bad.in new file mode 100644 index 00000000..809832de --- /dev/null +++ b/regress/roff/shift/bad.in @@ -0,0 +1,30 @@ +.\" $OpenBSD: bad.in,v 1.1 2018/08/23 14:16:12 schwarze Exp $ +.TH SHIFT_BAD 1 "August 23, 2018" +.SH NAME +.B shift-bad +\(en wrong usage of macro arguments +.SH DESCRIPTION +initial text +.de mym +in macro: "\\$1" +.PP +invalid argument number 'x': "\\$x" +.. +.PP +argument used before call: "\$1" +.shift +.PP +.mym argument +.PP +argument used after call: "\$1" +.shift 2 +.PP +.de mym +.shift badarg +after shift badarg: "\\$1" +.shift 2 +after excessive shift: \\n(.$ "\\$1" +.. +.mym arg1 arg2 +.PP +final text -- cgit v1.2.3-56-ge451