diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-17 23:57:06 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-05-17 23:57:06 +0000 |
commit | 26062711bedfc2a29550c2d705beb1d77d7ee0b3 (patch) | |
tree | 191667292c6c27bf1989ad6bb8654d7f6f94a4a9 /mdoc_action.c | |
parent | 67ec6f950232a27295516acb54b9a80b5ddd08f0 (diff) | |
download | mandoc-26062711bedfc2a29550c2d705beb1d77d7ee0b3.tar.gz |
Increase performance by stashing the list type in struct mdoc_node.
This will eventually be used so that mdoc_macro can known whether to
dump list line arguments into the body (`Bl -column' overflowing).
Remove a2list() and arg_listtype() because of this.
Diffstat (limited to 'mdoc_action.c')
-rw-r--r-- | mdoc_action.c | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/mdoc_action.c b/mdoc_action.c index 12b62d1b..e886a3d0 100644 --- a/mdoc_action.c +++ b/mdoc_action.c @@ -33,7 +33,7 @@ #include "libmandoc.h" #define POST_ARGS struct mdoc *m, struct mdoc_node *n -#define PRE_ARGS struct mdoc *m, const struct mdoc_node *n +#define PRE_ARGS struct mdoc *m, struct mdoc_node *n #define NUMSIZ 32 #define DATESIZ 32 @@ -216,7 +216,7 @@ static const enum mdoct rsord[RSORD_MAX] = { int -mdoc_action_pre(struct mdoc *m, const struct mdoc_node *n) +mdoc_action_pre(struct mdoc *m, struct mdoc_node *n) { switch (n->type) { @@ -942,8 +942,63 @@ pre_offset(PRE_ARGS) static int pre_bl(PRE_ARGS) { + int pos; + + if (MDOC_BLOCK != n->type) { + 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; + return(1); + } + + assert(LIST__NONE == n->data.list); + + for (pos = 0; pos < (int)n->args->argc; pos++) { + switch (n->args->argv[pos].arg) { + case (MDOC_Bullet): + n->data.list = LIST_bullet; + break; + case (MDOC_Dash): + n->data.list = LIST_dash; + break; + case (MDOC_Enum): + n->data.list = LIST_enum; + break; + case (MDOC_Hyphen): + n->data.list = LIST_hyphen; + break; + case (MDOC_Item): + n->data.list = LIST_item; + break; + case (MDOC_Tag): + n->data.list = LIST_tag; + break; + case (MDOC_Diag): + n->data.list = LIST_diag; + break; + case (MDOC_Hang): + n->data.list = LIST_hang; + break; + case (MDOC_Ohang): + n->data.list = LIST_ohang; + break; + case (MDOC_Inset): + n->data.list = LIST_inset; + break; + case (MDOC_Column): + n->data.list = LIST_column; + break; + default: + break; + } + if (LIST__NONE != n->data.list) + break; + } - return(MDOC_BLOCK == n->type ? pre_offset(m, n) : 1); + assert(LIST__NONE != n->data.list); + return(pre_offset(m, n)); } |