barcode/barcode-0.98-debian_fix.patch

79 lines
2.7 KiB
Diff
Raw Normal View History

diff -pur barcode-0.98/main.c barcode-0.98-fix/main.c
--- barcode-0.98/main.c 2002-03-01 21:31:07.000000000 +0000
+++ barcode-0.98-fix/main.c 2005-10-11 07:19:39.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,14 +548,6 @@ 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 */
@@ -564,35 +555,28 @@ int main(int argc, char **argv)
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");