version 1.88, 2010/12/06 14:04:11 |
version 1.95, 2011/01/11 00:39:00 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> |
|
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* 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 94 static int pre_ign(DECL_ARGS); |
|
Line 95 static int pre_ign(DECL_ARGS); |
|
static int pre_in(DECL_ARGS); |
static int pre_in(DECL_ARGS); |
static int pre_literal(DECL_ARGS); |
static int pre_literal(DECL_ARGS); |
static int pre_sp(DECL_ARGS); |
static int pre_sp(DECL_ARGS); |
|
static int pre_ft(DECL_ARGS); |
|
|
static void post_IP(DECL_ARGS); |
static void post_IP(DECL_ARGS); |
static void post_HP(DECL_ARGS); |
static void post_HP(DECL_ARGS); |
Line 125 static const struct termact termacts[MAN_MAX] = { |
|
Line 127 static const struct termact termacts[MAN_MAX] = { |
|
{ pre_alternate, NULL, 0 }, /* IR */ |
{ pre_alternate, NULL, 0 }, /* IR */ |
{ pre_alternate, NULL, 0 }, /* RI */ |
{ pre_alternate, NULL, 0 }, /* RI */ |
{ NULL, NULL, MAN_NOTEXT }, /* na */ |
{ NULL, NULL, MAN_NOTEXT }, /* na */ |
{ pre_I, NULL, 0 }, /* i */ |
|
{ pre_sp, NULL, MAN_NOTEXT }, /* sp */ |
{ pre_sp, NULL, MAN_NOTEXT }, /* sp */ |
{ pre_literal, NULL, 0 }, /* nf */ |
{ pre_literal, NULL, 0 }, /* nf */ |
{ pre_literal, NULL, 0 }, /* fi */ |
{ pre_literal, NULL, 0 }, /* fi */ |
{ NULL, NULL, 0 }, /* r */ |
|
{ NULL, NULL, 0 }, /* RE */ |
{ NULL, NULL, 0 }, /* RE */ |
{ pre_RS, post_RS, 0 }, /* RS */ |
{ pre_RS, post_RS, 0 }, /* RS */ |
{ pre_ign, NULL, 0 }, /* DT */ |
{ pre_ign, NULL, 0 }, /* DT */ |
Line 137 static const struct termact termacts[MAN_MAX] = { |
|
Line 137 static const struct termact termacts[MAN_MAX] = { |
|
{ pre_ign, NULL, 0 }, /* PD */ |
{ pre_ign, NULL, 0 }, /* PD */ |
{ pre_ign, NULL, 0 }, /* AT */ |
{ pre_ign, NULL, 0 }, /* AT */ |
{ pre_in, NULL, MAN_NOTEXT }, /* in */ |
{ pre_in, NULL, MAN_NOTEXT }, /* in */ |
|
{ pre_ft, NULL, MAN_NOTEXT }, /* ft */ |
}; |
}; |
|
|
|
|
Line 320 pre_B(DECL_ARGS) |
|
Line 321 pre_B(DECL_ARGS) |
|
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
static int |
static int |
|
pre_ft(DECL_ARGS) |
|
{ |
|
const char *cp; |
|
|
|
if (NULL == n->child) { |
|
term_fontlast(p); |
|
return(0); |
|
} |
|
|
|
cp = n->child->string; |
|
switch (*cp) { |
|
case ('4'): |
|
/* FALLTHROUGH */ |
|
case ('3'): |
|
/* FALLTHROUGH */ |
|
case ('B'): |
|
term_fontrepl(p, TERMFONT_BOLD); |
|
break; |
|
case ('2'): |
|
/* FALLTHROUGH */ |
|
case ('I'): |
|
term_fontrepl(p, TERMFONT_UNDER); |
|
break; |
|
case ('P'): |
|
term_fontlast(p); |
|
break; |
|
case ('1'): |
|
/* FALLTHROUGH */ |
|
case ('C'): |
|
/* FALLTHROUGH */ |
|
case ('R'): |
|
term_fontrepl(p, TERMFONT_NONE); |
|
break; |
|
default: |
|
break; |
|
} |
|
return(0); |
|
} |
|
|
|
/* ARGSUSED */ |
|
static int |
pre_in(DECL_ARGS) |
pre_in(DECL_ARGS) |
{ |
{ |
int len, less; |
int len, less; |
Line 355 pre_in(DECL_ARGS) |
|
Line 397 pre_in(DECL_ARGS) |
|
else |
else |
p->offset = v; |
p->offset = v; |
|
|
|
/* Don't let this creep beyond the right margin. */ |
|
|
|
if (p->offset > p->rmargin) |
|
p->offset = p->rmargin; |
|
|
return(0); |
return(0); |
} |
} |
|
|
Line 472 pre_IP(DECL_ARGS) |
|
Line 519 pre_IP(DECL_ARGS) |
|
{ |
{ |
const struct man_node *nn; |
const struct man_node *nn; |
size_t len; |
size_t len; |
int ival; |
int savelit, ival; |
|
|
switch (n->type) { |
switch (n->type) { |
case (MAN_BODY): |
case (MAN_BODY): |
Line 492 pre_IP(DECL_ARGS) |
|
Line 539 pre_IP(DECL_ARGS) |
|
len = mt->lmargin; |
len = mt->lmargin; |
ival = -1; |
ival = -1; |
|
|
/* Calculate offset. */ |
/* Calculate the offset from the optional second argument. */ |
|
|
if (NULL != (nn = n->parent->head->child)) |
if (NULL != (nn = n->parent->head->child)) |
if (NULL != (nn = nn->next)) { |
if (NULL != (nn = nn->next)) |
for ( ; nn->next; nn = nn->next) |
|
/* Do nothing. */ ; |
|
if ((ival = a2width(p, nn->string)) >= 0) |
if ((ival = a2width(p, nn->string)) >= 0) |
len = (size_t)ival; |
len = (size_t)ival; |
} |
|
|
|
switch (n->type) { |
switch (n->type) { |
case (MAN_HEAD): |
case (MAN_HEAD): |
Line 516 pre_IP(DECL_ARGS) |
|
Line 559 pre_IP(DECL_ARGS) |
|
/* Set the saved left-margin. */ |
/* Set the saved left-margin. */ |
mt->lmargin = (size_t)ival; |
mt->lmargin = (size_t)ival; |
|
|
/* Don't print the length value. */ |
savelit = MANT_LITERAL & mt->fl; |
for (nn = n->child; nn->next; nn = nn->next) |
mt->fl &= ~MANT_LITERAL; |
print_man_node(p, mt, nn, m); |
|
|
if (n->child) |
|
print_man_node(p, mt, n->child, m); |
|
|
|
if (savelit) |
|
mt->fl |= MANT_LITERAL; |
|
|
return(0); |
return(0); |
case (MAN_BODY): |
case (MAN_BODY): |
p->offset = mt->offset + len; |
p->offset = mt->offset + len; |
Line 544 post_IP(DECL_ARGS) |
|
Line 593 post_IP(DECL_ARGS) |
|
p->rmargin = p->maxrmargin; |
p->rmargin = p->maxrmargin; |
break; |
break; |
case (MAN_BODY): |
case (MAN_BODY): |
term_flushln(p); |
term_newln(p); |
p->flags &= ~TERMP_NOLPAD; |
p->flags &= ~TERMP_NOLPAD; |
break; |
break; |
default: |
default: |
Line 559 pre_TP(DECL_ARGS) |
|
Line 608 pre_TP(DECL_ARGS) |
|
{ |
{ |
const struct man_node *nn; |
const struct man_node *nn; |
size_t len; |
size_t len; |
int ival; |
int savelit, ival; |
|
|
switch (n->type) { |
switch (n->type) { |
case (MAN_HEAD): |
case (MAN_HEAD): |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_TWOSPACE; |
|
break; |
break; |
case (MAN_BODY): |
case (MAN_BODY): |
p->flags |= TERMP_NOLPAD; |
p->flags |= TERMP_NOLPAD; |
Line 599 pre_TP(DECL_ARGS) |
|
Line 647 pre_TP(DECL_ARGS) |
|
p->offset = mt->offset; |
p->offset = mt->offset; |
p->rmargin = mt->offset + len; |
p->rmargin = mt->offset + len; |
|
|
|
savelit = MANT_LITERAL & mt->fl; |
|
mt->fl &= ~MANT_LITERAL; |
|
|
/* Don't print same-line elements. */ |
/* Don't print same-line elements. */ |
for (nn = n->child; nn; nn = nn->next) |
for (nn = n->child; nn; nn = nn->next) |
if (nn->line > n->line) |
if (nn->line > n->line) |
print_man_node(p, mt, nn, m); |
print_man_node(p, mt, nn, m); |
|
|
|
if (savelit) |
|
mt->fl |= MANT_LITERAL; |
|
|
if (ival >= 0) |
if (ival >= 0) |
mt->lmargin = (size_t)ival; |
mt->lmargin = (size_t)ival; |
|
|
Line 633 post_TP(DECL_ARGS) |
|
Line 687 post_TP(DECL_ARGS) |
|
p->rmargin = p->maxrmargin; |
p->rmargin = p->maxrmargin; |
break; |
break; |
case (MAN_BODY): |
case (MAN_BODY): |
term_flushln(p); |
term_newln(p); |
p->flags &= ~TERMP_NOLPAD; |
p->flags &= ~TERMP_NOLPAD; |
break; |
break; |
default: |
default: |
Line 820 print_man_node(DECL_ARGS) |
|
Line 874 print_man_node(DECL_ARGS) |
|
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
term_flushln(p); |
term_flushln(p); |
|
p->flags &= ~TERMP_NOLPAD; |
p->rmargin = rm; |
p->rmargin = rm; |
p->maxrmargin = rmax; |
p->maxrmargin = rmax; |
} |
} |
break; |
break; |
|
case (MAN_TBL): |
|
if (TBL_SPAN_FIRST & n->span->flags) |
|
term_newln(p); |
|
term_tbl(p, n->span); |
|
break; |
default: |
default: |
if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) |
if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) |
term_fontrepl(p, TERMFONT_NONE); |
term_fontrepl(p, TERMFONT_NONE); |
Line 835 print_man_node(DECL_ARGS) |
|
Line 895 print_man_node(DECL_ARGS) |
|
if (c && n->child) |
if (c && n->child) |
print_man_nodelist(p, mt, n->child, m); |
print_man_nodelist(p, mt, n->child, m); |
|
|
if (MAN_TEXT != n->type) { |
switch (n->type) { |
|
case (MAN_TEXT): |
|
/* FALLTHROUGH */ |
|
case (MAN_TBL): |
|
break; |
|
default: |
if (termacts[n->tok].post) |
if (termacts[n->tok].post) |
(*termacts[n->tok].post)(p, mt, n, m); |
(*termacts[n->tok].post)(p, mt, n, m); |
if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) |
if ( ! (MAN_NOTEXT & termacts[n->tok].flags)) |
term_fontrepl(p, TERMFONT_NONE); |
term_fontrepl(p, TERMFONT_NONE); |
|
break; |
} |
} |
|
|
if (MAN_EOS & n->flags) |
if (MAN_EOS & n->flags) |