CLI/Tcl: fix version check (need <= 999 for DAFT permille)

UPNQR: fix required binary mode using mode_preset
UPNQR: allow mask to be manually specified
GUI: use non-native QColorDialog on Unix also; no noEXE for CLI equivalent;
  add shortcuts for copy-to-clipboard and CLI equivalent
CLI: new --version option to print Zint version
This commit is contained in:
gitlost 2022-05-12 20:35:06 +01:00
parent f58c80e290
commit 9aae557cdc
24 changed files with 777 additions and 109 deletions

View file

@ -96,8 +96,8 @@ static void types(void) {
);
}
/* Output usage information */
static void usage(void) {
/* Output version information */
static void version(void) {
const int zint_version = ZBarcode_Version();
const int version_major = zint_version / 10000;
const int version_minor = (zint_version % 10000) / 100;
@ -113,6 +113,11 @@ static void usage(void) {
/* This is a stable release */
printf("Zint version %d.%d.%d\n", version_major, version_minor, version_release);
}
}
/* Output usage information */
static void usage(void) {
version();
printf( "Encode input data in a barcode and save as BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT\n\n"
" -b, --barcode=TYPE Number or name of barcode type. Default is 20 (CODE128)\n"
@ -172,6 +177,7 @@ static void usage(void) {
" --structapp=I,C[,ID] Set Structured Append info (I index, C count)\n"
" -t, --types Display table of barcode types\n"
" --vers=NUMBER Set symbol version (size, check digits, other options)\n"
" --version Display Zint version\n"
" --vwhitesp=NUMBER Set height of vertical whitespace in multiples of X-dim\n"
" -w, --whitesp=NUMBER Set width of horizontal whitespace in multiples of X-dim\n"
" --werror Convert all warnings into errors\n"
@ -900,7 +906,7 @@ int main(int argc, char **argv) {
OPT_ROTATE, OPT_ROWS, OPT_SCALE, OPT_SCMVV, OPT_SECURE,
OPT_SEG1, OPT_SEG2, OPT_SEG3, OPT_SEG4, OPT_SEG5, OPT_SEG6, OPT_SEG7, OPT_SEG8, OPT_SEG9,
OPT_SEPARATOR, OPT_SMALL, OPT_SQUARE, OPT_STRUCTAPP,
OPT_VERBOSE, OPT_VERS, OPT_VWHITESP, OPT_WERROR,
OPT_VERBOSE, OPT_VERS, OPT_VERSION, OPT_VWHITESP, OPT_WERROR,
};
int option_index = 0;
static const struct option long_options[] = {
@ -971,6 +977,7 @@ int main(int argc, char **argv) {
{"types", 0, NULL, 't'},
{"verbose", 0, NULL, OPT_VERBOSE}, // Currently undocumented, output some debug info
{"vers", 1, NULL, OPT_VERS},
{"version", 0, NULL, OPT_VERSION},
{"vwhitesp", 1, NULL, OPT_VWHITESP},
{"werror", 0, NULL, OPT_WERROR},
{"whitesp", 1, NULL, 'w'},
@ -1335,10 +1342,10 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error 133: Invalid version value (digits only)\n");
return do_exit(1);
}
if ((val >= 1) && (val <= 84)) {
if ((val >= 1) && (val <= 999)) {
my_symbol->option_2 = val;
} else {
fprintf(stderr, "Warning 113: Version value out of range (1 to 84), ignoring\n");
fprintf(stderr, "Warning 113: Version value out of range (1 to 999), ignoring\n");
fflush(stderr);
}
break;
@ -1363,6 +1370,11 @@ int main(int argc, char **argv) {
help = 1;
break;
case OPT_VERSION:
version();
help = 1;
break;
case 't':
types();
help = 1;

View file

@ -762,7 +762,7 @@ static void test_checks(int index, int debug) {
/* 29*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, -1, "Error 128: Invalid separator value (digits only)" },
/* 30*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, "Warning 127: Separator value out of range (0 to 4), ignoring" },
/* 31*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, -1, "Error 133: Invalid version value (digits only)" },
/* 32*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, -1, -1, "Warning 113: Version value out of range (1 to 84), ignoring" },
/* 32*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1000, -1, -1, "Warning 113: Version value out of range (1 to 999), ignoring" },
/* 33*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -1, "Error 153: Invalid vertical whitespace value '-2' (digits only)" },
/* 34*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1001, -1, "Warning 154: Vertical whitespace value out of range (0 to 1000), ignoring" },
/* 35*/ { -1, -1, -1, -1, -1, NULL, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, "Error 120: Invalid horizontal whitespace value '-2' (digits only)" },
@ -1000,11 +1000,11 @@ static void test_other_opts(int index, int debug) {
/* 0*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900", "" },
/* 1*/ { BARCODE_CODE128, "1", -1, " -bg=", "EF9900", "" },
/* 2*/ { BARCODE_CODE128, "1", -1, " --bg=", "EF9900AA", "" },
/* 3*/ { BARCODE_CODE128, "1", -1, " --bg=", "GF9900", "Error 654: Malformed background colour target" },
/* 3*/ { BARCODE_CODE128, "1", -1, " --bg=", "GF9900", "Error 654: Malformed background colour 'GF9900' (hexadecimal only)" },
/* 4*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000", "" },
/* 5*/ { BARCODE_CODE128, "1", -1, " --fg=", "00000000", "" },
/* 6*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000F", "Error 651: Malformed foreground colour target" },
/* 7*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000FG", "Error 653: Malformed foreground colour target" },
/* 6*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000F", "Error 651: Malformed foreground colour (6 or 8 characters only)" },
/* 7*/ { BARCODE_CODE128, "1", -1, " --fg=", "000000FG", "Error 653: Malformed foreground colour '000000FG' (hexadecimal only)" },
/* 8*/ { BARCODE_CODE128, "1", -1, " --compliantheight", "", "" },
/* 9*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "10", "" },
/* 10*/ { BARCODE_CODE128, "1", -1, " --fontsize=", "101", "Warning 126: Font size out of range (0 to 100), ignoring" },