1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-05-14 18:13:53 +00:00

DATAMATRIX: add new options DM_B256_START and DM_C40_START to

`options_3`, allowing forcing of Base 256 or C40 mode a la BWIPP
  for initial no. of characters specified in `option_1`, with 0
  meaning all (CLI "--dmb256=" and "--dmc40=", GUI also (apart
  from MAILMARK_2D, which may be added later);
  export masks `DM_B256_C40_START_MASK` & `DM_SQUARE_DMRE_MASK` in
  "zint.h"
ZBarcode_Encode_File: report filename (possibly truncated) in error
  message on failed open
GUI: uniquify some accelerators and add some child widget getter
  helpers to "mainwindow.cpp"
backend/DEVELOPER -> backend/README, with some expansion
debian/copyright: a few more fixes
BWIPP/pandoc: update to latest
tests/fuzz: adjust for new DATAMATRIX options
This commit is contained in:
gitlost
2026-03-30 21:25:22 +01:00
parent 3c193d7306
commit f9a493522f
40 changed files with 1706 additions and 920 deletions

View File

@@ -184,16 +184,18 @@ static void usage(const int no_png, const int have_gs1syntaxengine) {
" --compliantheight Warn if height not compliant, and use standard default\n"
" -d, --data=DATA Set the symbol data content (segment 0)\n", stdout);
fputs( " --direct Send output to stdout\n"
" --dmb256=INTEGER Start Data Matrix in Base 256 for given length (0 all)\n"
" --dmc40=INTERGER Start Data Matrix in C40 mode for given length (0 all)\n"
" --dmiso144 Use ISO format for 144x144 Data Matrix symbols\n"
" --dmre Allow Data Matrix Rectangular Extended\n"
" --dotsize=NUMBER Set radius of dots in dotty mode\n"
" --dotty Use dots instead of squares for matrix symbols\n", stdout);
fputs( " --dump Dump hexadecimal representation to stdout\n"
" --dmre Allow Data Matrix Rectangular Extended\n", stdout);
fputs( " --dotsize=NUMBER Set radius of dots in dotty mode\n"
" --dotty Use dots instead of squares for matrix symbols\n"
" --dump Dump hexadecimal representation to stdout\n"
" -e, --ecinos Display ECI (Extended Channel Interpretation) table\n"
" --eci=INTEGER Set the ECI code for the data (segment 0)\n"
" --embedfont Embed font in vector output (SVG only)\n"
" --esc Process escape sequences in input data\n", stdout);
fputs( " --extraesc Process symbology-specific escape sequences (Code 128)\n"
" --eci=INTEGER Set the ECI code for the data (segment 0)\n", stdout);
fputs( " --embedfont Embed font in vector output (SVG only)\n"
" --esc Process escape sequences in input data\n"
" --extraesc Process symbology-specific escape sequences (Code 128)\n"
" --fast Use faster encodation or other shortcuts if available\n"
" --fg=COLOUR Specify a foreground colour (as RGB(A) or \"C,M,Y,K\")\n", stdout);
printf(" --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX%s/SVG/TIF/TXT\n", no_png_type);
@@ -205,17 +207,17 @@ static void usage(const int no_png, const int have_gs1syntaxengine) {
if (have_gs1syntaxengine) {
fputs( " --gs1strict Use GS1 Syntax Engine to strictly validate GS1 data\n", stdout);
}
fputs( " --gssep Use separator GS for GS1 (Data Matrix)\n", stdout);
fputs( " --guarddescent=NUMBER Set height of guard bar descent in X-dims (EAN/UPC)\n"
fputs( " --gssep Use separator GS for GS1 (Data Matrix)\n"
" --guarddescent=NUMBER Set height of guard bar descent in X-dims (EAN/UPC)\n"
" --guardwhitespace Add quiet zone indicators (\"<\"/\">\") to HRT (EAN/UPC)\n"
" -h, --help Display help message\n"
" --height=NUMBER Set height of symbol in multiples of X-dimension\n"
" --heightperrow Treat height as per-row\n", stdout);
fputs( " -i, --input=FILE Read input data from FILE\n"
" --height=NUMBER Set height of symbol in multiples of X-dimension\n", stdout);
fputs( " --heightperrow Treat height as per-row\n"
" -i, --input=FILE Read input data from FILE\n"
" --init Create Reader Initialisation (Programming) symbol\n"
" --mask=INTEGER Set masking pattern to use (QR/Han Xin/DotCode)\n"
" --mirror Use batch data to determine filename\n"
" --mode=INTEGER Set encoding mode (MaxiCode/Composite)\n", stdout);
" --mirror Use batch data to determine filename\n", stdout);
fputs( " --mode=INTEGER Set encoding mode (MaxiCode/Composite)\n", stdout);
printf(" --nobackground Remove background (EMF/EPS/GIF%s/SVG/TIF only)\n", no_png_type);
fputs( " --noquietzones Disable default quiet zones\n"
" --notext Remove human readable text (HRT)\n", stdout);
@@ -1138,7 +1140,7 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil
}
/* Skip escape characters */
if ((buffer[i] == '\\') && (symbol->input_mode & ESCAPE_MODE)) {
if (buffer[i] == '\\' && (symbol->input_mode & ESCAPE_MODE)) {
i++;
if (buffer[i] == 'x') {
i += 2;
@@ -1183,9 +1185,9 @@ static int batch_process(struct zint_symbol *const symbol, const char *const fil
break;
}
character = (unsigned char) intChar;
} while ((!feof(file)) && (character != '\n'));
} while (!feof(file) && character != '\n');
}
} while ((!feof(file)) && (line_count < 2000000000));
} while (!feof(file) && line_count < 2000000000);
if (character != '\n') {
fprintf(stderr, "Warning 104: No newline at end of input file, last line **IGNORED**\n");
@@ -1548,7 +1550,7 @@ int main(int argc, char **argv) {
OPT_ADDONGAP = 128, OPT_AZFULL,
OPT_BATCH, OPT_BINARY, OPT_BG, OPT_BIND, OPT_BIND_TOP, OPT_BOLD, OPT_BORDER, OPT_BOX,
OPT_CMYK, OPT_COLS, OPT_COMPLIANTHEIGHT,
OPT_DIRECT, OPT_DMISO144, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
OPT_DIRECT, OPT_DMISO144, OPT_DMRE, OPT_DMB256, OPT_DMC40, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
OPT_ECI, OPT_EMBEDFONT, OPT_ESC, OPT_EXTRAESC, OPT_FAST, OPT_FG, OPT_FILETYPE, OPT_FULLMULTIBYTE,
OPT_GS1, OPT_GS1NOCHECK, OPT_GS1PARENS, OPT_GS1RAW, OPT_GS1STRICT /*GS1SYNTAXENGINE_MODE*/,
OPT_GSSEP, OPT_GUARDDESCENT, OPT_GUARDWHITESPACE,
@@ -1581,6 +1583,8 @@ int main(int argc, char **argv) {
{"compliantheight", 0, NULL, OPT_COMPLIANTHEIGHT},
{"data", 1, NULL, 'd'},
{"direct", 0, NULL, OPT_DIRECT},
{"dmb256", 1, NULL, OPT_DMB256},
{"dmc40", 1, NULL, OPT_DMC40},
{"dmiso144", 0, NULL, OPT_DMISO144},
{"dmre", 0, NULL, OPT_DMRE},
{"dotsize", 1, NULL, OPT_DOTSIZE},
@@ -1721,7 +1725,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error 131: Invalid columns value (digits only)\n");
return do_exit(ZINT_ERROR_INVALID_OPTION);
}
if ((val >= 1) && (val <= 200)) {
if (val >= 1 && val <= 200) {
my_symbol->option_2 = val;
} else {
fprintf(stderr, "Warning 111: Number of columns '%d' out of range (1 to 200), **IGNORED**\n",
@@ -1736,13 +1740,46 @@ int main(int argc, char **argv) {
case OPT_DIRECT:
my_symbol->output_options |= BARCODE_STDOUT;
break;
case OPT_DMB256:
if (!validate_int(optarg, -1 /*len*/, &val)) {
fprintf(stderr, "Error 158: Invalid Data Matrix Base 256 mode length value (digits only)\n");
return do_exit(ZINT_ERROR_INVALID_OPTION);
}
/* C40 overrides Base 256 */
if ((my_symbol->option_3 & DM_B256_C40_START_MASK) == DM_C40_START) {
fprintf(stderr, "Warning 159: '--dmc40' already set, '--dmb256' **IGNORED**\n");
fflush(stderr);
warn_number = ZINT_WARN_INVALID_OPTION;
} else {
my_symbol->option_1 = val;
my_symbol->option_3 = DM_B256_START | (my_symbol->option_3 & ~DM_B256_C40_START_MASK);
}
break;
case OPT_DMC40:
if (!validate_int(optarg, -1 /*len*/, &val)) {
fprintf(stderr, "Error 160: Invalid Data Matrix C40 mode length value (digits only)\n");
return do_exit(ZINT_ERROR_INVALID_OPTION);
}
/* C40 overwrites Base 256 */
if ((my_symbol->option_3 & DM_B256_C40_START_MASK) == DM_B256_START) {
fprintf(stderr, "Warning 161: previous '--dmb256' overwritten by '--dmc40'\n");
fflush(stderr);
warn_number = ZINT_WARN_INVALID_OPTION;
}
my_symbol->option_1 = val;
my_symbol->option_3 = DM_C40_START | (my_symbol->option_3 & ~DM_B256_C40_START_MASK);
break;
case OPT_DMISO144:
my_symbol->option_3 |= DM_ISO_144;
break;
case OPT_DMRE:
/* Square overwrites DMRE */
if ((my_symbol->option_3 & 0x7F) != DM_SQUARE) {
my_symbol->option_3 = DM_DMRE | (my_symbol->option_3 & ~0x7F);
/* Square overrides DMRE */
if ((my_symbol->option_3 & DM_SQUARE_DMRE_MASK) != DM_SQUARE) {
my_symbol->option_3 = DM_DMRE | (my_symbol->option_3 & ~DM_SQUARE_DMRE_MASK);
} else {
fprintf(stderr, "Warning 156: '--square' already set, '--dmre' **IGNORED**\n");
fflush(stderr);
warn_number = ZINT_WARN_INVALID_OPTION;
}
break;
case OPT_DOTSIZE:
@@ -1948,7 +1985,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error 132: Invalid rows value (digits only)\n");
return do_exit(ZINT_ERROR_INVALID_OPTION);
}
if ((val >= 1) && (val <= 90)) {
if (val >= 1 && val <= 90) {
rows = val;
} else {
fprintf(stderr, "Warning 112: Number of rows '%d' out of range (1 to 90), **IGNORED**\n", val);
@@ -2062,7 +2099,13 @@ int main(int argc, char **argv) {
my_symbol->output_options |= SMALL_TEXT;
break;
case OPT_SQUARE:
my_symbol->option_3 = DM_SQUARE | (my_symbol->option_3 & ~0x7F);
/* Square overwrites DMRE */
if ((my_symbol->option_3 & DM_SQUARE_DMRE_MASK) == DM_DMRE) {
fprintf(stderr, "Warning 157: previous '--dmre' overwritten by '--square'\n");
fflush(stderr);
warn_number = ZINT_WARN_INVALID_OPTION;
}
my_symbol->option_3 = DM_SQUARE | (my_symbol->option_3 & ~DM_SQUARE_DMRE_MASK);
break;
case OPT_STRUCTAPP:
memset(&my_symbol->structapp, 0, sizeof(my_symbol->structapp));
@@ -2101,7 +2144,7 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error 133: Invalid version value (digits only)\n");
return do_exit(ZINT_ERROR_INVALID_OPTION);
}
if ((val >= 1) && (val <= 999)) {
if (val >= 1 && val <= 999) {
my_symbol->option_2 = val;
} else {
fprintf(stderr, "Warning 113: Version value '%d' out of range (1 to 999), **IGNORED**\n", val);
@@ -2411,9 +2454,9 @@ int main(int argc, char **argv) {
if (error_number < ZINT_ERROR) {
error_number = ret;
}
if (error_number >= ZINT_ERROR) {
break;
}
}
if (error_number >= ZINT_ERROR) {
break;
}
}
if (error_number < ZINT_ERROR) {