version 1.164, 2014/12/24 09:58:35 |
version 1.170, 2015/03/15 16:53:41 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010-2015 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 |
|
|
|
|
#define DECL_ARGS struct termp *p, \ |
#define DECL_ARGS struct termp *p, \ |
struct mtermp *mt, \ |
struct mtermp *mt, \ |
const struct man_node *n, \ |
struct man_node *n, \ |
const struct man_meta *meta |
const struct man_meta *meta |
|
|
struct termact { |
struct termact { |
Line 114 static const struct termact termacts[MAN_MAX] = { |
|
Line 114 static const struct termact termacts[MAN_MAX] = { |
|
{ pre_I, NULL, 0 }, /* I */ |
{ pre_I, NULL, 0 }, /* I */ |
{ pre_alternate, NULL, 0 }, /* IR */ |
{ pre_alternate, NULL, 0 }, /* IR */ |
{ pre_alternate, NULL, 0 }, /* RI */ |
{ pre_alternate, NULL, 0 }, /* RI */ |
{ pre_ign, NULL, MAN_NOTEXT }, /* na */ |
|
{ 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 */ |
|
|
pre_alternate(DECL_ARGS) |
pre_alternate(DECL_ARGS) |
{ |
{ |
enum termfont font[2]; |
enum termfont font[2]; |
const struct man_node *nn; |
struct man_node *nn; |
int savelit, i; |
int savelit, i; |
|
|
switch (n->tok) { |
switch (n->tok) { |
|
|
pre_TP(DECL_ARGS) |
pre_TP(DECL_ARGS) |
{ |
{ |
struct roffsu su; |
struct roffsu su; |
const struct man_node *nn; |
struct man_node *nn; |
int len, savelit; |
int len, savelit; |
|
|
switch (n->type) { |
switch (n->type) { |
Line 744 pre_SS(DECL_ARGS) |
|
Line 743 pre_SS(DECL_ARGS) |
|
|
|
do { |
do { |
n = n->prev; |
n = n->prev; |
} while (n != NULL && termacts[n->tok].flags & MAN_NOTEXT); |
} while (n != NULL && n->tok != MAN_MAX && |
|
termacts[n->tok].flags & MAN_NOTEXT); |
if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) |
if (n == NULL || (n->tok == MAN_SS && n->body->child == NULL)) |
break; |
break; |
|
|
|
|
pre_RS(DECL_ARGS) |
pre_RS(DECL_ARGS) |
{ |
{ |
struct roffsu su; |
struct roffsu su; |
int len; |
|
|
|
switch (n->type) { |
switch (n->type) { |
case MAN_BLOCK: |
case MAN_BLOCK: |
Line 852 pre_RS(DECL_ARGS) |
|
Line 851 pre_RS(DECL_ARGS) |
|
break; |
break; |
} |
} |
|
|
len = SHRT_MAX + 1; |
n = n->parent->head; |
if ((n = n->parent->head->child) != NULL && |
n->aux = SHRT_MAX + 1; |
a2roffsu(n->string, &su, SCALE_EN)) |
if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN)) |
len = term_hspan(p, &su); |
n->aux = term_hspan(p, &su); |
if (len > SHRT_MAX) |
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset) |
len = term_len(p, p->defindent); |
n->aux = -mt->offset; |
|
else if (n->aux > SHRT_MAX) |
|
n->aux = term_len(p, p->defindent); |
|
|
if (len > 0 || (size_t)(-len) < mt->offset) |
mt->offset += n->aux; |
mt->offset += len; |
|
else |
|
mt->offset = 0; |
|
p->offset = mt->offset; |
p->offset = mt->offset; |
p->rmargin = p->maxrmargin; |
p->rmargin = p->maxrmargin; |
|
|
Line 876 pre_RS(DECL_ARGS) |
|
Line 874 pre_RS(DECL_ARGS) |
|
static void |
static void |
post_RS(DECL_ARGS) |
post_RS(DECL_ARGS) |
{ |
{ |
struct roffsu su; |
|
int len; |
|
|
|
switch (n->type) { |
switch (n->type) { |
case MAN_BLOCK: |
case MAN_BLOCK: |
Line 889 post_RS(DECL_ARGS) |
|
Line 885 post_RS(DECL_ARGS) |
|
break; |
break; |
} |
} |
|
|
len = SHRT_MAX + 1; |
mt->offset -= n->parent->head->aux; |
if ((n = n->parent->head->child) != NULL && |
|
a2roffsu(n->string, &su, SCALE_EN)) |
|
len = term_hspan(p, &su); |
|
if (len > SHRT_MAX) |
|
len = term_len(p, p->defindent); |
|
|
|
if (len < 0 || (size_t)len < mt->offset) |
|
mt->offset -= len; |
|
else |
|
mt->offset = 0; |
|
p->offset = mt->offset; |
p->offset = mt->offset; |
|
|
if (--mt->lmarginsz < MAXMARGINS) |
if (--mt->lmarginsz < MAXMARGINS) |
Line 960 print_man_node(DECL_ARGS) |
|
Line 946 print_man_node(DECL_ARGS) |
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
return; |
return; |
case MAN_TBL: |
case MAN_TBL: |
/* |
if (p->tbl.cols == NULL) |
* Tables are preceded by a newline. Then process a |
term_vspace(p); |
* table line, which will cause line termination, |
|
*/ |
|
if (TBL_SPAN_FIRST & n->span->flags) |
|
term_newln(p); |
|
term_tbl(p, n->span); |
term_tbl(p, n->span); |
return; |
return; |
default: |
default: |
|
|
print_man_nodelist(DECL_ARGS) |
print_man_nodelist(DECL_ARGS) |
{ |
{ |
|
|
print_man_node(p, mt, n, meta); |
while (n != NULL) { |
if ( ! n->next) |
print_man_node(p, mt, n, meta); |
return; |
n = n->next; |
print_man_nodelist(p, mt, n->next, meta); |
} |
} |
} |
|
|
static void |
static void |