diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-01-24 01:59:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2015-01-24 01:59:41 +0000 |
commit | d0cea2e71f8752aa97dae610e4eb8b34cdf6e45c (patch) | |
tree | 00a5d89aa3f7e3219195de98ac01bca20caf863c | |
parent | 2fda989bf1d6710a0aaa1f603209734760d23bd5 (diff) |
Support .RE with an argument; needed for audio/pms(1).
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/Makefile | 12 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/REarg.in | 26 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/REarg.out_ascii | 23 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/REarg.out_lint | 6 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/broken.in | 33 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/broken.out_ascii | 26 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/man/RS/broken.out_lint | 2 | ||||
-rw-r--r-- | share/man/man7/man.7 | 28 | ||||
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 3 |
11 files changed, 162 insertions, 26 deletions
diff --git a/regress/usr.bin/mandoc/man/RS/Makefile b/regress/usr.bin/mandoc/man/RS/Makefile index 40041f7ac66..33457370b89 100644 --- a/regress/usr.bin/mandoc/man/RS/Makefile +++ b/regress/usr.bin/mandoc/man/RS/Makefile @@ -1,11 +1,7 @@ -# $OpenBSD: Makefile,v 1.8 2014/08/18 16:26:13 schwarze Exp $ +# $OpenBSD: Makefile,v 1.9 2015/01/24 01:59:40 schwarze Exp $ -REGRESS_TARGETS = breaking broken empty literal lonelyRE nested noRE width -LINT_TARGETS = broken lonelyRE noRE - -# groff-1.22.2/mandoc difference: -# RS PP RE gives a blank line in groff, none in mandoc. - -SKIP_GROFF = broken +REGRESS_TARGETS = breaking broken empty literal lonelyRE +REGRESS_TARGETS += nested noRE REarg width +LINT_TARGETS = lonelyRE noRE REarg .include <bsd.regress.mk> diff --git a/regress/usr.bin/mandoc/man/RS/REarg.in b/regress/usr.bin/mandoc/man/RS/REarg.in new file mode 100644 index 00000000000..c023439c21c --- /dev/null +++ b/regress/usr.bin/mandoc/man/RS/REarg.in @@ -0,0 +1,26 @@ +.TH RS-REARG 1 "January 24, 2015" OpenBSD +.SH NAME +RS-REarg \- arguments to the RE macro +.SH DESCRIPTION +level 1 +.RS 4n +level 2 +.RS 2n +level 3 +.RE 2a +back to 2 +.RE 1b +back to 1 +.RS 4n +level 2 +.RS 2n +level 3 +.RE 1c +back to 1 +.RS 4n +level 2 +.RS 2n +level 3 +.RE 0d +back to 1 +.RE 1e diff --git a/regress/usr.bin/mandoc/man/RS/REarg.out_ascii b/regress/usr.bin/mandoc/man/RS/REarg.out_ascii new file mode 100644 index 00000000000..747e037be3a --- /dev/null +++ b/regress/usr.bin/mandoc/man/RS/REarg.out_ascii @@ -0,0 +1,23 @@ +RS-REARG(1) General Commands Manual RS-REARG(1) + + + +NNAAMMEE + RS-REarg - arguments to the RE macro + +DDEESSCCRRIIPPTTIIOONN + level 1 + level 2 + level 3 + back to 2 + back to 1 + level 2 + level 3 + back to 1 + level 2 + level 3 + back to 1 + + + +OpenBSD January 24, 2015 RS-REARG(1) diff --git a/regress/usr.bin/mandoc/man/RS/REarg.out_lint b/regress/usr.bin/mandoc/man/RS/REarg.out_lint new file mode 100644 index 00000000000..a10e4b18051 --- /dev/null +++ b/regress/usr.bin/mandoc/man/RS/REarg.out_lint @@ -0,0 +1,6 @@ +mandoc: REarg.in:10:6: ERROR: skipping excess arguments: RE ... a +mandoc: REarg.in:12:6: ERROR: skipping excess arguments: RE ... b +mandoc: REarg.in:18:6: ERROR: skipping excess arguments: RE ... c +mandoc: REarg.in:24:6: ERROR: skipping excess arguments: RE ... d +mandoc: REarg.in:26:6: ERROR: skipping excess arguments: RE ... e +mandoc: REarg.in:26:2: ERROR: fewer RS blocks open, skipping: RE 1 diff --git a/regress/usr.bin/mandoc/man/RS/broken.in b/regress/usr.bin/mandoc/man/RS/broken.in index b1ca9e333b3..5c915c640fe 100644 --- a/regress/usr.bin/mandoc/man/RS/broken.in +++ b/regress/usr.bin/mandoc/man/RS/broken.in @@ -1,15 +1,40 @@ -.TH RS-BROKEN 1 "August 28, 2014" OpenBSD +.TH RS-BROKEN 1 "January 24, 2015" OpenBSD .SH NAME RS-broken \- indented blocks broken by other blocks .SH DESCRIPTION -initial text +broken by PP: .RS 2n indented .PP still indented .RE -back to normal +broken by IP: .RS -.P +indented +.IP tag 6n +first line +.br +second line +.PP +still indented +.RE +broken by TP: +.RS +indented +.TP 6n +tag +first line +.br +second line +.PP +still indented +.RE +broken by HP: +.RS +indented +.HP 2n +Let's have a longer text here such that we can see the line break. +.PP +still indented .RE final text diff --git a/regress/usr.bin/mandoc/man/RS/broken.out_ascii b/regress/usr.bin/mandoc/man/RS/broken.out_ascii index 9984a54a166..199ef05fbde 100644 --- a/regress/usr.bin/mandoc/man/RS/broken.out_ascii +++ b/regress/usr.bin/mandoc/man/RS/broken.out_ascii @@ -6,13 +6,33 @@ NNAAMMEE RS-broken - indented blocks broken by other blocks DDEESSCCRRIIPPTTIIOONN - initial text + broken by PP: indented still indented - back to normal + broken by IP: + indented + + tag first line + second line + + still indented + broken by TP: + indented + + tag first line + second line + + still indented + broken by HP: + indented + + Let's have a longer text here such that we can see the line + break. + + still indented final text -OpenBSD August 28, 2014 RS-BROKEN(1) +OpenBSD January 24, 2015 RS-BROKEN(1) diff --git a/regress/usr.bin/mandoc/man/RS/broken.out_lint b/regress/usr.bin/mandoc/man/RS/broken.out_lint deleted file mode 100644 index 82861733f61..00000000000 --- a/regress/usr.bin/mandoc/man/RS/broken.out_lint +++ /dev/null @@ -1,2 +0,0 @@ -mandoc: broken.in:13:2: WARNING: skipping paragraph macro: P empty -mandoc: broken.in:12:2: WARNING: argument count wrong: want children (have none) diff --git a/share/man/man7/man.7 b/share/man/man7/man.7 index e1344a8948a..b7e563d7118 100644 --- a/share/man/man7/man.7 +++ b/share/man/man7/man.7 @@ -1,7 +1,7 @@ -.\" $OpenBSD: man.7,v 1.40 2014/12/28 15:22:42 schwarze Exp $ +.\" $OpenBSD: man.7,v 1.41 2015/01/24 01:59:40 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> -.\" Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> +.\" Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org> .\" Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any @@ -16,7 +16,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 28 2014 $ +.Dd $Mdocdate: January 24 2015 $ .Dt MAN 7 .Os .Sh NAME @@ -555,9 +555,29 @@ and .Ss \&RE Explicitly close out the scope of a prior .Sx \&RS . -The default left margin is restored to the state of the original +The default left margin is restored to the state before that .Sx \&RS invocation. +.Pp +The syntax is as follows: +.Bd -filled -offset indent +.Pf \. Sx \&RE +.Op Ar level +.Ed +.Pp +Without an argument, the most recent +.Sx \&RS +block is closed out. +If +.Ar level +is 1, all open +.Sx \&RS +blocks are closed out. +Otherwise, +.Ar level No \(mi 1 +nested +.Sx \&RS +blocks remain open. .Ss \&RI Text is rendered alternately in roman (the default font) and italics. Whitespace between arguments is omitted in output. diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index cb5430a52a2..ebf620a162d 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,7 +1,7 @@ -/* $OpenBSD: man_macro.c,v 1.54 2014/12/16 17:24:58 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.55 2015/01/24 01:59:40 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de> * * Permission to use, copy, modify, and distribute this software for any @@ -277,10 +277,30 @@ blk_close(MACRO_PROT_ARGS) { enum mant ntok; const struct man_node *nn; + char *p; + int nrew, target; + nrew = 1; switch (tok) { case MAN_RE: ntok = MAN_RS; + if ( ! man_args(man, line, pos, buf, &p)) + break; + for (nn = man->last->parent; nn; nn = nn->parent) + if (nn->tok == ntok && nn->type == MAN_BLOCK) + nrew++; + target = strtol(p, &p, 10); + if (*p != '\0') + mandoc_vmsg(MANDOCERR_ARG_EXCESS, man->parse, + line, p - buf, "RE ... %s", p); + if (target == 0) + target = 1; + nrew -= target; + if (nrew < 1) { + mandoc_vmsg(MANDOCERR_RE_NOTOPEN, man->parse, + line, ppos, "RE %d", target); + return; + } break; case MAN_UE: ntok = MAN_UR; @@ -291,7 +311,7 @@ blk_close(MACRO_PROT_ARGS) } for (nn = man->last->parent; nn; nn = nn->parent) - if (nn->tok == ntok && nn->type == MAN_BLOCK) + if (nn->tok == ntok && nn->type == MAN_BLOCK && ! --nrew) break; if (nn == NULL) { diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index ec68dc5356c..91696fdd60a 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.127 2015/01/22 21:36:44 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.128 2015/01/24 01:59:40 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -151,6 +151,7 @@ enum mandocerr { MANDOCERR_IT_STRAY, /* skipping item outside list: It ... */ MANDOCERR_TA_STRAY, /* skipping column outside column list: Ta */ MANDOCERR_BLK_NOTOPEN, /* skipping end of block that is not open */ + MANDOCERR_RE_NOTOPEN, /* fewer RS blocks open, skipping: RE arg */ MANDOCERR_BLK_BROKEN, /* inserting missing end of block: macro ... */ MANDOCERR_BLK_NOEND, /* appending missing end of block: macro */ diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 79762f42e9e..7f8c4c62b0a 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.89 2015/01/22 21:36:44 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.90 2015/01/24 01:59:40 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -190,6 +190,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "skipping item outside list", "skipping column outside column list", "skipping end of block that is not open", + "fewer RS blocks open, skipping", "inserting missing end of block", "appending missing end of block", |