summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-06-25 00:19:18 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-06-25 00:19:18 +0000
commitd52fe454632770eb4b02fdc9ff8c0528272af2e3 (patch)
tree03b9d60194192acd04895a7f4bfbae6e01935884
parent5785e0e8d5d1d9a3c9581b25fbe2a95ac2b72cb9 (diff)
Improve messages related to the roff(7) .so request.
In all these messages, show the filename argument that was passed to the .so request. In case of failure, show an additional message reporting the file and the line number where the failing request was found. The existing message reporting the reason for the failure - for example, "Permission denied" - is left in place, unchanged. Inspired by a question asked by Nick@ after he saw the confusing old messages that used to be emitted in this area.
-rw-r--r--usr.bin/mandoc/mandoc.h5
-rw-r--r--usr.bin/mandoc/read.c9
-rw-r--r--usr.bin/mandoc/roff.c9
3 files changed, 15 insertions, 8 deletions
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index ac1669dd460..b131b10d92f 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.66 2014/06/20 22:58:41 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.67 2014/06/25 00:19:17 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -162,7 +162,8 @@ enum mandocerr {
MANDOCERR_SYNTARGVCOUNT, /* argument count wrong, violates syntax */
MANDOCERR_SYNTCHILD, /* child violates parent syntax */
MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */
- MANDOCERR_SOPATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
+ MANDOCERR_SO_PATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */
+ MANDOCERR_SO_FAIL, /* .so request failed */
MANDOCERR_NODOCPROLOG, /* no document prologue */
MANDOCERR_MEM, /* static buffer exhausted */
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 8046676a225..4995a837b2f 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.29 2014/06/21 22:23:44 schwarze Exp $ */
+/* $Id: read.c,v 1.30 2014/06/25 00:19:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -198,6 +198,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"child violates parent syntax",
"argument count wrong, violates syntax",
"NOT IMPLEMENTED: .so with absolute path or \"..\"",
+ ".so request failed",
"no document prologue",
"static buffer exhausted",
@@ -498,8 +499,12 @@ rerun:
if (curp->secondary)
curp->secondary->sz -= pos + 1;
mparse_readfd(curp, -1, ln.buf + of);
- if (MANDOCLEVEL_FATAL <= curp->file_status)
+ if (MANDOCLEVEL_FATAL <= curp->file_status) {
+ mandoc_vmsg(MANDOCERR_SO_FAIL,
+ curp, curp->line, pos,
+ ".so %s", ln.buf + of);
break;
+ }
pos = 0;
continue;
default:
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 41859f35644..a404623bf6e 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.82 2014/04/23 16:07:06 schwarze Exp $ */
+/* $Id: roff.c,v 1.83 2014/06/25 00:19:17 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -1934,7 +1934,8 @@ roff_so(ROFF_ARGS)
{
char *name;
- mandoc_msg(MANDOCERR_SO, r->parse, ln, ppos, NULL);
+ name = *bufp + pos;
+ mandoc_vmsg(MANDOCERR_SO, r->parse, ln, ppos, ".so %s", name);
/*
* Handle `so'. Be EXTREMELY careful, as we shouldn't be
@@ -1943,9 +1944,9 @@ roff_so(ROFF_ARGS)
* or using absolute paths.
*/
- name = *bufp + pos;
if ('/' == *name || strstr(name, "../") || strstr(name, "/..")) {
- mandoc_msg(MANDOCERR_SOPATH, r->parse, ln, pos, NULL);
+ mandoc_vmsg(MANDOCERR_SO_PATH, r->parse, ln, ppos,
+ ".so %s", name);
return(ROFF_ERR);
}