[95543] trunk/dports/textproc/barcode

jmr at macports.org jmr at macports.org
Sun Jul 15 19:45:50 PDT 2012


Revision: 95543
          https://trac.macports.org/changeset/95543
Author:   jmr at macports.org
Date:     2012-07-15 19:45:47 -0700 (Sun, 15 Jul 2012)
Log Message:
-----------
barcode: correctly handle systempapername() returning NULL (#33000), apply debian patches, set license

Modified Paths:
--------------
    trunk/dports/textproc/barcode/Portfile
    trunk/dports/textproc/barcode/files/Makefile.in.patch

Added Paths:
-----------
    trunk/dports/textproc/barcode/files/01-codabar.patch
    trunk/dports/textproc/barcode/files/02-margin.patch
    trunk/dports/textproc/barcode/files/03-oversize.patch
    trunk/dports/textproc/barcode/files/main.c.patch

Modified: trunk/dports/textproc/barcode/Portfile
===================================================================
--- trunk/dports/textproc/barcode/Portfile	2012-07-15 23:49:48 UTC (rev 95542)
+++ trunk/dports/textproc/barcode/Portfile	2012-07-16 02:45:47 UTC (rev 95543)
@@ -5,8 +5,9 @@
 
 name                barcode
 version             0.98
-revision            1
+revision            2
 categories          textproc print
+license             GPL-2+
 maintainers         nomaintainer
 description         convert text strings to printed barcodes
 long_description    \
@@ -21,7 +22,12 @@
 master_sites        gnu
 checksums           md5 7f10c3307b84a19a4ab2fa4b3f2974da
 
-patchfiles          Makefile.in.patch
+patch.pre_args      -p1
+patchfiles          Makefile.in.patch \
+                    01-codabar.patch \
+                    02-margin.patch \
+                    03-oversize.patch \
+                    main.c.patch
 
 use_autoreconf      yes
 

Added: trunk/dports/textproc/barcode/files/01-codabar.patch
===================================================================
--- trunk/dports/textproc/barcode/files/01-codabar.patch	                        (rev 0)
+++ trunk/dports/textproc/barcode/files/01-codabar.patch	2012-07-16 02:45:47 UTC (rev 95543)
@@ -0,0 +1,46 @@
+Author: Chris Howie <crazycomputers at yahoo.com>
+Description: Following codabar specification (Closes: #320908).
+
+diff -Naurp barcode.orig/codabar.c barcode/codabar.c
+--- barcode.orig/codabar.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/codabar.c	2009-07-16 21:55:33.000000000 +0000
+@@ -29,10 +29,11 @@
+ 
+ /* this is ordered in decades to simplify encoding */
+ static char alphabet[] = 
+-   "0123456789" "-$:/.+ABCD";
++   "0123456789" "-$:/.+ABCDTN*E";
+ 
+ #define CODE_A	16
+ #define CODE_B	17
++#define CODE_T	20
+ 
+ #define NARROW	12
+ #define WIDE	14
+@@ -42,7 +43,8 @@ static char *patterns[] = {
+ "1111133","1111331","1113113","3311111","1131131",
+ "3111131","1311113","1311311","1331111","3113111",
+ "1113311","1133111","3111313","3131113","3131311",
+-"1131313","1133131","1313113","1113133","1113331" };
++"1131313","1133131","1313113","1113133","1113331",
++"1133131","1313113","1113133","1113331"};
+ 
+ /*
+  * Check that the text can be encoded. Returns 0 or -1.
+@@ -167,13 +169,13 @@ int Barcode_cbr_encode(struct Barcode_It
+     }
+     if (!startpresent) {
+ 	if (usesum) {
+-	    /* if no start character specified, B is used as a stop char */
+-	    checksum += CODE_B;
++	    /* if no start character specified, T is used as a stop char */
++	    checksum += CODE_T;
+ 	    checksum = (checksum + 15) / 16 * 16 - checksum;
+ 	    add_one(ptr, checksum);
+ 	    ptr += strlen(ptr);
+ 	}
+-	add_one(ptr, CODE_B);
++	add_one(ptr, CODE_T);
+     }
+     bc->partial = partial;
+     bc->textinfo = textinfo;

Added: trunk/dports/textproc/barcode/files/02-margin.patch
===================================================================
--- trunk/dports/textproc/barcode/files/02-margin.patch	                        (rev 0)
+++ trunk/dports/textproc/barcode/files/02-margin.patch	2012-07-16 02:45:47 UTC (rev 95543)
@@ -0,0 +1,83 @@
+Author: n/a
+Description: Adjusts correct margins.
+
+diff -Naurp barcode.orig/main.c barcode/main.c
+--- barcode.orig/main.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/main.c	2009-07-16 21:56:09.000000000 +0000
+@@ -419,7 +419,6 @@ char *strerror(int error)
+  */
+ int main(int argc, char **argv)
+ {
+-    struct Barcode_Item * bc;
+     FILE *ifile = stdin;
+     FILE *ofile = stdout;
+     char *line;
+@@ -549,50 +548,37 @@ int main(int argc, char **argv)
+ 	int ystep = (page_hei - ymargin0 - ymargin1)/lines;
+ 	int x = columns, y = -1; /* position in the table, start off-page */
+ 
+-	if (!ximargin) ximargin = BARCODE_DEFAULT_MARGIN;
+-	if (!yimargin) yimargin = BARCODE_DEFAULT_MARGIN;
+-	/* Assign default size unless -g did it (Joachim Reichelt) */
+-	if ( !code_width && !code_height) {
+-	    code_width = xstep - 2*ximargin;
+-	    code_height = ystep - 2*yimargin;
+-	}
+-
+ 	page=0;
++
++
+ 	while ( (line = retrieve_input_string(ifile)) ) {
+ 	    x++;  /* fit x and y */
+ 	    if (x >= columns) {
+ 		x=0; y--;
+ 		if (y<0) {
+ 		    y = lines-1; page++;
+-		    /* flush page */
+-		    if (ps && page > 1) fprintf(ofile, "showpage\n");
+-		    if (pcl && page > 1) fprintf(ofile, "\f");
+-		    /* new page */
+-		    if (ps) fprintf(ofile, "%%%%Page: %i %i\n\n",page,page);
++		    if (page>1) {
++			if (ps) {
++			    fprintf(ofile, "showpage\n");
++			    fprintf(ofile, "%%%%Page: %i %i\n\n",page,page);
++			}
++			if (pcl) fprintf(ofile, "\f");
++		    }
+ 		}
+ 	    }
+ 
+ 	    /*
+-	     * Create a barcode item. This allows to set the margin to 0, as
+-	     * we have [xy]imargin to use. But don't use Encode_and_Print(),
+-	     * unroll it here instead
++	     * Print this code, using the internal margins as spacing.
++	     * In order to remove the extra (default) margin, subtract it
++	     * in advance (dirty)
+ 	     */
+-	    bc = Barcode_Create(line);
+-	    if (!bc) {
+-		fprintf(stderr, "%s: Barcode_Create(): %s\n", argv[0],
+-			strerror(errno));
+-		exit(1);
+-	    }
+-	    bc->margin = 0;
+-	    if ( (Barcode_Position(bc, code_width, code_height,
+-				   xmargin0 + ximargin + x * xstep,
+-				   ymargin0 + yimargin + y * ystep, 0.0) < 0)
+-		 || (Barcode_Encode(bc, flags) < 0)
+-		 || (Barcode_Print(bc, ofile, flags) < 0) ) {
+-		fprintf(stderr, "%s: can't encode \"%s\": %s\n", argv[0],
+-			line, strerror(bc->error));
++	    if (Barcode_Encode_and_Print(line, ofile,
++		    xstep - 2*ximargin, ystep - 2*yimargin,
++		    xmargin0 + ximargin + x * xstep - BARCODE_DEFAULT_MARGIN,
++		    ymargin0 + yimargin + y * ystep - BARCODE_DEFAULT_MARGIN,
++		    flags)<0) {
++		fprintf(stderr, "%s: can't encode \"%s\"\n", argv[0], line);
+ 	    }
+-	    Barcode_Delete(bc);
+ 	}
+ 	if (ps) fprintf(ofile, "showpage\n\n%%%%Trailer\n\n");
+ 	if (pcl) fprintf(ofile, "\f");

Added: trunk/dports/textproc/barcode/files/03-oversize.patch
===================================================================
--- trunk/dports/textproc/barcode/files/03-oversize.patch	                        (rev 0)
+++ trunk/dports/textproc/barcode/files/03-oversize.patch	2012-07-16 02:45:47 UTC (rev 95543)
@@ -0,0 +1,147 @@
+Author: Paolo <oopla at users.sf.net>
+Description: Fixing oversized images (Closes: #320908).
+
+diff -Naurp barcode.orig/codabar.c barcode/codabar.c
+--- barcode.orig/codabar.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/codabar.c	2009-07-16 21:57:12.000000000 +0000
+@@ -165,6 +165,7 @@ int Barcode_cbr_encode(struct Barcode_It
+ 	    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 -Naurp barcode.orig/code128.c barcode/code128.c
+--- barcode.orig/code128.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/code128.c	2009-07-16 21:57:12.000000000 +0000
+@@ -142,6 +142,7 @@ int Barcode_128b_encode(struct Barcode_I
+         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 @@ int Barcode_128c_encode(struct Barcode_I
+         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 @@ int Barcode_128_encode(struct Barcode_It
+         textptr += strlen(textptr);
+         textpos += step;
+     }
++    textptr[-1] = '\0'; /* overwrite last space */
+ 
+     bc->partial = partial;
+     bc->textinfo = textinfo;
+@@ -593,6 +596,7 @@ int Barcode_128raw_encode(struct Barcode
+         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 -Naurp barcode.orig/code39.c barcode/code39.c
+--- barcode.orig/code39.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/code39.c	2009-07-16 21:57:12.000000000 +0000
+@@ -160,6 +160,7 @@ int Barcode_39_encode(struct Barcode_Ite
+         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 -Naurp barcode.orig/code93.c barcode/code93.c
+--- barcode.orig/code93.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/code93.c	2009-07-16 21:57:12.000000000 +0000
+@@ -182,6 +182,7 @@ int Barcode_93_encode(struct Barcode_Ite
+ 	 */
+         textpos += 9;
+     }
++    textptr[-1] = '\0'; /* overwrite last space */
+     c_checksum=0;
+     k_checksum=0;
+ 
+diff -Naurp barcode.orig/i25.c barcode/i25.c
+--- barcode.orig/i25.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/i25.c	2009-07-16 21:57:12.000000000 +0000
+@@ -153,6 +153,7 @@ int Barcode_i25_encode(struct Barcode_It
+         textpos += 18; /* width of two codes */
+         textptr += strlen(textptr);
+     }
++    textptr[-1] = '\0'; /* overwrite last space */
+     strcat(partial, guard[1]);
+ 
+     bc->partial = partial;
+diff -Naurp barcode.orig/msi.c barcode/msi.c
+--- barcode.orig/msi.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/msi.c	2009-07-16 21:57:12.000000000 +0000
+@@ -132,6 +132,7 @@ int Barcode_msi_encode(struct Barcode_It
+ 	    }
+ 	}
+     }
++    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 -Naurp barcode.orig/plessey.c barcode/plessey.c
+--- barcode.orig/plessey.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/plessey.c	2009-07-16 21:57:12.000000000 +0000
+@@ -140,6 +140,7 @@ int Barcode_pls_encode(struct Barcode_It
+ 	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 -Naurp barcode.orig/ps.c barcode/ps.c
+--- barcode.orig/ps.c	2009-07-16 21:49:31.000000000 +0000
++++ barcode/ps.c	2009-07-16 21:57:12.000000000 +0000
+@@ -146,11 +146,38 @@ int Barcode_ps_print(struct Barcode_Item
+ 	    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)  {

Modified: trunk/dports/textproc/barcode/files/Makefile.in.patch
===================================================================
--- trunk/dports/textproc/barcode/files/Makefile.in.patch	2012-07-15 23:49:48 UTC (rev 95542)
+++ trunk/dports/textproc/barcode/files/Makefile.in.patch	2012-07-16 02:45:47 UTC (rev 95543)
@@ -1,5 +1,5 @@
---- Makefile.in.orig	2012-02-03 15:32:12.000000000 +0100
-+++ Makefile.in	2012-02-03 15:32:39.000000000 +0100
+--- a/Makefile.in.orig	2012-02-03 15:32:12.000000000 +0100
++++ b/Makefile.in	2012-02-03 15:32:39.000000000 +0100
 @@ -3,12 +3,12 @@
  #
  

Added: trunk/dports/textproc/barcode/files/main.c.patch
===================================================================
--- trunk/dports/textproc/barcode/files/main.c.patch	                        (rev 0)
+++ trunk/dports/textproc/barcode/files/main.c.patch	2012-07-16 02:45:47 UTC (rev 95543)
@@ -0,0 +1,12 @@
+--- barcode-0.98/main.c.orig	2002-03-02 08:31:07.000000000 +1100
++++ barcode-0.98/main.c	2012-07-16 12:40:37.000000000 +1000
+@@ -299,6 +299,9 @@ int get_page_geometry(void *arg)
+     int n;
+     double dpw, dph; /* page width, height in mm or inches */
+     static char tmpstr[20];
++    if (!arg) {
++        return -1;
++    }
+     page_name = arg; /* if undecipherable, we won't run the program :) */
+     /*
+      * try to decode a "mm" string (eg. "210mmx297mm" or "210x297mm")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120715/6cf4c275/attachment-0001.html>


More information about the macports-changes mailing list