diff options
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | man.3 | 11 | ||||
-rw-r--r-- | man.c | 16 | ||||
-rw-r--r-- | man.h | 2 | ||||
-rw-r--r-- | man_validate.c | 2 | ||||
-rw-r--r-- | mdoc.3 | 2 | ||||
-rw-r--r-- | mdoc_validate.c | 2 | ||||
-rw-r--r-- | tree.c | 2 |
8 files changed, 41 insertions, 3 deletions
@@ -866,8 +866,11 @@ rerun: } else if (ROFF_EQN == rr) { assert(curp->man || curp->mdoc); assert(roff_eqn(curp->roff)); - if (curp->mdoc) - mdoc_addeqn(curp->mdoc, roff_eqn(curp->roff)); + rc = curp->mdoc ? + mdoc_addeqn(curp->mdoc, + roff_eqn(curp->roff)) : + man_addeqn(curp->man, + roff_eqn(curp->roff)); } else if (curp->man || curp->mdoc) { rc = curp->man ? man_parseln(curp->man, @@ -19,6 +19,8 @@ .Os .Sh NAME .Nm man , +.Nm man_addeqn , +.Nm man_addspan , .Nm man_alloc , .Nm man_endparse , .Nm man_free , @@ -32,6 +34,11 @@ .In man.h .Vt extern const char * const * man_macronames; .Ft int +.Fo man_addeqn +.Fa "struct man *man" +.Fa "const struct eqn *eqn" +.Fc +.Ft int .Fo man_addspan .Fa "struct man *man" .Fa "const struct tbl_span *span" @@ -106,6 +113,7 @@ for details. .El .Ss Functions If +.Fn man_addeqn , .Fn man_addspan , .Fn man_parseln , or @@ -116,6 +124,9 @@ or .Fn man_free will raise an assertion. .Bl -ohang +.It Fn man_addeqn +Add an equation to the parsing stream. +Returns 0 on failure, 1 on success. .It Fn man_addspan Add a table span to the parsing stream. Returns 0 on failure, 1 on success. @@ -346,6 +346,22 @@ man_node_delete(struct man *m, struct man_node *p) man_node_free(p); } +int +man_addeqn(struct man *m, const struct eqn *ep) +{ + struct man_node *n; + + assert( ! (MAN_HALT & m->flags)); + + n = man_node_alloc(m, ep->line, ep->pos, MAN_EQN, MAN_MAX); + n->eqn = ep; + + if ( ! man_node_append(m, n)) + return(0); + + m->next = MAN_NEXT_SIBLING; + return(man_descope(m, ep->line, ep->pos)); +} int man_addspan(struct man *m, const struct tbl_span *sp) @@ -104,6 +104,7 @@ struct man_node { struct man_node *head; /* BLOCK node HEAD ptr */ struct man_node *body; /* BLOCK node BODY ptr */ const struct tbl_span *span; /* TBL */ + const struct eqn *eqn; /* EQN */ }; /* @@ -123,6 +124,7 @@ int man_parseln(struct man *, int, char *, int); int man_endparse(struct man *); int man_addspan(struct man *, const struct tbl_span *); +int man_addeqn(struct man *, const struct eqn *); const struct man_node *man_node(const struct man *); const struct man_meta *man_meta(const struct man *); diff --git a/man_validate.c b/man_validate.c index 885814af..f9f48e14 100644 --- a/man_validate.c +++ b/man_validate.c @@ -152,6 +152,8 @@ man_valid_post(struct man *m) return(check_text(m, m->last)); case (MAN_ROOT): return(check_root(m, m->last)); + case (MAN_EQN): + /* FALLTHROUGH */ case (MAN_TBL): return(1); default: @@ -20,6 +20,8 @@ .Os .Sh NAME .Nm mdoc , +.Nm mdoc_addeqn , +.Nm mdoc_addspan , .Nm mdoc_alloc , .Nm mdoc_endparse , .Nm mdoc_free , diff --git a/mdoc_validate.c b/mdoc_validate.c index 852262e8..5316e5e4 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -369,6 +369,8 @@ mdoc_valid_post(struct mdoc *mdoc) switch (mdoc->last->type) { case (MDOC_TEXT): /* FALLTHROUGH */ + case (MDOC_EQN): + /* FALLTHROUGH */ case (MDOC_TBL): return(1); case (MDOC_ROOT): @@ -233,7 +233,7 @@ print_man(const struct man_node *n, int indent) case (MAN_TBL): break; case (MAN_EQN): - p = "eqn"; + p = n->eqn->data; break; default: abort(); |