From 0a8809aa2eea4b189b4ca02bea4883d7cf4ce706 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 24 Aug 2018 23:12:33 +0000 Subject: 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. --- regress/roff/while/Makefile | 13 +++++++++++++ regress/roff/while/badargs.in | 14 ++++++++++++++ regress/roff/while/badargs.out_ascii | 13 +++++++++++++ regress/roff/while/badargs.out_lint | 3 +++ regress/roff/while/basic.in | 30 ++++++++++++++++++++++++++++++ regress/roff/while/basic.out_ascii | 16 ++++++++++++++++ regress/roff/while/into.in | 20 ++++++++++++++++++++ regress/roff/while/into.out_ascii | 9 +++++++++ regress/roff/while/into.out_lint | 2 ++ regress/roff/while/nesting.in | 19 +++++++++++++++++++ regress/roff/while/nesting.out_ascii | 9 +++++++++ regress/roff/while/nesting.out_lint | 2 ++ regress/roff/while/outof.in | 18 ++++++++++++++++++ regress/roff/while/outof.out_ascii | 9 +++++++++ regress/roff/while/outof.out_lint | 2 ++ 15 files changed, 179 insertions(+) create mode 100644 regress/roff/while/Makefile create mode 100644 regress/roff/while/badargs.in create mode 100644 regress/roff/while/badargs.out_ascii create mode 100644 regress/roff/while/badargs.out_lint create mode 100644 regress/roff/while/basic.in create mode 100644 regress/roff/while/basic.out_ascii create mode 100644 regress/roff/while/into.in create mode 100644 regress/roff/while/into.out_ascii create mode 100644 regress/roff/while/into.out_lint create mode 100644 regress/roff/while/nesting.in create mode 100644 regress/roff/while/nesting.out_ascii create mode 100644 regress/roff/while/nesting.out_lint create mode 100644 regress/roff/while/outof.in create mode 100644 regress/roff/while/outof.out_ascii create mode 100644 regress/roff/while/outof.out_lint (limited to 'regress/roff/while') 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 diff --git a/regress/roff/while/badargs.in b/regress/roff/while/badargs.in new file mode 100644 index 00000000..bbbd7cd0 --- /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: 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/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..6bd09e3a --- /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: 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/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..5a840ab0 --- /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: 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/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..930b8b7a --- /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: 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/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..4da3453c --- /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: 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/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 -- cgit v1.2.3-56-ge451