-/* $Id: term.c,v 1.224 2014/07/06 18:51:13 schwarze Exp $ */
+/* $Id: term.c,v 1.228 2014/08/18 21:07:53 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include <sys/types.h>
break;
if (' ' == p->buf[i]) {
j = i;
- while (' ' == p->buf[i])
+ while (i < p->col && ' ' == p->buf[i])
i++;
dv = (i - j) * (*p->width)(p, ' ');
vbl += dv;
switch (su->unit) {
case SCALE_CM:
- r = su->scale * 2;
+ r = su->scale * 2.0;
break;
case SCALE_IN:
- r = su->scale * 6;
+ r = su->scale * 6.0;
break;
case SCALE_PC:
r = su->scale;
break;
case SCALE_PT:
- r = su->scale / 8;
+ r = su->scale / 8.0;
break;
case SCALE_MM:
- r = su->scale / 1000;
+ r = su->scale / 1000.0;
break;
case SCALE_VS:
r = su->scale;
break;
default:
- r = su->scale - 1;
+ r = su->scale - 1.0;
break;
}
if (r < 0.0)
r = 0.0;
- return((size_t)r);
+ return((size_t)(r + 0.0005));
}
size_t
{
double v;
- v = ((*p->hspan)(p, su));
+ v = (*p->hspan)(p, su);
if (v < 0.0)
v = 0.0;
- return((size_t)v);
+ return((size_t)(v + 0.0005));
}