version 1.62, 2009/03/20 15:14:01 |
version 1.69, 2009/03/23 09:42:43 |
|
|
#define TTYPE_DIAG 18 |
#define TTYPE_DIAG 18 |
#define TTYPE_LINK_ANCHOR 19 |
#define TTYPE_LINK_ANCHOR 19 |
#define TTYPE_LINK_TEXT 20 |
#define TTYPE_LINK_TEXT 20 |
#define TTYPE_REF_TITLE 21 |
#define TTYPE_REF_JOURNAL 21 |
#define TTYPE_NMAX 22 |
#define TTYPE_LIST 22 |
|
#define TTYPE_NMAX 23 |
|
|
/* |
/* |
* These define "styles" for element types, like command arguments or |
* These define "styles" for element types, like command arguments or |
Line 88 const int ttypes[TTYPE_NMAX] = { |
|
Line 89 const int ttypes[TTYPE_NMAX] = { |
|
TERMP_BOLD, /* TTYPE_DIAG */ |
TERMP_BOLD, /* TTYPE_DIAG */ |
TERMP_UNDER, /* TTYPE_LINK_ANCHOR */ |
TERMP_UNDER, /* TTYPE_LINK_ANCHOR */ |
TERMP_BOLD, /* TTYPE_LINK_TEXT */ |
TERMP_BOLD, /* TTYPE_LINK_TEXT */ |
TERMP_UNDER /* TTYPE_REF_TITLE */ |
TERMP_UNDER, /* TTYPE_REF_JOURNAL */ |
|
TERMP_BOLD /* TTYPE_LIST */ |
}; |
}; |
|
|
static int arg_hasattr(int, const struct mdoc_node *); |
static int arg_hasattr(int, const struct mdoc_node *); |
Line 98 static int arg_getattr(int, const struct mdoc_node |
|
Line 100 static int arg_getattr(int, const struct mdoc_node |
|
static size_t arg_offset(const struct mdoc_argv *); |
static size_t arg_offset(const struct mdoc_argv *); |
static size_t arg_width(const struct mdoc_argv *, int); |
static size_t arg_width(const struct mdoc_argv *, int); |
static int arg_listtype(const struct mdoc_node *); |
static int arg_listtype(const struct mdoc_node *); |
|
static int fmt_block_vspace(struct termp *, |
|
const struct mdoc_node *, |
|
const struct mdoc_node *); |
|
|
/* |
/* |
* What follows describes prefix and postfix operations for the abstract |
* What follows describes prefix and postfix operations for the abstract |
Line 118 static void name##_post(DECL_ARGS) |
|
Line 123 static void name##_post(DECL_ARGS) |
|
DECL_PRE(name); \ |
DECL_PRE(name); \ |
DECL_POST(name); |
DECL_POST(name); |
|
|
|
DECL_PREPOST(termp__t); |
DECL_PREPOST(termp_aq); |
DECL_PREPOST(termp_aq); |
DECL_PREPOST(termp_bd); |
DECL_PREPOST(termp_bd); |
DECL_PREPOST(termp_bq); |
DECL_PREPOST(termp_bq); |
Line 140 DECL_PREPOST(termp_ss); |
|
Line 146 DECL_PREPOST(termp_ss); |
|
DECL_PREPOST(termp_sq); |
DECL_PREPOST(termp_sq); |
DECL_PREPOST(termp_vt); |
DECL_PREPOST(termp_vt); |
|
|
DECL_PRE(termp__t); |
DECL_PRE(termp__j); |
DECL_PRE(termp_ap); |
DECL_PRE(termp_ap); |
DECL_PRE(termp_ar); |
DECL_PRE(termp_ar); |
DECL_PRE(termp_at); |
DECL_PRE(termp_at); |
Line 227 const struct termact __termacts[MDOC_MAX] = { |
|
Line 233 const struct termact __termacts[MDOC_MAX] = { |
|
{ NULL, termp____post }, /* %B */ |
{ NULL, termp____post }, /* %B */ |
{ NULL, termp____post }, /* %D */ |
{ NULL, termp____post }, /* %D */ |
{ NULL, termp____post }, /* %I */ |
{ NULL, termp____post }, /* %I */ |
{ NULL, termp____post }, /* %J */ |
{ termp__j_pre, termp____post }, /* %J */ |
{ NULL, termp____post }, /* %N */ |
{ NULL, termp____post }, /* %N */ |
{ NULL, termp____post }, /* %O */ |
{ NULL, termp____post }, /* %O */ |
{ NULL, termp____post }, /* %P */ |
{ NULL, termp____post }, /* %P */ |
{ NULL, termp____post }, /* %R */ |
{ NULL, termp____post }, /* %R */ |
{ termp__t_pre, termp____post }, /* %T */ |
{ termp__t_pre, termp__t_post }, /* %T */ |
{ NULL, termp____post }, /* %V */ |
{ NULL, termp____post }, /* %V */ |
{ NULL, NULL }, /* Ac */ |
{ NULL, NULL }, /* Ac */ |
{ termp_aq_pre, termp_aq_post }, /* Ao */ |
{ termp_aq_pre, termp_aq_post }, /* Ao */ |
Line 300 const struct termact __termacts[MDOC_MAX] = { |
|
Line 306 const struct termact __termacts[MDOC_MAX] = { |
|
{ NULL, NULL }, /* Es */ |
{ NULL, NULL }, /* Es */ |
{ NULL, NULL }, /* En */ |
{ NULL, NULL }, /* En */ |
{ termp_dx_pre, NULL }, /* Dx */ |
{ termp_dx_pre, NULL }, /* Dx */ |
|
{ NULL, NULL }, /* %Q */ |
}; |
}; |
|
|
const struct termact *termacts = __termacts; |
const struct termact *termacts = __termacts; |
Line 318 arg_width(const struct mdoc_argv *arg, int pos) |
|
Line 325 arg_width(const struct mdoc_argv *arg, int pos) |
|
if (0 == strcmp(arg->value[pos], "indent-two")) |
if (0 == strcmp(arg->value[pos], "indent-two")) |
return(INDENT * 2); |
return(INDENT * 2); |
|
|
len = (int)strlen(arg->value[pos]); |
if (0 == (len = (int)strlen(arg->value[pos]))) |
assert(len > 0); |
return(0); |
|
|
for (i = 0; i < len - 1; i++) |
for (i = 0; i < len - 1; i++) |
if ( ! isdigit((u_char)arg->value[pos][i])) |
if ( ! isdigit((u_char)arg->value[pos][i])) |
Line 428 arg_getattrs(const int *keys, int *vals, |
|
Line 435 arg_getattrs(const int *keys, int *vals, |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
fmt_block_vspace(struct termp *p, |
|
const struct mdoc_node *bl, |
|
const struct mdoc_node *node) |
|
{ |
|
const struct mdoc_node *n; |
|
|
|
term_newln(p); |
|
|
|
if (arg_hasattr(MDOC_Compact, bl)) |
|
return(1); |
|
|
|
for (n = node; n; n = n->parent) { |
|
if (MDOC_BLOCK != n->type) |
|
continue; |
|
if (MDOC_Ss == n->tok) |
|
break; |
|
if (MDOC_Sh == n->tok) |
|
break; |
|
if (NULL == n->prev) |
|
continue; |
|
term_vspace(p); |
|
break; |
|
} |
|
|
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
termp_dq_pre(DECL_ARGS) |
termp_dq_pre(DECL_ARGS) |
{ |
{ |
|
|
Line 455 termp_dq_post(DECL_ARGS) |
|
Line 492 termp_dq_post(DECL_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
termp_it_pre_block(DECL_ARGS) |
|
{ |
|
|
|
term_newln(p); |
|
if ( ! arg_hasattr(MDOC_Compact, node->parent->parent)) |
|
term_vspace(p); |
|
|
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
termp_it_pre(DECL_ARGS) |
termp_it_pre(DECL_ARGS) |
{ |
{ |
const struct mdoc_node *bl, *n; |
const struct mdoc_node *bl, *n; |
Line 476 termp_it_pre(DECL_ARGS) |
|
Line 500 termp_it_pre(DECL_ARGS) |
|
size_t width, offset; |
size_t width, offset; |
|
|
if (MDOC_BLOCK == node->type) |
if (MDOC_BLOCK == node->type) |
return(termp_it_pre_block(p, pair, meta, node)); |
return(fmt_block_vspace(p, node->parent->parent, node)); |
|
|
bl = node->parent->parent->parent; |
bl = node->parent->parent->parent; |
|
|
Line 1169 termp_fn_pre(DECL_ARGS) |
|
Line 1193 termp_fn_pre(DECL_ARGS) |
|
term_word(p, node->child->string); |
term_word(p, node->child->string); |
p->flags &= ~ttypes[TTYPE_FUNC_NAME]; |
p->flags &= ~ttypes[TTYPE_FUNC_NAME]; |
|
|
|
p->flags |= TERMP_NOSPACE; |
term_word(p, "("); |
term_word(p, "("); |
|
|
p->flags |= TERMP_NOSPACE; |
|
for (n = node->child->next; n; n = n->next) { |
for (n = node->child->next; n; n = n->next) { |
p->flags |= ttypes[TTYPE_FUNC_ARG]; |
p->flags |= ttypes[TTYPE_FUNC_ARG]; |
term_word(p, n->string); |
term_word(p, n->string); |
Line 1229 termp_fa_pre(DECL_ARGS) |
|
Line 1253 termp_fa_pre(DECL_ARGS) |
|
term_word(p, ","); |
term_word(p, ","); |
} |
} |
|
|
if (node->next && node->next->tok == MDOC_Fa) |
if (node->child && node->next && node->next->tok == MDOC_Fa) |
term_word(p, ","); |
term_word(p, ","); |
|
|
return(0); |
return(0); |
Line 1263 termp_bd_pre(DECL_ARGS) |
|
Line 1287 termp_bd_pre(DECL_ARGS) |
|
* line. Blank lines are allowed. |
* line. Blank lines are allowed. |
*/ |
*/ |
|
|
if (MDOC_BLOCK == node->type) { |
if (MDOC_BLOCK == node->type) |
/* FIXME: parent prev? */ |
return(fmt_block_vspace(p, node, node)); |
if (node->prev) |
else if (MDOC_BODY != node->type) |
term_vspace(p); |
|
return(1); |
return(1); |
} else if (MDOC_BODY != node->type) |
|
return(1); |
|
|
|
if (NULL == node->parent->args) |
if (NULL == node->parent->args) |
errx(1, "missing display type"); |
errx(1, "missing display type"); |
Line 1343 termp_bd_post(DECL_ARGS) |
|
Line 1364 termp_bd_post(DECL_ARGS) |
|
if (MDOC_BODY != node->type) |
if (MDOC_BODY != node->type) |
return; |
return; |
|
|
|
term_flushln(p); |
p->flags &= ~TERMP_LITERAL; |
p->flags &= ~TERMP_LITERAL; |
p->offset = pair->offset; |
p->offset = pair->offset; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
termp_sm_pre(DECL_ARGS) |
termp_sm_pre(DECL_ARGS) |
{ |
{ |
|
|
#if notyet |
if (NULL == node->child || MDOC_TEXT != node->child->type) |
assert(node->child); |
errx(1, "expected boolean line argument"); |
if (0 == strcmp("off", node->child->data.text.string)) { |
|
|
if (0 == strcmp("on", node->child->string)) { |
p->flags &= ~TERMP_NONOSPACE; |
p->flags &= ~TERMP_NONOSPACE; |
p->flags &= ~TERMP_NOSPACE; |
p->flags &= ~TERMP_NOSPACE; |
} else { |
} else |
p->flags |= TERMP_NONOSPACE; |
p->flags |= TERMP_NONOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
} |
|
#endif |
|
|
|
return(0); |
return(0); |
} |
} |
Line 1830 termp_ap_pre(DECL_ARGS) |
|
Line 1850 termp_ap_pre(DECL_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
termp__j_pre(DECL_ARGS) |
|
{ |
|
|
|
TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_REF_JOURNAL]); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
termp__t_pre(DECL_ARGS) |
termp__t_pre(DECL_ARGS) |
{ |
{ |
|
|
TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_REF_TITLE]); |
term_word(p, "\""); |
|
p->flags |= TERMP_NOSPACE; |
return(1); |
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
termp__t_post(DECL_ARGS) |
|
{ |
|
|
|
p->flags |= TERMP_NOSPACE; |
|
term_word(p, "\""); |
|
termp____post(p, pair, meta, node); |
} |
} |
|
|
|
|