summaryrefslogtreecommitdiffstats
path: root/action.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-20 12:51:28 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-20 12:51:28 +0000
commitff707aa645312b3a39818f27c27f11dc06eca2d6 (patch)
treec6f5e809ed79a338048fc6ce2c1e6549493c33f3 /action.c
parent850e4d98238e14f001698386740f660b1d4ea2df (diff)
downloadmandoc-ff707aa645312b3a39818f27c27f11dc06eca2d6.tar.gz
Moved prologue-pruning into action.c.
Added line-arg softmax.
Diffstat (limited to 'action.c')
-rw-r--r--action.c49
1 files changed, 40 insertions, 9 deletions
diff --git a/action.c b/action.c
index 1d8a91c5..abe3b901 100644
--- a/action.c
+++ b/action.c
@@ -29,11 +29,13 @@ struct actions {
/* Per-macro action routines. */
-static int post_sh(struct mdoc *);
-static int post_os(struct mdoc *);
-static int post_dt(struct mdoc *);
-static int post_dd(struct mdoc *);
-static int post_nm(struct mdoc *);
+static int post_sh(struct mdoc *);
+static int post_os(struct mdoc *);
+static int post_dt(struct mdoc *);
+static int post_dd(struct mdoc *);
+static int post_nm(struct mdoc *);
+
+static int post_prologue(struct mdoc *);
/* Array of macro action routines. */
@@ -226,7 +228,8 @@ post_dt(struct mdoc *mdoc)
if (NULL == mdoc->meta.title)
mdoc->meta.title = xstrdup("untitled");
- return(1);
+
+ return(post_prologue(mdoc));
}
@@ -244,7 +247,9 @@ post_os(struct mdoc *mdoc)
mdoc->meta.os = xstrdup(buf[0] ? buf : "local");
mdoc->sec_lastn = mdoc->sec_last = SEC_BODY;
- return(1);
+ mdoc->flags |= MDOC_BODYPARSE;
+
+ return(post_prologue(mdoc));
}
@@ -285,15 +290,41 @@ post_dd(struct mdoc *mdoc)
}
if (mdoc->meta.date && NULL == n)
- return(1);
+ return(post_prologue(mdoc));
else if (n)
return(mdoc_err(mdoc, "invalid parameter syntax"));
if ((mdoc->meta.date = mdoc_atotime(date)))
- return(1);
+ return(post_prologue(mdoc));
return(mdoc_err(mdoc, "invalid parameter syntax"));
}
+static int
+post_prologue(struct mdoc *mdoc)
+{
+ struct mdoc_node *n;
+
+ if (mdoc->last->parent->child == mdoc->last)
+ mdoc->last->parent->child = mdoc->last->prev;
+ if (mdoc->last->prev)
+ mdoc->last->prev->next = NULL;
+
+ n = mdoc->last;
+ assert(NULL == mdoc->last->next);
+
+ if (mdoc->last->prev) {
+ mdoc->last = mdoc->last->prev;
+ mdoc->next = MDOC_NEXT_SIBLING;
+ } else {
+ mdoc->last = mdoc->last->parent;
+ mdoc->next = MDOC_NEXT_CHILD;
+ }
+
+ mdoc_node_freelist(n);
+ return(1);
+}
+
+
int
mdoc_action_post(struct mdoc *mdoc)
{