From 8525597b814bf0df281990cd153e2177f6e9f08e Mon Sep 17 00:00:00 2001 From: gitlost Date: Mon, 4 Jul 2022 21:55:06 +0100 Subject: [PATCH] frontend: batch: for @ use + instead of * on Windows as * not allowed in filenames GUI: sequence: similarly for * use + instead of * on Windows --- docs/manual.pmd | 21 +++++++++++---------- docs/manual.txt | 15 ++++++++------- frontend/main.c | 7 ++++++- frontend/tests/test_args.c | 7 ++++++- frontend_qt/extSequence.ui | 8 ++++---- frontend_qt/sequencewindow.cpp | 6 +++++- 6 files changed, 40 insertions(+), 24 deletions(-) diff --git a/docs/manual.pmd b/docs/manual.pmd index cb468fbe..6b7212ca 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -341,12 +341,12 @@ each line of text in the right hand panel. The format field determines the format of the automatically generated sequence where characters have the meanings as given below: -| Character | Effect | -|:-------------------|:------------------------| -|`#` | Insert leading spaces | -|`$` | Insert leading zeroes | -|`*` | Insert leading asterisks| -|Any other character | Interpreted literally | +| Character | Effect | +|:-------------------|:---------------------------------------------------| +|`$` | Insert leading zeroes | +|`#` | Insert leading spaces | +|`*` | Insert leading asterisks (or plus signs on Windows)| +|Any other character | Interpreted literally | Table: {#tbl:sequence_format_characters tag=": Sequence Format Characters"} @@ -1243,10 +1243,10 @@ with `--batch` using special characters in the output filename as shown in the table below: Input Character Interpretation ---------------- ------------------------ +--------------- ------------------------------------------ `~` Insert a number or 0 `#` Insert a number or space -`@` Insert a number or `*` +`@` Insert a number or `*` (or `+` on Windows) Any other Insert literally Table: {#tbl:batch_filename_formatting tag=": Batch Filename Formatting"} @@ -1254,9 +1254,10 @@ Table: {#tbl:batch_filename_formatting tag=": Batch Filename Formatting"} The following table shows some examples to clarify this method: Input Filenames Generated ------------------ ------------------------------------------------ +----------------- --------------------------------------------------- `-o file~~~.svg` `file001.svg`, `file002.svg`, `file003.svg` -`-o @@@@bar.png` `***1.png`, `***2.png`, `***3.png` +`-o @@@@bar.png` `***1.png`, `***2.png`, `***3.png` (except Windows) +`-o @@@@bar.png` `+++1.png`, `+++2.png`, `+++3.png` (on Windows) `-o my~~~bar.eps` `my001.bar.eps`, `my002.bar.eps`, `my003bar.eps` `-o t@es~t~.png` `t*es0t1.png`, `t*es0t2.png`, `t*es0t3.png` diff --git a/docs/manual.txt b/docs/manual.txt index 50de6a9a..7ebae415 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -502,10 +502,10 @@ format of the automatically generated sequence where characters have the meanings as given below: Character Effect - --------------------- -------------------------- - # Insert leading spaces + --------------------- ----------------------------------------------------- $ Insert leading zeroes - * Insert leading asterisks + # Insert leading spaces + * Insert leading asterisks (or plus signs on Windows) Any other character Interpreted literally : TableĀ : Sequence Format Characters: @@ -1319,10 +1319,10 @@ By default Zint will output numbered filenames starting with 00001.png, below: Input Character Interpretation - ----------------- -------------------------- + ----------------- ---------------------------------------- ~ Insert a number or 0 # Insert a number or space - @ Insert a number or * + @ Insert a number or * (or + on Windows) Any other Insert literally : TableĀ : Batch Filename Formatting: @@ -1330,9 +1330,10 @@ below: The following table shows some examples to clarify this method: Input Filenames Generated - ----------------- -------------------------------------------- + ----------------- ----------------------------------------------- -o file~~~.svg file001.svg, file002.svg, file003.svg - -o @@@@bar.png ***1.png, ***2.png, ***3.png + -o @@@@bar.png ***1.png, ***2.png, ***3.png (except Windows) + -o @@@@bar.png +++1.png, +++2.png, +++3.png (on Windows) -o my~~~bar.eps my001.bar.eps, my002.bar.eps, my003bar.eps -o t@es~t~.png t*es0t1.png, t*es0t2.png, t*es0t3.png diff --git a/frontend/main.c b/frontend/main.c index 4bf14e12..5c2f5eba 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -702,7 +702,8 @@ static int batch_process(struct zint_symbol *symbol, const char *filename, const } else { file = fopen(filename, "rb"); if (!file) { - sprintf(symbol->errtxt, "102: Unable to read input file '%s'", filename); + fprintf(stderr, "Error 102: Unable to read input file '%s'\n", filename); + fflush(stderr); return ZINT_ERROR_INVALID_DATA; } } @@ -765,7 +766,11 @@ static int batch_process(struct zint_symbol *symbol, const char *filename, const adjusted[0] = reverse_number[inpos - 1]; inpos--; } else { +#ifndef _WIN32 adjusted[0] = '*'; +#else + adjusted[0] = '+'; +#endif } break; default: diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index a92d9172..c609dce4 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -469,6 +469,11 @@ static void test_input(int index, int debug) { #define TEST_INPUT_LONG "test_67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" +#ifndef _WIN32 +#define TEST_INPUT_AMPERSAND_EXPECTED "***1.gif\000***2.gif" +#else +#define TEST_INPUT_AMPERSAND_EXPECTED "+++1.gif\000+++2.gif" +#endif struct item { int b; int batch; @@ -485,7 +490,7 @@ static void test_input(int index, int debug) { struct item data[] = { /* 0*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", "", 2, "00001.gif\00000002.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, 0, "gif", "123\n456\n", "@@@@.gif", 2, "***1.gif\000***2.gif" }, + /* 2*/ { BARCODE_CODE128, 1, -1, 0, "gif", "123\n456\n", "@@@@.gif", 2, TEST_INPUT_AMPERSAND_EXPECTED }, /* 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, -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\n", NULL, 3, "123.gif\000456.gif\0007890123456789.gif" }, diff --git a/frontend_qt/extSequence.ui b/frontend_qt/extSequence.ui index d0e67795..a608abfc 100644 --- a/frontend_qt/extSequence.ui +++ b/frontend_qt/extSequence.ui @@ -119,9 +119,9 @@ Format sequence using special characters<table cellspacing="3"> -<tr><td>#</td><td>Number or space</td></tr> <tr><td>$</td><td>Number or '0'</td></tr> -<tr><td>*</td><td>Number or '*'</td></tr> +<tr><td>#</td><td>Number or space</td></tr> +<tr><td>*</td><td>Number or '*' ('+' on Windows)</td></tr> <tr><td>Other</td><td>Insert literally</td></tr> </table> @@ -137,9 +137,9 @@ Format sequence using special characters<table cellspacing="3"> -<tr><td>#</td><td>Number or space</td></tr> <tr><td>$</td><td>Number or '0'</td></tr> -<tr><td>*</td><td>Number or '*'</td></tr> +<tr><td>#</td><td>Number or space</td></tr> +<tr><td>*</td><td>Number or '*' ('+' on Windows)</td></tr> <tr><td>Other</td><td>Insert literally</td></tr> </table> diff --git a/frontend_qt/sequencewindow.cpp b/frontend_qt/sequencewindow.cpp index 3215480b..1e22fe46 100644 --- a/frontend_qt/sequencewindow.cpp +++ b/frontend_qt/sequencewindow.cpp @@ -120,7 +120,11 @@ QString SequenceWindow::apply_format(const QString& raw_number) adjusted += raw_number[inpos - 1]; inpos--; } else { +#ifndef _WIN32 adjusted += '*'; +#else + adjusted += '+'; +#endif } break; default: @@ -129,7 +133,7 @@ QString SequenceWindow::apply_format(const QString& raw_number) } } - for(i = format_len; i > 0; i--) { + for (i = format_len; i > 0; i--) { reversed += adjusted[i - 1]; }