From: schwarze Date: Tue, 27 Jun 2017 12:17:35 +0000 (+0000) Subject: warn about .Ns macros that have no effect because they are followed X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=676013e4814854f52b2942c1d628cfa561bdf2db;p=openbsd warn about .Ns macros that have no effect because they are followed by an isolated closing delimiter; inspired by mdoclint --- diff --git a/regress/usr.bin/mandoc/mdoc/Ns/position.in b/regress/usr.bin/mandoc/mdoc/Ns/position.in index 1325df25c5f..56fc5de6b86 100644 --- a/regress/usr.bin/mandoc/mdoc/Ns/position.in +++ b/regress/usr.bin/mandoc/mdoc/Ns/position.in @@ -1,4 +1,4 @@ -.Dd September 15, 2013 +.Dd June 27, 2017 .Dt NS-POSITION 1 .Os OpenBSD .Sh NAME @@ -20,6 +20,12 @@ After some macro and a block closing: In the middle of a macro line: .Oo before Oc Ns Op after .Pp +After closing punctuation: +.Oo before Oc : Ns Op after +.Pp +Before closing punctuation: +.Oo before Oc Ns : Op after +.Pp At the end of a macro line: .Oo before Oc Ns .Op after diff --git a/regress/usr.bin/mandoc/mdoc/Ns/position.out_ascii b/regress/usr.bin/mandoc/mdoc/Ns/position.out_ascii index a2bd6c4583b..26de056232d 100644 --- a/regress/usr.bin/mandoc/mdoc/Ns/position.out_ascii +++ b/regress/usr.bin/mandoc/mdoc/Ns/position.out_ascii @@ -12,8 +12,12 @@ DDEESSCCRRIIPPTTIIOONN In the middle of a macro line: [before][after] + After closing punctuation: [before]:[after] + + Before closing punctuation: [before]: [after] + At the end of a macro line: [before][after] At the end of partial implicit: [before][after] -OpenBSD September 15, 2013 OpenBSD +OpenBSD June 27, 2017 OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Ns/position.out_lint b/regress/usr.bin/mandoc/mdoc/Ns/position.out_lint index 9169589536b..aa1f3275cc1 100644 --- a/regress/usr.bin/mandoc/mdoc/Ns/position.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Ns/position.out_lint @@ -1,4 +1,5 @@ mandoc: position.in:3:5: BASE: operating system explicitly specified: Os OpenBSD (OpenBSD) -mandoc: position.in:1:5: BASE: Mdocdate missing: Dd September (OpenBSD) +mandoc: position.in:1:5: BASE: Mdocdate missing: Dd June (OpenBSD) mandoc: position.in:10:2: WARNING: skipping no-space macro +mandoc: position.in:27:15: WARNING: skipping no-space macro mandoc: position.in: BASE: RCS id missing: (OpenBSD) diff --git a/regress/usr.bin/mandoc/mdoc/Ns/position.out_markdown b/regress/usr.bin/mandoc/mdoc/Ns/position.out_markdown index 14414a3e9b3..8b6c509c68c 100644 --- a/regress/usr.bin/mandoc/mdoc/Ns/position.out_markdown +++ b/regress/usr.bin/mandoc/mdoc/Ns/position.out_markdown @@ -20,10 +20,16 @@ still before]\[after] In the middle of a macro line: \[before]\[after] +After closing punctuation: +\[before]:\[after] + +Before closing punctuation: +\[before]: \[after] + At the end of a macro line: \[before]\[after] At the end of partial implicit: \[before]\[after] -OpenBSD - September 15, 2013 +OpenBSD - June 27, 2017 diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index 931aabfa428..232ba78cdac 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.131 2017/06/25 17:42:37 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.132 2017/06/27 12:17:35 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2017 Ingo Schwarze @@ -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: June 25 2017 $ +.Dd $Mdocdate: June 27 2017 $ .Dt MANDOC 1 .Os .Sh NAME @@ -1175,7 +1175,9 @@ The paragraph macro is moved after the end of the list. .Pq mdoc An input line begins with an .Ic \&Ns -macro. +macro, or the next argument after an +.Ic \&Ns +macro is an isolated closing delimiter. The macro is ignored. .It Sy "blocks badly nested" .Pq mdoc diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 0b45e79303b..04b4324c2a7 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_validate.c,v 1.258 2017/06/25 17:42:37 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.259 2017/06/27 12:17:35 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -1968,10 +1968,13 @@ post_hyph(POST_ARGS) static void post_ns(POST_ARGS) { + struct roff_node *n; - if (mdoc->last->flags & NODE_LINE) + n = mdoc->last; + if (n->flags & NODE_LINE || + (n->next != NULL && n->next->flags & NODE_DELIMC)) mandoc_msg(MANDOCERR_NS_SKIP, mdoc->parse, - mdoc->last->line, mdoc->last->pos, NULL); + n->line, n->pos, NULL); } static void