aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/makewhatis.c
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
commit9a1658910c9c2fa6e8b2d75172f98c96f3c99ba2 (patch)
tree71f758718594a0cbbfa664de2ab1156b74317978 /makewhatis.c
parent45daa587bf05616e4aa458f5d77fae7aaccc6518 (diff)
downloadmandoc-9a1658910c9c2fa6e8b2d75172f98c96f3c99ba2.tar.gz
mandoc-9a1658910c9c2fa6e8b2d75172f98c96f3c99ba2.tar.zst
mandoc-9a1658910c9c2fa6e8b2d75172f98c96f3c99ba2.zip
Add cross-reference records to makewhatis.
Diffstat (limited to 'makewhatis.c')
-rw-r--r--makewhatis.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/makewhatis.c b/makewhatis.c
index 44751b68..574e51a1 100644
--- a/makewhatis.c
+++ b/makewhatis.c
@@ -1,4 +1,4 @@
-/* $Id: makewhatis.c,v 1.10 2011/06/22 10:36:36 kristaps Exp $ */
+/* $Id: makewhatis.c,v 1.11 2011/06/25 13:19:25 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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;