source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Fix handling of \} on roff request lines.
@ 2017-07-04 22:52 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-07-04 22:52 UTC (permalink / raw)
  To: source

Log Message:
-----------
Fix handling of \} on roff request lines.
Cures bogus error messages in pages generated with pod2man(1).

Modified Files:
--------------
    mandoc:
        roff.c
    mandoc/regress/roff/cond:
        ie.in
        ie.out_ascii

Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.317
retrieving revision 1.318
diff -Lroff.c -Lroff.c -u -p -r1.317 -r1.318
--- roff.c
+++ roff.c
@@ -1926,15 +1926,6 @@ roff_cond_sub(ROFF_ARGS)
 
 	rr = r->last->rule;
 	roffnode_cleanscope(r);
-	t = roff_parse(r, buf->buf, &pos, ln, ppos);
-
-	/*
-	 * Fully handle known macros when they are structurally
-	 * required or when the conditional evaluated to true.
-	 */
-
-	if (t != TOKEN_NONE && (rr || roffs[t].flags & ROFFMAC_STRUCT))
-		return (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs);
 
 	/*
 	 * If `\}' occurs on a macro line without a preceding macro,
@@ -1948,14 +1939,29 @@ roff_cond_sub(ROFF_ARGS)
 	/* Always check for the closing delimiter `\}'. */
 
 	while ((ep = strchr(ep, '\\')) != NULL) {
-		if (*(++ep) == '}') {
-			*ep = '&';
-			roff_ccond(r, ln, ep - buf->buf - 1);
-		}
-		if (*ep != '\0')
+		switch (ep[1]) {
+		case '}':
+			memmove(ep, ep + 2, strlen(ep + 2) + 1);
+			roff_ccond(r, ln, ep - buf->buf);
+			break;
+		case '\0':
 			++ep;
+			break;
+		default:
+			ep += 2;
+			break;
+		}
 	}
-	return rr ? ROFF_CONT : ROFF_IGN;
+
+	/*
+	 * Fully handle known macros when they are structurally
+	 * required or when the conditional evaluated to true.
+	 */
+
+	t = roff_parse(r, buf->buf, &pos, ln, ppos);
+	return t != TOKEN_NONE && (rr || roffs[t].flags & ROFFMAC_STRUCT)
+	    ? (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs) : rr
+	    ? ROFF_CONT : ROFF_IGN;
 }
 
 static enum rofferr
Index: ie.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/cond/ie.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/roff/cond/ie.in -Lregress/roff/cond/ie.in -u -p -r1.2 -r1.3
--- regress/roff/cond/ie.in
+++ regress/roff/cond/ie.in
@@ -1,5 +1,5 @@
-.\" $OpenBSD: ie.in,v 1.5 2017/07/04 14:53:26 schwarze Exp $
-.TH IE 1 "December 16, 2014"
+.\" $OpenBSD: ie.in,v 1.6 2017/07/04 22:49:59 schwarze Exp $
+.TH IE 1 "July 4, 2017"
 .SH NAME
 if \- the roff conditional instruction with else-clause
 .SH DESCRIPTION
@@ -10,6 +10,14 @@ Text following the true condition.
 .el One-line else after true.
 .el Another else after true.
 .br
+.ie n \{\
+Two-line
+true condition.
+.br\}
+.el \{\
+Two-line
+else after true.
+.br\}
 .ie t One-line false condition.
 Text following the false condition.
 .br
Index: ie.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/cond/ie.out_ascii,v
retrieving revision 1.1
retrieving revision 1.2
diff -Lregress/roff/cond/ie.out_ascii -Lregress/roff/cond/ie.out_ascii -u -p -r1.1 -r1.2
--- regress/roff/cond/ie.out_ascii
+++ regress/roff/cond/ie.out_ascii
@@ -8,6 +8,7 @@ N\bNA\bAM\bME\bE
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
        One-line true condition.
        Text following the true condition.
+       Two-line true condition.
        Text following the false condition.
        Two-line else after false.
        Else after empty condition.
@@ -16,4 +17,4 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
 
 
 
-OpenBSD                        December 16, 2014                         IE(1)
+OpenBSD                          July 4, 2017                            IE(1)
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-04 22:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-04 22:52 mandoc: Fix handling of \} on roff request lines 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).