version 1.163, 2014/12/23 13:48:57 |
version 1.165, 2014/12/24 18:04:10 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <limits.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
|
|
#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 { |
|
|
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) { |
Line 432 pre_in(DECL_ARGS) |
|
Line 433 pre_in(DECL_ARGS) |
|
p->offset += v; |
p->offset += v; |
else |
else |
p->offset = v; |
p->offset = v; |
|
if (p->offset > SHRT_MAX) |
|
p->offset = term_len(p, p->defindent); |
|
|
return(0); |
return(0); |
} |
} |
Line 508 pre_HP(DECL_ARGS) |
|
Line 511 pre_HP(DECL_ARGS) |
|
if ((nn = n->parent->head->child) != NULL && |
if ((nn = n->parent->head->child) != NULL && |
a2roffsu(nn->string, &su, SCALE_EN)) { |
a2roffsu(nn->string, &su, SCALE_EN)) { |
len = term_hspan(p, &su); |
len = term_hspan(p, &su); |
|
if (len < 0 && (size_t)(-len) > mt->offset) |
|
len = -mt->offset; |
|
else if (len > SHRT_MAX) |
|
len = term_len(p, p->defindent); |
mt->lmargin[mt->lmargincur] = len; |
mt->lmargin[mt->lmargincur] = len; |
} else |
} else |
len = mt->lmargin[mt->lmargincur]; |
len = mt->lmargin[mt->lmargincur]; |
|
|
p->offset = mt->offset; |
p->offset = mt->offset; |
if (len > 0 || (size_t)(-len) < mt->offset) |
p->rmargin = mt->offset + len; |
p->rmargin = mt->offset + len; |
|
else |
|
p->rmargin = 0; |
|
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 582 pre_IP(DECL_ARGS) |
|
Line 585 pre_IP(DECL_ARGS) |
|
(nn = nn->next) != NULL && |
(nn = nn->next) != NULL && |
a2roffsu(nn->string, &su, SCALE_EN)) { |
a2roffsu(nn->string, &su, SCALE_EN)) { |
len = term_hspan(p, &su); |
len = term_hspan(p, &su); |
mt->lmargin[mt->lmargincur] = len; |
|
if (len < 0 && (size_t)(-len) > mt->offset) |
if (len < 0 && (size_t)(-len) > mt->offset) |
len = -mt->offset; |
len = -mt->offset; |
|
else if (len > SHRT_MAX) |
|
len = term_len(p, p->defindent); |
|
mt->lmargin[mt->lmargincur] = len; |
} else |
} else |
len = mt->lmargin[mt->lmargincur]; |
len = mt->lmargin[mt->lmargincur]; |
|
|
|
|
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 662 pre_TP(DECL_ARGS) |
|
Line 667 pre_TP(DECL_ARGS) |
|
nn->string != NULL && ! (MAN_LINE & nn->flags) && |
nn->string != NULL && ! (MAN_LINE & nn->flags) && |
a2roffsu(nn->string, &su, SCALE_EN)) { |
a2roffsu(nn->string, &su, SCALE_EN)) { |
len = term_hspan(p, &su); |
len = term_hspan(p, &su); |
mt->lmargin[mt->lmargincur] = len; |
|
if (len < 0 && (size_t)(-len) > mt->offset) |
if (len < 0 && (size_t)(-len) > mt->offset) |
len = -mt->offset; |
len = -mt->offset; |
|
else if (len > SHRT_MAX) |
|
len = term_len(p, p->defindent); |
|
mt->lmargin[mt->lmargincur] = len; |
} else |
} else |
len = mt->lmargin[mt->lmargincur]; |
len = mt->lmargin[mt->lmargincur]; |
|
|
|
|
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 845 pre_RS(DECL_ARGS) |
|
Line 851 pre_RS(DECL_ARGS) |
|
break; |
break; |
} |
} |
|
|
if ((n = n->parent->head->child) != NULL && |
n = n->parent->head; |
a2roffsu(n->string, &su, SCALE_EN)) |
n->aux = SHRT_MAX + 1; |
len = term_hspan(p, &su); |
if (n->child != NULL && a2roffsu(n->child->string, &su, SCALE_EN)) |
else |
n->aux = term_hspan(p, &su); |
len = term_len(p, p->defindent); |
if (n->aux < 0 && (size_t)(-n->aux) > mt->offset) |
|
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 868 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 881 post_RS(DECL_ARGS) |
|
Line 885 post_RS(DECL_ARGS) |
|
break; |
break; |
} |
} |
|
|
if ((n = n->parent->head->child) != NULL && |
mt->offset -= n->parent->head->aux; |
a2roffsu(n->string, &su, SCALE_EN)) |
|
len = term_hspan(p, &su); |
|
else |
|
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) |