diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-07-02 19:54:40 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-07-02 19:54:40 +0000 |
commit | dc0bdce4b544aa493fd4b6572810467a95ee79c5 (patch) | |
tree | 77aa02cf2f9996a4974aae4e64e83b6d44598598 /usr.bin | |
parent | 9587320ce1092476d021b7802c77eae38d7b487f (diff) |
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.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 23 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_man.c | 13 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 14 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_validate.c | 9 |
4 files changed, 30 insertions, 29 deletions
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index e4f3856642e..6444e9e68ed 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.74 2014/07/02 03:47:07 schwarze Exp $ */ +/* $Id: mdoc_html.c,v 1.75 2014/07/02 19:54:39 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -1520,23 +1520,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/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c index 1e4792e0a8a..bd6d38b23ac 100644 --- a/usr.bin/mandoc/mdoc_man.c +++ b/usr.bin/mandoc/mdoc_man.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.63 2014/07/02 03:47:07 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.64 2014/07/02 19:54:39 schwarze Exp $ */ /* * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> * @@ -1561,11 +1561,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/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 55b37af7133..a240be9f8f7 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.170 2014/07/02 03:47:07 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.171 2014/07/02 19:54:39 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -2052,14 +2052,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/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 9ff94ee2628..60564525cf3 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.139 2014/07/02 13:10:15 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.140 2014/07/02 19:54:39 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -1664,11 +1664,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); |