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
+86
View File
@@ -3430,6 +3430,91 @@ static void test_hrt_content_segs(const testCtx *const p_ctx) {
testFinish();
}
/* TODO: add new "raster.h" & put these in it */
#define VECT_FAIL_ID_RECT 1
#define VECT_FAIL_ID_HEXAGON 2
#define VECT_FAIL_ID_CIRCLE 3
#define VECT_FAIL_ID_STR 4
#define VECT_FAIL_ID_SUBSTR 5
#define VECT_FAIL_ID_HDR 6
INTERNAL void zint_test_vector_set_fail(const int op, const int at);
static void test_alloc(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int border_width;
int output_options;
const char *data;
int ret;
int ats[6];
int at_cnt;
int id;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_HDR },
/* 1*/ { BARCODE_DATAMATRIX, -1, -1, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_RECT },
/* 2*/ { BARCODE_DATAMATRIX, -1, BARCODE_DOTTY_MODE, "123", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_CIRCLE },
/* 3*/ { BARCODE_ULTRA, -1, -1, "123", ZINT_ERROR_MEMORY, { 3, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_RECT },
/* 4*/ { BARCODE_MAXICODE, -1, -1, "123", ZINT_ERROR_MEMORY, { 5, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_HEXAGON },
/* 5*/ { BARCODE_MAXICODE, -1, -1, "123", ZINT_ERROR_MEMORY, { 1, 2, 3, 0, 0, 0 }, 3, VECT_FAIL_ID_CIRCLE },
/* 6*/ { BARCODE_TELEPEN, -1, -1, "AB", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_STR },
/* 7*/ { BARCODE_TELEPEN, -1, -1, "AB", ZINT_ERROR_MEMORY, { 1, 0, 0, 0, 0, 0 }, 1, VECT_FAIL_ID_SUBSTR },
/* 8*/ { BARCODE_UPCE, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 0 }, 5, VECT_FAIL_ID_STR },
/* 9*/ { BARCODE_UPCE, -1, -1, "123456+12", ZINT_ERROR_MEMORY, { 1, 20, 0, 0, 0, 0 }, 2, VECT_FAIL_ID_RECT },
/* 10*/ { BARCODE_EAN8, -1, EANUPC_GUARD_WHITESPACE, "123456", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 0, 0 }, 4, VECT_FAIL_ID_STR },
/* 11*/ { BARCODE_EAN8, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 0 }, 5, VECT_FAIL_ID_STR },
/* 12*/ { BARCODE_UPCA, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 6 }, 6, VECT_FAIL_ID_STR },
/* 13*/ { BARCODE_EAN13, -1, EANUPC_GUARD_WHITESPACE, "123456+12", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 5, 0 }, 5, VECT_FAIL_ID_STR },
/* 14*/ { BARCODE_EAN13, -1, EANUPC_GUARD_WHITESPACE, "123456", ZINT_ERROR_MEMORY, { 1, 2, 3, 4, 0, 0 }, 4, VECT_FAIL_ID_STR },
/* 15*/ { BARCODE_EAN_2ADDON, -1, EANUPC_GUARD_WHITESPACE, "12", ZINT_ERROR_MEMORY, { 1, 2, 0, 0, 0, 0 }, 2, VECT_FAIL_ID_STR },
/* 16*/ { BARCODE_CODABLOCKF, -1, -1, "12", ZINT_ERROR_MEMORY, { 57, 58, 0, 0, 0, 0 }, 2, VECT_FAIL_ID_RECT },
/* 17*/ { BARCODE_CHANNEL, 1, BARCODE_BOX, "12", ZINT_ERROR_MEMORY, { 10, 11, 12, 0, 0, 0 }, 3, VECT_FAIL_ID_RECT },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
int j;
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
for (j = 0; j < data[i].at_cnt; j++) {
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug);
strcpy(symbol->outfile, "out.svg");
if (data[i].border_width != -1) {
symbol->border_width = data[i].border_width;
}
ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length);
assert_nonzero(ret < ZINT_ERROR, "i:%d %s ZBarcode_Encode ret %d >= ZINT_ERROR %s\n",
i, testUtilBarcodeName(data[i].symbology), ret, symbol->errtxt);
zint_test_vector_set_fail(data[i].id, data[i].ats[j]);
ret = ZBarcode_Print(symbol, 0 /*rotate_angle*/);
assert_equal(ret, data[i].ret, "i:%d j:%d ZBarcode_Print (%d,%d) ret %d != %d (%s)\n",
i, j, data[i].id, data[i].ats[j], ret, data[i].ret, symbol->errtxt);
ZBarcode_Reset(symbol);
}
zint_test_vector_set_fail(0, 0);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */
@@ -3449,6 +3534,7 @@ int main(int argc, char *argv[]) {
{ "test_height", test_height },
{ "test_height_per_row", test_height_per_row },
{ "test_hrt_content_segs", test_hrt_content_segs },
{ "test_alloc", test_alloc },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));