summaryrefslogtreecommitdiffstats
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
commit4282adef89d16d5427bc44016843f13275666f72 (patch)
tree94839cb3dd6b9dc512134d1646a420d2e037e0d7 /read.c
parent5e614e747c24e529f84dbfb18721534f909128e9 (diff)
downloadmandoc-4282adef89d16d5427bc44016843f13275666f72.tar.gz
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.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/read.c b/read.c
index 09ff1c63..2d1ef621 100644
--- a/read.c
+++ b/read.c
@@ -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);