aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.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 /read.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 'read.c')
-rw-r--r--read.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/read.c b/read.c
index 7106c52d..417200e7 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.40 2014/01/02 16:29:55 schwarze Exp $ */
+/* $Id: read.c,v 1.41 2014/01/05 20:26:36 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -60,10 +60,10 @@ struct mparse {
struct roff *roff; /* roff parser (!NULL) */
int reparse_count; /* finite interp. stack */
mandocmsg mmsg; /* warning/error message handler */
- void *arg; /* argument to mmsg */
const char *file;
struct buf *secondary;
char *defos; /* default operating system */
+ int quick; /* abort the parse early */
};
static void resize_buf(struct buf *, size_t);
@@ -258,13 +258,14 @@ pset(const char *buf, int pos, struct mparse *curp)
case (MPARSE_MDOC):
if (NULL == curp->pmdoc)
curp->pmdoc = mdoc_alloc(curp->roff, curp,
- curp->defos);
+ curp->defos, curp->quick);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
case (MPARSE_MAN):
if (NULL == curp->pman)
- curp->pman = man_alloc(curp->roff, curp);
+ curp->pman = man_alloc(curp->roff, curp,
+ curp->quick);
assert(curp->pman);
curp->man = curp->pman;
return;
@@ -275,14 +276,14 @@ pset(const char *buf, int pos, struct mparse *curp)
if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) {
if (NULL == curp->pmdoc)
curp->pmdoc = mdoc_alloc(curp->roff, curp,
- curp->defos);
+ curp->defos, curp->quick);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
}
if (NULL == curp->pman)
- curp->pman = man_alloc(curp->roff, curp);
+ curp->pman = man_alloc(curp->roff, curp, curp->quick);
assert(curp->pman);
curp->man = curp->pman;
}
@@ -560,7 +561,8 @@ rerun:
if (0 == rc) {
assert(MANDOCLEVEL_FATAL <= curp->file_status);
break;
- }
+ } else if (2 == rc)
+ break;
/* Temporary buffers typically are not full. */
@@ -763,7 +765,7 @@ out:
struct mparse *
mparse_alloc(enum mparset inttype, enum mandoclevel wlevel,
- mandocmsg mmsg, void *arg, char *defos)
+ mandocmsg mmsg, char *defos, int quick)
{
struct mparse *curp;
@@ -773,9 +775,9 @@ mparse_alloc(enum mparset inttype, enum mandoclevel wlevel,
curp->wlevel = wlevel;
curp->mmsg = mmsg;
- curp->arg = arg;
curp->inttype = inttype;
curp->defos = defos;
+ curp->quick = quick;
curp->roff = roff_alloc(inttype, curp);
return(curp);