source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: warn about .Ns macros that have no effect because they are
@ 2017-06-27 12:18 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-06-27 12:18 UTC (permalink / raw)
  To: source

Log Message:
-----------
warn about .Ns macros that have no effect because they are followed
by an isolated closing delimiter; inspired by mdoclint

Modified Files:
--------------
    mandoc:
        mandoc.1
        mdoc_validate.c
    mandoc/regress/mdoc/Ns:
        position.in
        position.out_ascii
        position.out_lint
        position.out_markdown

Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_validate.c,v
retrieving revision 1.343
retrieving revision 1.344
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.343 -r1.344
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1983,10 +1983,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
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.1,v
retrieving revision 1.207
retrieving revision 1.208
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.207 -r1.208
--- mandoc.1
+++ mandoc.1
@@ -1175,7 +1175,9 @@ The paragraph macro is moved after the e
 .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
Index: position.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ns/position.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Ns/position.in -Lregress/mdoc/Ns/position.in -u -p -r1.1 -r1.2
--- regress/mdoc/Ns/position.in
+++ regress/mdoc/Ns/position.in
@@ -1,4 +1,4 @@
-.Dd September 15, 2013
+.Dd June 27, 2017
 .Dt NS-POSITION 1
 .Os OpenBSD
 .Sh NAME
@@ -19,6 +19,12 @@ After some macro and a block closing:
 .Pp
 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
Index: position.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ns/position.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Ns/position.out_ascii -Lregress/mdoc/Ns/position.out_ascii -u -p -r1.1 -r1.2
--- regress/mdoc/Ns/position.out_ascii
+++ regress/mdoc/Ns/position.out_ascii
@@ -12,8 +12,12 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
 
      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
Index: position.out_lint
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ns/position.out_lint,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lregress/mdoc/Ns/position.out_lint -Lregress/mdoc/Ns/position.out_lint -u -p -r1.4 -r1.5
--- regress/mdoc/Ns/position.out_lint
+++ regress/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)
Index: position.out_markdown
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Ns/position.out_markdown,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/mdoc/Ns/position.out_markdown -Lregress/mdoc/Ns/position.out_markdown -u -p -r1.1 -r1.2
--- regress/mdoc/Ns/position.out_markdown
+++ regress/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
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-27 12:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 12:18 mandoc: warn about .Ns macros that have no effect because they are schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).