diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-09 14:45:44 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-01-09 14:45:44 +0000 |
commit | fb53bc928f34b334a138fad9fa6a6b9081a9f7c7 (patch) | |
tree | 25f71c9f9afde5a617e279092971c17628d795ef /mdoc.c | |
parent | 89154444b764aaaab42730cdbca579364a797bfa (diff) | |
download | mandoc-fb53bc928f34b334a138fad9fa6a6b9081a9f7c7.tar.gz |
*** empty log message ***
Diffstat (limited to 'mdoc.c')
-rw-r--r-- | mdoc.c | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -243,7 +243,13 @@ mdoc_alloc(void *data, const struct mdoc_cb *cb) p->data = data; (void)memcpy(&p->cb, cb, sizeof(struct mdoc_cb)); + p->last = xcalloc(1, sizeof(struct mdoc_node)); + p->last->type = MDOC_ROOT; + p->first = p->last; + + p->next = MDOC_NEXT_CHILD; p->htab = mdoc_tokhash_alloc(); + return(p); } @@ -418,17 +424,9 @@ mdoc_node_append(struct mdoc *mdoc, struct mdoc_node *p) /* NOTREACHED */ } - if (NULL == mdoc->first) { - assert(NULL == mdoc->last); - if ( ! mdoc_valid_pre(mdoc, p)) - return(0); - if ( ! mdoc_action_pre(mdoc, p)) - return(0); - mdoc->first = p; - mdoc->last = p; - mdoc_msg(mdoc, "parse: root %s `%s'", nt, nn); - return(1); - } + assert(mdoc->last); + assert(mdoc->first); + assert(MDOC_ROOT != p->type); switch (mdoc->last->type) { case (MDOC_TEXT): @@ -455,6 +453,10 @@ mdoc_node_append(struct mdoc *mdoc, struct mdoc_node *p) on = mdoc_macronames[mdoc->last->data.block.tok]; ot = "block"; break; + case (MDOC_ROOT): + on = "root"; + ot = "root"; + break; default: abort(); /* NOTREACHED */ @@ -545,6 +547,19 @@ mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, int tok) int +mdoc_root_alloc(struct mdoc *mdoc) +{ + struct mdoc_node *p; + + p = xcalloc(1, sizeof(struct mdoc_node)); + + p->type = MDOC_ROOT; + + return(mdoc_node_append(mdoc, p)); +} + + +int mdoc_block_alloc(struct mdoc *mdoc, int line, int pos, int tok, size_t argsz, const struct mdoc_arg *args) { |