aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-12 11:58:22 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-12 11:58:22 +0000
commit305a1c805ebbdca0c2e2de3a301a7f6759d2e200 (patch)
treea2ceb4a968963c27576e246394c6c007722311cf
parent9e1c8c4504be3ee8555871134f21b59fba7bd8ac (diff)
downloadmandoc-305a1c805ebbdca0c2e2de3a301a7f6759d2e200.tar.gz
mandoc-305a1c805ebbdca0c2e2de3a301a7f6759d2e200.tar.zst
mandoc-305a1c805ebbdca0c2e2de3a301a7f6759d2e200.zip
`Bl' is now using a struct instead of a single enum mdoc_list for its
cached values. You can probably guess where this is going.
-rw-r--r--mdoc.c10
-rw-r--r--mdoc.h8
-rw-r--r--mdoc_argv.c4
-rw-r--r--mdoc_html.c8
-rw-r--r--mdoc_term.c11
-rw-r--r--mdoc_validate.c27
6 files changed, 37 insertions, 31 deletions
diff --git a/mdoc.c b/mdoc.c
index b1059ead..bdd03482 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.145 2010/05/31 21:32:57 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.146 2010/06/12 11:58:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -568,7 +568,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->data.list) {
+ LIST_column == n->data.Bl.type) {
/* `Bl' is open without any children. */
m->flags |= MDOC_FREECOL;
return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
@@ -577,7 +577,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
NULL != n->parent &&
MDOC_Bl == n->parent->tok &&
- LIST_column == n->parent->data.list) {
+ LIST_column == n->parent->data.Bl.type) {
/* `Bl' has block-level `It' children. */
m->flags |= MDOC_FREECOL;
return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
@@ -783,7 +783,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->data.list) {
+ LIST_column == n->data.Bl.type) {
m->flags |= MDOC_FREECOL;
if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf))
goto err;
@@ -799,7 +799,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
NULL != n->parent &&
MDOC_Bl == n->parent->tok &&
- LIST_column == n->parent->data.list) {
+ LIST_column == n->parent->data.Bl.type) {
m->flags |= MDOC_FREECOL;
if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf))
goto err;
diff --git a/mdoc.h b/mdoc.h
index bf62321f..741c63f1 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.85 2010/06/12 11:21:44 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.86 2010/06/12 11:58:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -278,6 +278,10 @@ struct mdoc_bd {
int comp;
};
+struct mdoc_bl {
+ enum mdoc_list type;
+};
+
/* Node in AST. */
struct mdoc_node {
struct mdoc_node *parent; /* parent AST node */
@@ -305,7 +309,7 @@ struct mdoc_node {
char *string; /* TEXT */
union {
- enum mdoc_list list; /* `Bl' nodes */
+ struct mdoc_bl Bl;
struct mdoc_bd Bd;
} data;
};
diff --git a/mdoc_argv.c b/mdoc_argv.c
index dde686d9..334a6087 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.52 2010/05/31 13:39:13 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.53 2010/06/12 11:58:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -359,7 +359,7 @@ mdoc_args(struct mdoc *m, int line, int *pos,
if (MDOC_Bl == n->tok)
break;
- if (n && LIST_column == n->data.list) {
+ if (n && LIST_column == n->data.Bl.type) {
fl |= ARGS_TABSEP;
fl &= ~ARGS_DELIM;
}
diff --git a/mdoc_html.c b/mdoc_html.c
index 302cecb8..e4337efb 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.80 2010/06/12 11:21:44 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.81 2010/06/12 11:58:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1035,7 +1035,7 @@ mdoc_it_pre(MDOC_ARGS)
if (MDOC_BLOCK != n->type)
bl = bl->parent;
- type = bl->data.list;
+ type = bl->data.Bl.type;
/* Set default width and offset. */
@@ -1123,7 +1123,7 @@ mdoc_bl_pre(MDOC_ARGS)
return(0);
if (MDOC_BLOCK != n->type)
return(1);
- if (LIST_enum != n->data.list)
+ if (LIST_enum != n->data.Bl.type)
return(1);
ord = malloc(sizeof(struct ord));
@@ -1147,7 +1147,7 @@ mdoc_bl_post(MDOC_ARGS)
if (MDOC_BLOCK != n->type)
return;
- if (LIST_enum != n->data.list)
+ if (LIST_enum != n->data.Bl.type)
return;
ord = h->ords.head;
diff --git a/mdoc_term.c b/mdoc_term.c
index 6ef185d0..fe657446 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.148 2010/06/12 11:21:44 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.149 2010/06/12 11:58:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -570,6 +570,7 @@ print_bvspace(struct termp *p,
{
const struct mdoc_node *nn;
+ /* FIXME: MDOC_Bd == bl->tok && bl->data.Bd.comp */
term_newln(p);
if (arg_hasattr(MDOC_Compact, bl))
return;
@@ -590,13 +591,13 @@ print_bvspace(struct termp *p,
/* A `-column' does not assert vspace within the list. */
- if (MDOC_Bl == bl->tok && LIST_column == bl->data.list)
+ if (MDOC_Bl == bl->tok && LIST_column == bl->data.Bl.type)
if (n->prev && MDOC_It == n->prev->tok)
return;
/* A `-diag' without body does not vspace. */
- if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list)
+ if (MDOC_Bl == bl->tok && LIST_diag == bl->data.Bl.type)
if (n->prev && MDOC_It == n->prev->tok) {
assert(n->prev->body);
if (NULL == n->prev->body->child)
@@ -661,7 +662,7 @@ termp_it_pre(DECL_ARGS)
arg_getattrs(keys, vals, 3, bl);
- type = bl->data.list;
+ type = bl->data.Bl.type;
/*
* First calculate width and offset. This is pretty easy unless
@@ -989,7 +990,7 @@ termp_it_post(DECL_ARGS)
if (MDOC_BLOCK == n->type)
return;
- type = n->parent->parent->parent->data.list;
+ type = n->parent->parent->parent->data.Bl.type;
switch (type) {
case (LIST_item):
diff --git a/mdoc_validate.c b/mdoc_validate.c
index ad7b6418..62a126b3 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.95 2010/06/12 11:41:50 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.96 2010/06/12 11:58:22 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -539,8 +539,9 @@ pre_bl(PRE_ARGS)
assert(n->parent);
assert(MDOC_BLOCK == n->parent->type);
assert(MDOC_Bl == n->parent->tok);
- assert(LIST__NONE != n->parent->data.list);
- n->data.list = n->parent->data.list;
+ assert(LIST__NONE != n->parent->data.Bl.type);
+ memcpy(&n->data.Bl, &n->parent->data.Bl,
+ sizeof(struct mdoc_bl));
return(1);
}
@@ -550,7 +551,7 @@ pre_bl(PRE_ARGS)
* ones. If we find no list type, we default to LIST_item.
*/
- assert(LIST__NONE == n->data.list);
+ assert(LIST__NONE == n->data.Bl.type);
offs = width = cmpt = -1;
/* LINTED */
@@ -618,18 +619,18 @@ pre_bl(PRE_ARGS)
/* Check: multiple list types. */
- if (LIST__NONE != lt && n->data.list != LIST__NONE)
+ if (LIST__NONE != lt && n->data.Bl.type != LIST__NONE)
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP))
return(0);
/* Assign list type. */
- if (LIST__NONE != lt && n->data.list == LIST__NONE)
- n->data.list = lt;
+ if (LIST__NONE != lt && n->data.Bl.type == LIST__NONE)
+ n->data.Bl.type = lt;
/* The list type should come first. */
- if (n->data.list == LIST__NONE)
+ if (n->data.Bl.type == LIST__NONE)
if (width >= 0 || offs >= 0 || cmpt >= 0)
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST))
return(0);
@@ -639,10 +640,10 @@ pre_bl(PRE_ARGS)
/* Allow lists to default to LIST_item. */
- if (LIST__NONE == n->data.list) {
+ if (LIST__NONE == n->data.Bl.type) {
if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE))
return(0);
- n->data.list = LIST_item;
+ n->data.Bl.type = LIST_item;
}
/*
@@ -651,7 +652,7 @@ pre_bl(PRE_ARGS)
* and must also be warned.
*/
- switch (n->data.list) {
+ switch (n->data.Bl.type) {
case (LIST_tag):
if (width >= 0)
break;
@@ -1031,7 +1032,7 @@ post_it(POST_ARGS)
return(1);
n = mdoc->last->parent->parent;
- lt = n->data.list;
+ lt = n->data.Bl.type;
if (LIST__NONE == lt) {
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
@@ -1123,7 +1124,7 @@ post_bl_head(POST_ARGS)
assert(mdoc->last->parent);
n = mdoc->last->parent;
- if (LIST_column == n->data.list) {
+ if (LIST_column == n->data.Bl.type) {
for (i = 0; i < (int)n->args->argc; i++)
if (MDOC_Column == n->args->argv[i].arg)
break;