From 9a1658910c9c2fa6e8b2d75172f98c96f3c99ba2 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sat, 25 Jun 2011 13:19:25 +0000 Subject: Add cross-reference records to makewhatis. --- makewhatis.1 | 8 ++++++-- makewhatis.c | 25 +++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/makewhatis.1 b/makewhatis.1 index 3546cb3c..aaa11775 100644 --- a/makewhatis.1 +++ b/makewhatis.1 @@ -1,4 +1,4 @@ -.\" $Id: makewhatis.1,v 1.6 2011/06/22 10:36:36 kristaps Exp $ +.\" $Id: makewhatis.1,v 1.7 2011/06/25 13:19:25 kristaps Exp $ .\" .\" Copyright (c) 2011 Kristaps Dzonsons .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 22 2011 $ +.Dd $Mdocdate: June 25 2011 $ .Dt MAKEWHATIS 1 .Os .Sh NAME @@ -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 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 * @@ -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 */ @@ -650,6 +652,25 @@ pmdoc_St(MDOC_ARGS) hash_put(hash, buf, TYPE_STANDARD); } +/* 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) -- cgit v1.2.3-56-ge451