diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mandoc.1 | 22 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.h | 9 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 47 |
3 files changed, 30 insertions, 48 deletions
diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index da3753a740c..266f40cf5bc 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,7 +1,7 @@ -.\" $OpenBSD: mandoc.1,v 1.70 2014/12/28 14:39:08 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.71 2015/01/14 22:02:00 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> -.\" Copyright (c) 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> +.\" Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 28 2014 $ +.Dd $Mdocdate: January 14 2015 $ .Dt MANDOC 1 .Os .Sh NAME @@ -543,8 +543,8 @@ A fatal parsing error occurred. Invalid command line arguments were specified. No input files have been read. .It 6 -An operating system error occurred, for example memory exhaustion or an -error accessing input files. +An operating system error occurred, for example exhaustion +of memory, file descriptors, or process table entries. Such errors cause .Nm to exit at once, possibly in the middle of parsing or formatting a file. @@ -603,9 +603,6 @@ fields. .Pp Message levels have the following meanings: .Bl -tag -width "warning" -.It Cm syserr -Opening or reading an input file failed, so the parser cannot -even be started and no output is produced from that input file. .It Cm fatal The parser is unable to parse a given input file at all. No formatted output is produced from that input file. @@ -619,6 +616,12 @@ the parser is able to continue, and the error does not prevent generation of formatted output, but typically, preparing that output involves information loss, broken document structure or unintended formatting. +.Pp +Non-existent or unreadable input files are also reported on the +.Cm error +level. +In that case, the parser cannot even be started and no output +is produced from those input files. .It Cm warning An input file uses obsolete, discouraged or non-portable syntax. All the same, the meaning of the input is unambiguous and a correct @@ -632,7 +635,8 @@ Messages of the .Cm warning and .Cm error -levels are hidden unless their level, or a lower level, is requested using a +levels except those about non-existent or unreadable input files +are hidden unless their level, or a lower level, is requested using a .Fl W option or .Fl T Ns Cm lint diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 5b792373654..99523a2b0ac 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.120 2015/01/14 17:45:25 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.121 2015/01/14 22:02:00 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -147,6 +147,7 @@ enum mandocerr { MANDOCERR_TBLMACRO, /* ignoring macro in table: macro */ /* related to document structure and macros */ + MANDOCERR_FILE, /* cannot open file */ MANDOCERR_ROFFLOOP, /* input stack limit exceeded, infinite loop? */ MANDOCERR_BADCHAR, /* skipping bad character: number */ MANDOCERR_MACRO, /* skipping unknown macro: macro */ @@ -175,12 +176,6 @@ enum mandocerr { MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */ MANDOCERR_SO_FAIL, /* .so request failed */ - /* ===== system errors ===== */ - - MANDOCERR_SYSEXIT, /* gunzip failed with code */ - MANDOCERR_SYSOPEN, /* cannot open file */ - MANDOCERR_SYSSIG, /* gunzip died from signal */ - MANDOCERR_MAX }; diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index ebb47034fbe..c96382d5ba3 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.82 2015/01/14 17:45:25 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.83 2015/01/14 22:02:00 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org> @@ -186,6 +186,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "ignoring macro in table", /* related to document structure and macros */ + NULL, "input stack limit exceeded, infinite loop?", "skipping bad character", "skipping unknown macro", @@ -213,11 +214,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "input too large", "NOT IMPLEMENTED: .so with absolute path or \"..\"", ".so request failed", - - /* system errors */ - "gunzip failed with code", - NULL, - "gunzip died from signal", }; static const char * const mandoclevels[MANDOCLEVEL_MAX] = { @@ -753,7 +749,7 @@ mparse_readfd(struct mparse *curp, int fd, const char *file) save_child = curp->child; if (fd != -1) curp->child = 0; - else if (mparse_open(curp, &fd, file) >= MANDOCLEVEL_SYSERR) + else if (mparse_open(curp, &fd, file) != MANDOCLEVEL_OK) goto out; if (read_whole_file(curp, file, fd, &blk, &with_mmap)) { @@ -783,9 +779,7 @@ mparse_open(struct mparse *curp, int *fd, const char *file) int pfd[2]; int save_errno; char *cp; - enum mandocerr err; - pfd[1] = -1; curp->file = file; /* Unless zipped, try to just open the file. */ @@ -809,8 +803,11 @@ mparse_open(struct mparse *curp, int *fd, const char *file) if (access(file, R_OK) == -1) { if (cp != NULL) errno = save_errno; - err = MANDOCERR_SYSOPEN; - goto out; + free(cp); + *fd = -1; + curp->child = 0; + mandoc_msg(MANDOCERR_FILE, curp, 0, 0, strerror(errno)); + return(MANDOCLEVEL_ERROR); } /* Run gunzip(1). */ @@ -838,18 +835,6 @@ mparse_open(struct mparse *curp, int *fd, const char *file) *fd = pfd[0]; return(MANDOCLEVEL_OK); } - -out: - free(cp); - *fd = -1; - curp->child = 0; - curp->file_status = MANDOCLEVEL_SYSERR; - if (curp->mmsg) - (*curp->mmsg)(err, curp->file_status, curp->file, - 0, 0, strerror(errno)); - if (pfd[1] != -1) - exit(1); - return(curp->file_status); } enum mandoclevel @@ -865,16 +850,14 @@ mparse_wait(struct mparse *curp) exit((int)MANDOCLEVEL_SYSERR); } if (WIFSIGNALED(status)) { - mandoc_vmsg(MANDOCERR_SYSSIG, curp, 0, 0, - "%d", WTERMSIG(status)); - curp->file_status = MANDOCLEVEL_SYSERR; - return(curp->file_status); + mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0, + "gunzip died from signal %d", WTERMSIG(status)); + return(MANDOCLEVEL_ERROR); } if (WEXITSTATUS(status)) { - mandoc_vmsg(MANDOCERR_SYSEXIT, curp, 0, 0, - "%d", WEXITSTATUS(status)); - curp->file_status = MANDOCLEVEL_SYSERR; - return(curp->file_status); + mandoc_vmsg(MANDOCERR_FILE, curp, 0, 0, + "gunzip failed with code %d", WEXITSTATUS(status)); + return(MANDOCLEVEL_ERROR); } return(MANDOCLEVEL_OK); } @@ -987,7 +970,7 @@ mandoc_msg(enum mandocerr er, struct mparse *m, while (er < mandoclimits[level]) level--; - if (level < m->wlevel) + if (level < m->wlevel && er != MANDOCERR_FILE) return; if (m->mmsg) |