summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/roff.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r--usr.bin/mandoc/roff.c65
1 files changed, 62 insertions, 3 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 9f988eaf1a8..d4f3d962cdd 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: roff.c,v 1.138 2015/04/19 13:50:10 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.139 2015/04/19 14:25:05 schwarze Exp $ */
/*
- * Copyright (c) 2009-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -30,7 +30,6 @@
#include "libmandoc.h"
#include "roff_int.h"
#include "libroff.h"
-#include "libmdoc.h"
/* Maximum number of nested if-else conditionals. */
#define RSTACK_MAX 128
@@ -1065,6 +1064,36 @@ roff_node_append(struct roff_man *man, struct roff_node *n)
man->last = n;
}
+void
+roff_word_alloc(struct roff_man *man, int line, int pos, const char *word)
+{
+ struct roff_node *n;
+
+ n = roff_node_alloc(man, line, pos, ROFFT_TEXT, TOKEN_NONE);
+ n->string = roff_strdup(man->roff, word);
+ roff_node_append(man, n);
+ if (man->macroset == MACROSET_MDOC)
+ mdoc_valid_post(man);
+ else
+ man_valid_post(man);
+ man->next = ROFF_NEXT_SIBLING;
+}
+
+void
+roff_word_append(struct roff_man *man, const char *word)
+{
+ struct roff_node *n;
+ char *addstr, *newstr;
+
+ n = man->last;
+ addstr = roff_strdup(man->roff, word);
+ mandoc_asprintf(&newstr, "%s %s", n->string, addstr);
+ free(addstr);
+ free(n->string);
+ n->string = newstr;
+ man->next = ROFF_NEXT_SIBLING;
+}
+
struct roff_node *
roff_head_alloc(struct roff_man *man, int line, int pos, int tok)
{
@@ -1088,6 +1117,36 @@ roff_body_alloc(struct roff_man *man, int line, int pos, int tok)
}
void
+roff_addeqn(struct roff_man *man, const struct eqn *eqn)
+{
+ struct roff_node *n;
+
+ n = roff_node_alloc(man, eqn->ln, eqn->pos, ROFFT_EQN, TOKEN_NONE);
+ n->eqn = eqn;
+ if (eqn->ln > man->last->line)
+ n->flags |= MDOC_LINE;
+ roff_node_append(man, n);
+ man->next = ROFF_NEXT_SIBLING;
+}
+
+void
+roff_addtbl(struct roff_man *man, const struct tbl_span *tbl)
+{
+ struct roff_node *n;
+
+ if (man->macroset == MACROSET_MAN)
+ man_breakscope(man, TOKEN_NONE);
+ n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);
+ n->span = tbl;
+ roff_node_append(man, n);
+ if (man->macroset == MACROSET_MDOC)
+ mdoc_valid_post(man);
+ else
+ man_valid_post(man);
+ man->next = ROFF_NEXT_SIBLING;
+}
+
+void
roff_node_unlink(struct roff_man *man, struct roff_node *n)
{