summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2011-02-06 17:33:20 +0000
committerschwarze <schwarze@openbsd.org>2011-02-06 17:33:20 +0000
commitaf2167175922761b46fd28968f5718ced3acd06e (patch)
tree6c853a19d46d36f5281f5ac4c7bf103db3a98630
parentFix NULL dereference with "sudo -g group" when the sudoers rule has (diff)
downloadwireguard-openbsd-af2167175922761b46fd28968f5718ced3acd06e.tar.xz
wireguard-openbsd-af2167175922761b46fd28968f5718ced3acd06e.zip
If .Ns is specified on its own line, ignore it, like groff does;
from kristaps@.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Ns/Makefile6
-rw-r--r--regress/usr.bin/mandoc/mdoc/Ns/position.in17
-rw-r--r--regress/usr.bin/mandoc/mdoc/Ns/position.out_ascii12
-rw-r--r--share/man/man7/mdoc.78
-rw-r--r--usr.bin/mandoc/main.c3
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc_html.c5
-rw-r--r--usr.bin/mandoc/mdoc_term.c5
-rw-r--r--usr.bin/mandoc/mdoc_validate.c15
9 files changed, 60 insertions, 14 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Ns/Makefile b/regress/usr.bin/mandoc/mdoc/Ns/Makefile
index 5a71b25cf28..f10e864b552 100644
--- a/regress/usr.bin/mandoc/mdoc/Ns/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/Ns/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.1 2011/02/06 00:18:58 schwarze Exp $
+# $OpenBSD: Makefile,v 1.2 2011/02/06 17:33:21 schwarze Exp $
-REGRESS_TARGETS=punct
-GROFF_TARGETS=punct
+REGRESS_TARGETS=position punct
+GROFF_TARGETS=position punct
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/Ns/position.in b/regress/usr.bin/mandoc/mdoc/Ns/position.in
new file mode 100644
index 00000000000..5798a9b4edb
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Ns/position.in
@@ -0,0 +1,17 @@
+.Dd February 6, 2011
+.Dt NS-POSITION 1
+.Os
+.Sh NAME
+.Nm Ns-position
+.Nd effect of the position of the no space macro on the line
+.Sh DESCRIPTION
+In the middle of a macro line:
+.Oo before Oc Ns Op after
+.Pp
+At the beginning of a macro line:
+.Op before
+.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
new file mode 100644
index 00000000000..34de43b45c3
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/Ns/position.out_ascii
@@ -0,0 +1,12 @@
+NS-POSITION(1) OpenBSD Reference Manual NS-POSITION(1)
+
+NNAAMMEE
+ NNss--ppoossiittiioonn - effect of the position of the no space macro on the line
+
+DDEESSCCRRIIPPTTIIOONN
+ In the middle of a macro line: [before][after]
+
+ At the beginning of a macro line: [before] [after]
+
+ At the end of a macro line: [before][after]
+
diff --git a/share/man/man7/mdoc.7 b/share/man/man7/mdoc.7
index 24f8616fd47..83d44030a1e 100644
--- a/share/man/man7/mdoc.7
+++ b/share/man/man7/mdoc.7
@@ -1,6 +1,6 @@
-.\" $OpenBSD: mdoc.7,v 1.63 2011/01/25 00:37:39 schwarze Exp $
+.\" $OpenBSD: mdoc.7,v 1.64 2011/02/06 17:33:20 schwarze Exp $
.\"
-.\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
@@ -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: January 25 2011 $
+.Dd $Mdocdate: February 6 2011 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -2203,6 +2203,8 @@ Suppress a space.
Following invocation, text is interpreted as free-form text until a
macro is encountered.
.Pp
+This has no effect when invoked at the start of a macro line.
+.Pp
Examples:
.Dl \&.Fl o \&Ns \&Ar output
.Pp
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 30cd1db3cba..3f26a6ce6a9 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.71 2011/01/25 12:24:26 schwarze Exp $ */
+/* $Id: main.c,v 1.72 2011/02/06 17:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -131,6 +131,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
/* related to macros and nesting */
"skipping obsolete macro",
"skipping paragraph macro",
+ "skipping no-space macro",
"blocks badly nested",
"child violates parent syntax",
"nested displays are not portable",
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 923b3f774a7..6165e156caf 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.31 2011/01/16 19:27:25 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.32 2011/02/06 17:33:20 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -68,6 +68,7 @@ enum mandocerr {
/* related to macros and nesting */
MANDOCERR_MACROOBS, /* skipping obsolete macro */
MANDOCERR_IGNPAR, /* skipping paragraph macro */
+ MANDOCERR_IGNNS, /* skipping no-space macro */
MANDOCERR_SCOPENEST, /* blocks badly nested */
MANDOCERR_CHILD, /* child violates parent syntax */
MANDOCERR_NESTEDDISP, /* nested displays are not portable */
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c
index 5aec02fa59d..d57108e71a2 100644
--- a/usr.bin/mandoc/mdoc_html.c
+++ b/usr.bin/mandoc/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.50 2011/01/31 03:04:26 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.51 2011/02/06 17:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -776,7 +776,8 @@ static int
mdoc_ns_pre(MDOC_ARGS)
{
- h->flags |= HTML_NOSPACE;
+ if ( ! (MDOC_LINE & n->flags))
+ h->flags |= HTML_NOSPACE;
return(1);
}
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 5fc657f2070..572e93c45b0 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.126 2011/01/30 18:28:01 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.127 2011/02/06 17:33:20 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -1147,7 +1147,8 @@ static int
termp_ns_pre(DECL_ARGS)
{
- p->flags |= TERMP_NOSPACE;
+ if ( ! (MDOC_LINE & n->flags))
+ p->flags |= TERMP_NOSPACE;
return(1);
}
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 7c7a0d046b8..5f61829cb60 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.87 2011/01/30 18:28:01 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.88 2011/02/06 17:33:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -99,6 +99,7 @@ static int post_eoln(POST_ARGS);
static int post_it(POST_ARGS);
static int post_lb(POST_ARGS);
static int post_nm(POST_ARGS);
+static int post_ns(POST_ARGS);
static int post_os(POST_ARGS);
static int post_ignpar(POST_ARGS);
static int post_prol(POST_ARGS);
@@ -143,6 +144,7 @@ static v_post posts_lb[] = { post_lb, NULL };
static v_post posts_nd[] = { berr_ge1, NULL };
static v_post posts_nm[] = { post_nm, NULL };
static v_post posts_notext[] = { ewarn_eq0, NULL };
+static v_post posts_ns[] = { post_ns, NULL };
static v_post posts_os[] = { post_os, post_prol, NULL };
static v_post posts_rs[] = { post_rs, NULL };
static v_post posts_sh[] = { post_ignpar, hwarn_ge1, bwarn_ge1, post_sh, NULL };
@@ -244,7 +246,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Fx */
{ NULL, NULL }, /* Ms */
{ NULL, posts_notext }, /* No */
- { NULL, posts_notext }, /* Ns */
+ { NULL, posts_ns }, /* Ns */
{ NULL, NULL }, /* Nx */
{ NULL, NULL }, /* Ox */
{ NULL, NULL }, /* Pc */
@@ -1739,6 +1741,15 @@ post_rs(POST_ARGS)
}
static int
+post_ns(POST_ARGS)
+{
+
+ if (MDOC_LINE & mdoc->last->flags)
+ mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNNS);
+ return(1);
+}
+
+static int
post_sh(POST_ARGS)
{