version 1.165, 2010/07/01 22:56:17 |
version 1.170, 2010/07/04 21:59:30 |
Line 57 static size_t a2width(const struct termp *, const ch |
|
Line 57 static size_t a2width(const struct termp *, const ch |
|
static size_t a2height(const struct termp *, const char *); |
static size_t a2height(const struct termp *, const char *); |
static size_t a2offs(const struct termp *, const char *); |
static size_t a2offs(const struct termp *, const char *); |
|
|
static int arg_hasattr(int, const struct mdoc_node *); |
|
static int arg_getattr(int, const struct mdoc_node *); |
|
static void print_bvspace(struct termp *, |
static void print_bvspace(struct termp *, |
const struct mdoc_node *, |
const struct mdoc_node *, |
const struct mdoc_node *); |
const struct mdoc_node *); |
Line 528 a2offs(const struct termp *p, const char *v) |
|
Line 526 a2offs(const struct termp *p, const char *v) |
|
|
|
|
|
/* |
/* |
* Return 1 if an argument has a particular argument value or 0 if it |
|
* does not. See arg_getattr(). |
|
*/ |
|
static int |
|
arg_hasattr(int arg, const struct mdoc_node *n) |
|
{ |
|
|
|
return(-1 != arg_getattr(arg, n)); |
|
} |
|
|
|
|
|
/* |
|
* Get the index of an argument in a node's argument list or -1 if it |
|
* does not exist. |
|
*/ |
|
static int |
|
arg_getattr(int v, const struct mdoc_node *n) |
|
{ |
|
int i; |
|
|
|
if (NULL == n->args) |
|
return(0); |
|
|
|
for (i = 0; i < (int)n->args->argc; i++) |
|
if (n->args->argv[i].arg == v) |
|
return(i); |
|
|
|
return(-1); |
|
} |
|
|
|
|
|
/* |
|
* Determine how much space to print out before block elements of `It' |
* Determine how much space to print out before block elements of `It' |
* (and thus `Bl') and `Bd'. And then go ahead and print that space, |
* (and thus `Bl') and `Bd'. And then go ahead and print that space, |
* too. |
* too. |
Line 644 termp_it_pre(DECL_ARGS) |
|
Line 610 termp_it_pre(DECL_ARGS) |
|
{ |
{ |
const struct mdoc_node *bl, *nn; |
const struct mdoc_node *bl, *nn; |
char buf[7]; |
char buf[7]; |
int i, col; |
int i; |
size_t width, offset, ncols, dcol; |
size_t width, offset, ncols, dcol; |
enum mdoc_list type; |
enum mdoc_list type; |
|
|
Line 673 termp_it_pre(DECL_ARGS) |
|
Line 639 termp_it_pre(DECL_ARGS) |
|
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
break; |
break; |
|
|
col = arg_getattr(MDOC_Column, bl); |
|
|
|
/* |
/* |
* Imitate groff's column handling: |
* Imitate groff's column handling: |
* - For each earlier column, add its width. |
* - For each earlier column, add its width. |
Line 684 termp_it_pre(DECL_ARGS) |
|
Line 648 termp_it_pre(DECL_ARGS) |
|
* column. |
* column. |
* - For more than 5 columns, add only one column. |
* - For more than 5 columns, add only one column. |
*/ |
*/ |
ncols = bl->args->argv[col].sz; |
ncols = bl->data.Bl->ncols; |
|
|
/* LINTED */ |
/* LINTED */ |
dcol = ncols < 5 ? term_len(p, 4) : |
dcol = ncols < 5 ? term_len(p, 4) : |
ncols == 5 ? term_len(p, 3) : term_len(p, 1); |
ncols == 5 ? term_len(p, 3) : term_len(p, 1); |
Line 698 termp_it_pre(DECL_ARGS) |
|
Line 663 termp_it_pre(DECL_ARGS) |
|
nn->prev && i < (int)ncols; |
nn->prev && i < (int)ncols; |
nn = nn->prev, i++) |
nn = nn->prev, i++) |
offset += dcol + a2width |
offset += dcol + a2width |
(p, bl->args->argv[col].value[i]); |
(p, bl->data.Bl->cols[i]); |
|
|
/* |
/* |
* When exceeding the declared number of columns, leave |
* When exceeding the declared number of columns, leave |
Line 713 termp_it_pre(DECL_ARGS) |
|
Line 678 termp_it_pre(DECL_ARGS) |
|
* Use the declared column widths, extended as explained |
* Use the declared column widths, extended as explained |
* in the preceding paragraph. |
* in the preceding paragraph. |
*/ |
*/ |
width = a2width(p, bl->args->argv[col].value[i]) + dcol; |
width = a2width(p, bl->data.Bl->cols[i]) + dcol; |
break; |
break; |
default: |
default: |
if (NULL == bl->data.Bl->width) |
if (NULL == bl->data.Bl->width) |
Line 1141 termp_an_post(DECL_ARGS) |
|
Line 1106 termp_an_post(DECL_ARGS) |
|
return; |
return; |
} |
} |
|
|
if (arg_hasattr(MDOC_Split, n)) { |
if (AUTH_split == n->data.An.auth) { |
p->flags &= ~TERMP_NOSPLIT; |
p->flags &= ~TERMP_NOSPLIT; |
p->flags |= TERMP_SPLIT; |
p->flags |= TERMP_SPLIT; |
} else { |
} else if (AUTH_nosplit == n->data.An.auth) { |
p->flags &= ~TERMP_SPLIT; |
p->flags &= ~TERMP_SPLIT; |
p->flags |= TERMP_NOSPLIT; |
p->flags |= TERMP_NOSPLIT; |
} |
} |
Line 2025 termp_fo_pre(DECL_ARGS) |
|
Line 1990 termp_fo_pre(DECL_ARGS) |
|
return(1); |
return(1); |
} |
} |
|
|
|
if (NULL == n->child) |
|
return(0); |
|
|
/* XXX: we drop non-initial arguments as per groff. */ |
/* XXX: we drop non-initial arguments as per groff. */ |
|
|
assert(n->child); |
|
assert(n->child->string); |
assert(n->child->string); |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
term_word(p, n->child->string); |
term_word(p, n->child->string); |
Line 2057 termp_fo_post(DECL_ARGS) |
|
Line 2024 termp_fo_post(DECL_ARGS) |
|
static int |
static int |
termp_bf_pre(DECL_ARGS) |
termp_bf_pre(DECL_ARGS) |
{ |
{ |
const struct mdoc_node *nn; |
|
|
|
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
return(0); |
return(0); |
else if (MDOC_BLOCK != n->type) |
else if (MDOC_BLOCK != n->type) |
return(1); |
return(1); |
|
|
if (NULL == (nn = n->head->child)) { |
assert(n->data.Bf); |
if (arg_hasattr(MDOC_Emphasis, n)) |
|
term_fontpush(p, TERMFONT_UNDER); |
|
else if (arg_hasattr(MDOC_Symbolic, n)) |
|
term_fontpush(p, TERMFONT_BOLD); |
|
else |
|
term_fontpush(p, TERMFONT_NONE); |
|
|
|
return(1); |
if (FONT_Em == n->data.Bf->font) |
} |
|
|
|
assert(MDOC_TEXT == nn->type); |
|
if (0 == strcmp("Em", nn->string)) |
|
term_fontpush(p, TERMFONT_UNDER); |
term_fontpush(p, TERMFONT_UNDER); |
else if (0 == strcmp("Sy", nn->string)) |
else if (FONT_Sy == n->data.Bf->font) |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
else |
else |
term_fontpush(p, TERMFONT_NONE); |
term_fontpush(p, TERMFONT_NONE); |
|
|
return(1); |
return(1); |
Line 2170 termp_bk_pre(DECL_ARGS) |
|
Line 2126 termp_bk_pre(DECL_ARGS) |
|
|
|
switch (n->type) { |
switch (n->type) { |
case (MDOC_BLOCK): |
case (MDOC_BLOCK): |
return(1); |
break; |
case (MDOC_HEAD): |
case (MDOC_HEAD): |
return(0); |
return(0); |
case (MDOC_BODY): |
case (MDOC_BODY): |
p->flags |= TERMP_PREKEEP; |
p->flags |= TERMP_PREKEEP; |
return(1); |
break; |
default: |
default: |
abort(); |
abort(); |
|
/* NOTREACHED */ |
} |
} |
|
|
|
return(1); |
} |
} |
|
|
|
|