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

RAW_TEXT: change source to be unconverted, i.e. UTF-8 (unless

`DATA_MODE`); allows ZXing-C++ to be built in writer-only mode
  without needing "libzueci"
library: in GS1 mode check that ECI if any is ASCII compatible
general: some code fiddling, `mode` -> `modes`
This commit is contained in:
gitlost
2025-09-05 17:23:18 +01:00
parent 44e2099a65
commit 9b4d097516
39 changed files with 798 additions and 630 deletions

View File

@@ -981,17 +981,14 @@ static int c1_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
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()` */
/* Raw text dealt with by `ZBarcode_Encode_Segs()`, except for `eci` feedback.
Note not updating `eci` for GS1 mode as not converted (and ignored & not written anyway) */
const int raw_text = !gs1 && (symbol->output_options & BARCODE_RAW_TEXT);
if (raw_text && z_rt_init_segs(symbol, seg_count)) {
return ZINT_ERROR_MEMORY; /* `z_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 && z_rt_cpy_seg(symbol, i, &segs[i])) {
return ZINT_ERROR_MEMORY; /* `z_rt_cpy_seg()` only fails with OOM */
if (raw_text && segs[i].eci) {
z_rt_set_seg_eci(symbol, i, segs[i].eci);
}
}
@@ -1073,7 +1070,6 @@ INTERNAL int zint_codeone(struct zint_symbol *symbol, struct zint_seg segs[], co
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 z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 715, "Multiple segments not supported for Version S");
@@ -1109,10 +1105,6 @@ INTERNAL int zint_codeone(struct zint_symbol *symbol, struct zint_seg segs[], co
printf("Subversion: %d\n", sub_version);
}
if (raw_text && z_rt_cpy(symbol, segs[0].source, segs[0].length)) {
return ZINT_ERROR_MEMORY; /* `z_rt_cpy()` only fails with OOM */
}
/* Convert value plus one to binary */
zint_large_load_str_u64(&elreg, segs[0].source, segs[0].length);
zint_large_add_u64(&elreg, 1);
@@ -1152,6 +1144,8 @@ INTERNAL int zint_codeone(struct zint_symbol *symbol, struct zint_seg segs[], co
symbol->rows = 8;
symbol->width = 10 * sub_version + 1;
/* Raw text dealt with by `ZBarcode_Encode_Segs()`, and `eci` feedback can't change as numeric only */
} else if (symbol->option_2 == 10) {
/* Version T */
unsigned int target[C1_MAX_CWS + C1_MAX_ECCS]; /* Use same buffer size as A to H to avail of loop checks */