source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: libroff now intelligently throws away `am', `ami', `am1', `de',
@ 2010-05-17  0:37 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-05-17  0:37 UTC (permalink / raw)
  To: source

Log Message:
-----------
libroff now intelligently throws away `am', `ami', `am1', `de', `dei',
and `de1'.  This is also documented in roff.7.

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.2
retrieving revision 1.3
diff -Lroff.7 -Lroff.7 -u -p -r1.2 -r1.3
--- roff.7
+++ roff.7
@@ -65,9 +65,56 @@ Thus, the following are equivalent:
 .Sh REFERENCE
 This section is a canonical reference of all macros, arranged
 alphabetically.
+.Ss \&am
+The syntax of this macro is the same as that of
+.Sx \&ig ,
+except that a leading argument must be specified.
+It is ignored, as are its children.
+.Ss \&ami
+The syntax of this macro is the same as that of
+.Sx \&ig ,
+except that a leading argument must be specified.
+It is ignored, as are its children.
+.Ss \&am1
+The syntax of this macro is the same as that of
+.Sx \&ig ,
+except that a leading argument must be specified.
+It is ignored, as are its children.
+.Ss \&de
+The syntax of this macro is the same as that of
+.Sx \&ig ,
+except that a leading argument must be specified.
+It is ignored, as are its children.
+.Ss \&dei
+The syntax of this macro is the same as that of
+.Sx \&ig ,
+except that a leading argument must be specified.
+It is ignored, as are its children.
+.Ss \&de1
+The syntax of this macro is the same as that of
+.Sx \&ig ,
+except that a leading argument must be specified.
+It is ignored, as are its children.
 .Ss \&if
-Begins a conditional.
-Has the following syntax:
+Begins a conditional that always evaluates to false.
+If a conditional is false, its children are not processed, but are
+syntactically interpreted to preserve the integrity of the input
+document.
+Thus,
+.Pp
+.D1 \&.if t \e .ig
+.Pp
+will discard the
+.Sq \&.ig ,
+which may lead to interesting results, but
+.Pp
+.D1 \&.if t \e .if t \e{\e
+.Pp
+will continue to syntactically interpret to the block close of the final
+conditional.
+Sub-conditionals, in this case, obviously inherit the truth value of
+the parent.
+This macro has the following syntax:
 .Pp
 .Bd -literal -offset indent -compact
 \&.if COND \e{\e
@@ -88,7 +135,8 @@ BODY...
 BODY
 .Ed
 .Pp
-COND is a conditional (TODO: document).
+COND is a conditional (for the time being, this always evaluates to
+false).
 .Pp
 If the BODY section is begun by an escaped brace
 .Sq \e{ ,
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -Lroff.c -Lroff.c -u -p -r1.79 -r1.80
--- roff.c
+++ roff.c
@@ -30,15 +30,17 @@
 	('.' == (c) || '\'' == (c))
 
 enum	rofft {
+	ROFF_am,
+	ROFF_ami,
+	ROFF_am1,
+	ROFF_de,
+	ROFF_dei,
+	ROFF_de1,
 	ROFF_if,
 	ROFF_ig,
 	ROFF_cblock,
 	ROFF_ccond,
 #if 0
-	ROFF_am,
-	ROFF_ami,
-	ROFF_de,
-	ROFF_dei,
 	ROFF_ie,
 	ROFF_el,
 #endif
@@ -86,18 +88,24 @@ struct	roffmac {
 #define	ROFFMAC_STRUCT	(1 << 0) /* always interpret */
 };
 
+static	enum rofferr	 roff_block(ROFF_ARGS);
+static	enum rofferr	 roff_block_text(ROFF_ARGS);
+static	enum rofferr	 roff_block_sub(ROFF_ARGS);
+static	enum rofferr	 roff_cblock(ROFF_ARGS);
+static	enum rofferr	 roff_ccond(ROFF_ARGS);
 static	enum rofferr	 roff_if(ROFF_ARGS);
 static	enum rofferr	 roff_if_text(ROFF_ARGS);
 static	enum rofferr	 roff_if_sub(ROFF_ARGS);
-static	enum rofferr	 roff_ig(ROFF_ARGS);
-static	enum rofferr	 roff_ig_text(ROFF_ARGS);
-static	enum rofferr	 roff_ig_sub(ROFF_ARGS);
-static	enum rofferr	 roff_cblock(ROFF_ARGS);
-static	enum rofferr	 roff_ccond(ROFF_ARGS);
 
 const	struct roffmac	 roffs[ROFF_MAX] = {
+	{ "am", roff_block, roff_block_text, roff_block_sub, 0 },
+	{ "ami", roff_block, roff_block_text, roff_block_sub, 0 },
+	{ "am1", roff_block, roff_block_text, roff_block_sub, 0 },
+	{ "de", roff_block, roff_block_text, roff_block_sub, 0 },
+	{ "dei", roff_block, roff_block_text, roff_block_sub, 0 },
+	{ "de1", roff_block, roff_block_text, roff_block_sub, 0 },
 	{ "if", roff_if, roff_if_text, roff_if_sub, ROFFMAC_STRUCT },
-	{ "ig", roff_ig, roff_ig_text, roff_ig_sub, 0 },
+	{ "ig", roff_block, roff_block_text, roff_block_sub, 0 },
 	{ ".", roff_cblock, NULL, NULL, 0 },
 	{ "\\}", roff_ccond, NULL, NULL, 0 },
 };
@@ -396,11 +404,22 @@ roff_ccond(ROFF_ARGS)
 
 /* ARGSUSED */
 static enum rofferr
-roff_ig(ROFF_ARGS)
+roff_block(ROFF_ARGS)
 {
 	int		sv;
 	size_t		sz;
 
+	if (ROFF_ig != tok && '\0' == (*bufp)[pos]) {
+		if ( ! (*r->msg)(MANDOCERR_NOARGS, r->data, ln, ppos, NULL))
+			return(ROFF_ERR);
+		return(ROFF_IGN);
+	} else if (ROFF_ig != tok) {
+		while ((*bufp)[pos] && ' ' != (*bufp)[pos])
+			pos++;
+		while (' ' == (*bufp)[pos])
+			pos++;
+	}
+
 	if ( ! roffnode_push(r, tok, ln, ppos))
 		return(ROFF_ERR);
 
@@ -474,7 +493,7 @@ roff_if_sub(ROFF_ARGS)
 
 /* ARGSUSED */
 static enum rofferr
-roff_ig_sub(ROFF_ARGS)
+roff_block_sub(ROFF_ARGS)
 {
 	enum rofft	t;
 	int		i, j;
@@ -530,7 +549,7 @@ roff_ig_sub(ROFF_ARGS)
 
 /* ARGSUSED */
 static enum rofferr
-roff_ig_text(ROFF_ARGS)
+roff_block_text(ROFF_ARGS)
 {
 
 	return(ROFF_IGN);
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

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

only message in thread, other threads:[~2010-05-17  0:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-17  0:37 mdocml: libroff now intelligently throws away `am', `ami', `am1', `de', kristaps

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).