1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-07-31 10:29:52 +00:00

CLI: make --mirror available in standard non-batch mode via

new routines `mirror_start()`, `mirror_outfile()` & limit
  substitutions on Unix to backslash (Windows remains the same);
  restrict "borderwidth", "textgap", "vwhitesp", "whitesp" < 100
CODEONE: fix `ceilf()` -> `C1_MULT_CEIL()` in FAST_MODE encodation
  (improves/changes some encodation)
composite: preserve `gs1_verify()` warning using `warn_level` hack;
  fix wrong name `zint_dbar_omnstk_set_height()` ->
  `zint_dbar_stk_set_height()`;
  use new `zint_micropdf_variant()` & `zint_micropdf_expand()`
  routines (see below)
MICROPDF417: move variant determination into new shareable routine
  `zint_micropdf_variant()` & expansion into `zint_micropdf_expand()`
qzint: add helper methods `setbordertypevalue()`,
  `encodedinputmode()`, `encodedoutputoptions()`,
  `ecivaluetoeciindex()` and `eciindextoecivalue()`
dbar: for performance pre-calculate `combins()` as array
coverage: add `malloc()`-type failure testing to AZTEC,
  CONTENT_SEGS, MEMORY_FILE, raster, Reed-Solomon & vector;
  numerous changes to remove unused code and test more branches
common: add `isxdigit()`
general: various code fiddlings
manual: add char names to sequence and batch format char tables;
  mention long options can be shortened (& use "--compliantheight"
  -> "--compliant");
  expand mirror explanation & document substitutions in footnote;
  workaround xecjk putting space after double quote when quoting
  cjk chars & rejig input mode examples;
  workaround html alignment bug in table gs1-enabled symbologies by
  adding extra rh dashes to header cols;
  add "figure nn: " to txt image tags via sed:
  various other small fixes and rephrasings
This commit is contained in:
gitlost
2026-06-23 23:25:23 +01:00
parent 4a60a0b068
commit a81c9d9258
91 changed files with 6879 additions and 4368 deletions
+37 -31
View File
@@ -69,34 +69,37 @@
#include "gs1.h"
#include "rss.h"
/* `combins()' in ISO/IEC 24724:2011 Annex B */
/* `combins()` in ISO/IEC 24724:2011 Annex B */
/****************************************************************************
* dbar_combins(n,r): returns the number of Combinations of r selected from n:
* Combinations = n! / (n - r)! * r!
****************************************************************************/
static int dbar_combins(const int n, const int r) {
int i;
int maxDenom, minDenom;
int val = 1, j = 1;
/* Generated by "backend/tests/test_rss -f test_generate_combins -g" (which uses `combins()`) */
static const short combins[18][6] = {
{ 1, 1, 1, 1, 1, 1 }, /* 0 */
{ 1, 1, 1, 1, 1, 1 }, /* 1 */
{ 1, 2, 1, 1, 1, 1 }, /* 2 */
{ 1, 3, 3, 1, 1, 1 }, /* 3 */
{ 1, 4, 6, 4, 1, 1 }, /* 4 */
{ 1, 5, 10, 10, 5, 1 }, /* 5 */
{ 1, 6, 15, 20, 15, 6 }, /* 6 */
{ 1, 7, 21, 35, 35, 21 }, /* 7 */
{ 1, 8, 28, 56, 70, 56 }, /* 8 */
{ 1, 9, 36, 84, 126, 126 }, /* 9 */
{ 1, 10, 45, 120, 210, 252 }, /* 10 */
{ 1, 11, 55, 165, 330, 462 }, /* 11 */
{ 1, 12, 66, 220, 495, 792 }, /* 12 */
{ 1, 13, 78, 286, 715, 1287 }, /* 13 */
{ 1, 14, 91, 364, 1001, 2002 }, /* 14 */
{ 1, 15, 105, 455, 1365, 3003 }, /* 15 */
{ 1, 16, 120, 560, 1820, 4368 }, /* 16 */
{ 1, 17, 136, 680, 2380, 6188 } /* 17 */
};
if (n - r > r) {
minDenom = r;
maxDenom = n - r;
} else {
minDenom = n - r;
maxDenom = r;
}
for (i = n; i > maxDenom; i--) {
val *= i;
if (j <= minDenom) {
val /= j;
j++;
}
}
for (; j <= minDenom; j++) {
val /= j;
}
return val;
assert(n >= 0 && n < 18); /* Max 19 modules (DBAR_LTD) - 2 */
assert(r >= 0 && r < 6); /* Max 7 elements (DBAR_LTD) - 2 */
return combins[n][r];
}
/* `getRSSwidths()' in ISO/IEC 24724:2011 Annex B, modified to use arg `widths` instead of static,
@@ -280,7 +283,8 @@ static void dbar_omn_separator(struct zint_symbol *symbol, int width, const int
}
/* Set Databar Stacked height, maintaining 5:7 ratio of the 2 main row heights */
INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_row) {
INTERNAL int zint_dbar_stk_set_height(struct zint_symbol *symbol, const int first_row, const int no_errtxt) {
int error_number = 0;
float fixed_height = 0.0f;
const int second_row = first_row + 2; /* 2 row separator */
int i;
@@ -297,12 +301,11 @@ INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int f
(symbol->row_height[first_row] + symbol->row_height[second_row]));
if (symbol->row_height[first_row] < 0.5f) { /* Absolute minimum */
symbol->row_height[first_row] = 0.5f;
symbol->row_height[second_row] = 0.7f;
symbol->row_height[second_row] = 0.7f; /* 0.7f is actually 0.699999988 (0x3F333333) */
} else {
symbol->row_height[second_row] = z_stripf(symbol->height - fixed_height - symbol->row_height[first_row]);
if (symbol->row_height[second_row] < 0.7f) {
symbol->row_height[second_row] = 0.7f;
}
/* (h - 1) * 5/12 >= 0.5 -> h - 1 >= 0.5 * 12/5 -> h >= 2.2 -> rh[sr] >= (2.2 - 1 - 0.5) -> rh[sr] >= 0.7 */
assert(symbol->row_height[second_row] >= 0.7f);
}
}
symbol->height = z_stripf(z_stripf(symbol->row_height[first_row] + symbol->row_height[second_row])
@@ -310,11 +313,14 @@ INTERNAL int zint_dbar_omnstk_set_height(struct zint_symbol *symbol, const int f
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->row_height[first_row] < 5.0f || symbol->row_height[second_row] < 7.0f) {
return z_errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 379, "Height not compliant with standards");
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
z_errtxt(0, symbol, 379, "Height not compliant with standards");
}
}
}
return 0;
return error_number;
}
/* Return DataBar Omnidirectional group (outside -1, inside +5-1) */
@@ -523,8 +529,8 @@ INTERNAL int zint_dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[]
symbol->width = 50;
}
if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls `zint_dbar_omnstk_set_height()` itself */
error_number = zint_dbar_omnstk_set_height(symbol, 0 /*first_row*/);
if (symbol->symbology != BARCODE_DBAR_STK_CC) { /* Composite calls `zint_dbar_stk_set_height()` itself */
error_number = zint_dbar_stk_set_height(symbol, 0 /*first_row*/, 0 /*no_errtxt*/);
}
} else if (symbol->symbology == BARCODE_DBAR_OMNSTK || symbol->symbology == BARCODE_DBAR_OMNSTK_CC) {