aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-01-05 20:26:36 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-01-05 20:26:36 +0000
commit3d871d9086bbc5f79cd485dfb26b9d02a19cf2e3 (patch)
tree12c6882973b4bed0d9b5eb332153635e293e50e2 /man.c
parentd9597fb775134ff4c4ae106fdb7f3214b5af2463 (diff)
downloadmandoc-3d871d9086bbc5f79cd485dfb26b9d02a19cf2e3.tar.gz
mandoc-3d871d9086bbc5f79cd485dfb26b9d02a19cf2e3.tar.zst
mandoc-3d871d9086bbc5f79cd485dfb26b9d02a19cf2e3.zip
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.
Diffstat (limited to 'man.c')
-rw-r--r--man.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/man.c b/man.c
index 72c6afab..b810ac7b 100644
--- a/man.c
+++ b/man.c
@@ -1,6 +1,7 @@
-/* $Id: man.c,v 1.122 2013/12/31 23:23:10 schwarze Exp $ */
+/* $Id: man.c,v 1.123 2014/01/05 20:26:36 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -97,7 +98,7 @@ man_free(struct man *man)
struct man *
-man_alloc(struct roff *roff, struct mparse *parse)
+man_alloc(struct roff *roff, struct mparse *parse, int quick)
{
struct man *p;
@@ -105,6 +106,7 @@ man_alloc(struct roff *roff, struct mparse *parse)
man_hash_init();
p->parse = parse;
+ p->quick = quick;
p->roff = roff;
man_alloc1(p);
@@ -604,6 +606,12 @@ man_pmacro(struct man *man, int ln, char *buf, int offs)
if ( ! (*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf))
goto err;
+ /* In quick mode (for mandocdb), abort after the NAME section. */
+
+ if (man->quick && MAN_SH == tok &&
+ strcmp(man->last->prev->child->string, "NAME"))
+ return(2);
+
/*
* We weren't in a block-line scope when entering the
* above-parsed macro, so return.