aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-01-01 12:18:37 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-01-01 12:18:37 +0000
commite6cfc592798a7e03016169696640f0dd9f11d5e6 (patch)
treee9e5e188e11b13d858969b59b69d45953be7504d /mdoc.c
parent0b95ed5dc93d34749b819aa398725ff81f524b89 (diff)
downloadmandoc-e6cfc592798a7e03016169696640f0dd9f11d5e6.tar.gz
mandoc-e6cfc592798a7e03016169696640f0dd9f11d5e6.tar.zst
mandoc-e6cfc592798a7e03016169696640f0dd9f11d5e6.zip
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).
Diffstat (limited to 'mdoc.c')
-rw-r--r--mdoc.c38
1 files changed, 37 insertions, 1 deletions
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 <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -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)