diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-24 01:58:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-01-24 01:58:33 +0000 |
commit | 991c1bddc9c3575802d343811e28c260b842dc84 (patch) | |
tree | 5aa08b22b4a4ceb0455bb8a67cfc91a2e0a1cfb9 | |
parent | 4d5758c224d49c1ba03a52b3d534ecba57dab18d (diff) | |
download | mandoc-991c1bddc9c3575802d343811e28c260b842dc84.tar.gz |
Support .RE with an argument; needed for audio/pms(1).
-rw-r--r-- | man.7 | 24 | ||||
-rw-r--r-- | man_macro.c | 24 | ||||
-rw-r--r-- | mandoc.1 | 17 | ||||
-rw-r--r-- | mandoc.h | 1 | ||||
-rw-r--r-- | read.c | 1 |
5 files changed, 61 insertions, 6 deletions
@@ -1,7 +1,7 @@ .\" $Id$ .\" .\" 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 @@ -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/man_macro.c b/man_macro.c index 2bec95bf..51d93692 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * 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 @@ -279,10 +279,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; @@ -293,7 +313,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) { @@ -1369,6 +1369,16 @@ right delimiter or closing brace, or the end of an equation, table, or .Xr roff 7 conditional request is encountered but no matching block is open. The offending request or macro is discarded. +.It Sy "fewer RS blocks open, skipping" +.Pq man +The +.Ic \&RE +macro is invoked with an argument, but less than the specified number of +.Ic \&RS +blocks is open. +The +.Ic \&RE +macro is discarded. .It Sy "inserting missing end of block" .Pq mdoc , tbl Various @@ -1537,10 +1547,13 @@ macro, or a block closing request is invoked with at least one argument. All arguments are ignored. .It Sy "skipping excess arguments" -.Pq mdoc , roff +.Pq mdoc , man , roff The .Ic \&Bf -macro is invoked with more than one argument, or a request of the +macro is invoked with more than one argument, the +.Ic \&RE +macro is invoked with more than one argument +or with a non-integer argument, or a request of the .Ic \&de family is invoked with more than two arguments. The excess arguments are ignored. @@ -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 */ @@ -195,6 +195,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", |