source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: When .Sm is called without an argument, groff toggles the
Date: Wed, 2 Jul 2014 15:55:10 -0400 (EDT)	[thread overview]
Message-ID: <201407021955.s62JtA76002974@krisdoz.my.domain> (raw)

Log Message:
-----------
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.

Modified Files:
--------------
    mdocml:
        mdoc_html.c
        mdoc_man.c
        mdoc_term.c
        mdoc_validate.c

Revision Data
-------------
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.64 -r1.65
--- mdoc_man.c
+++ 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);
 }
 
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.221
retrieving revision 1.222
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.221 -r1.222
--- mdoc_validate.c
+++ 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);
 
Index: mdoc_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_html.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.191 -r1.192
--- mdoc_html.c
+++ mdoc_html.c
@@ -1524,22 +1524,15 @@ 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);
 }
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.268
retrieving revision 1.269
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.268 -r1.269
--- mdoc_term.c
+++ mdoc_term.c
@@ -2056,13 +2056,15 @@ 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);
 }
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

             reply	other threads:[~2014-07-02 19:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02 19:55 schwarze [this message]
2014-08-08 16:38 schwarze

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201407021955.s62JtA76002974@krisdoz.my.domain \
    --to=schwarze@mdocml.bsd.lv \
    --cc=source@mdocml.bsd.lv \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).