summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-04-04 17:46:59 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-04-04 17:46:59 +0000
commitd754351ef53f06fab6f82d76db709f0d09a96679 (patch)
treec69bb8b619308e5754442c5232bcff7a14f940e7 /usr.bin/mandoc/term.c
parent506f9818b8492e36d1b35e5a6ce5440b69bd4ec9 (diff)
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).
Diffstat (limited to 'usr.bin/mandoc/term.c')
-rw-r--r--usr.bin/mandoc/term.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index dce82c28501..9e6ee91a392 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.106 2015/04/02 23:47:43 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.107 2015/04/04 17:46:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -617,8 +617,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;
@@ -829,11 +828,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));
}