-/* $OpenBSD: man_term.c,v 1.116 2014/12/23 13:48:15 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.117 2014/12/24 09:57:41 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
#include <assert.h>
#include <ctype.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
p->offset += v;
else
p->offset = v;
+ if (p->offset > SHRT_MAX)
+ p->offset = term_len(p, p->defindent);
return(0);
}
if ((nn = n->parent->head->child) != NULL &&
a2roffsu(nn->string, &su, SCALE_EN)) {
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;
} else
len = mt->lmargin[mt->lmargincur];
p->offset = mt->offset;
- if (len > 0 || (size_t)(-len) < mt->offset)
- p->rmargin = mt->offset + len;
- else
- p->rmargin = 0;
-
+ p->rmargin = mt->offset + len;
return(1);
}
(nn = nn->next) != NULL &&
a2roffsu(nn->string, &su, SCALE_EN)) {
len = term_hspan(p, &su);
- mt->lmargin[mt->lmargincur] = len;
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;
} else
len = mt->lmargin[mt->lmargincur];
nn->string != NULL && ! (MAN_LINE & nn->flags) &&
a2roffsu(nn->string, &su, SCALE_EN)) {
len = term_hspan(p, &su);
- mt->lmargin[mt->lmargincur] = len;
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;
} else
len = mt->lmargin[mt->lmargincur];
break;
}
+ len = SHRT_MAX + 1;
if ((n = n->parent->head->child) != NULL &&
a2roffsu(n->string, &su, SCALE_EN))
len = term_hspan(p, &su);
- else
+ if (len > SHRT_MAX)
len = term_len(p, p->defindent);
if (len > 0 || (size_t)(-len) < mt->offset)
break;
}
+ len = SHRT_MAX + 1;
if ((n = n->parent->head->child) != NULL &&
a2roffsu(n->string, &su, SCALE_EN))
len = term_hspan(p, &su);
- else
+ if (len > SHRT_MAX)
len = term_len(p, p->defindent);
if (len < 0 || (size_t)len < mt->offset)
-/* $OpenBSD: term.c,v 1.100 2014/12/23 13:48:15 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.101 2014/12/24 09:57:41 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
term_vspan(const struct termp *p, const struct roffsu *su)
{
double r;
+ int ri;
switch (su->unit) {
case SCALE_BU:
abort();
/* NOTREACHED */
}
- return(r > 0.0 ? r + 0.4995 : r - 0.4995);
+ ri = r > 0.0 ? r + 0.4995 : r - 0.4995;
+ return(ri < 66 ? ri : 1);
}
int