underflow. Found while preparing an audit of termp.rmargin.
Overflow can also happen, but i see no sane way to deal with it,
so just let it happen. It doesn't happen for any sane input anyway,
groff behaviour is undefined, and the resulting values are legal,
even though they are useless.
-/* $Id: term_ascii.c,v 1.39 2014/10/28 18:49:33 schwarze Exp $ */
+/* $Id: term_ascii.c,v 1.40 2014/11/20 13:56:20 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
{
p->rmargin = p->defrmargin;
- if (0 < iop)
+ if (iop > 0)
p->defrmargin += width;
- else if (0 > iop)
+ else if (iop == 0)
+ p->defrmargin = width ? width : p->lastrmargin;
+ else if (p->defrmargin > width)
p->defrmargin -= width;
else
- p->defrmargin = width ? width : p->lastrmargin;
+ p->defrmargin = 0;
p->lastrmargin = p->rmargin;
p->rmargin = p->maxrmargin = p->defrmargin;
}
-/* $Id: term_ps.c,v 1.68 2014/10/28 17:36:19 schwarze Exp $ */
+/* $Id: term_ps.c,v 1.69 2014/11/20 13:56:20 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
size_t lastwidth;
lastwidth = p->ps->width;
- if (0 < iop)
+ if (iop > 0)
p->ps->width += width;
- else if (0 > iop)
+ else if (iop == 0)
+ p->ps->width = width ? width : p->ps->lastwidth;
+ else if (p->ps->width > width)
p->ps->width -= width;
else
- p->ps->width = width ? width : p->ps->lastwidth;
+ p->ps->width = 0;
p->ps->lastwidth = lastwidth;
}