version 1.255, 2013/12/25 00:39:31 |
version 1.263, 2014/04/08 07:13:12 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> |
|
* Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 103 static int termp_ft_pre(DECL_ARGS); |
|
Line 104 static int termp_ft_pre(DECL_ARGS); |
|
static int termp_in_pre(DECL_ARGS); |
static int termp_in_pre(DECL_ARGS); |
static int termp_it_pre(DECL_ARGS); |
static int termp_it_pre(DECL_ARGS); |
static int termp_li_pre(DECL_ARGS); |
static int termp_li_pre(DECL_ARGS); |
|
static int termp_ll_pre(DECL_ARGS); |
static int termp_lk_pre(DECL_ARGS); |
static int termp_lk_pre(DECL_ARGS); |
static int termp_nd_pre(DECL_ARGS); |
static int termp_nd_pre(DECL_ARGS); |
static int termp_nm_pre(DECL_ARGS); |
static int termp_nm_pre(DECL_ARGS); |
Line 243 static const struct termact termacts[MDOC_MAX] = { |
|
Line 245 static const struct termact termacts[MDOC_MAX] = { |
|
{ termp_sp_pre, NULL }, /* sp */ |
{ termp_sp_pre, NULL }, /* sp */ |
{ NULL, termp____post }, /* %U */ |
{ NULL, termp____post }, /* %U */ |
{ NULL, NULL }, /* Ta */ |
{ NULL, NULL }, /* Ta */ |
|
{ termp_ll_pre, NULL }, /* ll */ |
}; |
}; |
|
|
|
|
Line 383 print_mdoc_node(DECL_ARGS) |
|
Line 386 print_mdoc_node(DECL_ARGS) |
|
if (MDOC_EOS & n->flags) |
if (MDOC_EOS & n->flags) |
p->flags |= TERMP_SENTENCE; |
p->flags |= TERMP_SENTENCE; |
|
|
p->offset = offset; |
if (MDOC_ll != n->tok) { |
p->rmargin = rmargin; |
p->offset = offset; |
|
p->rmargin = rmargin; |
|
} |
} |
} |
|
|
|
|
Line 614 print_bvspace(struct termp *p, |
|
Line 619 print_bvspace(struct termp *p, |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
termp_ll_pre(DECL_ARGS) |
|
{ |
|
|
|
term_setwidth(p, n->nchild ? n->child->string : NULL); |
|
return(0); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
termp_it_pre(DECL_ARGS) |
termp_it_pre(DECL_ARGS) |
{ |
{ |
const struct mdoc_node *bl, *nn; |
const struct mdoc_node *bl, *nn; |
Line 804 termp_it_pre(DECL_ARGS) |
|
Line 819 termp_it_pre(DECL_ARGS) |
|
MDOC_Bd == n->next->child->tok)) |
MDOC_Bd == n->next->child->tok)) |
break; |
break; |
|
|
p->flags |= TERMP_NOBREAK | TERMP_HANG; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; |
p->trailspace = 1; |
p->trailspace = 1; |
break; |
break; |
case (LIST_tag): |
case (LIST_tag): |
if (MDOC_HEAD != n->type) |
if (MDOC_HEAD != n->type) |
break; |
break; |
|
|
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND; |
p->trailspace = 2; |
p->trailspace = 2; |
|
|
if (NULL == n->next || NULL == n->next->child) |
if (NULL == n->next || NULL == n->next->child) |
Line 833 termp_it_pre(DECL_ARGS) |
|
Line 848 termp_it_pre(DECL_ARGS) |
|
case (LIST_diag): |
case (LIST_diag): |
if (MDOC_HEAD != n->type) |
if (MDOC_HEAD != n->type) |
break; |
break; |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND; |
p->trailspace = 1; |
p->trailspace = 1; |
break; |
break; |
default: |
default: |
Line 872 termp_it_pre(DECL_ARGS) |
|
Line 887 termp_it_pre(DECL_ARGS) |
|
assert(width); |
assert(width); |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->rmargin = p->offset + width; |
p->rmargin = p->offset + width; |
else |
else { |
p->offset += width; |
p->offset += width; |
|
if (p->rmargin < p->offset) |
|
p->rmargin = p->offset; |
|
} |
break; |
break; |
case (LIST_column): |
case (LIST_column): |
assert(width); |
assert(width); |
Line 984 termp_it_post(DECL_ARGS) |
|
Line 1002 termp_it_post(DECL_ARGS) |
|
* has munged them in the meanwhile. |
* has munged them in the meanwhile. |
*/ |
*/ |
|
|
p->flags &= ~TERMP_DANGLE; |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | |
p->flags &= ~TERMP_NOBREAK; |
TERMP_DANGLE | TERMP_HANG); |
p->flags &= ~TERMP_HANG; |
|
p->trailspace = 0; |
p->trailspace = 0; |
} |
} |
|
|
Line 1011 termp_nm_pre(DECL_ARGS) |
|
Line 1028 termp_nm_pre(DECL_ARGS) |
|
MDOC_TEXT == n->prev->child->type ? |
MDOC_TEXT == n->prev->child->type ? |
term_strlen(p, n->prev->child->string) : |
term_strlen(p, n->prev->child->string) : |
term_len(p, 5)); |
term_len(p, 5)); |
|
if (p->rmargin < p->offset) |
|
p->rmargin = p->offset; |
return(1); |
return(1); |
} |
} |
|
|
Line 1021 termp_nm_pre(DECL_ARGS) |
|
Line 1040 termp_nm_pre(DECL_ARGS) |
|
synopsis_pre(p, n->parent); |
synopsis_pre(p, n->parent); |
|
|
if (MDOC_HEAD == n->type && n->next->child) { |
if (MDOC_HEAD == n->type && n->next->child) { |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK; |
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND; |
p->trailspace = 1; |
p->trailspace = 1; |
p->rmargin = p->offset + term_len(p, 1); |
p->rmargin = p->offset + term_len(p, 1); |
if (NULL == n->child) { |
if (NULL == n->child) { |
Line 1052 termp_nm_post(DECL_ARGS) |
|
Line 1071 termp_nm_post(DECL_ARGS) |
|
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); |
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP); |
} else if (MDOC_HEAD == n->type && n->next->child) { |
} else if (MDOC_HEAD == n->type && n->next->child) { |
term_flushln(p); |
term_flushln(p); |
p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); |
p->trailspace = 0; |
p->trailspace = 0; |
} else if (MDOC_BODY == n->type && n->child) |
} else if (MDOC_BODY == n->type && n->child) |
term_flushln(p); |
term_flushln(p); |
Line 1528 termp_ft_pre(DECL_ARGS) |
|
Line 1547 termp_ft_pre(DECL_ARGS) |
|
static int |
static int |
termp_fn_pre(DECL_ARGS) |
termp_fn_pre(DECL_ARGS) |
{ |
{ |
size_t width, rmargin = 0; |
size_t rmargin = 0; |
int pretty; |
int pretty; |
|
|
pretty = MDOC_SYNPRETTY & n->flags; |
pretty = MDOC_SYNPRETTY & n->flags; |
Line 1539 termp_fn_pre(DECL_ARGS) |
|
Line 1558 termp_fn_pre(DECL_ARGS) |
|
return(0); |
return(0); |
|
|
if (pretty) { |
if (pretty) { |
width = term_len(p, 4); |
|
rmargin = p->rmargin; |
rmargin = p->rmargin; |
p->rmargin = p->offset + width; |
p->rmargin = p->offset + term_len(p, 4); |
p->flags |= TERMP_NOBREAK | TERMP_HANG; |
p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG; |
} |
} |
|
|
assert(MDOC_TEXT == n->type); |
assert(MDOC_TEXT == n->type); |
Line 1552 termp_fn_pre(DECL_ARGS) |
|
Line 1570 termp_fn_pre(DECL_ARGS) |
|
|
|
if (pretty) { |
if (pretty) { |
term_flushln(p); |
term_flushln(p); |
p->flags &= ~(TERMP_NOBREAK | TERMP_HANG); |
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG); |
p->offset = p->rmargin; |
p->offset = p->rmargin; |
p->rmargin = rmargin; |
p->rmargin = rmargin; |
} |
} |
Line 1601 termp_fa_pre(DECL_ARGS) |
|
Line 1619 termp_fa_pre(DECL_ARGS) |
|
|
|
for (nn = n->child; nn; nn = nn->next) { |
for (nn = n->child; nn; nn = nn->next) { |
term_fontpush(p, TERMFONT_UNDER); |
term_fontpush(p, TERMFONT_UNDER); |
|
p->flags |= TERMP_NBRWORD; |
term_word(p, nn->string); |
term_word(p, nn->string); |
term_fontpop(p); |
term_fontpop(p); |
|
|
if (nn->next) { |
if (nn->next || (n->next && n->next->tok == MDOC_Fa)) { |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
term_word(p, ","); |
term_word(p, ","); |
} |
} |
} |
} |
|
|
if (n->child && n->next && n->next->tok == MDOC_Fa) { |
|
p->flags |= TERMP_NOSPACE; |
|
term_word(p, ","); |
|
} |
|
|
|
return(0); |
return(0); |
} |
} |
|
|
Line 2036 termp_quote_post(DECL_ARGS) |
|
Line 2050 termp_quote_post(DECL_ARGS) |
|
static int |
static int |
termp_fo_pre(DECL_ARGS) |
termp_fo_pre(DECL_ARGS) |
{ |
{ |
|
size_t rmargin = 0; |
|
int pretty; |
|
|
|
pretty = MDOC_SYNPRETTY & n->flags; |
|
|
if (MDOC_BLOCK == n->type) { |
if (MDOC_BLOCK == n->type) { |
synopsis_pre(p, n); |
synopsis_pre(p, n); |
return(1); |
return(1); |
} else if (MDOC_BODY == n->type) { |
} else if (MDOC_BODY == n->type) { |
|
if (pretty) { |
|
rmargin = p->rmargin; |
|
p->rmargin = p->offset + term_len(p, 4); |
|
p->flags |= TERMP_NOBREAK | TERMP_BRIND | |
|
TERMP_HANG; |
|
} |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
term_word(p, "("); |
term_word(p, "("); |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
if (pretty) { |
|
term_flushln(p); |
|
p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | |
|
TERMP_HANG); |
|
p->offset = p->rmargin; |
|
p->rmargin = rmargin; |
|
} |
return(1); |
return(1); |
} |
} |
|
|
if (NULL == n->child) |
if (NULL == n->child) |
return(0); |
return(0); |
Line 2073 termp_fo_post(DECL_ARGS) |
|
Line 2104 termp_fo_post(DECL_ARGS) |
|
if (MDOC_SYNPRETTY & n->flags) { |
if (MDOC_SYNPRETTY & n->flags) { |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
term_word(p, ";"); |
term_word(p, ";"); |
|
term_flushln(p); |
} |
} |
} |
} |
|
|