From: schwarze Date: Wed, 14 Jan 2015 22:57:57 +0000 (+0000) Subject: downgrade ".so with absolute path" from FATAL to ERROR; X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f8fd269e4cc1929a206ea8ff0b25e3179aa3a93f;p=openbsd downgrade ".so with absolute path" from FATAL to ERROR; allows to get rid of ROFF_ERR --- diff --git a/usr.bin/mandoc/libmandoc.h b/usr.bin/mandoc/libmandoc.h index 0d259a9e6ff..84a55c31bc3 100644 --- a/usr.bin/mandoc/libmandoc.h +++ b/usr.bin/mandoc/libmandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libmandoc.h,v 1.39 2014/12/28 14:39:08 schwarze Exp $ */ +/* $OpenBSD: libmandoc.h,v 1.40 2015/01/14 22:57:57 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2013, 2014 Ingo Schwarze @@ -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/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 99523a2b0ac..6b5f83b18ca 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.h,v 1.121 2015/01/14 22:02:00 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.122 2015/01/14 22:57:57 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index c96382d5ba3..a300cb82773 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.83 2015/01/14 22:02:00 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.84 2015/01/14 22:57:57 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -205,6 +205,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", @@ -212,7 +213,6 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "generic fatal error", "input too large", - "NOT IMPLEMENTED: .so with absolute path or \"..\"", ".so request failed", }; @@ -499,9 +499,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/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 356326e5316..bb9db497599 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.120 2015/01/07 12:19:17 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.121 2015/01/14 22:57:57 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -2101,7 +2101,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); @@ -2116,7 +2116,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;