version 1.28, 2009/02/28 19:15:28 |
version 1.30, 2009/02/28 21:31:13 |
|
|
|
|
#include "term.h" |
#include "term.h" |
|
|
#define INDENT 8 |
#define INDENT 6 |
|
|
/* |
/* |
* Performs actions on nodes of the abstract syntax tree. Both pre- and |
* Performs actions on nodes of the abstract syntax tree. Both pre- and |
Line 118 DECL_PREPOST(termp_fd); |
|
Line 118 DECL_PREPOST(termp_fd); |
|
DECL_PREPOST(termp_fn); |
DECL_PREPOST(termp_fn); |
DECL_PREPOST(termp_fo); |
DECL_PREPOST(termp_fo); |
DECL_PREPOST(termp_ft); |
DECL_PREPOST(termp_ft); |
|
DECL_PREPOST(termp_in); |
DECL_PREPOST(termp_it); |
DECL_PREPOST(termp_it); |
DECL_PREPOST(termp_op); |
DECL_PREPOST(termp_op); |
DECL_PREPOST(termp_pf); |
DECL_PREPOST(termp_pf); |
Line 142 DECL_PRE(termp_fa); |
|
Line 143 DECL_PRE(termp_fa); |
|
DECL_PRE(termp_fl); |
DECL_PRE(termp_fl); |
DECL_PRE(termp_fx); |
DECL_PRE(termp_fx); |
DECL_PRE(termp_ic); |
DECL_PRE(termp_ic); |
DECL_PRE(termp_in); |
|
DECL_PRE(termp_ms); |
DECL_PRE(termp_ms); |
DECL_PRE(termp_nd); |
DECL_PRE(termp_nd); |
DECL_PRE(termp_nm); |
DECL_PRE(termp_nm); |
Line 174 const struct termact __termacts[MDOC_MAX] = { |
|
Line 174 const struct termact __termacts[MDOC_MAX] = { |
|
{ termp_ss_pre, termp_ss_post }, /* Ss */ |
{ termp_ss_pre, termp_ss_post }, /* Ss */ |
{ termp_pp_pre, NULL }, /* Pp */ |
{ termp_pp_pre, NULL }, /* Pp */ |
{ termp_d1_pre, termp_d1_post }, /* D1 */ |
{ termp_d1_pre, termp_d1_post }, /* D1 */ |
{ NULL, NULL }, /* Dl */ |
{ termp_d1_pre, termp_d1_post }, /* Dl */ |
{ termp_bd_pre, termp_bd_post }, /* Bd */ |
{ termp_bd_pre, termp_bd_post }, /* Bd */ |
{ NULL, NULL }, /* Ed */ |
{ NULL, NULL }, /* Ed */ |
{ NULL, termp_bl_post }, /* Bl */ |
{ NULL, termp_bl_post }, /* Bl */ |
Line 195 const struct termact __termacts[MDOC_MAX] = { |
|
Line 195 const struct termact __termacts[MDOC_MAX] = { |
|
{ termp_fn_pre, termp_fn_post }, /* Fn */ |
{ termp_fn_pre, termp_fn_post }, /* Fn */ |
{ termp_ft_pre, termp_ft_post }, /* Ft */ |
{ termp_ft_pre, termp_ft_post }, /* Ft */ |
{ termp_ic_pre, NULL }, /* Ic */ |
{ termp_ic_pre, NULL }, /* Ic */ |
{ termp_in_pre, NULL }, /* In */ |
{ termp_in_pre, termp_in_post }, /* In */ |
{ NULL, NULL }, /* Li */ |
{ NULL, NULL }, /* Li */ |
{ termp_nd_pre, NULL }, /* Nd */ |
{ termp_nd_pre, NULL }, /* Nd */ |
{ termp_nm_pre, NULL }, /* Nm */ |
{ termp_nm_pre, NULL }, /* Nm */ |
Line 208 const struct termact __termacts[MDOC_MAX] = { |
|
Line 208 const struct termact __termacts[MDOC_MAX] = { |
|
{ termp_vt_pre, termp_vt_post }, /* Vt */ |
{ termp_vt_pre, termp_vt_post }, /* Vt */ |
{ termp_xr_pre, NULL }, /* Xr */ |
{ termp_xr_pre, NULL }, /* Xr */ |
{ NULL, termp____post }, /* %A */ |
{ NULL, termp____post }, /* %A */ |
{ NULL, NULL }, /* %B */ |
{ NULL, termp____post }, /* %B */ |
{ NULL, termp____post }, /* %D */ |
{ NULL, termp____post }, /* %D */ |
{ NULL, NULL }, /* %I */ |
{ NULL, termp____post }, /* %I */ |
{ NULL, termp____post }, /* %J */ |
{ NULL, termp____post }, /* %J */ |
{ NULL, NULL }, /* %N */ |
{ NULL, termp____post }, /* %N */ |
{ NULL, NULL }, /* %O */ |
{ NULL, termp____post }, /* %O */ |
{ NULL, NULL }, /* %P */ |
{ NULL, termp____post }, /* %P */ |
{ NULL, NULL }, /* %R */ |
{ NULL, termp____post }, /* %R */ |
{ termp__t_pre, termp__t_post }, /* %T */ |
{ termp__t_pre, termp__t_post }, /* %T */ |
{ NULL, NULL }, /* %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 */ |
{ termp_aq_pre, termp_aq_post }, /* Aq */ |
{ termp_aq_pre, termp_aq_post }, /* Aq */ |
Line 303 arg_width(const struct mdoc_arg *arg) |
|
Line 303 arg_width(const struct mdoc_arg *arg) |
|
} |
} |
|
|
} |
} |
return(strlen(*arg->value) + 1); |
return(strlen(*arg->value) + 2); |
} |
} |
|
|
|
|
Line 395 termp_it_pre(DECL_ARGS) |
|
Line 395 termp_it_pre(DECL_ARGS) |
|
bl = &n->data.block; |
bl = &n->data.block; |
|
|
if (MDOC_BLOCK == node->type) { |
if (MDOC_BLOCK == node->type) { |
if (arg_hasattr(MDOC_Compact, bl->argc, bl->argv)) |
newln(p); |
newln(p); |
if ( ! arg_hasattr(MDOC_Compact, bl->argc, bl->argv)) |
else |
if (node->prev || n->prev) |
vspace(p); |
vspace(p); |
return(1); |
return(1); |
} |
} |
|
|
|
|
termp_nm_pre(DECL_ARGS) |
termp_nm_pre(DECL_ARGS) |
{ |
{ |
|
|
|
if (SEC_SYNOPSIS == node->sec) |
|
newln(p); |
|
|
TERMPAIR_SETFLAG(pair, ttypes[TTYPE_PROG]); |
TERMPAIR_SETFLAG(pair, ttypes[TTYPE_PROG]); |
if (NULL == node->child) |
if (NULL == node->child) |
word(p, meta->name); |
word(p, meta->name); |
|
|
termp_ar_pre(DECL_ARGS) |
termp_ar_pre(DECL_ARGS) |
{ |
{ |
|
|
TERMPAIR_SETFLAG(pair, ttypes[TTYPE_CMD_ARG]); |
if (node->child) { |
if (NULL == node->child) |
TERMPAIR_SETFLAG(pair, ttypes[TTYPE_CMD_ARG]); |
word(p, "..."); |
return(1); |
|
} |
|
p->flags |= ttypes[TTYPE_CMD_ARG]; |
|
word(p, "file"); |
|
word(p, "..."); |
|
p->flags &= ~ttypes[TTYPE_CMD_ARG]; |
return(1); |
return(1); |
} |
} |
|
|
|
|
termp_rs_pre(DECL_ARGS) |
termp_rs_pre(DECL_ARGS) |
{ |
{ |
|
|
if (MDOC_BLOCK == node->type) |
if (MDOC_BLOCK == node->type && node->prev) |
vspace(p); |
vspace(p); |
return(1); |
return(1); |
} |
} |
|
|
termp_fd_post(DECL_ARGS) |
termp_fd_post(DECL_ARGS) |
{ |
{ |
|
|
if (node->sec == SEC_SYNOPSIS) |
if (node->sec != SEC_SYNOPSIS) |
|
return; |
|
newln(p); |
|
if (node->next && MDOC_Fd != node->next->tok) |
vspace(p); |
vspace(p); |
} |
} |
|
|
|
|
termp_fn_post(DECL_ARGS) |
termp_fn_post(DECL_ARGS) |
{ |
{ |
|
|
if (node->sec == SEC_SYNOPSIS) |
if (node->sec == SEC_SYNOPSIS && node->next) |
vspace(p); |
vspace(p); |
|
|
} |
} |
Line 1046 termp_bd_pre(DECL_ARGS) |
|
Line 1057 termp_bd_pre(DECL_ARGS) |
|
int i; |
int i; |
|
|
if (MDOC_BLOCK == node->type) { |
if (MDOC_BLOCK == node->type) { |
vspace(p); |
if (node->prev) |
|
vspace(p); |
return(1); |
return(1); |
} else if (MDOC_BODY != node->type) |
} else if (MDOC_BODY != node->type) |
return(1); |
return(1); |
|
|
termp_in_pre(DECL_ARGS) |
termp_in_pre(DECL_ARGS) |
{ |
{ |
|
|
|
p->flags |= ttypes[TTYPE_INCLUDE]; |
|
word(p, "#include"); |
|
word(p, "<"); |
|
p->flags &= ~ttypes[TTYPE_INCLUDE]; |
|
p->flags |= TERMP_NOSPACE; |
TERMPAIR_SETFLAG(pair, ttypes[TTYPE_INCLUDE]); |
TERMPAIR_SETFLAG(pair, ttypes[TTYPE_INCLUDE]); |
return(1); |
return(1); |
} |
} |
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
|
static void |
|
termp_in_post(DECL_ARGS) |
|
{ |
|
|
|
p->flags |= TERMP_NOSPACE; |
|
word(p, ">"); |
|
|
|
newln(p); |
|
if (SEC_SYNOPSIS != node->sec) |
|
return; |
|
if (node->next && MDOC_In != node->next->tok) |
|
vspace(p); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
static int |
static int |
termp_at_pre(DECL_ARGS) |
termp_at_pre(DECL_ARGS) |
{ |
{ |
Line 1344 termp_bq_pre(DECL_ARGS) |
|
Line 1377 termp_bq_pre(DECL_ARGS) |
|
|
|
if (MDOC_BODY != node->type) |
if (MDOC_BODY != node->type) |
return(1); |
return(1); |
word(p, "\\["); |
word(p, "["); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
return(1); |
return(1); |
} |
} |
Line 1368 termp_pq_pre(DECL_ARGS) |
|
Line 1401 termp_pq_pre(DECL_ARGS) |
|
|
|
if (MDOC_BODY != node->type) |
if (MDOC_BODY != node->type) |
return(1); |
return(1); |
word(p, "\\&("); |
word(p, "("); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
return(1); |
return(1); |
} |
} |