diff options
author | 2014-01-05 20:26:27 +0000 | |
---|---|---|
committer | 2014-01-05 20:26:27 +0000 | |
commit | f1da507fdd28f0ef6cf390c0be3a759d812fde8b (patch) | |
tree | 44f79d233e003ad6cef81a350a22c69bbffba1d0 /usr.bin/mandoc/mdoc.c | |
parent | Don't use the first 64KB for anything, including tramps. Move tramps and (diff) | |
download | wireguard-openbsd-f1da507fdd28f0ef6cf390c0be3a759d812fde8b.tar.xz wireguard-openbsd-f1da507fdd28f0ef6cf390c0be3a759d812fde8b.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().
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 'usr.bin/mandoc/mdoc.c')
-rw-r--r-- | usr.bin/mandoc/mdoc.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c index 40595d95729..3c4370aa29c 100644 --- a/usr.bin/mandoc/mdoc.c +++ b/usr.bin/mandoc/mdoc.c @@ -1,7 +1,7 @@ -/* $Id: mdoc.c,v 1.97 2013/12/30 00:52:18 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.98 2014/01/05 20:26:27 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010, 2012, 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 @@ -193,7 +193,8 @@ mdoc_free(struct mdoc *mdoc) * Allocate volatile and non-volatile parse resources. */ struct mdoc * -mdoc_alloc(struct roff *roff, struct mparse *parse, char *defos) +mdoc_alloc(struct roff *roff, struct mparse *parse, + char *defos, int quick) { struct mdoc *p; @@ -201,6 +202,7 @@ mdoc_alloc(struct roff *roff, struct mparse *parse, char *defos) p->parse = parse; p->defos = defos; + p->quick = quick; p->roff = roff; mdoc_hash_init(); @@ -957,6 +959,12 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs) if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf)) goto err; + /* In quick mode (for mandocdb), abort after the NAME section. */ + + if (mdoc->quick && MDOC_Sh == tok && + SEC_NAME != mdoc->last->sec) + return(2); + return(1); err: /* Error out. */ |