version 1.21, 2011/07/21 23:30:39 |
version 1.25, 2011/10/08 15:42:29 |
|
|
mandocmsg mmsg; /* warning/error message handler */ |
mandocmsg mmsg; /* warning/error message handler */ |
void *arg; /* argument to mmsg */ |
void *arg; /* argument to mmsg */ |
const char *file; |
const char *file; |
|
struct buf *secondary; |
}; |
}; |
|
|
static void resize_buf(struct buf *, size_t); |
static void resize_buf(struct buf *, size_t); |
Line 152 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
Line 153 static const char * const mandocerrs[MANDOCERR_MAX] = |
|
"generic error", |
"generic error", |
|
|
/* related to equations */ |
/* related to equations */ |
"bad equation macro syntax", |
|
"too many nested equation defines", |
|
"unexpected equation scope closure", |
"unexpected equation scope closure", |
"equation scope open on exit", |
"equation scope open on exit", |
"overlapping equation scopes", |
"overlapping equation scopes", |
Line 413 mparse_buf_r(struct mparse *curp, struct buf blk, int |
|
Line 412 mparse_buf_r(struct mparse *curp, struct buf blk, int |
|
|
|
of = 0; |
of = 0; |
|
|
|
/* |
|
* Maintain a lookaside buffer of all parsed lines. We |
|
* only do this if mparse_keep() has been invoked (the |
|
* buffer may be accessed with mparse_getkeep()). |
|
*/ |
|
|
|
if (curp->secondary) { |
|
curp->secondary->buf = |
|
mandoc_realloc |
|
(curp->secondary->buf, |
|
curp->secondary->sz + pos + 2); |
|
memcpy(curp->secondary->buf + |
|
curp->secondary->sz, |
|
ln.buf, pos); |
|
curp->secondary->sz += pos; |
|
curp->secondary->buf |
|
[curp->secondary->sz] = '\n'; |
|
curp->secondary->sz++; |
|
curp->secondary->buf |
|
[curp->secondary->sz] = '\0'; |
|
} |
rerun: |
rerun: |
rr = roff_parseln |
rr = roff_parseln |
(curp->roff, curp->line, |
(curp->roff, curp->line, |
|
|
assert(MANDOCLEVEL_FATAL <= curp->file_status); |
assert(MANDOCLEVEL_FATAL <= curp->file_status); |
break; |
break; |
case (ROFF_SO): |
case (ROFF_SO): |
|
/* |
|
* We remove `so' clauses from our lookaside |
|
* buffer because we're going to descend into |
|
* the file recursively. |
|
*/ |
|
if (curp->secondary) |
|
curp->secondary->sz -= pos + 1; |
mparse_readfd_r(curp, -1, ln.buf + of, 1); |
mparse_readfd_r(curp, -1, ln.buf + of, 1); |
if (MANDOCLEVEL_FATAL <= curp->file_status) |
if (MANDOCLEVEL_FATAL <= curp->file_status) |
break; |
break; |
Line 706 mparse_reset(struct mparse *curp) |
|
Line 733 mparse_reset(struct mparse *curp) |
|
mdoc_reset(curp->mdoc); |
mdoc_reset(curp->mdoc); |
if (curp->man) |
if (curp->man) |
man_reset(curp->man); |
man_reset(curp->man); |
|
if (curp->secondary) |
|
curp->secondary->sz = 0; |
|
|
curp->file_status = MANDOCLEVEL_OK; |
curp->file_status = MANDOCLEVEL_OK; |
curp->mdoc = NULL; |
curp->mdoc = NULL; |
Line 722 mparse_free(struct mparse *curp) |
|
Line 751 mparse_free(struct mparse *curp) |
|
man_free(curp->pman); |
man_free(curp->pman); |
if (curp->roff) |
if (curp->roff) |
roff_free(curp->roff); |
roff_free(curp->roff); |
|
if (curp->secondary) |
|
free(curp->secondary->buf); |
|
|
|
free(curp->secondary); |
free(curp); |
free(curp); |
} |
} |
|
|
|
|
mparse_strlevel(enum mandoclevel lvl) |
mparse_strlevel(enum mandoclevel lvl) |
{ |
{ |
return(mandoclevels[lvl]); |
return(mandoclevels[lvl]); |
|
} |
|
|
|
void |
|
mparse_keep(struct mparse *p) |
|
{ |
|
|
|
assert(NULL == p->secondary); |
|
p->secondary = mandoc_calloc(1, sizeof(struct buf)); |
|
} |
|
|
|
const char * |
|
mparse_getkeep(const struct mparse *p) |
|
{ |
|
|
|
assert(p->secondary); |
|
return(p->secondary->sz ? p->secondary->buf : NULL); |
} |
} |