From a203fd4e6f05d56d51d63d78b0357f1c67ffec39 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 4 Apr 2015 17:47:18 +0000 Subject: Rounding rules for horizontal scaling widths are more complicated. There is a first rounding to basic units on the input side. After that, rounding rules differ between requests and macros. Requests round to the nearest possible character position. Macros round to the next character position to the left. Implement that by changing the return value of term_hspan() to basic units and leaving the second scaling and rounding stage to the formatters instead of doing it in the terminal handler. Improves for example argtable2(3). --- term.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'term.c') diff --git a/term.c b/term.c index 6476b0e7..68f3ea04 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.246 2015/04/02 23:48:20 schwarze Exp $ */ +/* $Id: term.c,v 1.247 2015/04/04 17:47:18 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2015 Ingo Schwarze @@ -619,8 +619,7 @@ void term_setwidth(struct termp *p, const char *wstr) { struct roffsu su; - size_t width; - int iop; + int iop, width; iop = 0; width = 0; @@ -831,11 +830,12 @@ term_vspan(const struct termp *p, const struct roffsu *su) return(ri < 66 ? ri : 1); } +/* + * Convert a scaling width to basic units, rounding down. + */ int term_hspan(const struct termp *p, const struct roffsu *su) { - double v; - v = (*p->hspan)(p, su); - return(v > 0.0 ? v + 0.0005 : v - 0.0005); + return((*p->hspan)(p, su)); } -- cgit v1.2.3-56-ge451