version 1.15, 2008/11/28 15:25:49 |
version 1.16, 2008/11/28 18:15:29 |
Line 357 const char *const *tokargnames = tokargnamesp; |
|
Line 357 const char *const *tokargnames = tokargnamesp; |
|
int |
int |
roff_free(struct rofftree *tree, int flush) |
roff_free(struct rofftree *tree, int flush) |
{ |
{ |
int error; |
int error, t; |
struct roffnode *n; |
struct roffnode *n; |
|
|
error = 0; |
if ( ! flush) |
|
goto end; |
|
|
for (n = tree->last; n->parent; n = n->parent) |
error = 1; |
if (tokens[n->tok].ctx == 0) { |
|
roff_warn(tree, NULL, "closing explicit scope " |
|
"of `%s'", toknames[n->tok]); |
|
error = 1; |
|
} |
|
|
|
if (0 == error && (ROFF_PRELUDE & tree->state)) { |
if (ROFF_PRELUDE & tree->state) { |
roff_warn(tree, NULL, "prelude never finished"); |
roff_warn(tree, NULL, "prelude never finished"); |
error = 1; |
goto end; |
|
} |
|
|
|
for (n = tree->last; n->parent; n = n->parent) { |
|
if (0 != tokens[n->tok].ctx) |
|
break; |
|
roff_warn(tree, NULL, "closing explicit scope `%s'", |
|
toknames[n->tok]); |
|
goto end; |
} |
} |
|
|
|
while (tree->last) { |
|
t = tree->last->tok; |
|
if ( ! (*tokens[t].cb)(t, tree, NULL, ROFF_EXIT)) |
|
goto end; |
|
} |
|
|
|
if ( ! (*tree->cb.roffhead)(tree->arg)) |
|
goto end; |
|
|
|
error = 0; |
|
|
|
end: |
|
|
while (tree->last) |
while (tree->last) |
roffnode_free(tree); |
roffnode_free(tree); |
|
|
Line 394 roff_alloc(const struct roffcb *cb, void *args) |
|
Line 411 roff_alloc(const struct roffcb *cb, void *args) |
|
tree->arg = args; |
tree->arg = args; |
|
|
(void)memcpy(&tree->cb, cb, sizeof(struct roffcb)); |
(void)memcpy(&tree->cb, cb, sizeof(struct roffcb)); |
|
|
|
if ( ! (*tree->cb.roffhead)(args)) { |
|
free(tree); |
|
return(NULL); |
|
} |
|
|
return(tree); |
return(tree); |
} |
} |