diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2020-04-24 12:02:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2020-04-24 12:02:33 +0000 |
commit | 8cb870017a69040560be430c7f7978efa809acb3 (patch) | |
tree | 47f257f67a01e84b2f35c6e70b21c7c6bc3e9de8 /read.c | |
parent | 2258889db3530de027ab40978bb09a8a824e9c5f (diff) | |
download | mandoc-8cb870017a69040560be430c7f7978efa809acb3.tar.gz |
provide a STYLE message when mandoc knows the file name and the extension
disagrees with the section number given in the .Dt or .TH macro;
feature suggested and patch tested by jmc@
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -554,7 +554,7 @@ mparse_readfd(struct mparse *curp, int fd, const char *filename) struct buf blk; struct buf *save_primary; - const char *save_filename; + const char *save_filename, *cp; size_t offset; int save_filenc, save_lineno; int with_mmap; @@ -562,7 +562,13 @@ mparse_readfd(struct mparse *curp, int fd, const char *filename) if (recursion_depth > 64) { mandoc_msg(MANDOCERR_ROFFLOOP, curp->line, 0, NULL); return; - } + } else if (recursion_depth == 0 && + (cp = strrchr(filename, '.')) != NULL && + cp[1] >= '1' && cp[1] <= '9') + curp->man->filesec = cp[1]; + else + curp->man->filesec = '\0'; + if (read_whole_file(curp, fd, &blk, &with_mmap) == -1) return; |