[barcode] [PATCH] for including barcode to w2k ps

Jeff Chua jeff96@silk.corp.fedex.com
Wed, 30 Apr 2003 23:23:48 +0800 (SGT)


Below is a patch to allow negative x,y coordinates and disabling false
negative scaling ...

Thanks,
Jeff

--- main.c.org	Wed Apr 30 22:17:30 2003
+++ main.c	Wed Apr 30 22:17:47 2003
@@ -226,12 +226,24 @@
     double x = 0.0, y = 0.0;
     int n;

-    if (((char *)arg)[0]=='+') {
-	n = sscanf((char *)arg, "+%lf+%lf%s", &x, &y, (char *)arg);
-    } else {
-	n = sscanf((char *)arg, "%lfx%lf+%lf+%lf%s", &w, &h, &x, &y,
-		   (char *)arg);
-    }
+	if(((char *)arg)[0] != '+' && ((char *)arg)[0] != '-') {
+		n = sscanf((char *)arg, "%lfx%lf%s", &w, &h, (char *)arg) - 1;
+	}
+
+	if(((char *)arg)[0] == '+') {
+		n = sscanf((char *)arg, "+%lf%s", &x, (char *)arg) - 1;
+	} else {
+		n = sscanf((char *)arg, "-%lf%s", &x, (char *)arg) - 1;
+		x = -x;
+	}
+
+	if(((char *)arg)[0] == '+') {
+		n += sscanf((char *)arg, "+%lf%s", &y, (char *)arg);
+	} else {
+		n += sscanf((char *)arg, "-%lf%s", &y, (char *)arg);
+		y = -y;
+	}
+
     if (n!=4 && n!=2) {
 	fprintf(stderr, "%s: wrong geometry \"%s\"\n", prgname, (char *)arg);
 	return -2;
--- ps.c.org	Wed Apr 30 22:17:35 2003
+++ ps.c	Wed Apr 30 22:17:51 2003
@@ -97,6 +97,7 @@
     if (!bc->width) bc->width = barlen * scalef +1;

     /* But it can be too small, in this case enlarge and center the area */
+#if 0
     if (bc->width < barlen * scalef) {
         int wid = barlen * scalef + 1;
         bc->xoff -= (wid - bc->width)/2 ;
@@ -107,6 +108,7 @@
             bc->xoff = 0;
         }
     }
+#endif

     /* The height defaults to 80 points (rescaled) */
     if (!bc->height) bc->height = 80 * scalef;