summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roff.754
-rw-r--r--roff.c45
2 files changed, 83 insertions, 16 deletions
diff --git a/roff.7 b/roff.7
index 10b319a5..2d3ae9cb 100644
--- a/roff.7
+++ b/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{ ,
diff --git a/roff.c b/roff.c
index 47cf8d50..7b9784a8 100644
--- a/roff.c
+++ b/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);