mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
frontend: batch mode: fix default "~~~~~" output (github issue #65)
This commit is contained in:
parent
f0fc8f9fae
commit
d6dddfa2ce
@ -677,7 +677,7 @@ static int validate_seg(const char *optarg, const int N, struct zint_seg segs[10
|
|||||||
|
|
||||||
/* Batch mode - output symbol for each line of text in `filename` */
|
/* Batch mode - output symbol for each line of text in `filename` */
|
||||||
static int batch_process(struct zint_symbol *symbol, const char *filename, const int mirror_mode,
|
static int batch_process(struct zint_symbol *symbol, const char *filename, const int mirror_mode,
|
||||||
const char *filetype, const int rotate_angle) {
|
const char *filetype, const int output_given, const int rotate_angle) {
|
||||||
FILE *file;
|
FILE *file;
|
||||||
unsigned char buffer[ZINT_MAX_DATA_LEN] = {0}; // Maximum HanXin input
|
unsigned char buffer[ZINT_MAX_DATA_LEN] = {0}; // Maximum HanXin input
|
||||||
unsigned char character = 0;
|
unsigned char character = 0;
|
||||||
@ -689,7 +689,7 @@ static int batch_process(struct zint_symbol *symbol, const char *filename, const
|
|||||||
int format_len, i, o;
|
int format_len, i, o;
|
||||||
char adjusted[2] = {0};
|
char adjusted[2] = {0};
|
||||||
|
|
||||||
if (symbol->outfile[0] == '\0') {
|
if (symbol->outfile[0] == '\0' || !output_given) {
|
||||||
strcpy(format_string, "~~~~~.");
|
strcpy(format_string, "~~~~~.");
|
||||||
strncat(format_string, filetype, 3);
|
strncat(format_string, filetype, 3);
|
||||||
} else {
|
} else {
|
||||||
@ -955,6 +955,7 @@ int main(int argc, char **argv) {
|
|||||||
int addon_gap = 0;
|
int addon_gap = 0;
|
||||||
int rows = 0;
|
int rows = 0;
|
||||||
char filetype[4] = {0};
|
char filetype[4] = {0};
|
||||||
|
int output_given = 0;
|
||||||
int no_png;
|
int no_png;
|
||||||
int png_refused;
|
int png_refused;
|
||||||
int val;
|
int val;
|
||||||
@ -1552,6 +1553,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
strncpy(my_symbol->outfile, optarg, 255);
|
strncpy(my_symbol->outfile, optarg, 255);
|
||||||
|
output_given = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
@ -1633,7 +1635,8 @@ int main(int argc, char **argv) {
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
warn_number = ZINT_WARN_INVALID_OPTION;
|
warn_number = ZINT_WARN_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = batch_process(my_symbol, arg_opts[0].arg, mirror_mode, filetype, rotate_angle);
|
error_number = batch_process(my_symbol, arg_opts[0].arg, mirror_mode, filetype, output_given,
|
||||||
|
rotate_angle);
|
||||||
} else {
|
} else {
|
||||||
if (seg_count) {
|
if (seg_count) {
|
||||||
if (data_arg_num > 1) {
|
if (data_arg_num > 1) {
|
||||||
|
@ -483,22 +483,26 @@ static void test_input(int index, int debug) {
|
|||||||
};
|
};
|
||||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", "test_batch~.gif", 2, "test_batch1.gif\000test_batch2.gif" },
|
/* 0*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", "", 2, "00001.gif\00000002.gif" },
|
||||||
/* 1*/ { BARCODE_CODE128, 1, -1, 1, "gif", "123\n456\n7890123456789\n", NULL, 3, "123.gif\000456.gif\0007890123456789.gif" },
|
/* 1*/ { BARCODE_CODE128, 1, -1, 0, "gif", "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "~~~.gif", 10, "001.gif\000002.gif\000003.gif\000004.gif\000005.gif\000006.gif\000007.gif\000008.gif\000009.gif\000010.gif" },
|
||||||
/* 2*/ { BARCODE_CODE128, 1, -1, 1, "svg", "123\n456\n7890123456789\n", NULL, 3, "123.svg\000456.svg\0007890123456789.svg" },
|
/* 2*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", "@@@@.gif", 2, "***1.gif\000***2.gif" },
|
||||||
/* 3*/ { BARCODE_CODE128, 1, -1, 1, "gif", "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_xA0B.gif" },
|
/* 3*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n789\n", "#####.gif", 3, " 1.gif\000 2.gif\000 3.gif" },
|
||||||
/* 4*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" },
|
/* 4*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", "test_batch~.gif", 2, "test_batch1.gif\000test_batch2.gif" },
|
||||||
/* 5*/ { BARCODE_CODE128, 1, -1, 1, "gif", "123\n456\n7890123456789\nA\\u00A0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_u00A0B.gif" },
|
/* 5*/ { BARCODE_CODE128, 1, -1, 1, "gif", "123\n456\n7890123456789\n", NULL, 3, "123.gif\000456.gif\0007890123456789.gif" },
|
||||||
/* 6*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", "123\n456\n7890123456789\nA\\u00A0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" },
|
/* 6*/ { BARCODE_CODE128, 1, -1, 1, "svg", "123\n456\n7890123456789\n", NULL, 3, "123.svg\000456.svg\0007890123456789.svg" },
|
||||||
/* 7*/ { BARCODE_CODE128, 1, -1, 0, "gif", "\n", "test_batch.gif", 0, NULL },
|
/* 7*/ { BARCODE_CODE128, 1, -1, 1, "gif", "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_xA0B.gif" },
|
||||||
/* 8*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", TEST_INPUT_LONG "~.gif", 2, TEST_INPUT_LONG "1.gif\000" TEST_INPUT_LONG "2.gif" },
|
/* 8*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", "123\n456\n7890123456789\nA\\xA0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" },
|
||||||
/* 9*/ { BARCODE_CODE128, 0, -1, 0, "svg", "123", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" },
|
/* 9*/ { BARCODE_CODE128, 1, -1, 1, "gif", "123\n456\n7890123456789\nA\\u00A0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_u00A0B.gif" },
|
||||||
/* 10*/ { BARCODE_CODE128, 1, -1, 0, "svg", "123\n", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" },
|
/* 10*/ { BARCODE_CODE128, 1, ESCAPE_MODE, 1, "gif", "123\n456\n7890123456789\nA\\u00A0B\n", NULL, 4, "123.gif\000456.gif\0007890123456789.gif\000A_B.gif" },
|
||||||
/* 11*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n", "test_batch.jpeg", 1, "test_batch.jpeg.gif" },
|
/* 11*/ { BARCODE_CODE128, 1, -1, 0, "gif", "\n", "test_batch.gif", 0, NULL },
|
||||||
/* 12*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n", "test_batch.jpg", 1, "test_batch.gif" },
|
/* 12*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", TEST_INPUT_LONG "~.gif", 2, TEST_INPUT_LONG "1.gif\000" TEST_INPUT_LONG "2.gif" },
|
||||||
/* 13*/ { BARCODE_CODE128, 1, -1, 0, "emf", "123\n", "test_batch.jpeg", 1, "test_batch.jpeg.emf" },
|
/* 13*/ { BARCODE_CODE128, 0, -1, 0, "svg", "123", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" },
|
||||||
/* 14*/ { BARCODE_CODE128, 1, -1, 0, "emf", "123\n", "test_batch.jpg", 1, "test_batch.emf" },
|
/* 14*/ { BARCODE_CODE128, 1, -1, 0, "svg", "123\n", TEST_INPUT_LONG "1.gif", 1, TEST_INPUT_LONG "1.svg" },
|
||||||
/* 15*/ { BARCODE_CODE128, 1, -1, 0, "eps", "123\n", "test_batch.ps", 1, "test_batch.eps" },
|
/* 15*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n", "test_batch.jpeg", 1, "test_batch.jpeg.gif" },
|
||||||
|
/* 16*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n", "test_batch.jpg", 1, "test_batch.gif" },
|
||||||
|
/* 17*/ { BARCODE_CODE128, 1, -1, 0, "emf", "123\n", "test_batch.jpeg", 1, "test_batch.jpeg.emf" },
|
||||||
|
/* 18*/ { BARCODE_CODE128, 1, -1, 0, "emf", "123\n", "test_batch.jpg", 1, "test_batch.emf" },
|
||||||
|
/* 19*/ { BARCODE_CODE128, 1, -1, 0, "eps", "123\n", "test_batch.ps", 1, "test_batch.eps" },
|
||||||
};
|
};
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
int i;
|
int i;
|
||||||
@ -667,7 +671,7 @@ static void test_batch_large(int index, int debug) {
|
|||||||
};
|
};
|
||||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||||
struct item data[] = {
|
struct item data[] = {
|
||||||
/* 0*/ { BARCODE_HANXIN, 0, "1", 7827, "out.gif" },
|
/* 0*/ { BARCODE_HANXIN, 0, "1", 7827, "00001.gif" },
|
||||||
/* 1*/ { BARCODE_HANXIN, 1, "1", 7827, "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.gif" },
|
/* 1*/ { BARCODE_HANXIN, 1, "1", 7827, "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.gif" },
|
||||||
/* 2*/ { BARCODE_HANXIN, 0, "1", 7828, NULL },
|
/* 2*/ { BARCODE_HANXIN, 0, "1", 7828, NULL },
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user