summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-02-02 21:40:45 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-02-02 21:40:45 +0000
commitfe1e1c9e6ff55e0dc447b3cbe2c90acec57abb94 (patch)
tree41487390a8b9f98c9f16c129452bb52b69fae3ec
parent4d5fae7359175bce01187d32473e257174341f84 (diff)
downloadmandoc-fe1e1c9e6ff55e0dc447b3cbe2c90acec57abb94.tar.gz
If `Ns' is specified on its own line, it should be ignored. This is
shitty groff behaviour. Do the same, but raise a warning to this effect. This from a TODO noted by schwarze@.
-rw-r--r--TODO4
-rw-r--r--main.c1
-rw-r--r--mandoc.h1
-rw-r--r--mdoc.72
-rw-r--r--mdoc_html.c3
-rw-r--r--mdoc_term.c3
-rw-r--r--mdoc_validate.c13
7 files changed, 20 insertions, 7 deletions
diff --git a/TODO b/TODO
index 39c77e80..8d801250 100644
--- a/TODO
+++ b/TODO
@@ -246,10 +246,6 @@
should be indented, see e.g. rpc(3);
reported by jmc@ on discuss@ Fri, 29 Oct 2010 13:48:33 +0100
-- .Ns should only be effective when called by another macro,
- not as a stand-alone macro at the beginning of a line;
- see for example the awk(1) SYNOPSIS.
-
- .Ns should work when called at the end of an input line, see
the following code in vi(1):
.It Xo
diff --git a/main.c b/main.c
index 7e4bbb3a..1bf8712c 100644
--- a/main.c
+++ b/main.c
@@ -146,6 +146,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/mandoc.h b/mandoc.h
index 61a1f5ad..704ec745 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -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/mdoc.7 b/mdoc.7
index 9e4eb56e..3adfb256 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -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/mdoc_html.c b/mdoc_html.c
index 11171c21..e07766fd 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -780,7 +780,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/mdoc_term.c b/mdoc_term.c
index 942753b0..bad775e9 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1151,7 +1151,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/mdoc_validate.c b/mdoc_validate.c
index c8d65144..1b6fd138 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -104,6 +104,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);
@@ -148,6 +149,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 };
@@ -249,7 +251,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 */
@@ -1744,6 +1746,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)
{