summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.19
-rw-r--r--mandoc.h1
-rw-r--r--mdoc_macro.c11
-rw-r--r--mdoc_validate.c68
-rw-r--r--read.c1
5 files changed, 52 insertions, 38 deletions
diff --git a/mandoc.1 b/mandoc.1
index 9d212b72..6ab59a03 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1091,6 +1091,14 @@ macro has no argument, or only one argument and no macro follows
on the same input line.
This defeats its purpose; in particular, spacing is not suppressed
before the text or macros following on the next input line.
+.It Sy "empty reference block"
+.Pq mdoc
+An
+.Ic \&Rs
+macro is immediately followed by an
+.Ic \&Re
+macro on the next input line.
+Such an empty block does not produce any output.
.It Sy "missing -std argument, adding it"
.Pq mdoc
An
@@ -1595,6 +1603,7 @@ An
.Ic \&Ek ,
.Ic \&El ,
.Ic \&Re ,
+.Ic \&Rs ,
or
.Ic \&Ud
macro, an
diff --git a/mandoc.h b/mandoc.h
index a686799a..0be99722 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -103,6 +103,7 @@ enum mandocerr {
MANDOCERR_BF_NOFONT, /* missing font type, using \fR: Bf */
MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */
MANDOCERR_PF_SKIP, /* nothing follows prefix: Pf arg */
+ MANDOCERR_RS_EMPTY, /* empty reference block: Rs */
MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */
MANDOCERR_EQN_NOBOX, /* missing eqn box, using "": op */
diff --git a/mdoc_macro.c b/mdoc_macro.c
index 4dc3dade..14a2ef27 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1027,8 +1027,6 @@ blk_full(MACRO_PROT_ARGS)
la = *pos;
lac = ac;
ac = mdoc_args(mdoc, line, pos, buf, tok, &p);
- if (ac == ARGS_PUNCT)
- break;
if (ac == ARGS_EOLN) {
if (lac != ARGS_PPHRASE && lac != ARGS_PHRASE)
break;
@@ -1044,6 +1042,13 @@ blk_full(MACRO_PROT_ARGS)
body = mdoc_body_alloc(mdoc, line, ppos, tok);
break;
}
+ if (tok == MDOC_Rs) {
+ mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse,
+ line, la, "Rs %s", buf + la);
+ break;
+ }
+ if (ac == ARGS_PUNCT)
+ break;
/*
* Emit leading punctuation (i.e., punctuation before
@@ -1100,7 +1105,7 @@ blk_full(MACRO_PROT_ARGS)
return;
if (head == NULL)
head = mdoc_head_alloc(mdoc, line, ppos, tok);
- if (nl)
+ if (nl && tok != MDOC_Rs)
append_delims(mdoc, line, pos, buf);
if (body != NULL)
goto out;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 6f54235e..3b1afdf5 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1658,19 +1658,17 @@ post_st(POST_ARGS)
static void
post_rs(POST_ARGS)
{
- struct mdoc_node *nn, *next, *prev;
+ struct mdoc_node *np, *nch, *next, *prev;
int i, j;
- switch (mdoc->last->type) {
- case MDOC_HEAD:
- check_count(mdoc, MDOC_HEAD, CHECK_EQ, 0);
- return;
- case MDOC_BODY:
- if (mdoc->last->child)
- break;
- check_count(mdoc, MDOC_BODY, CHECK_GT, 0);
+ np = mdoc->last;
+
+ if (np->type != MDOC_BODY)
return;
- default:
+
+ if (np->child == NULL) {
+ mandoc_msg(MANDOCERR_RS_EMPTY, mdoc->parse,
+ np->line, np->pos, "Rs");
return;
}
@@ -1681,38 +1679,38 @@ post_rs(POST_ARGS)
*/
next = NULL;
- for (nn = mdoc->last->child->next; nn; nn = next) {
- /* Determine order of `nn'. */
+ for (nch = np->child->next; nch != NULL; nch = next) {
+ /* Determine order number of this child. */
for (i = 0; i < RSORD_MAX; i++)
- if (rsord[i] == nn->tok)
+ if (rsord[i] == nch->tok)
break;
if (i == RSORD_MAX) {
mandoc_msg(MANDOCERR_RS_BAD,
- mdoc->parse, nn->line, nn->pos,
- mdoc_macronames[nn->tok]);
+ mdoc->parse, nch->line, nch->pos,
+ mdoc_macronames[nch->tok]);
i = -1;
- } else if (MDOC__J == nn->tok || MDOC__B == nn->tok)
- mdoc->last->norm->Rs.quote_T++;
+ } else if (nch->tok == MDOC__J || nch->tok == MDOC__B)
+ np->norm->Rs.quote_T++;
/*
- * Remove `nn' from the chain. This somewhat
+ * Remove this child from the chain. This somewhat
* repeats mdoc_node_unlink(), but since we're
* just re-ordering, there's no need for the
* full unlink process.
*/
- if (NULL != (next = nn->next))
- next->prev = nn->prev;
+ if ((next = nch->next) != NULL)
+ next->prev = nch->prev;
- if (NULL != (prev = nn->prev))
- prev->next = nn->next;
+ if ((prev = nch->prev) != NULL)
+ prev->next = nch->next;
- nn->prev = nn->next = NULL;
+ nch->prev = nch->next = NULL;
/*
* Scan back until we reach a node that's
- * ordered before `nn'.
+ * to be ordered before this child.
*/
for ( ; prev ; prev = prev->prev) {
@@ -1728,21 +1726,21 @@ post_rs(POST_ARGS)
}
/*
- * Set `nn' back into its correct place in front
- * of the `prev' node.
+ * Set this child back into its correct place
+ * in front of the `prev' node.
*/
- nn->prev = prev;
+ nch->prev = prev;
- if (prev) {
- if (prev->next)
- prev->next->prev = nn;
- nn->next = prev->next;
- prev->next = nn;
+ if (prev == NULL) {
+ np->child->prev = nch;
+ nch->next = np->child;
+ np->child = nch;
} else {
- mdoc->last->child->prev = nn;
- nn->next = mdoc->last->child;
- mdoc->last->child = nn;
+ if (prev->next)
+ prev->next->prev = nch;
+ nch->next = prev->next;
+ prev->next = nch;
}
}
}
diff --git a/read.c b/read.c
index 0a5add74..7126c76d 100644
--- a/read.c
+++ b/read.c
@@ -147,6 +147,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"missing font type, using \\fR",
"unknown font type, using \\fR",
"nothing follows prefix",
+ "empty reference block",
"missing -std argument, adding it",
"missing eqn box, using \"\"",