version 1.44, 2009/03/08 13:52:29 |
version 1.52, 2009/03/10 11:16:43 |
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
* PERFORMANCE OF THIS SOFTWARE. |
* PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
#include <sys/types.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <err.h> |
#include <err.h> |
|
|
#define TTYPE_SYMB 16 |
#define TTYPE_SYMB 16 |
#define TTYPE_SYMBOL 17 |
#define TTYPE_SYMBOL 17 |
#define TTYPE_DIAG 18 |
#define TTYPE_DIAG 18 |
#define TTYPE_NMAX 19 |
#define TTYPE_LINK_ANCHOR 19 |
|
#define TTYPE_LINK_TEXT 20 |
|
#define TTYPE_NMAX 21 |
|
|
/* |
/* |
* These define "styles" for element types, like command arguments or |
* These define "styles" for element types, like command arguments or |
Line 80 const int ttypes[TTYPE_NMAX] = { |
|
Line 84 const int ttypes[TTYPE_NMAX] = { |
|
TERMP_BOLD, /* TTYPE_INCLUDE */ |
TERMP_BOLD, /* TTYPE_INCLUDE */ |
TERMP_BOLD, /* TTYPE_SYMB */ |
TERMP_BOLD, /* TTYPE_SYMB */ |
TERMP_BOLD, /* TTYPE_SYMBOL */ |
TERMP_BOLD, /* TTYPE_SYMBOL */ |
TERMP_BOLD /* TTYPE_DIAG */ |
TERMP_BOLD, /* TTYPE_DIAG */ |
|
TERMP_UNDERLINE, /* TTYPE_LINK_ANCHOR */ |
|
TERMP_BOLD /* TTYPE_LINK_TEXT */ |
}; |
}; |
|
|
static int arg_hasattr(int, const struct mdoc_node *); |
static int arg_hasattr(int, const struct mdoc_node *); |
Line 120 DECL_PREPOST(termp_fo); |
|
Line 126 DECL_PREPOST(termp_fo); |
|
DECL_PREPOST(termp_ft); |
DECL_PREPOST(termp_ft); |
DECL_PREPOST(termp_in); |
DECL_PREPOST(termp_in); |
DECL_PREPOST(termp_it); |
DECL_PREPOST(termp_it); |
|
DECL_PREPOST(termp_lb); |
DECL_PREPOST(termp_op); |
DECL_PREPOST(termp_op); |
DECL_PREPOST(termp_pf); |
DECL_PREPOST(termp_pf); |
DECL_PREPOST(termp_pq); |
DECL_PREPOST(termp_pq); |
Line 129 DECL_PREPOST(termp_ss); |
|
Line 136 DECL_PREPOST(termp_ss); |
|
DECL_PREPOST(termp_sq); |
DECL_PREPOST(termp_sq); |
DECL_PREPOST(termp_vt); |
DECL_PREPOST(termp_vt); |
|
|
|
DECL_PRE(termp_ap); |
DECL_PRE(termp_ar); |
DECL_PRE(termp_ar); |
DECL_PRE(termp_at); |
DECL_PRE(termp_at); |
DECL_PRE(termp_bf); |
DECL_PRE(termp_bf); |
Line 142 DECL_PRE(termp_fa); |
|
Line 150 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_lk); |
DECL_PRE(termp_ms); |
DECL_PRE(termp_ms); |
|
DECL_PRE(termp_mt); |
DECL_PRE(termp_nd); |
DECL_PRE(termp_nd); |
DECL_PRE(termp_nm); |
DECL_PRE(termp_nm); |
DECL_PRE(termp_ns); |
DECL_PRE(termp_ns); |
Line 164 DECL_PRE(termp_xr); |
|
Line 174 DECL_PRE(termp_xr); |
|
DECL_POST(termp___); |
DECL_POST(termp___); |
DECL_POST(termp_bl); |
DECL_POST(termp_bl); |
DECL_POST(termp_bx); |
DECL_POST(termp_bx); |
DECL_POST(termp_lb); |
|
|
|
const struct termact __termacts[MDOC_MAX] = { |
const struct termact __termacts[MDOC_MAX] = { |
{ NULL, NULL }, /* \" */ |
{ NULL, NULL }, /* \" */ |
Line 273 const struct termact __termacts[MDOC_MAX] = { |
|
Line 282 const struct termact __termacts[MDOC_MAX] = { |
|
{ NULL, NULL }, /* Hf */ |
{ NULL, NULL }, /* Hf */ |
{ NULL, NULL }, /* Fr */ |
{ NULL, NULL }, /* Fr */ |
{ termp_ud_pre, NULL }, /* Ud */ |
{ termp_ud_pre, NULL }, /* Ud */ |
{ NULL, termp_lb_post }, /* lb */ |
{ termp_lb_pre, termp_lb_post }, /* Lb */ |
|
{ termp_ap_pre, NULL }, /* Lb */ |
|
{ termp_pp_pre, NULL }, /* Pp */ |
|
{ termp_lk_pre, NULL }, /* Lk */ |
|
{ termp_mt_pre, NULL }, /* Mt */ |
}; |
}; |
|
|
const struct termact *termacts = __termacts; |
const struct termact *termacts = __termacts; |
Line 316 arg_listtype(const struct mdoc_node *n) |
|
Line 329 arg_listtype(const struct mdoc_node *n) |
|
|
|
assert(MDOC_BLOCK == n->type); |
assert(MDOC_BLOCK == n->type); |
|
|
len = n->args ? n->args->argc : 0; |
len = (int)(n->args ? n->args->argc : 0); |
|
|
for (i = 0; i < len; i++) |
for (i = 0; i < len; i++) |
switch (n->args->argv[i].arg) { |
switch (n->args->argv[i].arg) { |
Line 720 termp_st_pre(DECL_ARGS) |
|
Line 733 termp_st_pre(DECL_ARGS) |
|
{ |
{ |
const char *cp; |
const char *cp; |
|
|
if (node->child) { |
if (node->child && (cp = mdoc_a2st(node->child->string))) |
if (MDOC_TEXT != node->child->type) |
word(p, cp); |
errx(1, "expected text line arguments"); |
|
if ((cp = mdoc_a2st(node->child->string))) |
|
word(p, cp); |
|
} |
|
return(0); |
return(0); |
} |
} |
|
|
Line 834 termp_xr_pre(DECL_ARGS) |
|
Line 843 termp_xr_pre(DECL_ARGS) |
|
|
|
if (NULL == (n = node->child)) |
if (NULL == (n = node->child)) |
errx(1, "expected text line argument"); |
errx(1, "expected text line argument"); |
if (MDOC_TEXT != n->type) |
|
errx(1, "expected text line argument"); |
|
|
|
word(p, n->string); |
word(p, n->string); |
|
|
if (NULL == (n = n->next)) |
if (NULL == (n = n->next)) |
return(0); |
return(0); |
if (MDOC_TEXT != n->type) |
|
errx(1, "expected text line argument"); |
|
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
word(p, "("); |
word(p, "("); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
word(p, n->string); |
word(p, n->string); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
word(p, ")"); |
word(p, ")"); |
|
|
return(0); |
return(0); |
} |
} |
|
|
Line 970 termp_bt_pre(DECL_ARGS) |
|
Line 971 termp_bt_pre(DECL_ARGS) |
|
|
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
|
static int |
|
termp_lb_pre(DECL_ARGS) |
|
{ |
|
const char *lb; |
|
|
|
if (NULL == node->child) |
|
errx(1, "expected text line argument"); |
|
if ((lb = mdoc_a2lib(node->child->string))) { |
|
word(p, lb); |
|
return(0); |
|
} |
|
word(p, "library"); |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
static void |
static void |
termp_lb_post(DECL_ARGS) |
termp_lb_post(DECL_ARGS) |
{ |
{ |
Line 1069 termp_fn_pre(DECL_ARGS) |
|
Line 1087 termp_fn_pre(DECL_ARGS) |
|
|
|
if (NULL == node->child) |
if (NULL == node->child) |
errx(1, "expected text line arguments"); |
errx(1, "expected text line arguments"); |
if (MDOC_TEXT != node->child->type) |
|
errx(1, "expected text line arguments"); |
|
|
|
/* FIXME: can be "type funcname" "type varname"... */ |
/* FIXME: can be "type funcname" "type varname"... */ |
|
|
Line 1082 termp_fn_pre(DECL_ARGS) |
|
Line 1098 termp_fn_pre(DECL_ARGS) |
|
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
for (n = node->child->next; n; n = n->next) { |
for (n = node->child->next; n; n = n->next) { |
if (MDOC_TEXT != n->type) |
|
errx(1, "expected text line arguments"); |
|
p->flags |= ttypes[TTYPE_FUNC_ARG]; |
p->flags |= ttypes[TTYPE_FUNC_ARG]; |
word(p, n->string); |
word(p, n->string); |
p->flags &= ~ttypes[TTYPE_FUNC_ARG]; |
p->flags &= ~ttypes[TTYPE_FUNC_ARG]; |
Line 1133 termp_fa_pre(DECL_ARGS) |
|
Line 1147 termp_fa_pre(DECL_ARGS) |
|
} |
} |
|
|
for (n = node->child; n; n = n->next) { |
for (n = node->child; n; n = n->next) { |
if (MDOC_TEXT != n->type) |
|
errx(1, "expected text line arguments"); |
|
|
|
p->flags |= ttypes[TTYPE_FUNC_ARG]; |
p->flags |= ttypes[TTYPE_FUNC_ARG]; |
word(p, n->string); |
word(p, n->string); |
p->flags &= ~ttypes[TTYPE_FUNC_ARG]; |
p->flags &= ~ttypes[TTYPE_FUNC_ARG]; |
|
|
if (n->next) |
if (n->next) |
word(p, ","); |
word(p, ","); |
} |
} |
Line 1203 termp_bd_pre(DECL_ARGS) |
|
Line 1213 termp_bd_pre(DECL_ARGS) |
|
|
|
i = arg_getattr(MDOC_Offset, node->parent); |
i = arg_getattr(MDOC_Offset, node->parent); |
if (-1 != i) { |
if (-1 != i) { |
if (1 != node->args->argv[i].sz) |
if (1 != node->parent->args->argv[i].sz) |
errx(1, "expected single value"); |
errx(1, "expected single value"); |
p->offset += arg_offset(&node->args->argv[i]); |
p->offset += arg_offset(&node->parent->args->argv[i]); |
} |
} |
|
|
switch (type) { |
switch (type) { |
Line 1502 termp_at_pre(DECL_ARGS) |
|
Line 1512 termp_at_pre(DECL_ARGS) |
|
|
|
att = NULL; |
att = NULL; |
|
|
if (node->child) { |
if (node->child) |
if (MDOC_TEXT != node->child->type) |
|
errx(1, "expected text line argument"); |
|
att = mdoc_a2att(node->child->string); |
att = mdoc_a2att(node->child->string); |
} |
|
|
|
if (NULL == att) |
if (NULL == att) |
att = "AT&T UNIX"; |
att = "AT&T UNIX"; |
|
|
Line 1679 termp_sm_pre(DECL_ARGS) |
|
Line 1685 termp_sm_pre(DECL_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
termp_ap_pre(DECL_ARGS) |
|
{ |
|
|
|
p->flags |= TERMP_NOSPACE; |
|
word(p, "\\(aq"); |
|
p->flags |= TERMP_NOSPACE; |
|
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
termp__t_pre(DECL_ARGS) |
termp__t_pre(DECL_ARGS) |
{ |
{ |
|
|
Line 1709 termp____post(DECL_ARGS) |
|
Line 1727 termp____post(DECL_ARGS) |
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
word(p, node->next ? "," : "."); |
word(p, node->next ? "," : "."); |
} |
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
termp_lk_pre(DECL_ARGS) |
|
{ |
|
const struct mdoc_node *n; |
|
|
|
if (NULL == (n = node->child)) |
|
errx(1, "expected line argument"); |
|
|
|
p->flags |= ttypes[TTYPE_LINK_ANCHOR]; |
|
word(p, n->string); |
|
p->flags &= ~ttypes[TTYPE_LINK_ANCHOR]; |
|
p->flags |= TERMP_NOSPACE; |
|
word(p, ":"); |
|
|
|
p->flags |= ttypes[TTYPE_LINK_TEXT]; |
|
for ( ; n; n = n->next) { |
|
word(p, n->string); |
|
} |
|
p->flags &= ~ttypes[TTYPE_LINK_TEXT]; |
|
|
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
termp_mt_pre(DECL_ARGS) |
|
{ |
|
|
|
TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_LINK_ANCHOR]); |
|
return(1); |
|
} |
|
|