aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-07-20 14:36:36 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-07-20 14:36:36 +0000
commit0d1c0a686376f865341ab91184438f959f98dc68 (patch)
tree8eb5a6c213db67b15e4cfe9e03c5761339522b3d
parentfa9bd450fd23dcd2191412780cbdfb66f8464838 (diff)
downloadmandoc-0d1c0a686376f865341ab91184438f959f98dc68.tar.gz
mandoc-0d1c0a686376f865341ab91184438f959f98dc68.tar.zst
mandoc-0d1c0a686376f865341ab91184438f959f98dc68.zip
Do not call err(3) from the parser. Call mandoc_vmsg() and
return failure such that we can continue with the next file.
-rw-r--r--read.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/read.c b/read.c
index bed97580..1af1b283 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.191 2017/07/08 17:52:50 schwarze Exp $ */
+/* $Id: read.c,v 1.192 2017/07/20 14:36:36 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -24,9 +24,6 @@
#include <assert.h>
#include <ctype.h>
-#if HAVE_ERR
-#include <err.h>
-#endif
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
@@ -560,8 +557,11 @@ read_whole_file(struct mparse *curp, const char *file, int fd,
size_t off;
ssize_t ssz;
- if (fstat(fd, &st) == -1)
- err((int)MANDOCLEVEL_SYSERR, "%s", file);
+ if (fstat(fd, &st) == -1) {
+ mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,
+ "fstat: %s", strerror(errno));
+ return 0;
+ }
/*
* If we're a regular file, try just reading in the whole entry
@@ -583,8 +583,11 @@ read_whole_file(struct mparse *curp, const char *file, int fd,
}
if (curp->gzip) {
- if ((gz = gzdopen(fd, "rb")) == NULL)
- err((int)MANDOCLEVEL_SYSERR, "%s", file);
+ if ((gz = gzdopen(fd, "rb")) == NULL) {
+ mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,
+ "gzdopen: %s", strerror(errno));
+ return 0;
+ }
} else
gz = NULL;
@@ -613,8 +616,11 @@ read_whole_file(struct mparse *curp, const char *file, int fd,
fb->sz = off;
return 1;
}
- if (ssz == -1)
- err((int)MANDOCLEVEL_SYSERR, "%s", file);
+ if (ssz == -1) {
+ mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0,
+ "read: %s", strerror(errno));
+ break;
+ }
off += (size_t)ssz;
}