summaryrefslogtreecommitdiffstats
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
commit9182860daa80b4a3002521ca4fdbd780d009b616 (patch)
tree1b81397d2d235aab70575465e1b8dd9152d84674
parent16173bda3531a2bb54b45b2e327c8b7e2cf37fd6 (diff)
downloadmandoc-9182860daa80b4a3002521ca4fdbd780d009b616.tar.gz
`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.c8
-rw-r--r--mdoc.h6
-rw-r--r--mdoc_argv.c2
-rw-r--r--mdoc_html.c6
-rw-r--r--mdoc_term.c9
-rw-r--r--mdoc_validate.c25
6 files changed, 31 insertions, 25 deletions
diff --git a/mdoc.c b/mdoc.c
index 3a3f5b4c..25729ebe 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -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 def26d77..1145efc2 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -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 197443cd..febe3d04 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -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 04a313b1..cd0c5f54 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -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 b7a7f053..31c2e51e 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -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 ed0a4c25..ddd152be 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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;