diff options
-rw-r--r-- | libmdoc.h | 11 | ||||
-rw-r--r-- | main.c | 26 | ||||
-rw-r--r-- | mdoc.7 | 4 | ||||
-rw-r--r-- | mdoc.c | 21 | ||||
-rw-r--r-- | mdoc.h | 9 | ||||
-rw-r--r-- | mdoc_action.c | 7 | ||||
-rw-r--r-- | mdoc_argv.c | 9 | ||||
-rw-r--r-- | mdoc_macro.c | 4 | ||||
-rw-r--r-- | mdoc_validate.c | 16 |
9 files changed, 35 insertions, 72 deletions
@@ -64,16 +64,13 @@ __BEGIN_DECLS * When GCC2 is deprecated, most of these can be reverted to #define * as mdoc_vXXX using __VA_ARGS__. Until then, use real functions. */ -int mdoc_vwarn(struct mdoc *, int, int, - enum mdoc_warn, const char *, ...); -int mdoc_verr(struct mdoc *, int, int, - const char *, ...); +int mdoc_vwarn(struct mdoc *, int, int, const char *, ...); +int mdoc_verr(struct mdoc *, int, int, const char *, ...); int mdoc_nerr(struct mdoc *, const struct mdoc_node *, const char *, ...); -int mdoc_warn(struct mdoc *, enum mdoc_warn, const char *, ...); +int mdoc_warn(struct mdoc *, const char *, ...); int mdoc_err(struct mdoc *, const char *, ...); -int mdoc_pwarn(struct mdoc *, int, int, - enum mdoc_warn,const char *, ...); +int mdoc_pwarn(struct mdoc *, int, int, const char *, ...); int mdoc_perr(struct mdoc *, int, int, const char *, ...); int mdoc_macro(MACRO_PROT_ARGS); int mdoc_word_alloc(struct mdoc *, @@ -99,8 +99,7 @@ static int moptions(enum intt *, char *); static int woptions(int *, char *); static int merr(void *, int, int, const char *); static int manwarn(void *, int, int, const char *); -static int mdocwarn(void *, int, int, - enum mdoc_warn, const char *); +static int mdocwarn(void *, int, int, const char *); static int ffile(struct buf *, struct buf *, const char *, struct curparse *); static int fdesc(struct buf *, struct buf *, @@ -645,31 +644,14 @@ merr(void *arg, int line, int col, const char *msg) static int -mdocwarn(void *arg, int line, int col, - enum mdoc_warn type, const char *msg) +mdocwarn(void *arg, int line, int col, const char *msg) { struct curparse *curp; - char *wtype; curp = (struct curparse *)arg; - wtype = NULL; - switch (type) { - case (WARN_COMPAT): - wtype = "compat"; - if (curp->wflags & WARN_WCOMPAT) - break; - return(1); - case (WARN_SYNTAX): - wtype = "syntax"; - if (curp->wflags & WARN_WSYNTAX) - break; - return(1); - } - - assert(wtype); - warnx("%s:%d: %s warning: %s (column %d)", - curp->file, line, wtype, msg, col); + warnx("%s:%d: warning: %s (column %d)", + curp->file, line, msg, col); if ( ! (curp->wflags & WARN_WERR)) return(1); @@ -663,4 +663,8 @@ blocks. The \-split and \-nosplit arguments to .Sq \&.An are inane. +.\" LIST-ITEM +.It +The end-of-line whitespace warnings are superfluous holdovers from +historic groff. .El @@ -264,8 +264,7 @@ mdoc_verr(struct mdoc *mdoc, int ln, int pos, int -mdoc_vwarn(struct mdoc *mdoc, int ln, int pos, - enum mdoc_warn type, const char *fmt, ...) +mdoc_vwarn(struct mdoc *mdoc, int ln, int pos, const char *fmt, ...) { char buf[256]; va_list ap; @@ -276,7 +275,7 @@ mdoc_vwarn(struct mdoc *mdoc, int ln, int pos, va_start(ap, fmt); (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); va_end(ap); - return((*mdoc->cb.mdoc_warn)(mdoc->data, ln, pos, type, buf)); + return((*mdoc->cb.mdoc_warn)(mdoc->data, ln, pos, buf)); } @@ -299,8 +298,7 @@ mdoc_nerr(struct mdoc *mdoc, const struct mdoc_node *node, int -mdoc_warn(struct mdoc *mdoc, enum mdoc_warn type, - const char *fmt, ...) +mdoc_warn(struct mdoc *mdoc, const char *fmt, ...) { char buf[256]; va_list ap; @@ -311,8 +309,8 @@ mdoc_warn(struct mdoc *mdoc, enum mdoc_warn type, va_start(ap, fmt); (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); va_end(ap); - return((*mdoc->cb.mdoc_warn)(mdoc->data, mdoc->last->line, - mdoc->last->pos, type, buf)); + return((*mdoc->cb.mdoc_warn)(mdoc->data, mdoc->last->line, + mdoc->last->pos, buf)); } @@ -334,8 +332,7 @@ mdoc_err(struct mdoc *mdoc, const char *fmt, ...) int -mdoc_pwarn(struct mdoc *mdoc, int line, int pos, enum mdoc_warn type, - const char *fmt, ...) +mdoc_pwarn(struct mdoc *mdoc, int line, int pos, const char *fmt, ...) { char buf[256]; va_list ap; @@ -346,8 +343,7 @@ mdoc_pwarn(struct mdoc *mdoc, int line, int pos, enum mdoc_warn type, va_start(ap, fmt); (void)vsnprintf(buf, sizeof(buf) - 1, fmt, ap); va_end(ap); - return((*mdoc->cb.mdoc_warn)(mdoc->data, - line, pos, type, buf)); + return((*mdoc->cb.mdoc_warn)(mdoc->data, line, pos, buf)); } int @@ -652,8 +648,7 @@ macrowarn(struct mdoc *m, int ln, const char *buf) return(mdoc_perr(m, ln, 1, "unknown macro: %s%s", buf, strlen(buf) > 3 ? "..." : "")); - return(mdoc_pwarn(m, ln, 1, WARN_SYNTAX, - "unknown macro: %s%s", + return(mdoc_pwarn(m, ln, 1, "unknown macro: %s%s", buf, strlen(buf) > 3 ? "..." : "")); } @@ -179,12 +179,6 @@ #define MDOC_Nested 25 #define MDOC_ARG_MAX 26 -/* Warnings are either syntax or groff-compatibility. */ -enum mdoc_warn { - WARN_SYNTAX, - WARN_COMPAT -}; - /* Type of a syntax node. */ enum mdoc_type { MDOC_TEXT, @@ -279,8 +273,7 @@ struct mdoc_node { /* FIXME: unify somehow with man_cb. */ struct mdoc_cb { int (*mdoc_err)(void *, int, int, const char *); - int (*mdoc_warn)(void *, int, int, - enum mdoc_warn, const char *); + int (*mdoc_warn)(void *, int, int, const char *); }; /* See mdoc.3 for documentation. */ diff --git a/mdoc_action.c b/mdoc_action.c index 23df587f..f6ad9a4d 100644 --- a/mdoc_action.c +++ b/mdoc_action.c @@ -289,14 +289,12 @@ static int pwarn(struct mdoc *m, int line, int pos, enum mwarn type) { char *p; - int c; p = NULL; - c = WARN_SYNTAX; + switch (type) { case (WBADSEC): p = "inappropriate document section in manual section"; - c = WARN_COMPAT; break; case (WNOWIDTH): p = "cannot determine default width"; @@ -305,8 +303,9 @@ pwarn(struct mdoc *m, int line, int pos, enum mwarn type) p = "malformed date syntax"; break; } + assert(p); - return(mdoc_pwarn(m, line, pos, c, p)); + return(mdoc_pwarn(m, line, pos, p)); } diff --git a/mdoc_argv.c b/mdoc_argv.c index 1d8cbcd3..40a1e38c 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -369,6 +369,7 @@ perr(struct mdoc *mdoc, int line, int pos, enum merr code) p = "argument requires a value"; break; } + assert(p); return(mdoc_perr(mdoc, line, pos, p)); } @@ -378,10 +379,9 @@ static int pwarn(struct mdoc *mdoc, int line, int pos, enum mwarn code) { char *p; - int c; p = NULL; - c = WARN_SYNTAX; + switch (code) { case (WQUOTPARM): p = "unexpected quoted parameter"; @@ -391,15 +391,14 @@ pwarn(struct mdoc *mdoc, int line, int pos, enum mwarn code) break; case (WCOLEMPTY): p = "last list column is empty"; - c = WARN_COMPAT; break; case (WTAILWS): p = "trailing whitespace"; - c = WARN_COMPAT; break; } + assert(p); - return(mdoc_pwarn(mdoc, line, pos, c, p)); + return(mdoc_pwarn(mdoc, line, pos, p)); } diff --git a/mdoc_macro.c b/mdoc_macro.c index d7c3e35c..857c4bce 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -241,7 +241,7 @@ pwarn(struct mdoc *mdoc, int line, int pos, enum mwarn type) break; } assert(p); - return(mdoc_pwarn(mdoc, line, pos, WARN_SYNTAX, p)); + return(mdoc_pwarn(mdoc, line, pos, p)); } @@ -286,7 +286,7 @@ swarn(struct mdoc *mdoc, enum mdoc_type type, return(mdoc_perr(mdoc, line, pos, "%s scope breaks %s scope of %s", tt, t, n)); - return(mdoc_pwarn(mdoc, line, pos, WARN_SYNTAX, + return(mdoc_pwarn(mdoc, line, pos, "%s scope breaks %s scope of %s", tt, t, n)); } diff --git a/mdoc_validate.c b/mdoc_validate.c index 9fd8a302..b1ea9f00 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -444,30 +444,24 @@ static int pwarn(struct mdoc *m, int line, int pos, enum mwarn type) { char *p; - enum mdoc_warn c; - c = WARN_SYNTAX; p = NULL; + switch (type) { case (WBADMSEC): p = "inappropriate manual section"; - c = WARN_COMPAT; break; case (WBADSEC): p = "inappropriate document section"; - c = WARN_COMPAT; break; case (WARGVAL): p = "argument value suggested"; - c = WARN_COMPAT; break; case (WPROLREP): p = "prologue macros repeated"; - c = WARN_COMPAT; break; case (WPROLOOO): p = "prologue macros out-of-order"; - c = WARN_COMPAT; break; case (WNOWIDTH): p = "superfluous width argument"; @@ -495,7 +489,6 @@ pwarn(struct mdoc *m, int line, int pos, enum mwarn type) break; case (WWRONGMSEC): p = "document section in wrong manual section"; - c = WARN_COMPAT; break; case (WSECOOO): p = "document section out of conventional order"; @@ -510,8 +503,9 @@ pwarn(struct mdoc *m, int line, int pos, enum mwarn type) p = "NAME section contents incomplete/badly-ordered"; break; } + assert(p); - return(mdoc_pwarn(m, line, pos, c, p)); + return(mdoc_pwarn(m, line, pos, p)); } @@ -529,8 +523,8 @@ warn_count(struct mdoc *m, const char *k, int want, const char *v, int has) { - return(mdoc_warn(m, WARN_SYNTAX, - "suggests %s %s %d (has %d)", v, k, want, has)); + return(mdoc_warn(m, "suggests %s %s %d (has %d)", + v, k, want, has)); } |