From: Ingo Schwarze Date: Wed, 25 Jun 2014 00:20:19 +0000 (+0000) Subject: Improve messages related to the roff(7) .so request. X-Git-Tag: VERSION_1_13_1~134 X-Git-Url: https://git.cameronkatri.com/mandoc.git/commitdiff_plain/0b6903db7750adfcd88f388a0196037f91e474c6?ds=sidebyside 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. --- diff --git a/mandoc.h b/mandoc.h index 3f4ea86a..2b9e8f56 100644 --- a/mandoc.h +++ b/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.122 2014/06/20 23:02:31 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.123 2014/06/25 00:20:19 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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/read.c b/read.c index 22446046..c4edcc32 100644 --- a/read.c +++ b/read.c @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.51 2014/06/21 22:24:01 schwarze Exp $ */ +/* $Id: read.c,v 1.52 2014/06/25 00:20:19 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -206,6 +206,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", @@ -506,8 +507,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/roff.c b/roff.c index 07480a12..46ed2d7c 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.209 2014/04/23 16:08:33 schwarze Exp $ */ +/* $Id: roff.c,v 1.210 2014/06/25 00:20:19 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1938,7 +1938,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 @@ -1947,9 +1948,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); }