summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-06-25 13:19:25 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-06-25 13:19:25 +0000
commita0711566e81ba5fc0028c367fb6c9b3a6e2ba22d (patch)
tree0bb48558b3c290cea0fd039d91c09bfbc9285149
parent6979135dedb55ec6be8dce91e344b7d603b21b1c (diff)
downloadmandoc-a0711566e81ba5fc0028c367fb6c9b3a6e2ba22d.tar.gz
Add cross-reference records to makewhatis.
-rw-r--r--makewhatis.14
-rw-r--r--makewhatis.c23
2 files changed, 26 insertions, 1 deletions
diff --git a/makewhatis.1 b/makewhatis.1
index 5df47f7c..777157a0 100644
--- a/makewhatis.1
+++ b/makewhatis.1
@@ -114,6 +114,10 @@ An author as given in the AUTHORS section.
A configuration as given in the SYNOPSIS section.
.It Li 0x100
Free-form descriptive text as given in the NAME section.
+.It Li 0x200
+Cross-links between manuals.
+Listed as the link name, then a period, then the link section.
+If the link has no section, the period terminates the string.
.El
.Pp
The last four bytes are a host-ordered record number within the
diff --git a/makewhatis.c b/makewhatis.c
index 92b535a3..b51a61c4 100644
--- a/makewhatis.c
+++ b/makewhatis.c
@@ -54,6 +54,7 @@
#define TYPE_AUTHOR 0x40
#define TYPE_CONFIG 0x80
#define TYPE_DESC 0x100
+#define TYPE_XREF 0x200
/* Buffer for storing growable data. */
@@ -90,6 +91,7 @@ static void pmdoc_Nd(MDOC_ARGS);
static void pmdoc_Nm(MDOC_ARGS);
static void pmdoc_St(MDOC_ARGS);
static void pmdoc_Vt(MDOC_ARGS);
+static void pmdoc_Xr(MDOC_ARGS);
static void usage(void);
typedef void (*pmdoc_nf)(MDOC_ARGS);
@@ -135,7 +137,7 @@ static const pmdoc_nf mdocs[MDOC_MAX] = {
pmdoc_St, /* St */
pmdoc_Vt, /* Va */
pmdoc_Vt, /* Vt */
- NULL, /* Xr */
+ pmdoc_Xr, /* Xr */
NULL, /* %A */
NULL, /* %B */
NULL, /* %D */
@@ -652,6 +654,25 @@ pmdoc_St(MDOC_ARGS)
/* ARGSUSED */
static void
+pmdoc_Xr(MDOC_ARGS)
+{
+
+ if (NULL == (n = n->child))
+ return;
+
+ buf_appendb(buf, n->string, strlen(n->string));
+
+ if (NULL != (n = n->next)) {
+ buf_appendb(buf, ".", 1);
+ buf_appendb(buf, n->string, strlen(n->string) + 1);
+ } else
+ buf_appendb(buf, ".", 2);
+
+ hash_put(hash, buf, TYPE_XREF);
+}
+
+/* ARGSUSED */
+static void
pmdoc_Vt(MDOC_ARGS)
{
const char *start;