aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/eqn.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-25 15:37:00 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-25 15:37:00 +0000
commit499b7cc2df175e8f1cd3a0a7db00455e691d03de (patch)
tree356638e94fe0111d12f3ef9b7f7b8f40bbc92cdb /eqn.c
parenta36c339dbe615061842578e7f9191193481618c1 (diff)
downloadmandoc-499b7cc2df175e8f1cd3a0a7db00455e691d03de.tar.gz
mandoc-499b7cc2df175e8f1cd3a0a7db00455e691d03de.tar.zst
mandoc-499b7cc2df175e8f1cd3a0a7db00455e691d03de.zip
Implement the first steps of equation parsing from within libmdoc.
This consists of a shim around the text parser that calls out to libroff if equation components exist on the line. Right now this will do nothing, as the equation delimiter always returns nil.
Diffstat (limited to 'eqn.c')
-rw-r--r--eqn.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/eqn.c b/eqn.c
index 9c3b9783..37f01bcb 100644
--- a/eqn.c
+++ b/eqn.c
@@ -1,4 +1,4 @@
-/* $Id: eqn.c,v 1.37 2011/07/23 18:44:42 kristaps Exp $ */
+/* $Id: eqn.c,v 1.38 2011/07/25 15:37:00 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -294,8 +294,7 @@ eqn_read(struct eqn_node **epp, int ln,
*/
if (0 == strncmp(p, ".EN", 3)) {
- er = eqn_end(ep);
- *epp = NULL;
+ er = eqn_end(epp);
p += 3;
while (' ' == *p || '\t' == *p)
p++;
@@ -333,7 +332,7 @@ eqn_alloc(const char *name, int pos, int line, struct mparse *parse)
p = mandoc_calloc(1, sizeof(struct eqn_node));
- if ('\0' != *name) {
+ if (name && '\0' != *name) {
sz = strlen(name);
assert(sz);
do {
@@ -352,11 +351,15 @@ eqn_alloc(const char *name, int pos, int line, struct mparse *parse)
}
enum rofferr
-eqn_end(struct eqn_node *ep)
+eqn_end(struct eqn_node **epp)
{
+ struct eqn_node *ep;
struct eqn_box *root;
enum eqn_rest c;
+ ep = *epp;
+ *epp = NULL;
+
ep->eqn.root = mandoc_calloc(1, sizeof(struct eqn_box));
root = ep->eqn.root;