]> git.cameronkatri.com Git - mandoc.git/blobdiff - read.c
Improve messages related to the roff(7) .so request.
[mandoc.git] / read.c
diff --git a/read.c b/read.c
index 1548c9a00c741e7f0eca4222f87c774edfd0f26f..c4edcc3252930949f01813bd177e83a0b6b1ded0 100644 (file)
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/*     $Id: read.c,v 1.47 2014/04/20 16:46:05 schwarze Exp $ */
+/*     $Id: read.c,v 1.52 2014/06/25 00:20:19 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -93,7 +93,7 @@ static        const char * const      mandocerrs[MANDOCERR_MAX] = {
        "generic warning",
 
        /* related to the prologue */
-       "no title in document",
+       "no TH macro in document",
        "document title should be all caps",
        "unknown manual section",
        "unknown manual volume or arch",
@@ -106,6 +106,8 @@ static      const char * const      mandocerrs[MANDOCERR_MAX] = {
 
        /* related to document structure */
        ".so is fragile, better use ln(1)",
+       "no document body",
+       "content before the first section header",
        "NAME section must come first",
        "bad NAME section contents",
        "sections out of conventional order",
@@ -204,12 +206,12 @@ static    const char * const      mandocerrs[MANDOCERR_MAX] = {
        "child violates parent syntax",
        "argument count wrong, violates syntax",
        "NOT IMPLEMENTED: .so with absolute path or \"..\"",
-       "no document body",
+       ".so request failed",
        "no document prologue",
        "static buffer exhausted",
 
        /* system errors */
-       "cannot open file",
+       NULL,
        "cannot stat file",
        "cannot read file",
 };
@@ -505,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:
@@ -684,7 +690,7 @@ mparse_end(struct mparse *curp)
        }
 
        if ( ! (curp->mdoc || curp->man || curp->sodest)) {
-               mandoc_msg(MANDOCERR_NOTMANUAL, curp, 1, 0, NULL);
+               mandoc_msg(MANDOCERR_NOTMANUAL, curp, 0, 0, NULL);
                curp->file_status = MANDOCLEVEL_FATAL;
                return;
        }
@@ -852,7 +858,7 @@ mandoc_vmsg(enum mandocerr t, struct mparse *m,
        va_list          ap;
 
        va_start(ap, fmt);
-       vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+       (void)vsnprintf(buf, sizeof(buf), fmt, ap);
        va_end(ap);
 
        mandoc_msg(t, m, ln, pos, buf);