diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2018-08-24 23:12:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2018-08-24 23:12:33 +0000 |
commit | f5133ff5de286c3849ba772719280fcec35ca374 (patch) | |
tree | d010611a454ce17650edf5bc7d26c9d237d10c00 /regress | |
parent | 0278f391fed9ab1da96a2f7737b052872f5ced71 (diff) | |
download | mandoc-f5133ff5de286c3849ba772719280fcec35ca374.tar.gz |
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')
-rw-r--r-- | regress/roff/Makefile | 5 | ||||
-rw-r--r-- | regress/roff/while/Makefile | 13 | ||||
-rw-r--r-- | regress/roff/while/badargs.in | 14 | ||||
-rw-r--r-- | regress/roff/while/badargs.out_ascii | 13 | ||||
-rw-r--r-- | regress/roff/while/badargs.out_lint | 3 | ||||
-rw-r--r-- | regress/roff/while/basic.in | 30 | ||||
-rw-r--r-- | regress/roff/while/basic.out_ascii | 16 | ||||
-rw-r--r-- | regress/roff/while/into.in | 20 | ||||
-rw-r--r-- | regress/roff/while/into.out_ascii | 9 | ||||
-rw-r--r-- | regress/roff/while/into.out_lint | 2 | ||||
-rw-r--r-- | regress/roff/while/nesting.in | 19 | ||||
-rw-r--r-- | regress/roff/while/nesting.out_ascii | 9 | ||||
-rw-r--r-- | regress/roff/while/nesting.out_lint | 2 | ||||
-rw-r--r-- | regress/roff/while/outof.in | 18 | ||||
-rw-r--r-- | regress/roff/while/outof.out_ascii | 9 | ||||
-rw-r--r-- | regress/roff/while/outof.out_lint | 2 |
16 files changed, 182 insertions, 2 deletions
diff --git a/regress/roff/Makefile b/regress/roff/Makefile index 7c6f5e16..f338f83d 100644 --- a/regress/roff/Makefile +++ b/regress/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/roff/while/Makefile b/regress/roff/while/Makefile new file mode 100644 index 00000000..ed970474 --- /dev/null +++ b/regress/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/roff/while/badargs.in b/regress/roff/while/badargs.in new file mode 100644 index 00000000..1ad05a71 --- /dev/null +++ b/regress/roff/while/badargs.in @@ -0,0 +1,14 @@ +.\" $OpenBSD: badargs.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $ +.Dd $Mdocdate$ +.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/roff/while/badargs.out_ascii b/regress/roff/while/badargs.out_ascii new file mode 100644 index 00000000..6affcf5e --- /dev/null +++ b/regress/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 24, 2018 OpenBSD diff --git a/regress/roff/while/badargs.out_lint b/regress/roff/while/badargs.out_lint new file mode 100644 index 00000000..293ecc0a --- /dev/null +++ b/regress/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/roff/while/basic.in b/regress/roff/while/basic.in new file mode 100644 index 00000000..07cd1282 --- /dev/null +++ b/regress/roff/while/basic.in @@ -0,0 +1,30 @@ +.\" $OpenBSD: basic.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $ +.Dd $Mdocdate$ +.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/roff/while/basic.out_ascii b/regress/roff/while/basic.out_ascii new file mode 100644 index 00000000..920a9d28 --- /dev/null +++ b/regress/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 24, 2018 OpenBSD diff --git a/regress/roff/while/into.in b/regress/roff/while/into.in new file mode 100644 index 00000000..6a3bc064 --- /dev/null +++ b/regress/roff/while/into.in @@ -0,0 +1,20 @@ +.\" $OpenBSD: into.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $ +.Dd $Mdocdate$ +.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/roff/while/into.out_ascii b/regress/roff/while/into.out_ascii new file mode 100644 index 00000000..3785c1a7 --- /dev/null +++ b/regress/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 24, 2018 OpenBSD diff --git a/regress/roff/while/into.out_lint b/regress/roff/while/into.out_lint new file mode 100644 index 00000000..04a75220 --- /dev/null +++ b/regress/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/roff/while/nesting.in b/regress/roff/while/nesting.in new file mode 100644 index 00000000..c91e8198 --- /dev/null +++ b/regress/roff/while/nesting.in @@ -0,0 +1,19 @@ +.\" $OpenBSD: nesting.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $ +.Dd $Mdocdate$ +.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/roff/while/nesting.out_ascii b/regress/roff/while/nesting.out_ascii new file mode 100644 index 00000000..03055341 --- /dev/null +++ b/regress/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 24, 2018 OpenBSD diff --git a/regress/roff/while/nesting.out_lint b/regress/roff/while/nesting.out_lint new file mode 100644 index 00000000..7ea34bad --- /dev/null +++ b/regress/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/roff/while/outof.in b/regress/roff/while/outof.in new file mode 100644 index 00000000..f505c0c6 --- /dev/null +++ b/regress/roff/while/outof.in @@ -0,0 +1,18 @@ +.\" $OpenBSD: outof.in,v 1.1 2018/08/24 22:56:37 schwarze Exp $ +.Dd $Mdocdate$ +.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/roff/while/outof.out_ascii b/regress/roff/while/outof.out_ascii new file mode 100644 index 00000000..ae193201 --- /dev/null +++ b/regress/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 24, 2018 OpenBSD diff --git a/regress/roff/while/outof.out_lint b/regress/roff/while/outof.out_lint new file mode 100644 index 00000000..6ab0c9fd --- /dev/null +++ b/regress/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 |