version 1.93, 2011/01/03 15:30:25 |
version 1.96, 2011/01/12 10:43:22 |
|
|
/* $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 396 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 513 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 533 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 557 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 585 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 600 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 640 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 674 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 846 print_man_node(DECL_ARGS) |
|
Line 859 print_man_node(DECL_ARGS) |
|
|
|
switch (n->type) { |
switch (n->type) { |
case(MAN_TEXT): |
case(MAN_TEXT): |
if (0 == *n->string) { |
if ('\0' == *n->string) { |
term_vspace(p); |
term_vspace(p); |
break; |
break; |
} |
} |
|
|
|
if (' ' == *n->string && MAN_LINE & n->flags) |
|
term_newln(p); |
|
|
term_word(p, n->string); |
term_word(p, n->string); |
|
|
/* FIXME: this means that macro lines are munged! */ |
/* FIXME: this means that macro lines are munged! */ |
Line 861 print_man_node(DECL_ARGS) |
|
Line 877 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): |
case (MAN_TBL): |
if (TBL_SPAN_FIRST & n->span->flags) |
if (TBL_SPAN_FIRST & n->span->flags) |