summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmandoc.h3
-rw-r--r--mandoc.h2
-rw-r--r--read.c5
-rw-r--r--roff.c9
4 files changed, 10 insertions, 9 deletions
diff --git a/libmandoc.h b/libmandoc.h
index 71b9bb3f..0121b6da 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -24,8 +24,7 @@ enum rofferr {
ROFF_SO, /* include another file */
ROFF_IGN, /* ignore current line */
ROFF_TBL, /* a table row was successfully parsed */
- ROFF_EQN, /* an equation was successfully parsed */
- ROFF_ERR /* badness: puke and stop */
+ ROFF_EQN /* an equation was successfully parsed */
};
struct buf {
diff --git a/mandoc.h b/mandoc.h
index 20a3722f..060346d8 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -166,6 +166,7 @@ enum mandocerr {
MANDOCERR_OS_UNAME, /* uname(3) system call failed, using UNKNOWN */
MANDOCERR_ST_BAD, /* unknown standard specifier: St standard */
MANDOCERR_IT_NONUM, /* skipping request without numeric argument */
+ MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
MANDOCERR_ARG_SKIP, /* skipping all arguments: macro args */
MANDOCERR_ARG_EXCESS, /* skipping excess arguments: macro ... args */
MANDOCERR_DIVZERO, /* divide by zero */
@@ -173,7 +174,6 @@ enum mandocerr {
MANDOCERR_FATAL, /* ===== start of fatal errors ===== */
MANDOCERR_TOOLARGE, /* input too large */
- MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
MANDOCERR_SO_FAIL, /* .so request failed */
MANDOCERR_MAX
diff --git a/read.c b/read.c
index cf2d2bf8..00c7d699 100644
--- a/read.c
+++ b/read.c
@@ -210,6 +210,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"uname(3) system call failed, using UNKNOWN",
"unknown standard specifier",
"skipping request without numeric argument",
+ "NOT IMPLEMENTED: .so with absolute path or \"..\"",
"skipping all arguments",
"skipping excess arguments",
"divide by zero",
@@ -217,7 +218,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"generic fatal error",
"input too large",
- "NOT IMPLEMENTED: .so with absolute path or \"..\"",
".so request failed",
};
@@ -504,9 +504,6 @@ rerun:
case ROFF_IGN:
pos = 0;
continue;
- case ROFF_ERR:
- assert(MANDOCLEVEL_FATAL <= curp->file_status);
- break;
case ROFF_SO:
if ( ! (curp->options & MPARSE_SO) &&
(i >= blk.sz || blk.buf[i] == '\0')) {
diff --git a/roff.c b/roff.c
index d0ddc4a3..1b106da8 100644
--- a/roff.c
+++ b/roff.c
@@ -2103,7 +2103,7 @@ roff_tr(ROFF_ARGS)
static enum rofferr
roff_so(ROFF_ARGS)
{
- char *name;
+ char *name, *cp;
name = buf->buf + pos;
mandoc_vmsg(MANDOCERR_SO, r->parse, ln, ppos, "so %s", name);
@@ -2118,7 +2118,12 @@ roff_so(ROFF_ARGS)
if (*name == '/' || strstr(name, "../") || strstr(name, "/..")) {
mandoc_vmsg(MANDOCERR_SO_PATH, r->parse, ln, ppos,
".so %s", name);
- return(ROFF_ERR);
+ buf->sz = mandoc_asprintf(&cp,
+ ".sp\nSee the file %s.\n.sp", name) + 1;
+ free(buf->buf);
+ buf->buf = cp;
+ *offs = 0;
+ return(ROFF_REPARSE);
}
*offs = pos;