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

- MAXICODE: do not span segments when counting digits/alphas even

if no ECIs as current logic can't handle it (ticket #361, props
  Zhiyuan He, Numen Cyber Technology)
This commit is contained in:
gitlost
2026-10-09 09:56:10 +01:00
parent 4aec8df5cb
commit f5fd98106d
3 changed files with 79 additions and 7 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
Version 2.16.0.9 (dev) not released yet (2026-09-07) Version 2.16.0.9 (dev) not released yet (2026-10-09)
==================================================== ====================================================
**Incompatible changes** **Incompatible changes**
@@ -78,6 +78,8 @@ Bugs
- GRIDMATRIX: fix byte latch 6 -> 7, & allowing more than one non-digit in - GRIDMATRIX: fix byte latch 6 -> 7, & allowing more than one non-digit in
numeral (both caused misencodation) numeral (both caused misencodation)
- DOTCODE: fix not checking ECI on segs > 0 (MR #160, props Connor-Jay Dunn) - DOTCODE: fix not checking ECI on segs > 0 (MR #160, props Connor-Jay Dunn)
- MAXICODE: do not span segments when counting digits/alphas even if no ECIs
as current logic can't handle it (ticket #361, props Zhiyuan He)
Version 2.16.0 (2025-12-19) Version 2.16.0 (2025-12-19)
+3 -4
View File
@@ -293,9 +293,6 @@ static int mx_text_process_segs(unsigned char codewords[144], const int mode, st
unsigned char (*path_ops)[MX_STATES] unsigned char (*path_ops)[MX_STATES]
= (unsigned char (*)[MX_STATES]) z_alloca(sizeof(*path_ops) * (segs_len + 9)); = (unsigned char (*)[MX_STATES]) z_alloca(sizeof(*path_ops) * (segs_len + 9));
int digits = 0;
int num_a = 0;
int min_len = 999999; int min_len = 999999;
int min_state = 0; int min_state = 0;
int state; int state;
@@ -333,12 +330,14 @@ static int mx_text_process_segs(unsigned char codewords[144], const int mode, st
const unsigned char *const source = segs[seg].source; const unsigned char *const source = segs[seg].source;
const int length = segs[seg].length; const int length = segs[seg].length;
const int eci_len = mx_eci_len(segs[seg].eci); const int eci_len = mx_eci_len(segs[seg].eci);
int digits = 0; /* Counts don't span segments */
int num_a = 0;
if (eci_len) { if (eci_len) {
ci += eci_len; ci += eci_len;
if (ci > max_len) { if (ci > max_len) {
return ZINT_ERROR_TOO_LONG; return ZINT_ERROR_TOO_LONG;
} }
digits = 0;
} }
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
+73 -2
View File
@@ -1330,6 +1330,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
const char *comment; const char *comment;
const char *expected; const char *expected;
}; };
/* s/\v(\/\*)[ 0-9]*(\*\/)/\=printf("%s%3d%s", submatch(1), (@z+setreg('z',@z+1)), submatch(2))/ | let @z=0: */
static const struct item data[] = { static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, "", 0, 33, 30, 1, "ISO 16023:2000 4.15.4 example", /* 0*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, "", 0, 33, 30, 1, "ISO 16023:2000 4.15.4 example",
"010101010101010101010101010111" "010101010101010101010101010111"
@@ -1751,7 +1752,77 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"010101101100001010110111001100" "010101101100001010110111001100"
"101011011010100110010010100111" "101011011010100110010010100111"
}, },
/* 12*/ { UNICODE_MODE, -1, 96 + 1, { 0, 0, "" }, { { TU("12345678"), -1, 3 }, { TU("91234567901"), -1, 4 }, { TU("12345678"), -1, 5 } }, "9999840012", 0, 33, 30, 1, "SCM prefix mode 2", /* 12*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU("\000\000\0009"), 4, 0 },{ TU("9999"), -1, 0 }, { TU("9999"), -1, 0 } }, "", 0, 33, 30, 1, "Digits spanning segments, 0 ECIs, ticket #361",
"111111111111010101010101010111"
"010101010101000000000000000010"
"101010101010101010101010101000"
"010101010101010101010101010110"
"000000000000000000000000000001"
"101010101010101010101010101010"
"010101010101010101010101010100"
"000000000000000000000000000010"
"101010101010101010101010101001"
"010101010011000000111001010110"
"000000001101000010001000000001"
"101010101100000000101110101000"
"010101011100000000111101010100"
"000000100100000000111100000010"
"101010101000000000001110101001"
"010101111000000000001001010100"
"000000101000000000001000000000"
"101010011000000000001110101000"
"010101011100000000000001010110"
"000000100000000000001100000010"
"101010101100000000101010101010"
"010101011010000001110001010100"
"000000001110110101100100000010"
"101010101111110001101010101010"
"010101010101010101011010101010"
"000000000000000000000101000010"
"101010101010101010100101101001"
"000011110101111100001010000000"
"010100000101000010101010101001"
"010111110000111100001111000010"
"111100001010111110101010101001"
"111101011010111110100000101000"
"000011110000101001010000010101"
},
/* 13*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU("12345678"), -1, 3 },{ TU("91234567901"), -1, 0 }, { TU("12345678"), -1, 0 } }, "", 0, 33, 30, 1, "Digits spanning segments",
"111111100011110110111111111111"
"010100111111000011000000101000"
"001010111001111110100111001000"
"010101010101010101010111111110"
"000000000000000000000001101000"
"101010101010101010101000110110"
"010101010101010101010101010111"
"000000000000000000000000000010"
"101010101010101010101010101011"
"010101011111001100010001010110"
"000000000001001010011000000011"
"101010100000000000101010101010"
"010101011110000000011001010100"
"000000011000000000001100000010"
"101010101100000000011110101011"
"010101111000000000000101010100"
"000000101000000000001000000010"
"101010101000000000001110101000"
"010101010100000000000101010101"
"000000001100000000100000000000"
"101010001110000000101110101010"
"010101011100000001010101010110"
"000000001010101111111000000000"
"101010101010011101101110101000"
"010101010101010101011000000101"
"000000000000000000000100101010"
"101010101010101010101100001111"
"010110001011101000101100101010"
"101111001101101101010111010001"
"001101011000101001000110010100"
"101011000001011111110100001101"
"101010011111000111010000111100"
"011001001110110010001110101100"
},
/* 14*/ { UNICODE_MODE, -1, 96 + 1, { 0, 0, "" }, { { TU("12345678"), -1, 3 }, { TU("91234567901"), -1, 4 }, { TU("12345678"), -1, 5 } }, "9999840012", 0, 33, 30, 1, "SCM prefix mode 2",
"110101110110111110111110001111" "110101110110111110111110001111"
"010101010111000011011001000000" "010101010111000011011001000000"
"110110110001001010100111111001" "110110110001001010100111111001"
@@ -1786,7 +1857,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"110011010111010010100011101000" "110011010111010010100011101000"
"111010011111011100110001010110" "111010011111011100110001010110"
}, },
/* 13*/ { UNICODE_MODE, 3, 96 + 1, { 0, 0, "" }, { { TU("12345678"), -1, 3 }, { TU("91234567901"), -1, 4 }, { TU("12345678"), -1, 5 } }, "B999840012", 0, 33, 30, 1, "SCM prefix mode 3", /* 15*/ { UNICODE_MODE, 3, 96 + 1, { 0, 0, "" }, { { TU("12345678"), -1, 3 }, { TU("91234567901"), -1, 4 }, { TU("12345678"), -1, 5 } }, "B999840012", 0, 33, 30, 1, "SCM prefix mode 3",
"110101110110111110111110001111" "110101110110111110111110001111"
"010101010111000011011001000000" "010101010111000011011001000000"
"110110110001001010100111111001" "110110110001001010100111111001"