[prev in list] [next in list] [prev in thread] [next in thread]
List: mandoc-source
Subject: mdocml: Have conditional closure for both text and macro lines call
From: kristaps () mdocml ! bsd ! lv
Date: 2011-05-24 15:22:14
Message-ID: 201105241522.p4OFMEwk022395 () krisdoz ! my ! domain
[Download RAW message or body]
Log Message:
-----------
Have conditional closure for both text and macro lines call through to
ccond(). Fix the text handler to behave like the macro handler
regarding escaped \}. Make \} actually become a zero-width space, too,
and clean up the documentation in this regard.
Modified Files:
--------------
mdocml:
roff.7
roff.c
Revision Data
-------------
Index: roff.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.7,v
retrieving revision 1.28
retrieving revision 1.29
diff -Lroff.7 -Lroff.7 -u -p -r1.28 -r1.29
--- roff.7
+++ roff.7
@@ -448,15 +448,20 @@ than having the request or macro follow
The scope of a conditional is always parsed, but only executed if the
conditional evaluates to true.
.Pp
-Note that text following an
-.Sq \&.\e}
-escape sequence is discarded.
-Furthermore, if an explicit closing sequence
+Note that the
.Sq \e}
-is specified in a free-form line, the entire line is accepted within the
-scope of the prior request, not only the text preceding the close, with the
+is converted into a zero-width escape sequence if not passed as a
+standalone macro
+.Sq \&.\e} .
+For example,
+.Pp
+.D1 \&.Fl a \e} b
+.Pp
+will result in
.Sq \e}
-collapsing into a zero-width space.
+being considered an argument of the
+.Sq \&Fl
+macro.
.Ss \&ig
Ignore input.
Its syntax can be either
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.139
retrieving revision 1.140
diff -Lroff.c -Lroff.c -u -p -r1.139 -r1.140
--- roff.c
+++ roff.c
@@ -853,17 +853,12 @@ roff_cond_sub(ROFF_ARGS)
*/
if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos))) {
- /*
- * Jump through hoops to detect a \}, because it could
- * be (say) \\}, which is something completely
- * different.
- */
ep = &(*bufp)[pos];
for ( ; NULL != (ep = strchr(ep, '\\')); ep++) {
ep++;
if ('}' != *ep)
continue;
- *--ep = '\0';
+ *ep = '&';
roff_ccond(r, ROFF_ccond, bufp, szp,
ln, pos, pos + 2, offs);
break;
@@ -887,36 +882,27 @@ roff_cond_sub(ROFF_ARGS)
ln, ppos, pos, offs));
}
-
/* ARGSUSED */
static enum rofferr
roff_cond_text(ROFF_ARGS)
{
- char *ep, *st;
+ char *ep;
enum roffrule rr;
rr = r->last->rule;
+ roffnode_cleanscope(r);
- /*
- * We display the value of the text if out current evaluation
- * scope permits us to do so.
- */
-
- /* FIXME: use roff_ccond? */
-
- st = &(*bufp)[pos];
- if (NULL == (ep = strstr(st, "\\}"))) {
- roffnode_cleanscope(r);
- return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);
+ ep = &(*bufp)[pos];
+ for ( ; NULL != (ep = strchr(ep, '\\')); ep++) {
+ ep++;
+ if ('}' != *ep)
+ continue;
+ *ep = '&';
+ roff_ccond(r, ROFF_ccond, bufp, szp,
+ ln, pos, pos + 2, offs);
}
-
- if (ep == st || (ep > st && '\\' != *(ep - 1)))
- roffnode_pop(r);
-
- roffnode_cleanscope(r);
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);
}
-
static enum roffrule
roff_evalcond(const char *v, int *pos)
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic