From 3d871d9086bbc5f79cd485dfb26b9d02a19cf2e3 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 5 Jan 2014 20:26:36 +0000 Subject: Add an option -Q (quick) to mandocdb(8) for accelerated generation of reduced-size databases. Implement this by allowing the parsers to optionally abort the parse sequence after the NAME section. While here, garbage collect the unused void *arg attribute of struct mparse and mparse_alloc() and fix some errors in mandoc(3). This reduces the processing time of mandocdb(8) on /usr/share/man by a factor of 2 and the database size by a factor of 4. However, it still takes 5 times the time and 6 times the space of makewhatis(8), so more work is clearly needed. --- mandocdb.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'mandocdb.c') diff --git a/mandocdb.c b/mandocdb.c index 0effafbc..7068ddbc 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.101 2014/01/05 04:48:40 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.102 2014/01/05 20:26:36 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze @@ -167,8 +167,9 @@ static int treescan(void); static size_t utf8(unsigned int, char [7]); static char *progname; -static int use_all; /* use all found files */ static int nodb; /* no database changes */ +static int quick; /* abort the parse early */ +static int use_all; /* use all found files */ static int verb; /* print what we're doing */ static int warnings; /* warn about crap */ static int write_utf8; /* write UTF-8 output; else ASCII */ @@ -347,7 +348,7 @@ main(int argc, char *argv[]) path_arg = NULL; op = OP_DEFAULT; - while (-1 != (ch = getopt(argc, argv, "aC:d:nT:tu:vW"))) + while (-1 != (ch = getopt(argc, argv, "aC:d:nQT:tu:vW"))) switch (ch) { case ('a'): use_all = 1; @@ -365,6 +366,9 @@ main(int argc, char *argv[]) case ('n'): nodb = 1; break; + case ('Q'): + quick = 1; + break; case ('T'): if (strcmp(optarg, "utf8")) { fprintf(stderr, "-T%s: Unsupported " @@ -404,7 +408,7 @@ main(int argc, char *argv[]) exitcode = (int)MANDOCLEVEL_OK; mp = mparse_alloc(MPARSE_AUTO, - MANDOCLEVEL_FATAL, NULL, NULL, NULL); + MANDOCLEVEL_FATAL, NULL, NULL, quick); mc = mchars_alloc(); ohash_init(&mpages, 6, &mpages_info); @@ -494,11 +498,11 @@ out: ohash_delete(&mlinks); return(exitcode); usage: - fprintf(stderr, "usage: %s [-anvW] [-C file] [-Tutf8]\n" - " %s [-anvW] [-Tutf8] dir ...\n" - " %s [-nvW] [-Tutf8] -d dir [file ...]\n" + fprintf(stderr, "usage: %s [-anQvW] [-C file] [-Tutf8]\n" + " %s [-anQvW] [-Tutf8] dir ...\n" + " %s [-nQvW] [-Tutf8] -d dir [file ...]\n" " %s [-nvW] -u dir [file ...]\n" - " %s -t file ...\n", + " %s [-Q] -t file ...\n", progname, progname, progname, progname, progname); -- cgit v1.2.3-56-ge451