=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.270 retrieving revision 1.271 diff -u -p -r1.270 -r1.271 --- mandoc/term.c 2017/06/14 01:31:27 1.270 +++ mandoc/term.c 2017/06/14 17:51:15 1.271 @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.270 2017/06/14 01:31:27 schwarze Exp $ */ +/* $Id: term.c,v 1.271 2017/06/14 17:51:15 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2017 Ingo Schwarze @@ -528,7 +528,7 @@ term_word(struct termp *p, const char *word) case ESCAPE_HORIZ: if (a2roffsu(seq, &su, SCALE_EM) == NULL) continue; - uc = term_hspan(p, &su) / 24; + uc = term_hen(p, &su); if (uc > 0) while (uc-- > 0) bufferc(p, ASCII_NBRSP); @@ -549,7 +549,7 @@ term_word(struct termp *p, const char *word) case ESCAPE_HLINE: if ((seq = a2roffsu(seq, &su, SCALE_EM)) == NULL) continue; - uc = term_hspan(p, &su) / 24; + uc = term_hen(p, &su); if (uc <= 0) { if (p->tcol->rmargin <= p->tcol->offset) continue; @@ -966,11 +966,25 @@ term_vspan(const struct termp *p, const struct roffsu } /* - * Convert a scaling width to basic units, rounding down. + * Convert a scaling width to basic units, rounding towards 0. */ int term_hspan(const struct termp *p, const struct roffsu *su) { return (*p->hspan)(p, su); +} + +/* + * Convert a scaling width to basic units, rounding to closest. + */ +int +term_hen(const struct termp *p, const struct roffsu *su) +{ + int bu; + + if ((bu = (*p->hspan)(p, su)) >= 0) + return (bu + 11) / 24; + else + return -((-bu + 11) / 24); }