summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c7
-rw-r--r--man.311
-rw-r--r--man.c16
-rw-r--r--man.h2
-rw-r--r--man_validate.c2
-rw-r--r--mdoc.32
-rw-r--r--mdoc_validate.c2
-rw-r--r--tree.c2
8 files changed, 41 insertions, 3 deletions
diff --git a/main.c b/main.c
index 8ef19e68..308b4f72 100644
--- a/main.c
+++ b/main.c
@@ -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,
diff --git a/man.3 b/man.3
index 1ea19b64..0d39d5eb 100644
--- a/man.3
+++ b/man.3
@@ -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.
diff --git a/man.c b/man.c
index 64f577ca..161e69a9 100644
--- a/man.c
+++ b/man.c
@@ -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)
diff --git a/man.h b/man.h
index 13b7d0a7..9487e5f8 100644
--- a/man.h
+++ b/man.h
@@ -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:
diff --git a/mdoc.3 b/mdoc.3
index fe0b41de..c0561900 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -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):
diff --git a/tree.c b/tree.c
index c88d5eb6..d53bbfc0 100644
--- a/tree.c
+++ b/tree.c
@@ -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();