diff options
-rw-r--r-- | mandoc.1 | 16 | ||||
-rw-r--r-- | mandoc.h | 4 | ||||
-rw-r--r-- | mdoc_validate.c | 16 | ||||
-rw-r--r-- | read.c | 5 | ||||
-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 | 6 |
7 files changed, 45 insertions, 9 deletions
@@ -1,4 +1,4 @@ -.\" $Id: mandoc.1,v 1.188 2017/05/17 23:39:31 schwarze Exp $ +.\" $Id: mandoc.1,v 1.189 2017/05/30 19:30:38 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 17 2017 $ +.Dd $Mdocdate: May 30 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -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" @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.216 2017/05/16 19:06:30 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.217 2017/05/30 19:30:38 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -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 1d3d81e4..6879f08f 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.327 2017/05/14 14:00:58 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.328 2017/05/30 19:30:38 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -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. */ @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.165 2017/05/16 19:06:30 schwarze Exp $ */ +/* $Id: read.c,v 1.166 2017/05/30 19:30:39 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -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 c49743d5..4ba905af 100755 --- a/regress/regress.pl +++ b/regress/regress.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # -# $Id: regress.pl,v 1.5 2017/03/08 22:54:22 schwarze Exp $ +# $Id: regress.pl,v 1.6 2017/05/30 19:30:40 schwarze Exp $ # # Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> # @@ -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'; |