From 8343943a153c5bc606c8fa7b29765e500db48e1f Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Tue, 21 Jun 2011 14:16:05 +0000 Subject: Let descriptions (bit-mask 0x100) also be mined for text. This doubles the database size (one record for each file), but it's critical information. --- Makefile | 2 +- makewhatis.1 | 4 +++- makewhatis.c | 23 +++++++++++++++++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 86399a57..c535f105 100644 --- a/Makefile +++ b/Makefile @@ -353,7 +353,7 @@ llib-lmandoc.ln: $(MANDOC_LNS) # You'll need -ldb for Linux. makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a - $(CC) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a -ldb + $(CC) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a llib-lmakewhatis.ln: $(MAKEWHATIS_LNS) $(LINT) $(LINTFLAGS) -Cmakewhatis $(MAKEWHATIS_LNS) diff --git a/makewhatis.1 b/makewhatis.1 index e556b4c4..0e781c99 100644 --- a/makewhatis.1 +++ b/makewhatis.1 @@ -1,4 +1,4 @@ -.\" $Id: makewhatis.1,v 1.4 2011/06/21 13:09:19 kristaps Exp $ +.\" $Id: makewhatis.1,v 1.5 2011/06/21 14:16:05 kristaps Exp $ .\" .\" Copyright (c) 2011 Kristaps Dzonsons .\" @@ -107,6 +107,8 @@ A standard as given in the STANDARDS section. An author as given in the AUTHORS section. .It Li 0x80 A configuration as given in the SYNOPSIS section. +.It Li 0x100 +Free-form descriptive text as given in the NAME section. .El .Pp The last four bytes are a host-ordered record number within the diff --git a/makewhatis.c b/makewhatis.c index 1c154312..0b767704 100644 --- a/makewhatis.c +++ b/makewhatis.c @@ -1,4 +1,4 @@ -/* $Id: makewhatis.c,v 1.5 2011/06/21 13:54:05 kristaps Exp $ */ +/* $Id: makewhatis.c,v 1.6 2011/06/21 14:16:05 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -52,7 +52,7 @@ #define TYPE_STANDARD 0x20 #define TYPE_AUTHOR 0x40 #define TYPE_CONFIG 0x80 -#define TYPE__MAX TYPE_CONFIG +#define TYPE_DESC 0x100 /* Buffer for storing growable data. */ @@ -695,16 +695,25 @@ static void pmdoc_Nd(MDOC_ARGS) { int first; + size_t sz; for (first = 1, n = n->child; n; n = n->next) { if (MDOC_TEXT != n->type) continue; - if (first) - buf_appendb(dbuf, n->string, strlen(n->string) + 1); - else + + if (first) { + sz = strlen(n->string) + 1; + buf_appendb(dbuf, n->string, sz); + buf_appendb(buf, n->string, sz); + } else { buf_append(dbuf, n->string); + buf_append(buf, n->string); + } + first = 0; } + + hash_put(hash, buf, TYPE_DESC); } /* ARGSUSED */ @@ -897,7 +906,9 @@ pman_node(MAN_ARGS) while (' ' == *start) start++; - buf_appendb(dbuf, start, strlen(start) + 1); + sz = strlen(start) + 1; + buf_appendb(dbuf, start, sz); + buf_appendb(buf, start, sz); } } -- cgit v1.2.3-56-ge451