diff options
-rw-r--r-- | libmandoc.h | 3 | ||||
-rw-r--r-- | mandoc.h | 2 | ||||
-rw-r--r-- | read.c | 5 | ||||
-rw-r--r-- | roff.c | 9 |
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 { @@ -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 @@ -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')) { @@ -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; |