ok, fixed for my perusal - no thorough testing though, just a round for all
supported codes.
The problem was for upc only, as this has the rightmost digit external to 
the bars (like first).
Should work for any other (future) case though, as the patch simply takes 
into account the width of last digit to print, if BARCODE_NO_ASCII is unset.

WFM - HTH


-- 
 paolo
 
 GPG/PGP id:0x21426690 kfp:EDFB 0103 A8D8 4180 8AB5  D59E 9771 0F28 2142 6690
 "Indeed, it does come with warranty: it *will* fail, sometimes, somehow..."
                                                           - software vendor
diff -urN barcode-0.98.orig/codabar.c barcode-0.98/codabar.c
--- barcode-0.98.orig/codabar.c Wed Nov  8 18:13:27 2000
+++ barcode-0.98/codabar.c      Fri Apr 29 22:03:04 2005
@@ -165,6 +165,7 @@
            ptr += strlen(ptr);
        }
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     if (!startpresent) {
        if (usesum) {
            /* if no start character specified, B is used as a stop char */
diff -urN barcode-0.98.orig/code128.c barcode-0.98/code128.c
--- barcode-0.98.orig/code128.c Wed Feb 27 14:58:08 2002
+++ barcode-0.98/code128.c      Fri Apr 29 22:13:59 2005
@@ -142,6 +142,7 @@
         textptr += strlen(textptr);
         textpos += SYMBOL_WID; /* width of each code */
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     /* Add the checksum, independent of BARCODE_NO_CHECKSUM */
     checksum %= 103;
     strcat(partial, codeset[checksum]);
@@ -232,6 +233,7 @@
         textptr += strlen(textptr);
         textpos += SYMBOL_WID; /* width of each code */
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     /* Add the checksum, independent of BARCODE_NO_CHECKSUM */
     checksum %= 103;
     strcat(partial, codeset[checksum]);
@@ -492,6 +494,7 @@
         textptr += strlen(textptr);
         textpos += step;
     }
+    textptr[-1] = '\0'; /* overwrite last space */
 
     bc->partial = partial;
     bc->textinfo = textinfo;
@@ -593,6 +596,7 @@
         textpos += SYMBOL_WID; /* width of each code */
        i += n;
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     /* Add the checksum, independent of BARCODE_NO_CHECKSUM */
     checksum %= 103;
     strcat(partial, codeset[checksum]);
diff -urN barcode-0.98.orig/code39.c barcode-0.98/code39.c
--- barcode-0.98.orig/code39.c  Wed Feb 27 14:59:06 2002
+++ barcode-0.98/code39.c       Fri Apr 29 21:57:06 2005
@@ -160,6 +160,7 @@
         textptr += strlen(textptr);
         ptr += strlen(ptr); 
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     /* Add the checksum */
     if ( (bc->flags & BARCODE_NO_CHECKSUM)==0 ) {
        code = (strchr(alphabet, checkbet[checksum % 43]) - alphabet);
diff -urN barcode-0.98.orig/code93.c barcode-0.98/code93.c
--- barcode-0.98.orig/code93.c  Tue Oct 16 18:42:51 2001
+++ barcode-0.98/code93.c       Fri Apr 29 21:58:06 2005
@@ -182,6 +182,7 @@
         */
         textpos += 9;
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     c_checksum=0;
     k_checksum=0;
 
diff -urN barcode-0.98.orig/i25.c barcode-0.98/i25.c
--- barcode-0.98.orig/i25.c     Wed Feb 27 15:04:42 2002
+++ barcode-0.98/i25.c  Fri Apr 29 22:03:50 2005
@@ -153,6 +153,7 @@
         textpos += 18; /* width of two codes */
         textptr += strlen(textptr);
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     strcat(partial, guard[1]);
 
     bc->partial = partial;
diff -urN barcode-0.98.orig/msi.c barcode-0.98/msi.c
--- barcode-0.98.orig/msi.c     Tue Nov  7 18:45:35 2000
+++ barcode-0.98/msi.c  Fri Apr 29 22:04:32 2005
@@ -132,6 +132,7 @@
            }
        }
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     /* Some implementations use a double checksum. Currently the only way
      * to print a barcode with double checksum is to put the checksum
      * digit printed below at the end of a code in the command line
diff -urN barcode-0.98.orig/plessey.c barcode-0.98/plessey.c
--- barcode-0.98.orig/plessey.c Tue Nov  7 18:43:18 2000
+++ barcode-0.98/plessey.c      Fri Apr 29 22:05:13 2005
@@ -140,6 +140,7 @@
        checkptr[4*i+2] = (code >> 2) & 1;
        checkptr[4*i+3] = (code >> 3) & 1;
     }
+    textptr[-1] = '\0'; /* overwrite last space */
     /* The CRC checksum is required */
     for (i=0; i < 4*strlen(text); i++) {
         int j;
diff -urN barcode-0.98.orig/ps.c barcode-0.98/ps.c
--- barcode-0.98.orig/ps.c      Tue Nov 13 14:27:26 2001
+++ barcode-0.98/ps.c   Fri Apr 29 21:43:52 2005
@@ -146,11 +146,38 @@
            fprintf(f, "%%!PS-Adobe-2.0\n");
        fprintf(f, "%%%%Creator: libbarcode\n");
        if (bc->flags & BARCODE_OUT_EPS)  {
+           int bboxw;
+           bboxw=bc->xoff + bc->width + 2* bc->margin;
+            if (!(bc->flags & BARCODE_NO_ASCII)) {
+                ptr = strrchr(bc->textinfo,' ');
+               /*fprintf(stderr, "bc->textinfo=%s\n",bc->textinfo);*/
+               if (ptr == NULL) {
+                   fprintf(stderr, 
+                       "barcode: last char: impossible data: NULL\n");
+               } else {
+                   /*fprintf(stderr, "ptr=%s\n",ptr);*/
+                   if (sscanf(ptr, "%lf:%lf:%c", &f1, &f2, &c) != 3) {
+                       fprintf(stderr, 
+                          "barcode: last char: impossible data: %s\n", ptr);
+                   } else {
+                       /* Both the backslash and the two parens are special */
+                       if (c!='\\' && c!=')' && c!='(') {
+                           f1=bc->xoff + (f1+f2) * scalef + bc->margin;
+                           if (f1 > bboxw) bboxw=f1;
+                       }
+                   }
+               }
+           }
            fprintf(f, "%%%%BoundingBox: %i %i %i %i\n",
                    bc->xoff,
                    bc->yoff,
-                   bc->xoff + bc->width + 2* bc->margin,
+                   bboxw,
                    bc->yoff + bc->height + 2* bc->margin);
+       /*    fprintf(f, "%%DEBUG: bc->width=%i bc->height=%i bc->margin=%i "
+                    "scalef=%6.2f barlen=%6.2f bc->partial=%c\n",
+                   bc->width, bc->height, bc->margin, 
+                   scalef, (double)barlen, (char)bc->partial[0]);
+         */
        }
        fprintf(f, "%%%%EndComments\n");
        if (bc->flags & BARCODE_OUT_PS)  {

Reply via email to