summaryrefslogtreecommitdiff
path: root/regress/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-08-24 22:56:38 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-08-24 22:56:38 +0000
commitc96fec784ea47913e52fd0ae178dd4c12fc9bd14 (patch)
treea520e19aef4cb8ce22538b3f4c142f8a1fdcdd1c /regress/usr.bin/mandoc
parentb2183c8e49659ab53eb8ab74fdff137db689f39d (diff)
Rudimentary implementation of the roff(7) .while request.
Needed for example by groff_hdtbl(7). There are two limitations: It does not support nested .while requests yet, and each .while loop must start and end in the same scope. The roff_parseln() return codes are now more flexible and allow OR'ing options.
Diffstat (limited to 'regress/usr.bin/mandoc')
-rw-r--r--regress/usr.bin/mandoc/roff/Makefile5
-rw-r--r--regress/usr.bin/mandoc/roff/while/Makefile13
-rw-r--r--regress/usr.bin/mandoc/roff/while/badargs.in14
-rw-r--r--regress/usr.bin/mandoc/roff/while/badargs.out_ascii13
-rw-r--r--regress/usr.bin/mandoc/roff/while/badargs.out_lint3
-rw-r--r--regress/usr.bin/mandoc/roff/while/basic.in30
-rw-r--r--regress/usr.bin/mandoc/roff/while/basic.out_ascii16
-rw-r--r--regress/usr.bin/mandoc/roff/while/into.in20
-rw-r--r--regress/usr.bin/mandoc/roff/while/into.out_ascii9
-rw-r--r--regress/usr.bin/mandoc/roff/while/into.out_lint2
-rw-r--r--regress/usr.bin/mandoc/roff/while/nesting.in19
-rw-r--r--regress/usr.bin/mandoc/roff/while/nesting.out_ascii9
-rw-r--r--regress/usr.bin/mandoc/roff/while/nesting.out_lint2
-rw-r--r--regress/usr.bin/mandoc/roff/while/outof.in18
-rw-r--r--regress/usr.bin/mandoc/roff/while/outof.out_ascii9
-rw-r--r--regress/usr.bin/mandoc/roff/while/outof.out_lint2
16 files changed, 182 insertions, 2 deletions
diff --git a/regress/usr.bin/mandoc/roff/Makefile b/regress/usr.bin/mandoc/roff/Makefile
index 7c6f5e16dda..f338f83dad3 100644
--- a/regress/usr.bin/mandoc/roff/Makefile
+++ b/regress/usr.bin/mandoc/roff/Makefile
@@ -1,7 +1,8 @@
-# $OpenBSD: Makefile,v 1.25 2018/08/23 14:16:12 schwarze Exp $
+# $OpenBSD: Makefile,v 1.26 2018/08/24 22:56:37 schwarze Exp $
SUBDIR = args cond esc scale string
-SUBDIR += br cc de ds ft ig it ll na nr po ps return rm rn shift sp ta ti tr
+SUBDIR += br cc de ds ft ig it ll na nr po ps
+SUBDIR += return rm rn shift sp ta ti tr while
.include "../Makefile.sub"
.include <bsd.subdir.mk>
diff --git a/regress/usr.bin/mandoc/roff/while/Makefile b/regress/usr.bin/mandoc/roff/while/Makefile
new file mode 100644
index 00000000000..ed970474667
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/Makefile
@@ -0,0 +1,13 @@
+# $OpenBSD: Makefile,v 1.1 2018/08/24 22:56:37 schwarze Exp $
+
+REGRESS_TARGETS = basic badargs into nesting outof
+LINT_TARGETS = badargs into nesting outof
+
+# mandoc defects:
+# - if a while loop extends into a scope, mandoc may close it there
+# - mandoc does not support nested .while loops
+# - mandoc does not support .while loops extending out of the current scope
+
+SKIP_GROFF = into nesting outof
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/roff/while/badargs.in b/regress/usr.bin/mandoc/roff/while/badargs.in
new file mode 100644
index 00000000000..bbbd7cd056a
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/badargs.in
@@ -0,0 +1,14 @@
+.\" $OpenBSD: badargs.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $
+.Dd $Mdocdate: August 24 2018 $
+.Dt WHILE-BADARGS 1
+.Os
+.Sh NAME
+.Nm while-badargs
+.Nd dubious arguments for the while request
+.Sh DESCRIPTION
+while does not support next line scope:
+.nr cnt 2 1
+.while \n-[cnt]
+\n[cnt]
+.Pp
+final text
diff --git a/regress/usr.bin/mandoc/roff/while/badargs.out_ascii b/regress/usr.bin/mandoc/roff/while/badargs.out_ascii
new file mode 100644
index 00000000000..8878d64ebec
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/badargs.out_ascii
@@ -0,0 +1,13 @@
+WHILE-BADARGS(1) General Commands Manual WHILE-BADARGS(1)
+
+NNAAMMEE
+ wwhhiillee--bbaaddaarrggss - dubious arguments for the while request
+
+DDEESSCCRRIIPPTTIIOONN
+ while does not support next line scope:
+
+ 0
+
+ final text
+
+OpenBSD August 25, 2018 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/while/badargs.out_lint b/regress/usr.bin/mandoc/roff/while/badargs.out_lint
new file mode 100644
index 00000000000..293ecc0ac52
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/badargs.out_lint
@@ -0,0 +1,3 @@
+mandoc: badargs.in:11:2: WARNING: conditional request controls empty scope: while
+mandoc: badargs.in:11:9: WARNING: blank line in fill mode, using .sp
+mandoc: badargs.in:11:2: WARNING: conditional request controls empty scope: while
diff --git a/regress/usr.bin/mandoc/roff/while/basic.in b/regress/usr.bin/mandoc/roff/while/basic.in
new file mode 100644
index 00000000000..6bd09e3af4a
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/basic.in
@@ -0,0 +1,30 @@
+.\" $OpenBSD: basic.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $
+.Dd $Mdocdate: August 24 2018 $
+.Dt WHILE-BASIC 1
+.Os
+.Sh NAME
+.Nm while-basic
+.Nd the while request
+.Sh DESCRIPTION
+Loop with single-line scope:
+.nr cnt 11 1
+.de mym
+\\n-[cnt]
+..
+.while \n[cnt] .mym
+.Pp
+Loop with multi-line scope, text line closure:
+.nr cnt 11
+.while \n[cnt] \{\
+.nr cnt -1
+\n[cnt]\},
+boom.
+.Pp
+Loop with multi-line scope, macro line closure:
+.nr cnt 11
+.while \n[cnt] \{\
+.nr cnt -1
+\n[cnt]
+.\}
+.Pp
+final text
diff --git a/regress/usr.bin/mandoc/roff/while/basic.out_ascii b/regress/usr.bin/mandoc/roff/while/basic.out_ascii
new file mode 100644
index 00000000000..b97abb41bb0
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/basic.out_ascii
@@ -0,0 +1,16 @@
+WHILE-BASIC(1) General Commands Manual WHILE-BASIC(1)
+
+NNAAMMEE
+ wwhhiillee--bbaassiicc - the while request
+
+DDEESSCCRRIIPPTTIIOONN
+ Loop with single-line scope: 10 9 8 7 6 5 4 3 2 1 0
+
+ Loop with multi-line scope, text line closure: 10, 9, 8, 7, 6, 5, 4, 3,
+ 2, 1, 0, boom.
+
+ Loop with multi-line scope, macro line closure: 10 9 8 7 6 5 4 3 2 1 0
+
+ final text
+
+OpenBSD August 25, 2018 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/while/into.in b/regress/usr.bin/mandoc/roff/while/into.in
new file mode 100644
index 00000000000..5a840ab0bc2
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/into.in
@@ -0,0 +1,20 @@
+.\" $OpenBSD: into.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $
+.Dd $Mdocdate: August 24 2018 $
+.Dt WHILE-INTO 1
+.Os
+.Sh NAME
+.Nm while-into
+.Nd while request extending into a macro
+.Sh DESCRIPTION
+.nr cnt 10
+.de closeloop
+.nr cnt -1
+.\}
+..
+initial text
+.while \n[cnt] \{\
+\n[cnt]
+.closeloop
+after macro
+.\}
+final text
diff --git a/regress/usr.bin/mandoc/roff/while/into.out_ascii b/regress/usr.bin/mandoc/roff/while/into.out_ascii
new file mode 100644
index 00000000000..cf8e56146bb
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/into.out_ascii
@@ -0,0 +1,9 @@
+WHILE-INTO(1) General Commands Manual WHILE-INTO(1)
+
+NNAAMMEE
+ wwhhiillee--iinnttoo - while request extending into a macro
+
+DDEESSCCRRIIPPTTIIOONN
+ initial text 10 after macro final text
+
+OpenBSD August 25, 2018 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/while/into.out_lint b/regress/usr.bin/mandoc/roff/while/into.out_lint
new file mode 100644
index 00000000000..04a75220466
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/into.out_lint
@@ -0,0 +1,2 @@
+mandoc: into.in:17:5: UNSUPP: end of .while loop in inner scope
+mandoc: into.in:20:1: UNSUPP: end of scope with open .while loop
diff --git a/regress/usr.bin/mandoc/roff/while/nesting.in b/regress/usr.bin/mandoc/roff/while/nesting.in
new file mode 100644
index 00000000000..930b8b7ac75
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/nesting.in
@@ -0,0 +1,19 @@
+.\" $OpenBSD: nesting.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $
+.Dd $Mdocdate: August 24 2018 $
+.Dt WHILE-NESTING 1
+.Os
+.Sh NAME
+.Nm while-nesting
+.Nd nested while requests
+.Sh DESCRIPTION
+initial text
+.nr c1 3
+.while \n(c1 \{\
+. nr c2 3
+. while \n(c2 \{\
+. nop \n(c1\n(c2
+. nr c2 -1
+. \}
+. nr c1 -1
+.\}
+final text
diff --git a/regress/usr.bin/mandoc/roff/while/nesting.out_ascii b/regress/usr.bin/mandoc/roff/while/nesting.out_ascii
new file mode 100644
index 00000000000..8aae57d75ed
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/nesting.out_ascii
@@ -0,0 +1,9 @@
+WHILE-NESTING(1) General Commands Manual WHILE-NESTING(1)
+
+NNAAMMEE
+ wwhhiillee--nneessttiinngg - nested while requests
+
+DDEESSCCRRIIPPTTIIOONN
+ initial text 33 32 31 final text
+
+OpenBSD August 25, 2018 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/while/nesting.out_lint b/regress/usr.bin/mandoc/roff/while/nesting.out_lint
new file mode 100644
index 00000000000..7ea34bad961
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/nesting.out_lint
@@ -0,0 +1,2 @@
+mandoc: nesting.in:14:37: UNSUPP: nested .while loops
+mandoc: nesting.in:18:4: UNSUPP: cannot continue this .while loop
diff --git a/regress/usr.bin/mandoc/roff/while/outof.in b/regress/usr.bin/mandoc/roff/while/outof.in
new file mode 100644
index 00000000000..4da3453c43a
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/outof.in
@@ -0,0 +1,18 @@
+.\" $OpenBSD: outof.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $
+.Dd $Mdocdate: August 24 2018 $
+.Dt WHILE-OUTOF 1
+.Os
+.Sh NAME
+.Nm while-outof
+.Nd while request starting in a macro
+.Sh DESCRIPTION
+.nr cnt 10
+.de mym
+. while \\n[cnt] \{\
+. nop \\n[cnt]
+..
+initial text
+.mym
+. nr cnt -1
+.\}
+final text
diff --git a/regress/usr.bin/mandoc/roff/while/outof.out_ascii b/regress/usr.bin/mandoc/roff/while/outof.out_ascii
new file mode 100644
index 00000000000..4a3dbe7fe4e
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/outof.out_ascii
@@ -0,0 +1,9 @@
+WHILE-OUTOF(1) General Commands Manual WHILE-OUTOF(1)
+
+NNAAMMEE
+ wwhhiillee--oouuttooff - while request starting in a macro
+
+DDEESSCCRRIIPPTTIIOONN
+ initial text 10 final text
+
+OpenBSD August 25, 2018 OpenBSD
diff --git a/regress/usr.bin/mandoc/roff/while/outof.out_lint b/regress/usr.bin/mandoc/roff/while/outof.out_lint
new file mode 100644
index 00000000000..6ab0c9fde27
--- /dev/null
+++ b/regress/usr.bin/mandoc/roff/while/outof.out_lint
@@ -0,0 +1,2 @@
+mandoc: outof.in:15:1: UNSUPP: end of scope with open .while loop
+mandoc: outof.in:17:4: UNSUPP: cannot continue this .while loop