1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-18 02:17:06 +00:00

general: change BARCODE_RAW_TEXT to write to new zint_symbol

fields `raw_segs` and `raw_seg_count` instead of `text`, and to
  do so for all symbologies, using new common funcs `rt_cpy()` etc.
MICROPDF417: return ECC percentage in top byte of `option_1`
DBAR_EXP_STK: return `option_2`/`option_3` feedback
CLI: change warning text "ignoring" -> "**IGNORED**"
GUI: show feedback for DBAR_EXP_STK, MICROPDF417, UPNQR
ctest: fix recent inability to run tests via "ctest" on Windows
  (MSVC) by using cmake 3.22 feature `ENVIRONMENT_MODIFICATION`
manual: document feedback and RAW_TEXT in new "Feedback" section;
  rephrase some symbology descriptions
test suite: new general-use arg "-a"; add `func_name` to context;
  new "test_bwipp" test for testing BWIPP against ZXing-C++
This commit is contained in:
gitlost
2025-03-28 10:02:19 +00:00
parent d1bf02e156
commit a6c225447e
120 changed files with 10511 additions and 5620 deletions

View File

@@ -978,15 +978,26 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], int len
/* Call `c1_encode()` for each segment */
static int c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, const int gs1,
unsigned int target[], int *p_last_mode) {
unsigned int target[], int *p_data_length, int *p_last_mode) {
int i;
int tp = 0;
/* GS1 raw text dealt with by `ZBarcode_Encode_Segs()` */
const int raw_text = !gs1 && (symbol->output_options & BARCODE_RAW_TEXT);
if (raw_text && rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `rt_init_segs()` only fails with OOM */
}
for (i = 0; i < seg_count; i++) {
tp = c1_encode(symbol, segs[i].source, segs[i].length, segs[i].eci, seg_count, gs1, target, &tp, p_last_mode);
if (raw_text && rt_cpy_seg(symbol, i, &segs[i])) {
return ZINT_ERROR_MEMORY; /* `rt_cpy_seg()` only fails with OOM */
}
}
return tp;
*p_data_length = tp;
return 0;
}
/* Set symbol from datagrid */
@@ -1061,6 +1072,7 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
large_uint elreg;
unsigned int target[30], ecc[15];
int block_width;
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT; /* GS1 mode ignored for Version S */
if (seg_count > 1) {
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 715, "Multiple segments not supported for Version S");
@@ -1096,6 +1108,10 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
printf("Subversion: %d\n", sub_version);
}
if (raw_text && rt_cpy(symbol, segs[0].source, segs[0].length)) {
return ZINT_ERROR_MEMORY; /* `rt_cpy()` only fails with OOM */
}
/* Convert value plus one to binary */
large_load_str_u64(&elreg, segs[0].source, segs[0].length);
large_add_u64(&elreg, 1);
@@ -1148,7 +1164,9 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
i);
}
data_length = c1_encode_segs(symbol, segs, seg_count, gs1, target, &last_mode);
if (c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode)) {
return ZINT_ERROR_MEMORY; /* `c1_encode_segs()` only returns non-zero with OOM */
}
assert(data_length); /* Can't exceed C1_MAX_CWS as input <= 90 */
if (data_length > 38) {
@@ -1231,7 +1249,9 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
int blocks, data_blocks, ecc_blocks, ecc_length;
int last_mode;
data_length = c1_encode_segs(symbol, segs, seg_count, gs1, target, &last_mode);
if (c1_encode_segs(symbol, segs, seg_count, gs1, target, &data_length, &last_mode)) {
return ZINT_ERROR_MEMORY; /* `c1_encode_segs()` only returns non-zero with OOM */
}
if (data_length == 0) {
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 517,