From 3421776cece57041488f5a8c30f8906cf2929595 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Sun, 19 Oct 2014 17:20:49 +0330 Subject: [PATCH] fmt: for last lines, simply use the usual cost formula The main difference is that the length of the last line is assumed to be: \n(.l * \n[.pmll] / 100. --- fmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fmt.c b/fmt.c index f3bde68..0f8193f 100644 --- a/fmt.c +++ b/fmt.c @@ -366,7 +366,7 @@ static long FMT_COST(int llen, int lwid, int swid, int nspc) /* the ratio that the stretchable spaces of the line should be spread */ long ratio = abs((llen - lwid) * 100l / (swid ? swid : 1)); /* assigning a cost of 100 to each space stretching 100 percent */ - return (ratio < 4000 ? ratio * ratio : 16000000) / 100l * (nspc ? nspc : 4); + return (ratio < 4000 ? ratio * ratio : 16000000) / 100l * (nspc ? nspc : 1); } /* the cost of formatting last lines; should prevent widows */ @@ -374,7 +374,7 @@ static long FMT_LCOST(int llen, int lwid, int swid, int nspc) { if (!n_pmll || lwid >= llen * n_pmll / 100) return 0; - return FMT_COST(llen, llen * (100 - n_pmll) / 100 + lwid, swid, nspc); + return FMT_COST(llen * n_pmll / 100, lwid, swid, nspc); } /* the cost of putting a line break before word pos */ -- 2.11.4.GIT