diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-03-19 22:20:43 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-03-19 22:20:43 +0000 |
commit | 007dd8781c55fce01e2e54e6386731c355ad463d (patch) | |
tree | 744a417db38add0952cd00dc0691ba84dac03f0b | |
parent | cd337f65ece6ac4cd6eb91fcbd5a7a970956eb3f (diff) | |
download | mandoc-007dd8781c55fce01e2e54e6386731c355ad463d.tar.gz |
Without the MPARSE_SO option, if the file contains nothing but a
single .so request, do not read the file pointed to, but instead
let mparse_result() provide the file name pointed to as a return
value. To be used by makewhatis(8) in the future.
-rw-r--r-- | cgi.c | 2 | ||||
-rw-r--r-- | demandoc.c | 2 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | mandoc.h | 2 | ||||
-rw-r--r-- | mandocdb.c | 2 | ||||
-rw-r--r-- | read.c | 21 |
6 files changed, 24 insertions, 7 deletions
@@ -753,7 +753,7 @@ format(const struct req *req, const char *file) /*"includes=/cgi-bin/man.cgi/usr/include/%%I"*/, progname); - mparse_result(mp, &mdoc, &man); + mparse_result(mp, &mdoc, &man, NULL); if (NULL == man && NULL == mdoc) { resp_baddb(); mparse_free(mp); @@ -110,7 +110,7 @@ pmandoc(struct mparse *mp, int fd, const char *fn, int list) return; } - mparse_result(mp, &mdoc, &man); + mparse_result(mp, &mdoc, &man, NULL); line = 1; col = 0; @@ -294,7 +294,7 @@ parse(struct curparse *curp, int fd, } } - mparse_result(curp->mp, &mdoc, &man); + mparse_result(curp->mp, &mdoc, &man, NULL); /* Execute the out device, if it exists. */ @@ -427,7 +427,7 @@ enum mandoclevel mparse_readmem(struct mparse *, const void *, size_t, const char *); void mparse_reset(struct mparse *); void mparse_result(struct mparse *, - struct mdoc **, struct man **); + struct mdoc **, struct man **, char **); const char *mparse_getkeep(const struct mparse *); const char *mparse_strerror(enum mandocerr); const char *mparse_strlevel(enum mandoclevel); @@ -999,7 +999,7 @@ mpages_merge(struct mchars *mc, struct mparse *mp) FORM_CAT != mpage->mlinks->fform) { lvl = mparse_readfd(mp, -1, mpage->mlinks->file); if (lvl < MANDOCLEVEL_FATAL) - mparse_result(mp, &mdoc, &man); + mparse_result(mp, &mdoc, &man, NULL); } if (NULL != mdoc) { @@ -59,6 +59,7 @@ struct mparse { struct man *man; /* man parser */ struct mdoc *mdoc; /* mdoc parser */ struct roff *roff; /* roff parser (!NULL) */ + char *sodest; /* filename pointed to by .so */ int reparse_count; /* finite interp. stack */ mandocmsg mmsg; /* warning/error message handler */ const char *file; @@ -490,6 +491,12 @@ rerun: assert(MANDOCLEVEL_FATAL <= curp->file_status); break; case (ROFF_SO): + if (0 == (MPARSE_SO & curp->options) && + (i >= (int)blk.sz || '\0' == blk.buf[i])) { + curp->sodest = mandoc_strdup(ln.buf + of); + free(ln.buf); + return; + } /* * We remove `so' clauses from our lookaside * buffer because we're going to descend into @@ -676,7 +683,7 @@ mparse_end(struct mparse *curp) return; } - if ( ! (curp->man || curp->mdoc)) { + if ( ! (curp->mdoc || curp->man || curp->sodest)) { mandoc_msg(MANDOCERR_NOTMANUAL, curp, 1, 0, NULL); curp->file_status = MANDOCLEVEL_FATAL; return; @@ -798,6 +805,9 @@ mparse_reset(struct mparse *curp) curp->file_status = MANDOCLEVEL_OK; curp->mdoc = NULL; curp->man = NULL; + + free(curp->sodest); + curp->sodest = NULL; } void @@ -814,13 +824,20 @@ mparse_free(struct mparse *curp) free(curp->secondary->buf); free(curp->secondary); + free(curp->sodest); free(curp); } void -mparse_result(struct mparse *curp, struct mdoc **mdoc, struct man **man) +mparse_result(struct mparse *curp, + struct mdoc **mdoc, struct man **man, char **sodest) { + if (sodest && NULL != (*sodest = curp->sodest)) { + *mdoc = NULL; + *man = NULL; + return; + } if (mdoc) *mdoc = curp->mdoc; if (man) |