From fc3f88d1377c7bffa72b592c383a452c6267a2d1 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 27 Jun 2017 12:17:36 +0000 Subject: warn about .Ns macros that have no effect because they are followed by an isolated closing delimiter; inspired by mdoclint --- usr.bin/mandoc/mandoc.1 | 8 +++++--- usr.bin/mandoc/mdoc_validate.c | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'usr.bin/mandoc') 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 -- cgit v1.2.3