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.
-.\" $Id: roff.7,v 1.28 2011/04/30 10:18:25 kristaps Exp $
+.\" $Id: roff.7,v 1.29 2011/05/24 15:22:14 kristaps Exp $
.\"
.\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
.\"
.\" Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 30 2011 $
+.Dd $Mdocdate: May 24 2011 $
The scope of a conditional is always parsed, but only executed if the
conditional evaluates to true.
.Pp
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
-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
-collapsing into a zero-width space.
+being considered an argument of the
+.Sq \&Fl
+macro.
.Ss \&ig
Ignore input.
Its syntax can be either
.Ss \&ig
Ignore input.
Its syntax can be either
-/* $Id: roff.c,v 1.139 2011/05/24 14:00:39 kristaps Exp $ */
+/* $Id: roff.c,v 1.140 2011/05/24 15:22:14 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
*/
if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos))) {
*/
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 = &(*bufp)[pos];
for ( ; NULL != (ep = strchr(ep, '\\')); ep++) {
ep++;
if ('}' != *ep)
continue;
roff_ccond(r, ROFF_ccond, bufp, szp,
ln, pos, pos + 2, offs);
break;
roff_ccond(r, ROFF_ccond, bufp, szp,
ln, pos, pos + 2, offs);
break;
/* ARGSUSED */
static enum rofferr
roff_cond_text(ROFF_ARGS)
{
/* ARGSUSED */
static enum rofferr
roff_cond_text(ROFF_ARGS)
{
enum roffrule rr;
rr = r->last->rule;
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);
}
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);
}
static enum roffrule
roff_evalcond(const char *v, int *pos)
{
static enum roffrule
roff_evalcond(const char *v, int *pos)
{