aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/read.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-15 02:29:26 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-15 02:29:26 +0000
commit8b5853de9633ceece63738b2ccd5bdba06098315 (patch)
tree08c67de71f688503bb58a75a4c50fcb19e44145e /read.c
parente402ce0a4d1def17586b4c8b5d769063e5e841b9 (diff)
downloadmandoc-8b5853de9633ceece63738b2ccd5bdba06098315.tar.gz
mandoc-8b5853de9633ceece63738b2ccd5bdba06098315.tar.zst
mandoc-8b5853de9633ceece63738b2ccd5bdba06098315.zip
downgrade .so failure from FATAL to ERROR
Diffstat (limited to 'read.c')
-rw-r--r--read.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/read.c b/read.c
index 821ca89e..db19ab08 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.109 2015/01/14 22:58:16 schwarze Exp $ */
+/* $Id: read.c,v 1.110 2015/01/15 02:29:26 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -211,6 +211,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"unknown standard specifier",
"skipping request without numeric argument",
"NOT IMPLEMENTED: .so with absolute path or \"..\"",
+ ".so request failed",
"skipping all arguments",
"skipping excess arguments",
"divide by zero",
@@ -218,7 +219,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"generic fatal error",
"input too large",
- ".so request failed",
};
static const char * const mandoclevels[MANDOCLEVEL_MAX] = {
@@ -306,10 +306,13 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start)
{
const struct tbl_span *span;
struct buf ln;
+ char *cp;
size_t pos; /* byte number in the ln buffer */
enum rofferr rr;
int of;
int lnn; /* line number in the real file */
+ int fd;
+ pid_t save_child;
unsigned char c;
memset(&ln, 0, sizeof(ln));
@@ -518,13 +521,23 @@ rerun:
*/
if (curp->secondary)
curp->secondary->sz -= pos + 1;
- mparse_readfd(curp, -1, ln.buf + of);
- if (MANDOCLEVEL_FATAL <= curp->file_status) {
+ save_child = curp->child;
+ if (mparse_open(curp, &fd, ln.buf + of) ==
+ MANDOCLEVEL_OK)
+ mparse_readfd(curp, fd, ln.buf + of);
+ else {
mandoc_vmsg(MANDOCERR_SO_FAIL,
curp, curp->line, pos,
".so %s", ln.buf + of);
- break;
+ ln.sz = mandoc_asprintf(&cp,
+ ".sp\nSee the file %s.\n.sp",
+ ln.buf + of);
+ free(ln.buf);
+ ln.buf = cp;
+ of = 0;
+ mparse_buf_r(curp, ln, of, 0);
}
+ curp->child = save_child;
pos = 0;
continue;
default:
@@ -750,8 +763,6 @@ mparse_readmem(struct mparse *curp, void *buf, size_t len,
}
/*
- * If a file descriptor is given, use it and assume it points
- * to the named file. Otherwise, open the named file.
* Read the whole file into memory and call the parsers.
* Called recursively when an .so request is encountered.
*/
@@ -761,13 +772,6 @@ mparse_readfd(struct mparse *curp, int fd, const char *file)
struct buf blk;
int with_mmap;
int save_filenc;
- pid_t save_child;
-
- save_child = curp->child;
- if (fd != -1)
- curp->child = 0;
- else if (mparse_open(curp, &fd, file) != MANDOCLEVEL_OK)
- goto out;
if (read_whole_file(curp, file, fd, &blk, &with_mmap)) {
save_filenc = curp->filenc;
@@ -787,8 +791,6 @@ mparse_readfd(struct mparse *curp, int fd, const char *file)
perror(file);
mparse_wait(curp);
-out:
- curp->child = save_child;
return(curp->file_status);
}