summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-12-24 14:00:40 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-12-24 14:00:40 +0000
commit8d5ca2330a9d86880ee07d6fecf0befff8d445f4 (patch)
treeab6a339e99d6fcdd827aaecfee738abc32150be5
parent390e9bb2eebe070ac0a97222e307f0c172517e47 (diff)
downloadmandoc-8d5ca2330a9d86880ee07d6fecf0befff8d445f4.tar.gz
As per schwarze@'s suggestions, roll back the refcount structure in
favour of a simpler shim for normalised data in the node allocation and free routines. This removes the need to bump and copy references within validator handlers, removes a pointer redirect, and also kills the refcount structure itself. Data is assumed to "live" either in a MDOC_BLOCK or MDOC_ELEM and is copied accordingly.
-rw-r--r--mdoc.c50
-rw-r--r--mdoc.h11
-rw-r--r--mdoc_argv.c2
-rw-r--r--mdoc_html.c48
-rw-r--r--mdoc_term.c48
-rw-r--r--mdoc_validate.c136
6 files changed, 152 insertions, 143 deletions
diff --git a/mdoc.c b/mdoc.c
index 91248872..7dfbd585 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -328,6 +328,23 @@ node_append(struct mdoc *mdoc, struct mdoc_node *p)
p->parent->nchild++;
+ /*
+ * Copy over the normalised-data pointer of our parent. Not
+ * everybody has one, but copying a null pointer is fine.
+ */
+
+ switch (p->type) {
+ case (MDOC_BODY):
+ /* FALLTHROUGH */
+ case (MDOC_TAIL):
+ /* FALLTHROUGH */
+ case (MDOC_HEAD):
+ p->norm = p->parent->norm;
+ break;
+ default:
+ break;
+ }
+
if ( ! mdoc_valid_pre(mdoc, p))
return(0);
@@ -460,6 +477,19 @@ mdoc_block_alloc(struct mdoc *m, int line, int pos,
p->args = args;
if (p->args)
(args->refcnt)++;
+
+ switch (tok) {
+ case (MDOC_Bd):
+ /* FALLTHROUGH */
+ case (MDOC_Bf):
+ /* FALLTHROUGH */
+ case (MDOC_Bl):
+ p->norm = mandoc_calloc(1, sizeof(union mdoc_data));
+ break;
+ default:
+ break;
+ }
+
if ( ! node_append(m, p))
return(0);
m->next = MDOC_NEXT_CHILD;
@@ -477,6 +507,15 @@ mdoc_elem_alloc(struct mdoc *m, int line, int pos,
p->args = args;
if (p->args)
(args->refcnt)++;
+
+ switch (tok) {
+ case (MDOC_An):
+ p->norm = mandoc_calloc(1, sizeof(union mdoc_data));
+ break;
+ default:
+ break;
+ }
+
if ( ! node_append(m, p))
return(0);
m->next = MDOC_NEXT_CHILD;
@@ -511,9 +550,8 @@ static void
mdoc_node_free(struct mdoc_node *p)
{
- if (p->norm && 0 == --(p->norm->refcnt))
+ if (MDOC_BLOCK == p->type || MDOC_ELEM == p->type)
free(p->norm);
-
if (p->string)
free(p->string);
if (p->args)
@@ -608,7 +646,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int offs)
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->norm->d.Bl.type) {
+ LIST_column == n->norm->Bl.type) {
/* `Bl' is open without any children. */
m->flags |= MDOC_FREECOL;
return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
@@ -617,7 +655,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->norm->d.Bl.type) {
+ LIST_column == n->parent->norm->Bl.type) {
/* `Bl' has block-level `It' children. */
m->flags |= MDOC_FREECOL;
return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf));
@@ -798,7 +836,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
*/
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
- LIST_column == n->norm->d.Bl.type) {
+ LIST_column == n->norm->Bl.type) {
m->flags |= MDOC_FREECOL;
if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf))
goto err;
@@ -814,7 +852,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->norm->d.Bl.type) {
+ LIST_column == n->parent->norm->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 126bf3d9..6cf8364c 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -365,15 +365,6 @@ union mdoc_data {
struct mdoc_bl Bl;
};
-/*
- * Reference-counted structure for containing normalised arguments of
- * certain macros (those listed in union mdoc_data).
- */
-struct mdoc_norm {
- int refcnt;
- union mdoc_data d;
-};
-
/*
* Single node in tree-linked AST.
*/
@@ -396,7 +387,7 @@ struct mdoc_node {
#define MDOC_ENDED (1 << 5) /* rendering has been ended */
enum mdoc_type type; /* AST node type */
enum mdoc_sec sec; /* current named section */
- struct mdoc_norm *norm; /* ref-counted, normalised args */
+ union mdoc_data *norm; /* normalised args */
/* FIXME: these can be union'd to shave a few bytes. */
struct mdoc_arg *args; /* BLOCK/ELEM */
struct mdoc_node *pending; /* BLOCK */
diff --git a/mdoc_argv.c b/mdoc_argv.c
index 3762c876..9617fcc8 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -361,7 +361,7 @@ mdoc_args(struct mdoc *m, int line, int *pos,
if (MDOC_Bl == n->tok)
break;
- if (n && LIST_column == n->norm->d.Bl.type) {
+ if (n && LIST_column == n->norm->Bl.type) {
fl |= ARGS_TABSEP;
fl &= ~ARGS_DELIM;
}
diff --git a/mdoc_html.c b/mdoc_html.c
index f9ca7269..fcbcf550 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -839,7 +839,7 @@ mdoc_it_pre(MDOC_ARGS)
assert(bl);
- type = bl->norm->d.Bl.type;
+ type = bl->norm->Bl.type;
assert(lists[type]);
PAIR_CLASS_INIT(&tag[0], lists[type]);
@@ -865,7 +865,7 @@ mdoc_it_pre(MDOC_ARGS)
case(LIST_ohang):
/* FALLTHROUGH */
case(LIST_tag):
- SCALE_VS_INIT(&su, ! bl->norm->d.Bl.comp);
+ SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag[1], h);
print_otag(h, TAG_DT, 2, tag);
@@ -890,7 +890,7 @@ mdoc_it_pre(MDOC_ARGS)
case(LIST_enum):
/* FALLTHROUGH */
case(LIST_item):
- SCALE_VS_INIT(&su, ! bl->norm->d.Bl.comp);
+ SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag[1], h);
print_otag(h, TAG_LI, 2, tag);
@@ -904,17 +904,17 @@ mdoc_it_pre(MDOC_ARGS)
case(LIST_ohang):
/* FALLTHROUGH */
case(LIST_tag):
- if (NULL == bl->norm->d.Bl.width) {
+ if (NULL == bl->norm->Bl.width) {
print_otag(h, TAG_DD, 1, tag);
break;
}
- a2width(bl->norm->d.Bl.width, &su);
+ a2width(bl->norm->Bl.width, &su);
bufcat_su(h, "margin-left", &su);
PAIR_STYLE_INIT(&tag[1], h);
print_otag(h, TAG_DD, 2, tag);
break;
case(LIST_column):
- SCALE_VS_INIT(&su, ! bl->norm->d.Bl.comp);
+ SCALE_VS_INIT(&su, ! bl->norm->Bl.comp);
bufcat_su(h, "margin-top", &su);
PAIR_STYLE_INIT(&tag[1], h);
print_otag(h, TAG_TD, 2, tag);
@@ -945,13 +945,13 @@ mdoc_bl_pre(MDOC_ARGS)
char buf[BUFSIZ];
if (MDOC_BODY == n->type) {
- if (LIST_column == n->norm->d.Bl.type)
+ if (LIST_column == n->norm->Bl.type)
print_otag(h, TAG_TBODY, 0, NULL);
return(1);
}
if (MDOC_HEAD == n->type) {
- if (LIST_column != n->norm->d.Bl.type)
+ if (LIST_column != n->norm->Bl.type)
return(0);
/*
@@ -961,10 +961,10 @@ mdoc_bl_pre(MDOC_ARGS)
* screen and we want to preserve that behaviour.
*/
- for (i = 0; i < n->norm->d.Bl.ncols; i++) {
- a2width(n->norm->d.Bl.cols[i], &su);
+ for (i = 0; i < n->norm->Bl.ncols; i++) {
+ a2width(n->norm->Bl.cols[i], &su);
bufinit(h);
- if (i < n->norm->d.Bl.ncols - 1)
+ if (i < n->norm->Bl.ncols - 1)
bufcat_su(h, "width", &su);
else
bufcat_su(h, "min-width", &su);
@@ -980,19 +980,19 @@ mdoc_bl_pre(MDOC_ARGS)
bufcat_su(h, "margin-bottom", &su);
PAIR_STYLE_INIT(&tag[0], h);
- assert(lists[n->norm->d.Bl.type]);
+ assert(lists[n->norm->Bl.type]);
strlcpy(buf, "list ", BUFSIZ);
- strlcat(buf, lists[n->norm->d.Bl.type], BUFSIZ);
+ strlcat(buf, lists[n->norm->Bl.type], BUFSIZ);
PAIR_INIT(&tag[1], ATTR_CLASS, buf);
/* Set the block's left-hand margin. */
- if (n->norm->d.Bl.offs) {
- a2offs(n->norm->d.Bl.offs, &su);
+ if (n->norm->Bl.offs) {
+ a2offs(n->norm->Bl.offs, &su);
bufcat_su(h, "margin-left", &su);
}
- switch (n->norm->d.Bl.type) {
+ switch (n->norm->Bl.type) {
case(LIST_bullet):
/* FALLTHROUGH */
case(LIST_dash):
@@ -1145,7 +1145,7 @@ mdoc_bd_pre(MDOC_ARGS)
return(0);
if (MDOC_BLOCK == n->type) {
- comp = n->norm->d.Bd.comp;
+ comp = n->norm->Bd.comp;
for (nn = n; nn && ! comp; nn = nn->parent) {
if (MDOC_BLOCK != nn->type)
continue;
@@ -1160,14 +1160,14 @@ mdoc_bd_pre(MDOC_ARGS)
}
SCALE_HS_INIT(&su, 0);
- if (n->norm->d.Bd.offs)
- a2offs(n->norm->d.Bd.offs, &su);
+ if (n->norm->Bd.offs)
+ a2offs(n->norm->Bd.offs, &su);
bufcat_su(h, "margin-left", &su);
PAIR_STYLE_INIT(&tag[0], h);
- if (DISP_unfilled != n->norm->d.Bd.type &&
- DISP_literal != n->norm->d.Bd.type) {
+ if (DISP_unfilled != n->norm->Bd.type &&
+ DISP_literal != n->norm->Bd.type) {
PAIR_CLASS_INIT(&tag[1], "display");
print_otag(h, TAG_DIV, 2, tag);
return(1);
@@ -1750,11 +1750,11 @@ mdoc_bf_pre(MDOC_ARGS)
else if (MDOC_BODY != n->type)
return(1);
- if (FONT_Em == n->norm->d.Bf.font)
+ if (FONT_Em == n->norm->Bf.font)
PAIR_CLASS_INIT(&tag[0], "emph");
- else if (FONT_Sy == n->norm->d.Bf.font)
+ else if (FONT_Sy == n->norm->Bf.font)
PAIR_CLASS_INIT(&tag[0], "symb");
- else if (FONT_Li == n->norm->d.Bf.font)
+ else if (FONT_Li == n->norm->Bf.font)
PAIR_CLASS_INIT(&tag[0], "lit");
else
PAIR_CLASS_INIT(&tag[0], "none");
diff --git a/mdoc_term.c b/mdoc_term.c
index dbd5ac5e..28cdfdbd 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -556,9 +556,9 @@ print_bvspace(struct termp *p,
term_newln(p);
- if (MDOC_Bd == bl->tok && bl->norm->d.Bd.comp)
+ if (MDOC_Bd == bl->tok && bl->norm->Bd.comp)
return;
- if (MDOC_Bl == bl->tok && bl->norm->d.Bl.comp)
+ if (MDOC_Bl == bl->tok && bl->norm->Bl.comp)
return;
/* Do not vspace directly after Ss/Sh. */
@@ -577,13 +577,13 @@ print_bvspace(struct termp *p,
/* A `-column' does not assert vspace within the list. */
- if (MDOC_Bl == bl->tok && LIST_column == bl->norm->d.Bl.type)
+ if (MDOC_Bl == bl->tok && LIST_column == bl->norm->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->norm->d.Bl.type)
+ if (MDOC_Bl == bl->tok && LIST_diag == bl->norm->Bl.type)
if (n->prev && MDOC_It == n->prev->tok) {
assert(n->prev->body);
if (NULL == n->prev->body->child)
@@ -610,7 +610,7 @@ termp_it_pre(DECL_ARGS)
}
bl = n->parent->parent->parent;
- type = bl->norm->d.Bl.type;
+ type = bl->norm->Bl.type;
/*
* First calculate width and offset. This is pretty easy unless
@@ -620,8 +620,8 @@ termp_it_pre(DECL_ARGS)
width = offset = 0;
- if (bl->norm->d.Bl.offs)
- offset = a2offs(p, bl->norm->d.Bl.offs);
+ if (bl->norm->Bl.offs)
+ offset = a2offs(p, bl->norm->Bl.offs);
switch (type) {
case (LIST_column):
@@ -637,7 +637,7 @@ termp_it_pre(DECL_ARGS)
* column.
* - For more than 5 columns, add only one column.
*/
- ncols = bl->norm->d.Bl.ncols;
+ ncols = bl->norm->Bl.ncols;
/* LINTED */
dcol = ncols < 5 ? term_len(p, 4) :
@@ -652,7 +652,7 @@ termp_it_pre(DECL_ARGS)
nn->prev && i < (int)ncols;
nn = nn->prev, i++)
offset += dcol + a2width
- (p, bl->norm->d.Bl.cols[i]);
+ (p, bl->norm->Bl.cols[i]);
/*
* When exceeding the declared number of columns, leave
@@ -667,10 +667,10 @@ termp_it_pre(DECL_ARGS)
* Use the declared column widths, extended as explained
* in the preceding paragraph.
*/
- width = a2width(p, bl->norm->d.Bl.cols[i]) + dcol;
+ width = a2width(p, bl->norm->Bl.cols[i]) + dcol;
break;
default:
- if (NULL == bl->norm->d.Bl.width)
+ if (NULL == bl->norm->Bl.width)
break;
/*
@@ -678,8 +678,8 @@ termp_it_pre(DECL_ARGS)
* number for buffering single arguments. See the above
* handling for column for how this changes.
*/
- assert(bl->norm->d.Bl.width);
- width = a2width(p, bl->norm->d.Bl.width) + term_len(p, 2);
+ assert(bl->norm->Bl.width);
+ width = a2width(p, bl->norm->Bl.width) + term_len(p, 2);
break;
}
@@ -941,7 +941,7 @@ termp_it_post(DECL_ARGS)
if (MDOC_BLOCK == n->type)
return;
- type = n->parent->parent->parent->norm->d.Bl.type;
+ type = n->parent->parent->parent->norm->Bl.type;
switch (type) {
case (LIST_item):
@@ -1115,10 +1115,10 @@ termp_an_post(DECL_ARGS)
return;
}
- if (AUTH_split == n->norm->d.An.auth) {
+ if (AUTH_split == n->norm->An.auth) {
p->flags &= ~TERMP_NOSPLIT;
p->flags |= TERMP_SPLIT;
- } else if (AUTH_nosplit == n->norm->d.An.auth) {
+ } else if (AUTH_nosplit == n->norm->An.auth) {
p->flags &= ~TERMP_SPLIT;
p->flags |= TERMP_NOSPLIT;
}
@@ -1565,8 +1565,8 @@ termp_bd_pre(DECL_ARGS)
} else if (MDOC_HEAD == n->type)
return(0);
- if (n->norm->d.Bd.offs)
- p->offset += a2offs(p, n->norm->d.Bd.offs);
+ if (n->norm->Bd.offs)
+ p->offset += a2offs(p, n->norm->Bd.offs);
/*
* If -ragged or -filled are specified, the block does nothing
@@ -1576,8 +1576,8 @@ termp_bd_pre(DECL_ARGS)
* lines are allowed.
*/
- if (DISP_literal != n->norm->d.Bd.type &&
- DISP_unfilled != n->norm->d.Bd.type)
+ if (DISP_literal != n->norm->Bd.type &&
+ DISP_unfilled != n->norm->Bd.type)
return(1);
tabwidth = p->tabwidth;
@@ -1639,8 +1639,8 @@ termp_bd_post(DECL_ARGS)
rm = p->rmargin;
rmax = p->maxrmargin;
- if (DISP_literal == n->norm->d.Bd.type ||
- DISP_unfilled == n->norm->d.Bd.type)
+ if (DISP_literal == n->norm->Bd.type ||
+ DISP_unfilled == n->norm->Bd.type)
p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
p->flags |= TERMP_NOSPACE;
@@ -1995,9 +1995,9 @@ termp_bf_pre(DECL_ARGS)
else if (MDOC_BLOCK != n->type)
return(1);
- if (FONT_Em == n->norm->d.Bf.font)
+ if (FONT_Em == n->norm->Bf.font)
term_fontpush(p, TERMFONT_UNDER);
- else if (FONT_Sy == n->norm->d.Bf.font)
+ else if (FONT_Sy == n->norm->Bf.font)
term_fontpush(p, TERMFONT_BOLD);
else
term_fontpush(p, TERMFONT_NONE);
diff --git a/mdoc_validate.c b/mdoc_validate.c
index f0ae72c1..aa65061c 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -41,16 +41,6 @@
#define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n
#define POST_ARGS struct mdoc *mdoc
-#define NORM_BUMP(dst, src) do { \
- (dst)->norm = (src)->norm; \
- ((dst)->norm->refcnt)++; \
- } while (/* CONSTCOND */ 0)
-#define NORM_ALLOC(dst) do { \
- (dst)->norm = \
- mandoc_calloc(1, sizeof(struct mdoc_norm)); \
- (dst)->norm->refcnt = 1; \
- } while (/* CONSTCOND */ 0)
-
#define NUMSIZ 32
#define DATESIZE 32
@@ -619,12 +609,9 @@ pre_bl(PRE_ARGS)
assert(np);
assert(MDOC_BLOCK == np->type);
assert(MDOC_Bl == np->tok);
- NORM_BUMP(n, np);
return(1);
}
- NORM_ALLOC(n);
-
/*
* First figure out which kind of list to use: bind ourselves to
* the first mentioned list type and warn about any remaining
@@ -673,18 +660,18 @@ pre_bl(PRE_ARGS)
break;
/* Set list arguments. */
case (MDOC_Compact):
- dup = n->norm->d.Bl.comp;
+ dup = n->norm->Bl.comp;
comp = 1;
break;
case (MDOC_Width):
- dup = (NULL != n->norm->d.Bl.width);
+ dup = (NULL != n->norm->Bl.width);
width = n->args->argv[i].value[0];
break;
case (MDOC_Offset):
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
offs = n->args->argv[i].value[0];
- dup = (NULL != n->norm->d.Bl.offs);
+ dup = (NULL != n->norm->Bl.offs);
break;
}
mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
@@ -699,36 +686,36 @@ pre_bl(PRE_ARGS)
mdoc_nmsg(mdoc, n, MANDOCERR_ARGVREP);
if (comp && ! dup)
- n->norm->d.Bl.comp = comp;
+ n->norm->Bl.comp = comp;
if (offs && ! dup)
- n->norm->d.Bl.offs = offs;
+ n->norm->Bl.offs = offs;
if (width && ! dup)
- n->norm->d.Bl.width = width;
+ n->norm->Bl.width = width;
/* Check: multiple list types. */
- if (LIST__NONE != lt && n->norm->d.Bl.type != LIST__NONE)
+ if (LIST__NONE != lt && n->norm->Bl.type != LIST__NONE)
mdoc_nmsg(mdoc, n, MANDOCERR_LISTREP);
/* Assign list type. */
- if (LIST__NONE != lt && n->norm->d.Bl.type == LIST__NONE) {
- n->norm->d.Bl.type = lt;
+ if (LIST__NONE != lt && n->norm->Bl.type == LIST__NONE) {
+ n->norm->Bl.type = lt;
/* Set column information, too. */
if (LIST_column == lt) {
- n->norm->d.Bl.ncols =
+ n->norm->Bl.ncols =
n->args->argv[i].sz;
- n->norm->d.Bl.cols = (const char **)
+ n->norm->Bl.cols = (const char **)
n->args->argv[i].value;
}
}
/* The list type should come first. */
- if (n->norm->d.Bl.type == LIST__NONE)
- if (n->norm->d.Bl.width ||
- n->norm->d.Bl.offs ||
- n->norm->d.Bl.comp)
+ if (n->norm->Bl.type == LIST__NONE)
+ if (n->norm->Bl.width ||
+ n->norm->Bl.offs ||
+ n->norm->Bl.comp)
mdoc_nmsg(mdoc, n, MANDOCERR_LISTFIRST);
continue;
@@ -736,9 +723,9 @@ pre_bl(PRE_ARGS)
/* Allow lists to default to LIST_item. */
- if (LIST__NONE == n->norm->d.Bl.type) {
+ if (LIST__NONE == n->norm->Bl.type) {
mdoc_nmsg(mdoc, n, MANDOCERR_LISTTYPE);
- n->norm->d.Bl.type = LIST_item;
+ n->norm->Bl.type = LIST_item;
}
/*
@@ -747,9 +734,9 @@ pre_bl(PRE_ARGS)
* and must also be warned.
*/
- switch (n->norm->d.Bl.type) {
+ switch (n->norm->Bl.type) {
case (LIST_tag):
- if (n->norm->d.Bl.width)
+ if (n->norm->Bl.width)
break;
mdoc_nmsg(mdoc, n, MANDOCERR_NOWIDTHARG);
break;
@@ -762,7 +749,7 @@ pre_bl(PRE_ARGS)
case (LIST_inset):
/* FALLTHROUGH */
case (LIST_item):
- if (n->norm->d.Bl.width)
+ if (n->norm->Bl.width)
mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
break;
default:
@@ -791,12 +778,9 @@ pre_bd(PRE_ARGS)
assert(np);
assert(MDOC_BLOCK == np->type);
assert(MDOC_Bd == np->tok);
- NORM_BUMP(n, np);
return(1);
}
- NORM_ALLOC(n);
-
/* LINTED */
for (i = 0; n->args && i < (int)n->args->argc; i++) {
dt = DISP__NONE;
@@ -826,14 +810,14 @@ pre_bd(PRE_ARGS)
/* NB: this can be empty! */
if (n->args->argv[i].sz) {
offs = n->args->argv[i].value[0];
- dup = (NULL != n->norm->d.Bd.offs);
+ dup = (NULL != n->norm->Bd.offs);
break;
}
mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV);
break;
case (MDOC_Compact):
comp = 1;
- dup = n->norm->d.Bd.comp;
+ dup = n->norm->Bd.comp;
break;
default:
abort();
@@ -848,24 +832,24 @@ pre_bd(PRE_ARGS)
/* Make our auxiliary assignments. */
if (offs && ! dup)
- n->norm->d.Bd.offs = offs;
+ n->norm->Bd.offs = offs;
if (comp && ! dup)
- n->norm->d.Bd.comp = comp;
+ n->norm->Bd.comp = comp;
/* Check whether a type has already been assigned. */
- if (DISP__NONE != dt && n->norm->d.Bd.type != DISP__NONE)
+ if (DISP__NONE != dt && n->norm->Bd.type != DISP__NONE)
mdoc_nmsg(mdoc, n, MANDOCERR_DISPREP);
/* Make our type assignment. */
- if (DISP__NONE != dt && n->norm->d.Bd.type == DISP__NONE)
- n->norm->d.Bd.type = dt;
+ if (DISP__NONE != dt && n->norm->Bd.type == DISP__NONE)
+ n->norm->Bd.type = dt;
}
- if (DISP__NONE == n->norm->d.Bd.type) {
+ if (DISP__NONE == n->norm->Bd.type) {
mdoc_nmsg(mdoc, n, MANDOCERR_DISPTYPE);
- n->norm->d.Bd.type = DISP_ragged;
+ n->norm->Bd.type = DISP_ragged;
}
return(1);
@@ -910,8 +894,6 @@ pre_an(PRE_ARGS)
{
int i;
- NORM_ALLOC(n);
-
if (NULL == n->args)
return(1);
@@ -920,9 +902,9 @@ pre_an(PRE_ARGS)
n->args->argv[i].pos, MANDOCERR_IGNARGV);
if (MDOC_Split == n->args->argv[0].arg)
- n->norm->d.An.auth = AUTH_split;
+ n->norm->An.auth = AUTH_split;
else if (MDOC_Nosplit == n->args->argv[0].arg)
- n->norm->d.An.auth = AUTH_nosplit;
+ n->norm->An.auth = AUTH_nosplit;
else
abort();
@@ -1004,14 +986,12 @@ post_bf(POST_ARGS)
assert(np);
assert(MDOC_HEAD == np->type);
assert(MDOC_Bf == np->tok);
- NORM_BUMP(mdoc->last, np);
return(1);
}
np = mdoc->last;
assert(MDOC_BLOCK == np->parent->type);
assert(MDOC_Bf == np->parent->tok);
- NORM_ALLOC(np);
/*
* Cannot have both argument and parameter.
@@ -1031,11 +1011,11 @@ post_bf(POST_ARGS)
if (np->parent->args) {
arg = np->parent->args->argv[0].arg;
if (MDOC_Emphasis == arg)
- np->norm->d.Bf.font = FONT_Em;
+ np->norm->Bf.font = FONT_Em;
else if (MDOC_Literal == arg)
- np->norm->d.Bf.font = FONT_Li;
+ np->norm->Bf.font = FONT_Li;
else if (MDOC_Symbolic == arg)
- np->norm->d.Bf.font = FONT_Sy;
+ np->norm->Bf.font = FONT_Sy;
else
abort();
return(1);
@@ -1044,11 +1024,11 @@ post_bf(POST_ARGS)
/* Extract parameter into data. */
if (0 == strcmp(np->child->string, "Em"))
- np->norm->d.Bf.font = FONT_Em;
+ np->norm->Bf.font = FONT_Em;
else if (0 == strcmp(np->child->string, "Li"))
- np->norm->d.Bf.font = FONT_Li;
+ np->norm->Bf.font = FONT_Li;
else if (0 == strcmp(np->child->string, "Sy"))
- np->norm->d.Bf.font = FONT_Sy;
+ np->norm->Bf.font = FONT_Sy;
else
mdoc_nmsg(mdoc, np, MANDOCERR_FONTTYPE);
@@ -1254,14 +1234,14 @@ post_an(POST_ARGS)
struct mdoc_node *np;
np = mdoc->last;
- if (AUTH__NONE != np->norm->d.An.auth && np->child)
+ if (AUTH__NONE != np->norm->An.auth && np->child)
return(eerr_eq0(mdoc));
/*
* FIXME: make this ewarn and make sure that the front-ends
* don't print the arguments.
*/
- if (AUTH__NONE != np->norm->d.An.auth || np->child)
+ if (AUTH__NONE != np->norm->An.auth || np->child)
return(1);
mdoc_nmsg(mdoc, np, MANDOCERR_NOARGS);
@@ -1281,7 +1261,7 @@ post_it(POST_ARGS)
return(1);
n = mdoc->last->parent->parent;
- lt = n->norm->d.Bl.type;
+ lt = n->norm->Bl.type;
if (LIST__NONE == lt) {
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE);
@@ -1320,7 +1300,7 @@ post_it(POST_ARGS)
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST);
break;
case (LIST_column):
- cols = (int)n->norm->d.Bl.ncols;
+ cols = (int)n->norm->Bl.ncols;
assert(NULL == mdoc->last->head->child);
@@ -1364,17 +1344,17 @@ post_bl_block(POST_ARGS)
n = mdoc->last;
- if (LIST_tag == n->norm->d.Bl.type &&
- NULL == n->norm->d.Bl.width) {
+ if (LIST_tag == n->norm->Bl.type &&
+ NULL == n->norm->Bl.width) {
if ( ! post_bl_block_tag(mdoc))
return(0);
- } else if (NULL != n->norm->d.Bl.width) {
+ } else if (NULL != n->norm->Bl.width) {
if ( ! post_bl_block_width(mdoc))
return(0);
} else
return(1);
- assert(n->norm->d.Bl.width);
+ assert(n->norm->Bl.width);
return(1);
}
@@ -1398,9 +1378,9 @@ post_bl_block_width(POST_ARGS)
* the macro's width as set in share/tmac/mdoc/doc-common.
*/
- if (0 == strcmp(n->norm->d.Bl.width, "Ds"))
+ if (0 == strcmp(n->norm->Bl.width, "Ds"))
width = 6;
- else if (MDOC_MAX == (tok = mdoc_hash_find(n->norm->d.Bl.width)))
+ else if (MDOC_MAX == (tok = mdoc_hash_find(n->norm->Bl.width)))
return(1);
else if (0 == (width = mdoc_macro2len(tok))) {
mdoc_nmsg(mdoc, n, MANDOCERR_BADWIDTH);
@@ -1422,7 +1402,7 @@ post_bl_block_width(POST_ARGS)
n->args->argv[i].value[0] = mandoc_strdup(buf);
/* Set our width! */
- n->norm->d.Bl.width = n->args->argv[i].value[0];
+ n->norm->Bl.width = n->args->argv[i].value[0];
return(1);
}
@@ -1488,7 +1468,7 @@ post_bl_block_tag(POST_ARGS)
n->args->argv[i].value[0] = mandoc_strdup(buf);
/* Set our width! */
- n->norm->d.Bl.width = n->args->argv[i].value[0];
+ n->norm->Bl.width = n->args->argv[i].value[0];
return(1);
}
@@ -1499,7 +1479,7 @@ post_bl_head(POST_ARGS)
struct mdoc_node *np, *nn, *nnp;
int i, j;
- if (LIST_column != mdoc->last->norm->d.Bl.type)
+ if (LIST_column != mdoc->last->norm->Bl.type)
/* FIXME: this should be ERROR class... */
return(hwarn_eq0(mdoc));
@@ -1516,7 +1496,7 @@ post_bl_head(POST_ARGS)
* lists, but I'll leave that for another day.
*/
- if (mdoc->last->norm->d.Bl.ncols && mdoc->last->nchild) {
+ if (mdoc->last->norm->Bl.ncols && mdoc->last->nchild) {
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_COLUMNS);
return(0);
} else if (NULL == mdoc->last->child)
@@ -1542,8 +1522,8 @@ post_bl_head(POST_ARGS)
np->args->argv[j].value = mandoc_malloc
((size_t)mdoc->last->nchild * sizeof(char *));
- mdoc->last->norm->d.Bl.ncols = np->args->argv[j].sz;
- mdoc->last->norm->d.Bl.cols = (const char **)np->args->argv[j].value;
+ mdoc->last->norm->Bl.ncols = np->args->argv[j].sz;
+ mdoc->last->norm->Bl.cols = (const char **)np->args->argv[j].value;
for (i = 0, nn = mdoc->last->child; nn; i++) {
np->args->argv[j].value[i] = nn->string;
@@ -1925,11 +1905,11 @@ pre_par(PRE_ARGS)
if (MDOC_Pp != mdoc->last->tok && MDOC_Lp != mdoc->last->tok)
return(1);
- if (MDOC_Bl == n->tok && n->norm->d.Bl.comp)
+ if (MDOC_Bl == n->tok && n->norm->Bl.comp)
return(1);
- if (MDOC_Bd == n->tok && n->norm->d.Bd.comp)
+ if (MDOC_Bd == n->tok && n->norm->Bd.comp)
return(1);
- if (MDOC_It == n->tok && n->parent->norm->d.Bl.comp)
+ if (MDOC_It == n->tok && n->parent->norm->Bl.comp)
return(1);
mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNPAR);
@@ -1954,9 +1934,9 @@ pre_literal(PRE_ARGS)
mdoc->flags |= MDOC_LITERAL;
break;
case (MDOC_Bd):
- if (DISP_literal == n->norm->d.Bd.type)
+ if (DISP_literal == n->norm->Bd.type)
mdoc->flags |= MDOC_LITERAL;
- if (DISP_unfilled == n->norm->d.Bd.type)
+ if (DISP_unfilled == n->norm->Bd.type)
mdoc->flags |= MDOC_LITERAL;
break;
default: