summaryrefslogtreecommitdiffstats
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-20 07:43:15 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-20 07:43:15 +0000
commit2d394f98033c052fc94dabbbb074c32af0a74123 (patch)
treebd626fee2620f5d2c8840f7058423e55e4442498 /mdoc.c
parent557eea53236378e26b9f5085251d8c15c8dda4b5 (diff)
downloadmandoc-2d394f98033c052fc94dabbbb074c32af0a74123.tar.gz
Removed tree-writing capability (for now, only validates and exits).
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/mdoc.c b/mdoc.c
index 473f42b5..33372194 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -212,12 +212,14 @@ static void argfree(size_t, struct mdoc_arg *);
static void argcpy(struct mdoc_arg *,
const struct mdoc_arg *);
+static struct mdoc_node *mdoc_node_alloc(void);
static int mdoc_node_append(struct mdoc *,
struct mdoc_node *);
static void mdoc_elem_free(struct mdoc_elem *);
static void mdoc_text_free(struct mdoc_text *);
+
const struct mdoc_node *
mdoc_node(struct mdoc *mdoc)
{
@@ -510,6 +512,14 @@ mdoc_node_append(struct mdoc *mdoc, struct mdoc_node *p)
}
+static struct mdoc_node *
+mdoc_node_alloc(void)
+{
+
+ return(xcalloc(1, sizeof(struct mdoc_node)));
+}
+
+
int
mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, int tok)
{
@@ -518,7 +528,7 @@ mdoc_tail_alloc(struct mdoc *mdoc, int line, int pos, int tok)
assert(mdoc->first);
assert(mdoc->last);
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
p->line = line;
p->pos = pos;
@@ -537,7 +547,7 @@ mdoc_head_alloc(struct mdoc *mdoc, int line, int pos, int tok)
assert(mdoc->first);
assert(mdoc->last);
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
p->line = line;
p->pos = pos;
@@ -556,7 +566,7 @@ mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, int tok)
assert(mdoc->first);
assert(mdoc->last);
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
p->line = line;
p->pos = pos;
@@ -572,7 +582,7 @@ mdoc_root_alloc(struct mdoc *mdoc)
{
struct mdoc_node *p;
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
p->type = MDOC_ROOT;
@@ -586,7 +596,7 @@ mdoc_block_alloc(struct mdoc *mdoc, int line, int pos,
{
struct mdoc_node *p;
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
p->pos = pos;
p->line = line;
@@ -605,7 +615,7 @@ mdoc_elem_alloc(struct mdoc *mdoc, int line, int pos,
{
struct mdoc_node *p;
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
p->line = line;
p->pos = pos;
@@ -624,7 +634,8 @@ mdoc_word_alloc(struct mdoc *mdoc,
{
struct mdoc_node *p;
- p = xcalloc(1, sizeof(struct mdoc_node));
+ p = mdoc_node_alloc();
+
p->line = line;
p->pos = pos;
p->type = MDOC_TEXT;