aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-01-11 17:04:44 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-01-11 17:04:44 +0000
commit6cb1ffbb0c8669ce4942fa0380b0004a35db885d (patch)
treeb3902af05549abf9b378e811d4da0da506a0154e
parent55d8efa26c02803a45390d905d96a964405037d0 (diff)
downloadmandoc-6cb1ffbb0c8669ce4942fa0380b0004a35db885d.tar.gz
mandoc-6cb1ffbb0c8669ce4942fa0380b0004a35db885d.tar.zst
mandoc-6cb1ffbb0c8669ce4942fa0380b0004a35db885d.zip
Improve error reporting when a file given on the command line
cannot be opened: * Mention the filename. * Report the errno for the file itself, not the one with .gz appended.
-rw-r--r--main.c4
-rw-r--r--read.c8
2 files changed, 7 insertions, 5 deletions
diff --git a/main.c b/main.c
index 1f738439..36eb565d 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.317 2019/01/10 06:29:00 schwarze Exp $ */
+/* $Id: main.c,v 1.318 2019/01/11 17:04:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -561,7 +561,7 @@ main(int argc, char *argv[])
}
} else
mandoc_msg(MANDOCERR_FILE, 0, 0,
- "%s", strerror(errno));
+ "%s: %s", thisarg, strerror(errno));
if (curp.wstop && mandoc_msg_getrc() != MANDOCLEVEL_OK)
break;
diff --git a/read.c b/read.c
index afafcdb5..a3a1f982 100644
--- a/read.c
+++ b/read.c
@@ -1,7 +1,7 @@
-/* $Id: read.c,v 1.210 2018/12/31 04:55:47 schwarze Exp $ */
+/* $Id: read.c,v 1.211 2019/01/11 17:04:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2019 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -607,7 +607,7 @@ int
mparse_open(struct mparse *curp, const char *file)
{
char *cp;
- int fd;
+ int fd, save_errno;
cp = strrchr(file, '.');
curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz"));
@@ -623,9 +623,11 @@ mparse_open(struct mparse *curp, const char *file)
*/
if ( ! curp->gzip) {
+ save_errno = errno;
mandoc_asprintf(&cp, "%s.gz", file);
fd = open(cp, O_RDONLY);
free(cp);
+ errno = save_errno;
if (fd != -1) {
curp->gzip = 1;
return fd;