aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-12-20 21:30:32 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-12-20 21:30:32 +0000
commit3cfd064738dd1ac7b31bfbb5b6eab47b4ea99b2c (patch)
treee470d6cae4209486a3043053d194112212db80d6 /read.c
parenta72e5e50e1299fb4a5a88975ce1d68a543f8ac2f (diff)
downloadmandoc-3cfd064738dd1ac7b31bfbb5b6eab47b4ea99b2c.tar.gz
mandoc-3cfd064738dd1ac7b31bfbb5b6eab47b4ea99b2c.tar.zst
mandoc-3cfd064738dd1ac7b31bfbb5b6eab47b4ea99b2c.zip
Move the full responsibility for reporting open(2) errors from
mparse_open() to the caller. That is better because only the caller knows its preferred reporting method and format and only the caller has access to all the data that should be included - like the column number in .so processing or the current manpath in makewhatis(8). Moving the mandoc_msg() call out is possible because the caller can call strerror(3) just as easily as mparse_open() can. Move mandoc_msg_setinfilename() closer to the parsing of the file contents, to avoid problems *with* the file (like non-existence, lack of permissions, etc.) getting misreported as problems *in* the file. Fix the column number reported for .so failure: let it point to the beginning of the filename. Taken together, this prevents makewhatis(8) from spewing confusing messages about .so failures to stderr, a bug reported by Raf Czlonka <rczlonka at gmail dot com> on ports@. It also prevents mandoc(1) from issuing *two* messages for every single .so failure.
Diffstat (limited to 'read.c')
-rw-r--r--read.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/read.c b/read.c
index 08123026..17200e09 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.207 2018/12/14 06:33:14 schwarze Exp $ */
+/* $Id: read.c,v 1.208 2018/12/20 21:30:32 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -372,8 +372,9 @@ rerun:
mparse_readfd(curp, fd, ln.buf + of);
close(fd);
} else {
- mandoc_msg(MANDOCERR_SO_FAIL, curp->line,
- pos, ".so %s", ln.buf + of);
+ mandoc_msg(MANDOCERR_SO_FAIL,
+ curp->line, of, ".so %s: %s",
+ ln.buf + of, strerror(errno));
ln.sz = mandoc_asprintf(&cp,
".sp\nSee the file %s.\n.sp",
ln.buf + of);
@@ -633,7 +634,6 @@ mparse_open(struct mparse *curp, const char *file)
/* Neither worked, give up. */
- mandoc_msg(MANDOCERR_FILE, 0, 0, "%s", strerror(errno));
return -1;
}