diff options
-rw-r--r-- | main.c | 10 | ||||
-rw-r--r-- | man.h | 1 | ||||
-rw-r--r-- | man_term.c | 9 | ||||
-rw-r--r-- | man_validate.c | 10 | ||||
-rw-r--r-- | mandoc.1 | 12 | ||||
-rw-r--r-- | mandoc.h | 3 | ||||
-rw-r--r-- | mdoc_validate.c | 22 | ||||
-rw-r--r-- | read.c | 5 |
8 files changed, 42 insertions, 30 deletions
@@ -408,9 +408,13 @@ mmsg(enum mandocerr t, enum mandoclevel lvl, const char *file, int line, int col, const char *msg) { - fprintf(stderr, "%s: %s:%d:%d: %s: %s", progname, - file, line, col + 1, - mparse_strlevel(lvl), mparse_strerror(t)); + fprintf(stderr, "%s: %s:", progname, file); + + if (line) + fprintf(stderr, "%d:%d:", line, col + 1); + + fprintf(stderr, " %s: %s", mparse_strlevel(lvl), + mparse_strerror(t)); if (msg) fprintf(stderr, ": %s", msg); @@ -79,6 +79,7 @@ struct man_meta { char *vol; /* `TH' volume */ char *title; /* `TH' title (e.g., FOO) */ char *source; /* `TH' source (e.g., GNU) */ + int hasbody; /* document is not empty */ }; struct man_node { @@ -1061,7 +1061,8 @@ print_man_foot(struct termp *p, const void *arg) term_fontrepl(p, TERMFONT_NONE); - term_vspace(p); + if (meta->hasbody) + term_vspace(p); /* * Temporary, undocumented option to imitate mdoc(7) output. @@ -1070,8 +1071,10 @@ print_man_foot(struct termp *p, const void *arg) */ if ( ! p->mdocstyle) { - term_vspace(p); - term_vspace(p); + if (meta->hasbody) { + term_vspace(p); + term_vspace(p); + } mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec); } else if (meta->source) { diff --git a/man_validate.c b/man_validate.c index 0088e6f8..6ebf6cea 100644 --- a/man_validate.c +++ b/man_validate.c @@ -198,10 +198,12 @@ check_root(CHKARGS) man->flags &= ~MAN_BLINE; man->flags &= ~MAN_ELINE; - if (NULL == man->first->child) { - man_nmsg(man, n, MANDOCERR_NODOCBODY); - return(0); - } else if (NULL == man->meta.title) { + if (NULL == man->first->child) + man_nmsg(man, n, MANDOCERR_DOC_EMPTY); + else + man->meta.hasbody = 1; + + if (NULL == man->meta.title) { man_nmsg(man, n, MANDOCERR_TH_MISSING); /* @@ -498,9 +498,7 @@ parser: .Sh DIAGNOSTICS Standard error messages reporting parsing errors are prefixed by .Pp -.Sm off -.D1 Ar file : line : column : \ level : -.Sm on +.D1 Nm Ns : Ar file : Ns Ar line : Ns Ar column : level : .Pp where the fields have the following meanings: .Bl -tag -width "column" @@ -518,6 +516,12 @@ points to the first character of the word. The message level, printed in capital letters. .El .Pp +The +.Ar line +and +.Ar column +fields are omitted when meaningless. +.Pp Message levels have the following meanings: .Bl -tag -width "warning" .It Cm fatal @@ -557,7 +561,7 @@ The utility may also print messages related to invalid command line arguments or operating system errors, for example when memory is exhausted or input files cannot be read. -Such messages do not carry the prefix described above. +Such messages may not carry the prefix described above. .Sh COMPATIBILITY This section summarises .Nm @@ -62,6 +62,8 @@ enum mandocerr { /* related to document structure */ MANDOCERR_SO, /* .so is fragile, better use ln(1) */ + MANDOCERR_DOC_EMPTY, /* no document body */ + MANDOCERR_SEC_BEFORE, /* content before the first section header */ MANDOCERR_NAMESECFIRST, /* NAME section must come first */ MANDOCERR_BADNAMESEC, /* bad NAME section contents */ MANDOCERR_SECOOO, /* sections out of conventional order */ @@ -161,7 +163,6 @@ enum mandocerr { MANDOCERR_SYNTCHILD, /* child violates parent syntax */ MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */ MANDOCERR_SOPATH, /* NOT IMPLEMENTED: .so with absolute path or ".." */ - MANDOCERR_NODOCBODY, /* no document body */ MANDOCERR_NODOCPROLOG, /* no document prologue */ MANDOCERR_MEM, /* static buffer exhausted */ diff --git a/mdoc_validate.c b/mdoc_validate.c index 0078f8cc..d62dc6cf 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1645,15 +1645,15 @@ ebool(struct mdoc *mdoc) static int post_root(POST_ARGS) { - int erc; + int ret; struct mdoc_node *n; - erc = 0; + ret = 1; /* Check that we have a finished prologue. */ if ( ! (MDOC_PBODY & mdoc->flags)) { - erc++; + ret = 0; mdoc_nmsg(mdoc, mdoc->first, MANDOCERR_NODOCPROLOG); } @@ -1662,17 +1662,13 @@ post_root(POST_ARGS) /* Check that we begin with a proper `Sh'. */ - if (NULL == n->child) { - erc++; - mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY); - } else if (MDOC_BLOCK != n->child->type || - MDOC_Sh != n->child->tok) { - erc++; - /* Can this be lifted? See rxdebug.1 for example. */ - mdoc_nmsg(mdoc, n, MANDOCERR_NODOCBODY); - } + if (NULL == n->child) + mdoc_nmsg(mdoc, n, MANDOCERR_DOC_EMPTY); + else if (MDOC_BLOCK != n->child->type || + MDOC_Sh != n->child->tok) + mdoc_nmsg(mdoc, n->child, MANDOCERR_SEC_BEFORE); - return(erc ? 0 : 1); + return(ret); } static int @@ -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,7 +206,6 @@ 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", "no document prologue", "static buffer exhausted", @@ -684,7 +685,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; } |