* mdocml: When .Sm is called without an argument, groff toggles the
@ 2014-07-02 19:55 schwarze
0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2014-07-02 19:55 UTC (permalink / raw)
To: source
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* mdocml: When .Sm is called without an argument, groff toggles the
@ 2014-08-08 16:38 schwarze
0 siblings, 0 replies; 2+ messages in thread
From: schwarze @ 2014-08-08 16:38 UTC (permalink / raw)
To: source
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.7
Revision Data
-------------
Index: mdoc.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc.7,v
retrieving revision 1.233
retrieving revision 1.234
diff -Lmdoc.7 -Lmdoc.7 -u -p -r1.233 -r1.234
--- mdoc.7
+++ mdoc.7
@@ -468,7 +468,7 @@ in the alphabetical
.It Sx \&Pf Ta prefix, no following horizontal space (one argument)
.It Sx \&Ns Ta roman font, no preceding horizontal space (no arguments)
.It Sx \&Ap Ta apostrophe without surrounding whitespace (no arguments)
-.It Sx \&Sm Ta switch horizontal spacing mode: Cm on | off
+.It Sx \&Sm Ta switch horizontal spacing mode: Op Cm on | off
.It Sx \&Bk , \&Ek Ta keep block: Fl words
.It Sx \&br Ta force output line break in text mode (no arguments)
.It Sx \&sp Ta force vertical space: Op Ar height
@@ -2335,7 +2335,7 @@ and
Switches the spacing mode for output generated from macros.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Sm Cm on | off
+.D1 Pf \. Sx \&Sm Op Cm on | off
.Pp
By default, spacing is
.Cm on .
@@ -2344,6 +2344,11 @@ When switched
no white space is inserted between macro arguments and between the
output generated from adjacent macros, but text lines
still get normal spacing between words and sentences.
+.Pp
+When called without an argument, the
+.Sx \&Sm
+macro toggles the spacing mode.
+Using this is not recommended because it makes the code harder to read.
.Ss \&So
Multi-line version of
.Sx \&Sq .
@@ -3022,7 +3027,7 @@ then the macro accepts an arbitrary numb
.It Sx \&Pf Ta Yes Ta Yes Ta 1
.It Sx \&Pp Ta \&No Ta \&No Ta 0
.It Sx \&Rv Ta \&No Ta \&No Ta n
-.It Sx \&Sm Ta \&No Ta \&No Ta 1
+.It Sx \&Sm Ta \&No Ta \&No Ta <2
.It Sx \&St Ta \&No Ta Yes Ta 1
.It Sx \&Sx Ta Yes Ta Yes Ta >0
.It Sx \&Sy Ta Yes Ta Yes Ta >0
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-08 16:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-02 19:55 mdocml: When .Sm is called without an argument, groff toggles the schwarze
2014-08-08 16:38 schwarze
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).