aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/regress
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-08-23 14:29:38 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-08-23 14:29:38 +0000
commitc56c17992552256b55134ead16c3e16164fd2e67 (patch)
treecfe287e6cfd33a9dcb04a6a781b093af17e5b556 /regress
parent1483cf671448b44a8bf37ea7129c88e24f588abd (diff)
downloadmandoc-c56c17992552256b55134ead16c3e16164fd2e67.tar.gz
mandoc-c56c17992552256b55134ead16c3e16164fd2e67.tar.zst
mandoc-c56c17992552256b55134ead16c3e16164fd2e67.zip
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().
Diffstat (limited to 'regress')
-rw-r--r--regress/roff/Makefile4
-rw-r--r--regress/roff/de/infinite.in8
-rw-r--r--regress/roff/de/infinite.out_ascii4
-rw-r--r--regress/roff/de/infinite.out_lint3
-rw-r--r--regress/roff/return/Makefile6
-rw-r--r--regress/roff/return/basic.in23
-rw-r--r--regress/roff/return/basic.out_ascii15
-rw-r--r--regress/roff/return/basic.out_lint3
-rw-r--r--regress/roff/shift/Makefile6
-rw-r--r--regress/roff/shift/bad.in30
-rw-r--r--regress/roff/shift/bad.out_ascii25
-rw-r--r--regress/roff/shift/bad.out_lint7
-rw-r--r--regress/roff/shift/basic.in35
-rw-r--r--regress/roff/shift/basic.out_ascii25
14 files changed, 185 insertions, 9 deletions
diff --git a/regress/roff/Makefile b/regress/roff/Makefile
index 61501033..7c6f5e16 100644
--- a/regress/roff/Makefile
+++ b/regress/roff/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.20 2015/02/06 16:05:51 schwarze Exp $
+# $OpenBSD: Makefile,v 1.25 2018/08/23 14:16:12 schwarze Exp $
SUBDIR = args cond esc scale string
-SUBDIR += br cc de ds ft ig it ll na nr po ps rm rn sp ta ti tr
+SUBDIR += br cc de ds ft ig it ll na nr po ps return rm rn shift sp ta ti tr
.include "../Makefile.sub"
.include <bsd.subdir.mk>
diff --git a/regress/roff/de/infinite.in b/regress/roff/de/infinite.in
index 00931a06..dd17885f 100644
--- a/regress/roff/de/infinite.in
+++ b/regress/roff/de/infinite.in
@@ -1,5 +1,5 @@
-.\" $OpenBSD: infinite.in,v 1.3 2017/07/04 14:53:27 schwarze Exp $
-.Dd $Mdocdate: July 4 2017 $
+.\" $OpenBSD: infinite.in,v 1.4 2018/08/23 14:16:12 schwarze Exp $
+.Dd $Mdocdate: August 23 2018 $
.Dt DE-INFINITE 1
.Os
.Sh NAME
@@ -10,8 +10,8 @@ initial text
.de mym
.Op \\$1 \\$2
..
-.mym $1 \$1
-.mym \$1 nothing
+.mym $1 \$1 end
+.mym \$1 middle end
middle text
.de mym
.mym
diff --git a/regress/roff/de/infinite.out_ascii b/regress/roff/de/infinite.out_ascii
index 452af775..074362da 100644
--- a/regress/roff/de/infinite.out_ascii
+++ b/regress/roff/de/infinite.out_ascii
@@ -4,6 +4,6 @@ NNAAMMEE
ddee--iinnffiinniittee - inifinte recursion in a user-defined macro
DDEESSCCRRIIPPTTIIOONN
- initial text [$1 $1] middle text final text
+ initial text [$1 end] [middle end] middle text final text
-OpenBSD July 4, 2017 OpenBSD
+OpenBSD August 23, 2018 OpenBSD
diff --git a/regress/roff/de/infinite.out_lint b/regress/roff/de/infinite.out_lint
index e7beb090..06254be5 100644
--- a/regress/roff/de/infinite.out_lint
+++ b/regress/roff/de/infinite.out_lint
@@ -1,2 +1,3 @@
-mandoc: infinite.in:14:5: ERROR: input stack limit exceeded, infinite loop?
+mandoc: infinite.in:13:9: ERROR: using macro argument outside macro: \$1
+mandoc: infinite.in:14:6: ERROR: using macro argument outside macro: \$1
mandoc: infinite.in:20:5: ERROR: input stack limit exceeded, infinite loop?
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 <bsd.regress.mk>
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
diff --git a/regress/roff/shift/Makefile b/regress/roff/shift/Makefile
new file mode 100644
index 00000000..d356b963
--- /dev/null
+++ b/regress/roff/shift/Makefile
@@ -0,0 +1,6 @@
+# $OpenBSD: Makefile,v 1.1 2018/08/23 14:16:12 schwarze Exp $
+
+REGRESS_TARGETS = basic bad
+LINT_TARGETS = bad
+
+.include <bsd.regress.mk>
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
diff --git a/regress/roff/shift/bad.out_ascii b/regress/roff/shift/bad.out_ascii
new file mode 100644
index 00000000..0b21f574
--- /dev/null
+++ b/regress/roff/shift/bad.out_ascii
@@ -0,0 +1,25 @@
+SHIFT_BAD(1) General Commands Manual SHIFT_BAD(1)
+
+
+
+NNAAMMEE
+ sshhiifftt--bbaadd - wrong usage of macro arguments
+
+DDEESSCCRRIIPPTTIIOONN
+ initial text
+
+ argument used before call: ""
+
+ in macro: "argument"
+
+ invalid argument number 'x': ""
+
+ argument used after call: ""
+
+ after shift badarg: "arg2" after excessive shift: 0 ""
+
+ final text
+
+
+
+OpenBSD August 23, 2018 SHIFT_BAD(1)
diff --git a/regress/roff/shift/bad.out_lint b/regress/roff/shift/bad.out_lint
new file mode 100644
index 00000000..1f696fc8
--- /dev/null
+++ b/regress/roff/shift/bad.out_lint
@@ -0,0 +1,7 @@
+mandoc: bad.in:14:29: ERROR: using macro argument outside macro: \$1
+mandoc: bad.in:15:2: ERROR: ignoring request outside macro: shift
+mandoc: bad.in:17:31: ERROR: argument number is not numeric: \$x
+mandoc: bad.in:19:28: ERROR: using macro argument outside macro: \$1
+mandoc: bad.in:20:2: ERROR: ignoring request outside macro: shift
+mandoc: bad.in:28:8: ERROR: argument is not numeric, using 1: shift badarg
+mandoc: bad.in:28:9: ERROR: excessive shift: 2, but max is 1
diff --git a/regress/roff/shift/basic.in b/regress/roff/shift/basic.in
new file mode 100644
index 00000000..982042db
--- /dev/null
+++ b/regress/roff/shift/basic.in
@@ -0,0 +1,35 @@
+.\" $OpenBSD: basic.in,v 1.1 2018/08/23 14:16:12 schwarze Exp $
+.TH SHIFT_BASIC 1 "August 23, 2018"
+.SH NAME
+.B shift-basic
+\(en the shift request
+.SH DESCRIPTION
+.de showargs
+original arguments:
+.BI \\$@
+.PP
+.shift 2
+after shift 2:
+.BI \\$@
+.PP
+.shift
+after shift without argument:
+.BI \\$@
+.PP
+.shift 0
+after shift 0:
+.BI \\$@
+..
+.de useargs
+<\\$*>
+..
+.showargs one two three four five
+.PP
+expand to less than three bytes:
+.useargs 1
+.PP
+expand to exactly three bytes:
+.useargs x y
+.PP
+expand to more than three bytes:
+.useargs "a longer argument..." "and another"
diff --git a/regress/roff/shift/basic.out_ascii b/regress/roff/shift/basic.out_ascii
new file mode 100644
index 00000000..40675c67
--- /dev/null
+++ b/regress/roff/shift/basic.out_ascii
@@ -0,0 +1,25 @@
+SHIFT_BASIC(1) General Commands Manual SHIFT_BASIC(1)
+
+
+
+NNAAMMEE
+ sshhiifftt--bbaassiicc - the shift request
+
+DDEESSCCRRIIPPTTIIOONN
+ original arguments: oonnee_t_w_otthhrreeee_f_o_u_rffiivvee
+
+ after shift 2: tthhrreeee_f_o_u_rffiivvee
+
+ after shift without argument: ffoouurr_f_i_v_e
+
+ after shift 0: ffoouurr_f_i_v_e
+
+ expand to less than three bytes: <1>
+
+ expand to exactly three bytes: <x y>
+
+ expand to more than three bytes: <a longer argument... and another>
+
+
+
+OpenBSD August 23, 2018 SHIFT_BASIC(1)