summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-07-02 19:55:10 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-07-02 19:55:10 +0000
commitfdc95e0f088e210664eb7459003c922102fc748e (patch)
tree2941a73b51965c3192f9e63b7579762c3e8c0ad5
parente98d951b402f5f61bf0fafc86ae5ad5a03f1c85e (diff)
downloadmandoc-fdc95e0f088e210664eb7459003c922102fc748e.tar.gz
When .Sm is called without an argument, groff toggles the spacing mode,
so let us do the same for compatibility. Using this feature is of course not recommended except in manual page obfuscation contests.
-rw-r--r--mdoc_html.c21
-rw-r--r--mdoc_man.c11
-rw-r--r--mdoc_term.c12
-rw-r--r--mdoc_validate.c7
4 files changed, 26 insertions, 25 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 30c0132d..5c69b689 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1524,23 +1524,16 @@ static int
mdoc_sm_pre(MDOC_ARGS)
{
- assert(n->child && MDOC_TEXT == n->child->type);
- if (0 == strcmp("on", n->child->string)) {
- /*
- * FIXME: no p->col to check. Thus, if we have
- * .Bd -literal
- * .Sm off
- * 1 2
- * .Sm on
- * 3
- * .Ed
- * the "3" is preceded by a space.
- */
- h->flags &= ~HTML_NOSPACE;
+ if (NULL == n->child)
+ h->flags ^= HTML_NONOSPACE;
+ else if (0 == strcmp("on", n->child->string))
h->flags &= ~HTML_NONOSPACE;
- } else
+ else
h->flags |= HTML_NONOSPACE;
+ if ( ! (HTML_NONOSPACE & h->flags))
+ h->flags &= ~HTML_NOSPACE;
+
return(0);
}
diff --git a/mdoc_man.c b/mdoc_man.c
index 8e81a1fb..59de74ab 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1565,11 +1565,16 @@ static int
pre_sm(DECL_ARGS)
{
- assert(n->child && MDOC_TEXT == n->child->type);
- if (0 == strcmp("on", n->child->string))
- outflags |= MMAN_Sm | MMAN_spc;
+ if (NULL == n->child)
+ outflags ^= MMAN_Sm;
+ else if (0 == strcmp("on", n->child->string))
+ outflags |= MMAN_Sm;
else
outflags &= ~MMAN_Sm;
+
+ if (MMAN_Sm & outflags)
+ outflags |= MMAN_spc;
+
return(0);
}
diff --git a/mdoc_term.c b/mdoc_term.c
index 98eafa4f..89cdbdd6 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -2056,14 +2056,16 @@ static int
termp_sm_pre(DECL_ARGS)
{
- assert(n->child && MDOC_TEXT == n->child->type);
- if (0 == strcmp("on", n->child->string)) {
- if (p->col)
- p->flags &= ~TERMP_NOSPACE;
+ if (NULL == n->child)
+ p->flags ^= TERMP_NONOSPACE;
+ else if (0 == strcmp("on", n->child->string))
p->flags &= ~TERMP_NONOSPACE;
- } else
+ else
p->flags |= TERMP_NONOSPACE;
+ if (p->col && ! (TERMP_NONOSPACE & p->flags))
+ p->flags &= ~TERMP_NOSPACE;
+
return(0);
}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index cf75c67a..ecd1ee09 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1668,11 +1668,12 @@ ebool(struct mdoc *mdoc)
{
if (NULL == mdoc->last->child) {
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_MACROEMPTY);
- mdoc_node_delete(mdoc, mdoc->last);
+ if (MDOC_Sm == mdoc->last->tok)
+ mdoc->flags ^= MDOC_SMOFF;
return(1);
}
- check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1);
+
+ check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_LT, 2);
assert(MDOC_TEXT == mdoc->last->child->type);