From e6cfc592798a7e03016169696640f0dd9f11d5e6 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sat, 1 Jan 2011 12:18:37 +0000 Subject: Add table processing structures to -mdoc. This consists of an external-facing function mdoc_addspan(), then various bits to prohibit printing and scanning (this requires some if's to be converted into switch's). --- mdoc.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'mdoc.c') diff --git a/mdoc.c b/mdoc.c index d4f8b49c..d408449e 100644 --- a/mdoc.c +++ b/mdoc.c @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.174 2011/01/01 10:51:30 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.175 2011/01/01 12:18:37 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -98,6 +98,8 @@ static int node_append(struct mdoc *, struct mdoc_node *); static int mdoc_ptext(struct mdoc *, int, char *, int); static int mdoc_pmacro(struct mdoc *, int, char *, int); +static int mdoc_span_alloc(struct mdoc *, + const struct tbl_span *); const struct mdoc_node * @@ -221,6 +223,24 @@ mdoc_endparse(struct mdoc *m) return(0); } +int +mdoc_addspan(struct mdoc *m, const struct tbl_span *sp) +{ + + if (MDOC_HALT & m->flags) + return(0); + + /* No text before an initial macro. */ + + if (SEC_NONE == m->lastnamed) { + /* FIXME: grab from span. */ + mdoc_pmsg(m, 0, 0, MANDOCERR_NOTEXT); + return(1); + } + + return(mdoc_span_alloc(m, sp)); +} + /* * Main parse routine. Parses a single line -- really just hands off to @@ -525,6 +545,22 @@ mdoc_elem_alloc(struct mdoc *m, int line, int pos, return(1); } +static int +mdoc_span_alloc(struct mdoc *m, const struct tbl_span *sp) +{ + struct mdoc_node *n; + + /* FIXME: grab from tbl_span. */ + n = node_alloc(m, 0, 0, MDOC_MAX, MDOC_TBL); + n->span = sp; + + if ( ! node_append(m, n)) + return(0); + + m->next = MDOC_NEXT_SIBLING; + return(1); +} + int mdoc_word_alloc(struct mdoc *m, int line, int pos, const char *p) -- cgit v1.2.3