version 1.26, 2009/02/27 08:20:15 |
version 1.28, 2009/02/28 19:15:28 |
|
|
|
|
#include "term.h" |
#include "term.h" |
|
|
#define INDENT 6 |
#define INDENT 8 |
|
|
/* |
/* |
* 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 108 static void name##_post(DECL_ARGS) |
|
Line 108 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 150 DECL_PRE(termp_nx); |
|
Line 151 DECL_PRE(termp_nx); |
|
DECL_PRE(termp_ox); |
DECL_PRE(termp_ox); |
DECL_PRE(termp_pa); |
DECL_PRE(termp_pa); |
DECL_PRE(termp_pp); |
DECL_PRE(termp_pp); |
|
DECL_PRE(termp_rs); |
DECL_PRE(termp_rv); |
DECL_PRE(termp_rv); |
DECL_PRE(termp_sm); |
DECL_PRE(termp_sm); |
DECL_PRE(termp_st); |
DECL_PRE(termp_st); |
Line 160 DECL_PRE(termp_ux); |
|
Line 162 DECL_PRE(termp_ux); |
|
DECL_PRE(termp_va); |
DECL_PRE(termp_va); |
DECL_PRE(termp_xr); |
DECL_PRE(termp_xr); |
|
|
|
DECL_POST(termp___); |
DECL_POST(termp_bl); |
DECL_POST(termp_bl); |
|
|
const struct termact __termacts[MDOC_MAX] = { |
const struct termact __termacts[MDOC_MAX] = { |
Line 204 const struct termact __termacts[MDOC_MAX] = { |
|
Line 207 const struct termact __termacts[MDOC_MAX] = { |
|
{ termp_va_pre, NULL }, /* Va */ |
{ termp_va_pre, NULL }, /* Va */ |
{ 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, NULL }, /* %A */ |
{ NULL, termp____post }, /* %A */ |
{ NULL, NULL }, /* %B */ |
{ NULL, NULL }, /* %B */ |
{ NULL, NULL }, /* %D */ |
{ NULL, termp____post }, /* %D */ |
{ NULL, NULL }, /* %I */ |
{ NULL, NULL }, /* %I */ |
{ NULL, NULL }, /* %J */ |
{ NULL, termp____post }, /* %J */ |
{ NULL, NULL }, /* %N */ |
{ NULL, NULL }, /* %N */ |
{ NULL, NULL }, /* %O */ |
{ NULL, NULL }, /* %O */ |
{ NULL, NULL }, /* %P */ |
{ NULL, NULL }, /* %P */ |
{ NULL, NULL }, /* %R */ |
{ NULL, NULL }, /* %R */ |
{ NULL, NULL }, /* %T */ |
{ termp__t_pre, termp__t_post }, /* %T */ |
{ NULL, NULL }, /* %V */ |
{ NULL, NULL }, /* %V */ |
{ NULL, NULL }, /* Ac */ |
{ NULL, NULL }, /* Ac */ |
{ termp_aq_pre, termp_aq_post }, /* Ao */ |
{ termp_aq_pre, termp_aq_post }, /* Ao */ |
Line 248 const struct termact __termacts[MDOC_MAX] = { |
|
Line 251 const struct termact __termacts[MDOC_MAX] = { |
|
{ termp_qq_pre, termp_qq_post }, /* Qo */ |
{ termp_qq_pre, termp_qq_post }, /* Qo */ |
{ termp_qq_pre, termp_qq_post }, /* Qq */ |
{ termp_qq_pre, termp_qq_post }, /* Qq */ |
{ NULL, NULL }, /* Re */ |
{ NULL, NULL }, /* Re */ |
{ NULL, NULL }, /* Rs */ |
{ termp_rs_pre, NULL }, /* Rs */ |
{ NULL, NULL }, /* Sc */ |
{ NULL, NULL }, /* Sc */ |
{ termp_sq_pre, termp_sq_post }, /* So */ |
{ termp_sq_pre, termp_sq_post }, /* So */ |
{ termp_sq_pre, termp_sq_post }, /* Sq */ |
{ termp_sq_pre, termp_sq_post }, /* Sq */ |
Line 277 const struct termact *termacts = __termacts; |
|
Line 280 const struct termact *termacts = __termacts; |
|
static size_t |
static size_t |
arg_width(const struct mdoc_arg *arg) |
arg_width(const struct mdoc_arg *arg) |
{ |
{ |
size_t len, i, v; |
size_t v; |
|
int i, len; |
|
|
assert(*arg->value); |
assert(*arg->value); |
if (0 == strcmp(*arg->value, "indent")) |
if (0 == strcmp(*arg->value, "indent")) |
Line 285 arg_width(const struct mdoc_arg *arg) |
|
Line 289 arg_width(const struct mdoc_arg *arg) |
|
if (0 == strcmp(*arg->value, "indent-two")) |
if (0 == strcmp(*arg->value, "indent-two")) |
return(INDENT * 2); |
return(INDENT * 2); |
|
|
len = strlen(*arg->value); |
len = (int)strlen(*arg->value); |
assert(len > 0); |
assert(len > 0); |
|
|
for (i = 0; i < len - 1; i++) |
for (i = 0; i < len - 1; i++) |
Line 299 arg_width(const struct mdoc_arg *arg) |
|
Line 303 arg_width(const struct mdoc_arg *arg) |
|
} |
} |
|
|
} |
} |
return(strlen(*arg->value)); |
return(strlen(*arg->value) + 1); |
} |
} |
|
|
|
|
Line 627 termp_st_pre(DECL_ARGS) |
|
Line 631 termp_st_pre(DECL_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
termp_rs_pre(DECL_ARGS) |
|
{ |
|
|
|
if (MDOC_BLOCK == node->type) |
|
vspace(p); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
termp_rv_pre(DECL_ARGS) |
termp_rv_pre(DECL_ARGS) |
{ |
{ |
int i; |
int i; |
Line 1172 termp_sq_pre(DECL_ARGS) |
|
Line 1187 termp_sq_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 1483 termp_sm_pre(DECL_ARGS) |
|
Line 1498 termp_sm_pre(DECL_ARGS) |
|
#endif |
#endif |
|
|
return(0); |
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
termp__t_pre(DECL_ARGS) |
|
{ |
|
|
|
word(p, "\""); |
|
p->flags |= TERMP_NOSPACE; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
termp__t_post(DECL_ARGS) |
|
{ |
|
|
|
p->flags |= TERMP_NOSPACE; |
|
word(p, "\""); |
|
word(p, node->next ? "," : "."); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static void |
|
termp____post(DECL_ARGS) |
|
{ |
|
|
|
p->flags |= TERMP_NOSPACE; |
|
word(p, node->next ? "," : "."); |
} |
} |