shithub: neatpost

Download patch

ref: 1c4eef426bcd7025b22e36222a999aa2668e1fe6
parent: b5f3fef71fe1500540787b1757213bd204b73c0a
author: Ali Gholami Rudi <ali@rudi.ir>
date: Sat Aug 30 14:32:43 EDT 2014

out: the width of "x X eps" can be zero

In \X'eps epsfile width height', if width is zero, scale the
eps file according to the given height.

--- a/out.c
+++ b/out.c
@@ -254,9 +254,12 @@
 	int hwid, vwid;
 	FILE *filp;
 	int nspec, nbb;
-	nspec = sscanf(spec, "%s %d %d", eps, &hwid, &vwid);
-	if (nspec < 1)
+	if ((nspec = sscanf(spec, "%s %d %d", eps, &hwid, &vwid)) < 1)
 		return;
+	if (nspec < 2)
+		hwid = 0;
+	if (nspec < 3)
+		vwid = 0;
 	if (!(filp = fopen(eps, "r")))
 		return;
 	if (!fgets(buf, sizeof(buf), filp) ||
@@ -274,10 +277,12 @@
 	fclose(filp);
 	if (nbb < 4)		/* no BoundingBox comment */
 		return;
-	if (nspec == 1)
+	if (hwid <= 0 && vwid <= 0)
 		hwid = urx - llx;
-	if (nspec <= 2)
+	if (vwid <= 0)
 		vwid = (ury - lly) * hwid / (urx - llx);
+	if (hwid <= 0)
+		hwid = (urx - llx) * vwid / (ury - lly);
 	/* output the EPS file */
 	o_flush();
 	out_fontup(o_f);