diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-07-20 14:36:36 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-07-20 14:36:36 +0000 |
commit | b2372dd42b801bcd71447c8da82c59a80518d557 (patch) | |
tree | 9bd1509908ede351bbcb06964568fa8ed0dc3bc9 /read.c | |
parent | 9f530b39ae88833b05d44035c78cae9318615c56 (diff) | |
download | mandoc-b2372dd42b801bcd71447c8da82c59a80518d557.tar.gz |
Do not call err(3) from the parser. Call mandoc_vmsg() and
return failure such that we can continue with the next file.
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -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; } |