From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: Support .RE with an argument; needed for audio/pms(1).
Date: Fri, 23 Jan 2015 20:59:04 -0500 (EST) [thread overview]
Message-ID: <9026047973934858840.enqueue@fantadrom.bsd.lv> (raw)
Log Message:
-----------
Support .RE with an argument; needed for audio/pms(1).
Modified Files:
--------------
mdocml:
man.7
man_macro.c
mandoc.1
mandoc.h
read.c
Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/read.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -Lread.c -Lread.c -u -p -r1.114 -r1.115
--- read.c
+++ read.c
@@ -195,6 +195,7 @@ static const char * const mandocerrs[MAN
"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",
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.h,v
retrieving revision 1.185
retrieving revision 1.186
diff -Lmandoc.h -Lmandoc.h -u -p -r1.185 -r1.186
--- mandoc.h
+++ mandoc.h
@@ -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 */
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mandoc.1,v
retrieving revision 1.134
retrieving revision 1.135
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.134 -r1.135
--- mandoc.1
+++ mandoc.1
@@ -1369,6 +1369,16 @@ right delimiter or closing brace, or the
.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: man.7
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man.7,v
retrieving revision 1.128
retrieving revision 1.129
diff -Lman.7 -Lman.7 -u -p -r1.128 -r1.129
--- man.7
+++ man.7
@@ -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.
Index: man_macro.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/man_macro.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -Lman_macro.c -Lman_macro.c -u -p -r1.92 -r1.93
--- man_macro.c
+++ 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) {
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2015-01-24 1:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9026047973934858840.enqueue@fantadrom.bsd.lv \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).