aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2020-04-24 12:02:33 +0000
committerIngo Schwarze <schwarze@openbsd.org>2020-04-24 12:02:33 +0000
commit1849b727a60f67043a27dc863e3f90e2dbb84dfe (patch)
treea125523ca4600295cc5a94e8ca0582a1d871427f /read.c
parentd75c48416eef7eb48487f6dc9a1bafa2c262b81c (diff)
downloadmandoc-1849b727a60f67043a27dc863e3f90e2dbb84dfe.tar.gz
mandoc-1849b727a60f67043a27dc863e3f90e2dbb84dfe.tar.zst
mandoc-1849b727a60f67043a27dc863e3f90e2dbb84dfe.zip
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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/read.c b/read.c
index 92045964..03a71c33 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.218 2020/04/18 20:40:10 schwarze Exp $ */
+/* $Id: read.c,v 1.219 2020/04/24 12:02:33 schwarze Exp $ */
/*
* Copyright (c) 2010-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -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;