]> git.cameronkatri.com Git - mandoc.git/commitdiff
Support .RE with an argument; needed for audio/pms(1).
authorIngo Schwarze <schwarze@openbsd.org>
Sat, 24 Jan 2015 01:58:33 +0000 (01:58 +0000)
committerIngo Schwarze <schwarze@openbsd.org>
Sat, 24 Jan 2015 01:58:33 +0000 (01:58 +0000)
man.7
man_macro.c
mandoc.1
mandoc.h
read.c

diff --git a/man.7 b/man.7
index 5cccd328c26938581969e98454d60387b6617ee6..8c61748e69365c0d18bb7572c3adad5cb4051ca8 100644 (file)
--- a/man.7
+++ b/man.7
@@ -1,7 +1,7 @@
-.\"    $Id: man.7,v 1.128 2014/12/28 15:23:33 schwarze Exp $
+.\"    $Id: man.7,v 1.129 2015/01/24 01:58:33 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.
index f1796f3cc70e9976256381eec2596d6096adc9b5..042d133df3021e8b222b0c846863b54c285b599d 100644 (file)
@@ -1,7 +1,7 @@
-/*     $Id: man_macro.c,v 1.92 2014/12/16 17:26:00 schwarze Exp $ */
+/*     $Id: man_macro.c,v 1.93 2015/01/24 01:58:33 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
@@ -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) {
index 173518561800b231dc5672d8d2f50df74eca454b..9a536ea3e9ce0759a49014dde81bf7aec5097a16 100644 (file)
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\"    $Id: mandoc.1,v 1.134 2015/01/20 22:45:07 schwarze Exp $
+.\"    $Id: mandoc.1,v 1.135 2015/01/24 01:58:33 schwarze Exp $
 .\"
 .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
 .\" Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,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: January 20 2015 $
+.Dd $Mdocdate: January 24 2015 $
 .Dt MANDOC 1
 .Os
 .Sh NAME
@@ -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.
index 8c0e9c8c7b72924774c231cb2757eca03cf5fbed..96c570bb7edabcfa574adf4833f9728f8a169e7c 100644 (file)
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/*     $Id: mandoc.h,v 1.185 2015/01/22 21:38:16 schwarze Exp $ */
+/*     $Id: mandoc.h,v 1.186 2015/01/24 01:58:33 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/read.c b/read.c
index 0f79bed6d2c61e69516e733641b505c149ce67f2..70fe82407d98cb1c64a9a25dc102d699f740d6bb 100644 (file)
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/*     $Id: read.c,v 1.114 2015/01/22 21:38:16 schwarze Exp $ */
+/*     $Id: read.c,v 1.115 2015/01/24 01:58:33 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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",