From 4282adef89d16d5427bc44016843f13275666f72 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. --- mdoc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mdoc.c') diff --git a/mdoc.c b/mdoc.c index bc977d36..6ae1631c 100644 --- a/mdoc.c +++ b/mdoc.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2012, 2013 Ingo Schwarze + * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -197,7 +197,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; @@ -205,6 +206,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(); @@ -961,6 +963,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. */ -- cgit