summaryrefslogtreecommitdiffstats
path: root/man_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2023-10-24 20:53:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2023-10-24 20:53:12 +0000
commit91555cb3f3238cb10f575c9191c3c2729c8f9473 (patch)
tree039de9bbee59547678c7bbded6b319d34dcdc4e9 /man_validate.c
parent8a8bc122106d3c6164977db2ba5b07c3e2bf359d (diff)
downloadmandoc-91555cb3f3238cb10f575c9191c3c2729c8f9473.tar.gz
Implement the man(7) .MR macro, a 2023 GNU extension.
The syntax and semantics is almost identical to mdoc(7) .Xr. This will be needed for reading the groff manual pages once our port will be updated to 1.23, and the Linux Manual Pages Project is also determined to start using it sooner or later. I did not advocate for this new macro, but since we want to remain able to read all manual pages found in the wild, there is little choice but to support it. At least it is easy to do, they basically copied .Xr.
Diffstat (limited to 'man_validate.c')
-rw-r--r--man_validate.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/man_validate.c b/man_validate.c
index 722e4fdc..e3da8837 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2010, 2012-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012-2020, 2023 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -33,6 +33,7 @@
#include "mandoc_aux.h"
#include "mandoc.h"
+#include "mandoc_xr.h"
#include "roff.h"
#include "man.h"
#include "libmandoc.h"
@@ -54,6 +55,7 @@ static void post_AT(CHKARGS);
static void post_EE(CHKARGS);
static void post_EX(CHKARGS);
static void post_IP(CHKARGS);
+static void post_MR(CHKARGS);
static void post_OP(CHKARGS);
static void post_SH(CHKARGS);
static void post_TH(CHKARGS);
@@ -100,6 +102,7 @@ static const v_check man_valids[MAN_MAX - MAN_TH] = {
NULL, /* UE */
post_UR, /* MT */
NULL, /* ME */
+ post_MR, /* MR */
};
@@ -547,6 +550,32 @@ post_TH(CHKARGS)
}
static void
+post_MR(CHKARGS)
+{
+ struct roff_node *nch;
+
+ if ((nch = n->child) == NULL) {
+ mandoc_msg(MANDOCERR_NM_NONAME, n->line, n->pos, "MR");
+ return;
+ }
+ if (nch->next == NULL) {
+ mandoc_msg(MANDOCERR_XR_NOSEC,
+ n->line, n->pos, "MR %s", nch->string);
+ return;
+ }
+ if (mandoc_xr_add(nch->next->string, nch->string, nch->line, nch->pos))
+ mandoc_msg(MANDOCERR_XR_SELF, nch->line, nch->pos,
+ "MR %s %s", nch->string, nch->next->string);
+ if ((nch = nch->next->next) == NULL || nch->next == NULL)
+ return;
+
+ mandoc_msg(MANDOCERR_ARG_EXCESS, nch->next->line, nch->next->pos,
+ "MR ... %s", nch->next->string);
+ while (nch->next != NULL)
+ roff_node_delete(man, nch->next);
+}
+
+static void
post_UC(CHKARGS)
{
static const char * const bsd_versions[] = {