1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-18 10:27:09 +00:00

CODE128: reduce extended latch cut-off from 5 to 4 for better

encodation in certain cases (and no pessimizations found so far),
  props lyngklip (BWIPP);
  fix extended char latching when exactly 3 extended chars at end;
  count code set C (not digits) in loop deciding when to
  shift/latch to extended for better estimate
AZTEC: return warning if ECC < 5% (due to bit-stuffing when version
  given); return error if > 22 layers (Zint 26) for Reader
  Initialisation symbol requested for better error message
AZTEC/HANXIN/QRCODE: consolidate different ECC data size tables
  into one indexed by ECC
DBAR_EXP: check for reduced length <= 77 up front for better error
  message
HANXIN: use `malloc()` rather than `z_alloca()` for large binary
  array
QRCODE: `ecc_level` now 0-based (not 1-based)
MICROQR: consolidate different version end routines into one
  `microqr_end()` and use new `microqr_data` table to simplify code
MICROPDF417: use table for max codewords per column
library: centralize all error messages using new `errtxt()`,
  `errtxtf()`, `errtxt_adj()` funcs that protect `symbol->errtxt`
  from overflow, & try to make error messages more consistent
  thru-out, adding more feedback info to many, & use positional
  args "%n$" in prep for l10n (maybe);
  `is_sane/is_sane_lookup()` -> `not_sane/not_sane_lookup()`,
  returning 1-based position (zero on failure) instead of bool;
  `long` ints -> plain `int` (except those dealing with `ftell()`,
  `fread()` etc) as depend on int being 32-bits already
GUI: in "grpDATF.ui" use "PlainText" rather than "RichText" for
  tracker ratio examples as height of text messing up sometimes
manual: clarify Codablock-F length maximum & add examples
docs: README: pandoc 3.5, Ubuntu 24.04
CMake: use "-Wpedantic" for Clang only as GNU complains about
  `errtxtf()` positional args "%n$"
This commit is contained in:
gitlost
2024-10-27 21:33:33 +00:00
parent 752c1fae5d
commit 5e2044ff2e
104 changed files with 8102 additions and 7755 deletions

View File

@@ -1229,8 +1229,8 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
unsigned char *masked_codeword_array;
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "525: Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 525, "ECI code '%d' out of range (0 to 811799)",
symbol->eci);
}
user_mask = (symbol->option_3 >> 8) & 0x0F; /* User mask is mask + 1, so >= 1 and <= 8 */
@@ -1240,16 +1240,16 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if (symbol->structapp.count) {
if (symbol->structapp.count < 2 || symbol->structapp.count > 35) {
strcpy(symbol->errtxt, "730: Structured Append count out of range (2-35)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 730,
"Structured Append count '%d' out of range (2 to 35)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "731: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 731,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
strcpy(symbol->errtxt, "732: Structured Append ID not available for DotCode");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 732, "Structured Append ID not available for DotCode");
}
}
@@ -1258,14 +1258,14 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if (gs1 && warn_number == 0) {
for (i = 0; i < seg_count; i++) {
if (segs[i].eci) {
strcpy(symbol->errtxt, "733: Using ECI in GS1 mode not supported by GS1 standards");
warn_number = ZINT_WARN_NONCOMPLIANT;
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 733,
"Using ECI in GS1 mode not supported by GS1 standards");
break;
}
}
if (warn_number == 0 && symbol->structapp.count) {
strcpy(symbol->errtxt, "734: Using Structured Append in GS1 mode not supported by GS1 standards");
warn_number = ZINT_WARN_NONCOMPLIANT;
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 734,
"Using Structured Append in GS1 mode not supported by GS1 standards");
}
}
@@ -1337,9 +1337,9 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if ((height > 200) || (width > 200)) {
if (height > 200 && width > 200) {
sprintf(symbol->errtxt, "526: Symbol size %dx%d (WxH) is too large", width, height);
errtxtf(0, symbol, 526, "Symbol size '%1$dx%2$d' (WxH) is too large", width, height);
} else {
sprintf(symbol->errtxt, "528: Symbol %s %d is too large",
errtxtf(0, symbol, 528, "Symbol %1$s '%2$d' is too large",
width > 200 ? "width" : "height", width > 200 ? width : height);
}
return ZINT_ERROR_INVALID_OPTION;
@@ -1347,10 +1347,10 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if ((height < 5) || (width < 5)) {
if (height < 5 && width < 5) { /* Won't happen as if width < 5, min height is 19 */
sprintf(symbol->errtxt, "527: Symbol size %dx%d (WxH) is too small", width, height); /* Not reached */
errtxtf(0, symbol, 527, "Symbol size '%1$dx%2$d' (WxH) is too small", width, height); /* Not reached */
} else {
sprintf(symbol->errtxt, "529: Symbol %s %d is too small",
width < 5 ? "width" : "height", width < 5 ? width : height);
errtxtf(0, symbol, 529, "Symbol %1$s '%2$d' is too small",
width < 5 ? "width" : "height", width < 5 ? width : height);
}
return ZINT_ERROR_INVALID_OPTION;
}