diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-23 15:20:51 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-03-23 15:20:51 +0000 |
commit | 858ffa5feefe929dcf0dabf5d771106577f1d9e7 (patch) | |
tree | c7c60626c127f411298f6b68e1e41c01f8f1df40 /mdoc.c | |
parent | aab08c4fa94c384767d1d5da68aa283ced4004bd (diff) | |
download | mandoc-858ffa5feefe929dcf0dabf5d771106577f1d9e7.tar.gz |
-man printing linked to -Ttree.
Diffstat (limited to 'mdoc.c')
-rw-r--r-- | mdoc.c | 46 |
1 files changed, 26 insertions, 20 deletions
@@ -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); } |