summaryrefslogtreecommitdiffstats
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-03-23 15:20:51 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-03-23 15:20:51 +0000
commit858ffa5feefe929dcf0dabf5d771106577f1d9e7 (patch)
treec7c60626c127f411298f6b68e1e41c01f8f1df40 /mdoc.c
parentaab08c4fa94c384767d1d5da68aa283ced4004bd (diff)
downloadmandoc-858ffa5feefe929dcf0dabf5d771106577f1d9e7.tar.gz
-man printing linked to -Ttree.
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/mdoc.c b/mdoc.c
index 9781ecbe..3c6735a6 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -32,16 +32,6 @@
* in macro.c, validate.c and action.c.
*/
-/* FIXME: have this accept line/pos/tok. */
-static struct mdoc_node *mdoc_node_alloc(const struct mdoc *);
-static int mdoc_node_append(struct mdoc *,
- struct mdoc_node *);
-
-static int parsetext(struct mdoc *, int, char *);
-static int parsemacro(struct mdoc *, int, char *);
-static int macrowarn(struct mdoc *, int, const char *);
-
-
const char *const __mdoc_macronames[MDOC_MAX] = {
"\\\"", "Dd", "Dt", "Os",
"Sh", "Ss", "Pp", "D1",
@@ -95,29 +85,33 @@ const char *const __mdoc_argnames[MDOC_ARG_MAX] = {
const char * const *mdoc_macronames = __mdoc_macronames;
const char * const *mdoc_argnames = __mdoc_argnames;
+/* FIXME: have this accept line/pos/tok. */
+/* FIXME: mdoc_alloc1 and mdoc_free1 like in man.c. */
+static struct mdoc_node *mdoc_node_alloc(const struct mdoc *);
+static int mdoc_node_append(struct mdoc *,
+ struct mdoc_node *);
+
+static int parsetext(struct mdoc *, int, char *);
+static int parsemacro(struct mdoc *, int, char *);
+static int macrowarn(struct mdoc *, int, const char *);
+
/*
* Get the first (root) node of the parse tree.
*/
const struct mdoc_node *
-mdoc_node(const struct mdoc *mdoc)
+mdoc_node(const struct mdoc *m)
{
- if (MDOC_HALT & mdoc->flags)
- return(NULL);
- if (mdoc->first)
- assert(MDOC_ROOT == mdoc->first->type);
- return(mdoc->first);
+ return(MDOC_HALT & m->flags ? NULL : m->first);
}
const struct mdoc_meta *
-mdoc_meta(const struct mdoc *mdoc)
+mdoc_meta(const struct mdoc *m)
{
- if (MDOC_HALT & mdoc->flags)
- return(NULL);
- return(&mdoc->meta);
+ return(MDOC_HALT & m->flags ? NULL : &m->meta);
}
@@ -366,6 +360,18 @@ mdoc_node_append(struct mdoc *mdoc, struct mdoc_node *p)
}
mdoc->last = p;
+
+ switch (p->type) {
+ case (MDOC_TEXT):
+ if ( ! mdoc_valid_post(mdoc))
+ return(0);
+ if ( ! mdoc_action_post(mdoc))
+ return(0);
+ break;
+ default:
+ break;
+ }
+
return(1);
}