shithub: neatroff

Download patch

ref: 3421776cece57041488f5a8c30f8906cf2929595
parent: f1e9b608a0529f3867cc78fd00952d924d424c0f
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sun Oct 19 13:20:49 EDT 2014

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.

--- a/fmt.c
+++ b/fmt.c
@@ -366,7 +366,7 @@
 	/* 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 @@
 {
 	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 */