=================================================================== RCS file: /cvs/mandoc/read.c,v retrieving revision 1.40 retrieving revision 1.42 diff -u -p -r1.40 -r1.42 --- mandoc/read.c 2014/01/02 16:29:55 1.40 +++ mandoc/read.c 2014/01/06 00:53:33 1.42 @@ -1,7 +1,8 @@ -/* $Id: read.c,v 1.40 2014/01/02 16:29:55 schwarze Exp $ */ +/* $Id: read.c,v 1.42 2014/01/06 00:53:33 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze + * Copyright (c) 2010, 2012 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -60,10 +61,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 +259,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 +277,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 +562,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 +766,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 +776,9 @@ mparse_alloc(enum mparset inttype, enum mandoclevel wl 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);