aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-03-19 21:51:20 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-03-19 21:51:20 +0000
commit79d152fe17d260ddca9686d56a71ecaa8d58ecd2 (patch)
tree67e99d2be668b0013c9877e147deb8a4e9483f07 /read.c
parent4f76006bc436b161a057a905ad55d9b213a6a141 (diff)
downloadmandoc-79d152fe17d260ddca9686d56a71ecaa8d58ecd2.tar.gz
mandoc-79d152fe17d260ddca9686d56a71ecaa8d58ecd2.tar.zst
mandoc-79d152fe17d260ddca9686d56a71ecaa8d58ecd2.zip
Generalize the mparse_alloc() and roff_alloc() functions by giving
them an "options" argument, replacing the existing "inttype" and "quick" arguments, preparing for a future MPARSE_SO option. Store this argument in struct mparse and struct roff, replacing the existing "inttype", "parsetype", and "quick" members. No functional change except one tiny cosmetic fix in roff_TH().
Diffstat (limited to 'read.c')
-rw-r--r--read.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/read.c b/read.c
index 0cb75d6b..bc18991f 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.43 2014/01/06 21:34:31 schwarze Exp $ */
+/* $Id: read.c,v 1.44 2014/03/19 21:51:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -53,7 +53,7 @@ struct mparse {
enum mandoclevel file_status; /* status of current parse */
enum mandoclevel wlevel; /* ignore messages below this */
int line; /* line number in the file */
- enum mparset inttype; /* which parser to use */
+ int options; /* parser options */
struct man *pman; /* persistent man parser */
struct mdoc *pmdoc; /* persistent mdoc parser */
struct man *man; /* man parser */
@@ -64,7 +64,6 @@ struct mparse {
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);
@@ -255,36 +254,36 @@ pset(const char *buf, int pos, struct mparse *curp)
return;
}
- switch (curp->inttype) {
- case (MPARSE_MDOC):
+ if (MPARSE_MDOC & curp->options) {
if (NULL == curp->pmdoc)
- curp->pmdoc = mdoc_alloc(curp->roff, curp,
- curp->defos, curp->quick);
+ curp->pmdoc = mdoc_alloc(
+ curp->roff, curp, curp->defos,
+ MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
- case (MPARSE_MAN):
+ } else if (MPARSE_MAN & curp->options) {
if (NULL == curp->pman)
curp->pman = man_alloc(curp->roff, curp,
- curp->quick);
+ MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pman);
curp->man = curp->pman;
return;
- default:
- break;
}
if (pos >= 3 && 0 == memcmp(buf, ".Dd", 3)) {
if (NULL == curp->pmdoc)
- curp->pmdoc = mdoc_alloc(curp->roff, curp,
- curp->defos, curp->quick);
+ curp->pmdoc = mdoc_alloc(
+ curp->roff, curp, curp->defos,
+ MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pmdoc);
curp->mdoc = curp->pmdoc;
return;
}
if (NULL == curp->pman)
- curp->pman = man_alloc(curp->roff, curp, curp->quick);
+ curp->pman = man_alloc(curp->roff, curp,
+ MPARSE_QUICK & curp->options ? 1 : 0);
assert(curp->pman);
curp->man = curp->pman;
}
@@ -765,8 +764,8 @@ out:
}
struct mparse *
-mparse_alloc(enum mparset inttype, enum mandoclevel wlevel,
- mandocmsg mmsg, char *defos, int quick)
+mparse_alloc(int options, enum mandoclevel wlevel,
+ mandocmsg mmsg, char *defos)
{
struct mparse *curp;
@@ -774,13 +773,12 @@ mparse_alloc(enum mparset inttype, enum mandoclevel wlevel,
curp = mandoc_calloc(1, sizeof(struct mparse));
+ curp->options = options;
curp->wlevel = wlevel;
curp->mmsg = mmsg;
- curp->inttype = inttype;
curp->defos = defos;
- curp->quick = quick;
- curp->roff = roff_alloc(inttype, curp, curp->quick);
+ curp->roff = roff_alloc(curp, options);
return(curp);
}