From 94faba6938e92639a0faed14ee78cdfe518d1073 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sun, 5 Jan 2014 00:29:49 +0000 Subject: [PATCH] Put section and architecture info into the keys table, in preparation for removing them from the mpages table, aiming for cleaner and more uniform interfaces. Database growth is below 4%, part of which will be reclaimed. As a bonus, this allows searches like: ./obj/apropos An=kettenis -a arch=ppc ./obj/apropos An=kettenis -a sec~[^4] --- usr.bin/mandoc/mandocdb.c | 14 +++++++++++--- usr.bin/mandoc/mansearch.c | 4 +++- usr.bin/mandoc/mansearch.h | 4 +++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 6df2dd30db6..5837be9b990 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.53 2014/01/02 22:44:07 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.54 2014/01/05 00:29:49 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -1016,9 +1016,17 @@ mpages_merge(struct mchars *mc, struct mparse *mp, int check_reachable) mpage->title = mandoc_strdup(mpage->mlinks->name); } - - for (mlink = mpage->mlinks; mlink; mlink = mlink->next) + putkey(mpage, mpage->sec, TYPE_sec); + putkey(mpage, mpage->arch, TYPE_arch); + + for (mlink = mpage->mlinks; mlink; mlink = mlink->next) { + if ('\0' != *mlink->dsec) + putkey(mpage, mlink->dsec, TYPE_sec); + if ('\0' != *mlink->fsec) + putkey(mpage, mlink->fsec, TYPE_sec); + putkey(mpage, mlink->arch, TYPE_arch); putkey(mpage, mlink->name, TYPE_Nm); + } if (warnings && !use_all) { match = 0; diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index 233dca926e7..e6cb010a149 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.4 2014/01/04 23:42:32 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.5 2014/01/05 00:29:49 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -112,6 +112,8 @@ static const struct type types[] = { { TYPE_Va, "Va" }, { TYPE_Va, "Vt" }, { TYPE_Xr, "Xr" }, + { TYPE_sec, "sec" }, + { TYPE_arch,"arch" }, { ~0ULL, "any" }, { 0ULL, NULL } }; diff --git a/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h index 9f7568f0f54..913e5be902d 100644 --- a/usr.bin/mandoc/mansearch.h +++ b/usr.bin/mandoc/mansearch.h @@ -1,4 +1,4 @@ -/* $Id: mansearch.h,v 1.2 2013/12/31 03:41:09 schwarze Exp $ */ +/* $Id: mansearch.h,v 1.3 2014/01/05 00:29:49 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons * Copyright (c) 2013 Ingo Schwarze @@ -58,6 +58,8 @@ #define TYPE_Va 0x0000000800000000ULL #define TYPE_Vt 0x0000001000000000ULL #define TYPE_Xr 0x0000002000000000ULL +#define TYPE_sec 0x0000004000000000ULL +#define TYPE_arch 0x0000008000000000ULL __BEGIN_DECLS -- 2.20.1