diff options
-rw-r--r-- | mandoc.1 | 12 | ||||
-rw-r--r-- | mandoc.h | 2 | ||||
-rw-r--r-- | mdoc_validate.c | 14 | ||||
-rw-r--r-- | read.c | 3 | ||||
-rw-r--r-- | regress/mdoc/Tn/noarg.out_lint | 1 | ||||
-rw-r--r-- | regress/mdoc/Ud/arg.out_lint | 6 | ||||
-rwxr-xr-x | regress/regress.pl | 4 |
7 files changed, 39 insertions, 3 deletions
@@ -742,6 +742,18 @@ are hidden unless their level, or a lower level, is requested using a option or .Fl T Cm lint output mode. +.Ss Style messages +.Bl -ohang +.It Sy "useless macro" +.Pq mdoc +A +.Ic \&Bt , +.Ic \&Tn , +or +.Ic \Ud +macro was found. +Simply delete it, it serves no useful purpose. +.El .Ss Warnings related to the document prologue .Bl -ohang .It Sy "missing manual title, using UNTITLED" @@ -46,6 +46,8 @@ enum mandocerr { MANDOCERR_STYLE, /* ===== start of style suggestions ===== */ + MANDOCERR_MACRO_USELESS, /* useless macro: macro */ + MANDOCERR_WARNING, /* ===== start of warnings ===== */ /* related to the prologue */ diff --git a/mdoc_validate.c b/mdoc_validate.c index 04877d3e..a4b01c97 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -105,6 +105,7 @@ static void post_sh_authors(POST_ARGS); static void post_sm(POST_ARGS); static void post_st(POST_ARGS); static void post_std(POST_ARGS); +static void post_useless(POST_ARGS); static void post_xr(POST_ARGS); static void post_xx(POST_ARGS); @@ -201,7 +202,7 @@ static const v_post __mdoc_valids[MDOC_MAX - MDOC_Dd] = { post_sm, /* Sm */ post_hyph, /* Sx */ NULL, /* Sy */ - NULL, /* Tn */ + post_useless, /* Tn */ post_xx, /* Ux */ NULL, /* Xc */ NULL, /* Xo */ @@ -671,6 +672,7 @@ post_eoln(POST_ARGS) { struct roff_node *n; + post_useless(mdoc); n = mdoc->last; if (n->child != NULL) mandoc_vmsg(MANDOCERR_ARG_SKIP, mdoc->parse, n->line, @@ -866,6 +868,16 @@ post_obsolete(POST_ARGS) n->line, n->pos, roff_name[n->tok]); } +static void +post_useless(POST_ARGS) +{ + struct roff_node *n; + + n = mdoc->last; + mandoc_msg(MANDOCERR_MACRO_USELESS, mdoc->parse, + n->line, n->pos, roff_name[n->tok]); +} + /* * Block macros. */ @@ -87,6 +87,9 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "ok", "generic style suggestion", + + "useless macro", + "generic warning", /* related to the prologue */ diff --git a/regress/mdoc/Tn/noarg.out_lint b/regress/mdoc/Tn/noarg.out_lint index 74e0b6fc..340a3502 100644 --- a/regress/mdoc/Tn/noarg.out_lint +++ b/regress/mdoc/Tn/noarg.out_lint @@ -1 +1,2 @@ mandoc: noarg.in:11:2: WARNING: skipping empty macro: Tn +mandoc: noarg.in:9:2: STYLE: useless macro: Tn diff --git a/regress/mdoc/Ud/arg.out_lint b/regress/mdoc/Ud/arg.out_lint index 854845cd..eac1710f 100644 --- a/regress/mdoc/Ud/arg.out_lint +++ b/regress/mdoc/Ud/arg.out_lint @@ -1,4 +1,10 @@ +mandoc: arg.in:9:2: STYLE: useless macro: Ud +mandoc: arg.in:11:2: STYLE: useless macro: Bt +mandoc: arg.in:15:2: STYLE: useless macro: Ud mandoc: arg.in:15:2: ERROR: skipping all arguments: Ud bar +mandoc: arg.in:16:2: STYLE: useless macro: Bt mandoc: arg.in:16:2: ERROR: skipping all arguments: Bt foo +mandoc: arg.in:17:2: STYLE: useless macro: Ud mandoc: arg.in:17:2: ERROR: skipping all arguments: Ud one +mandoc: arg.in:18:2: STYLE: useless macro: Bt mandoc: arg.in:18:2: ERROR: skipping all arguments: Bt one diff --git a/regress/regress.pl b/regress/regress.pl index ce384b52..3d06556b 100755 --- a/regress/regress.pl +++ b/regress/regress.pl @@ -341,8 +341,8 @@ for my $testname (@lint_testnames) { if ($targets{lint}) { $count_lint++; $count_total++; - print "@mandoc -T lint $i\n" if $targets{verbose}; - syslint $o, @mandoc, qw(-T lint), $i + print "@mandoc -T lint -W all $i\n" if $targets{verbose}; + syslint $o, @mandoc, qw(-T lint -W all), $i and fail $subdir, $testname, 'lint:mandoc'; system @diff, $w, $o and fail $subdir, $testname, 'lint:diff'; |