diff --git a/ChangeLog b/ChangeLog index af4f700c..28ad4318 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,17 +1,20 @@ -Version 2.13.0.9 (dev) not released yet -======================================= +Version 2.13.0.9 (dev) not released yet (2024-11-18) +==================================================== **Incompatible changes** ------------------------ - New `memfile` & `memfile_size` fields in `symbol` for use with new output option `BARCODE_MEMORY_FILE` +- Buffer length of member `text` (HRT) in `zint_symbol` extended 200 -> 256 + (client buffers may need checking/extending) - Invalid `input_mode` now returns warning - Aztec Code symbols that due to input length & user-requested version have less than recommended 5% error correction codewords now return warning -- New CODE128-only special extra escape `\^1` for manually inserting FNC1s +- New CODE128-only special extra escapes beginning `\^` - Add-ons for UPC-A and UPC-E now descend to be level with the main symbol guard bars, and the righthand outside digit is now placed 1X less from main symbol to avoid touching any add-on +- GS1_128 now warns if READER_INIT option used Changes ------- @@ -24,10 +27,10 @@ Changes Gredler (Okapi) - CODE128: add new extra escape `\^1` for manual insertion of FNC1s, ticket #324, props Jim Shank; - add minimal encodation algorithm (non-extended ASCII only), props Alex Geller - (ZXing); - reduce extended latch cut-off from 5 to 4 for better encodation in certain - cases, props Bue Jensen (BWIPP) + new extra escapes `\^A`, `\^B`, `\^C` and `\^@` for manual switching of + Code Sets; + add minimal encodation algorithm, props Alex Geller (ZXing) and Bue Jensen + (BWIPP); - library: return warning on invalid `input_mode` reset - library/CLI: expanded error messages - GS1: new AIs 7250-7259 (GSCN 22-246); diff --git a/backend/code128.c b/backend/code128.c index 83c1d13b..44946007 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -37,16 +37,15 @@ #include "code128.h" #include "gs1.h" -#define C128_SYMBOL_MAX 99 -#define C128_SYMBOL_MAX_S "99" /* String version of above */ +#define C128_SYMBOL_MAX 102 /* 102 * 10 + 10 (check digit) + 13 (Stop) = 1043 */ +#define C128_SYMBOL_MAX_S "102" /* String version of above */ -static const char KRSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#define KRSET_F (IS_NUM_F | IS_UPR_F) +#define C128_VALUES_MAX (C128_SYMBOL_MAX + 2) /* Allow for debug/test check digit and Stop */ /* Code 128 tables checked against ISO/IEC 15417:2007 */ +/* Code 128 character encodation - Table 1 (with final CODE16K-only character in place of Stop character) */ INTERNAL_DATA const char C128Table[107][6] = { /* Used by CODABLOCKF and CODE16K also */ - /* Code 128 character encodation - Table 1 (with final CODE16K-only character in place of Stop character) */ {'2','1','2','2','2','2'}, {'2','2','2','1','2','2'}, {'2','2','2','2','2','1'}, {'1','2','1','2','2','3'}, {'1','2','1','3','2','2'}, {'1','3','1','2','2','2'}, {'1','2','2','2','1','3'}, {'1','2','2','3','1','2'}, {'1','3','2','2','1','2'}, {'2','2','1','2','1','3'}, {'2','2','1','3','1','2'}, {'2','3','1','2','1','2'}, @@ -76,210 +75,227 @@ INTERNAL_DATA const char C128Table[107][6] = { /* Used by CODABLOCKF and CODE16K {'2','1','1','2','1','4'}, {'2','1','1','2','3','2'}, {/* Only used by CODE16K */ '2','1','1','1','3','3'} }; -/* Whether `ch` can be encoded directly in code set `charset` (no shifts) (for `c128_define_mode()` below) */ -static int c128_can_aorb(const unsigned char ch, const int charset, const int check_fnc1) { +/* Code Set states */ +#define C128_A0 1 +#define C128_B0 2 +#define C128_A1 3 +#define C128_B1 4 +#define C128_C0 5 +#define C128_C1 6 +#define C128_STATES 7 - if (ch <= 31) { - return charset == 1 || (check_fnc1 && ch == '\x1D'); +/* Helpers to characterize Code Set states */ +#define C128_A0B0(cset) ((cset) <= C128_B0) +#define C128_C0C1(cset) ((cset) >= C128_C0) +#define C128_A0A1(cset) ((cset) & 1) /* Assuming !C */ +#define C128_AB(cset) ((cset) >> ((cset) > C128_B0)) /* Assuming !C */ + +/* Code Set states are named A0, B0, A1, B1, C0 and C1. A, B, and C are the Code 128 Code Sets. + 0 is for ASCII and 1 is for extended ASCII range */ +static const char c128_latch_seq[C128_STATES][C128_STATES][3] = { + /* Current: A0 B0 A1 B1 C0 C1 Prior */ + { {0} }, + { {0}, { 0 }, {100 }, {101,101 }, {100,100,100}, { 99 }, {101,101, 99} }, /* A0 */ + { {0}, {101 }, { 0 }, {101,101,101}, {100,100 }, { 99 }, {100,100, 99} }, /* B0 */ + { {0}, {101,101 }, {100,100,100}, { 0 }, {100 }, {101,101, 99}, { 99 } }, /* A1 */ + { {0}, {101,101,101}, {100,100 }, {101 }, { 0 }, {100,100, 99}, { 99 } }, /* B1 */ + { {0}, {101 }, {100 }, {101,101,101}, {100,100,100}, { 0 }, { 0 } }, /* C0 */ + { {0}, {101,101,101}, {100,100,100}, {101 }, {100 }, { 0 }, { 0 } }, /* C1 */ +}; +static const char c128_latch_len[C128_STATES][C128_STATES] = { /* Lengths of above */ + /* Current: A0 B0 A1 B1 C0 C1 Prior */ + { 0 }, + { 0, 0, 1, 2, 3, 1, 3 }, /* A0 */ + { 0, 1, 0, 3, 2, 1, 3 }, /* B0 */ + { 0, 2, 3, 0, 1, 3, 1 }, /* A1 */ + { 0, 3, 2, 1, 0, 3, 1 }, /* B1 */ + { 0, 1, 1, 3, 3, 0, 64 }, /* C0 */ + { 0, 3, 3, 1, 1, 64, 0 }, /* C1 */ +}; + +/* Start sequences for normal, GS1_MODE and READER_INIT (mutually exclusive) */ +static const char c128_start_latch_seq[3][C128_STATES][4] = { + /* A0 B0 A1 B1 C0 C1 (not used) */ + { {0}, {103 }, {104 }, {103,101,101 }, {104,100,100 }, {105 } }, /* Normal */ + { {0}, {103,102}, {104,102}, {103,102,101,101}, {104,102,100,100}, {105,102 } }, /* GS1_MODE */ + { {0}, {103, 96}, {104, 96}, {103, 96,101,101}, {104, 96,100,100}, {104, 96,99} }, /* READER_INIT */ +}; +static const char c128_start_latch_len[3][C128_STATES] = { /* Lengths of above */ + /* A0 B0 A1 B1 C0 C1 (not used) */ + { 0, 1, 1, 3, 3, 1 }, /* Normal */ + { 0, 2, 2, 4, 4, 2 }, /* GS1_MODE */ + { 0, 2, 2, 4, 4, 3 }, /* READER_INIT */ +}; + +/* Output cost (length) for Code Sets A/B */ +static int c128_cost_ab(const int cset, const unsigned char ch, int *p_mode) { + const unsigned char mask_0x60 = ch & 0x60; /* 0 for (ch & 0x7F) < 32, 0x60 for (ch & 0x7F) >= 96 */ + const int ga = C128_A0A1(cset); + int cost = 1; + + assert(!C128_C0C1(cset)); + + /* SHIFT */ + if ((ga && mask_0x60 == 0x60) || (!ga && !mask_0x60)) { /* A and (ch & 0x7F) >= 96, or B and (ch & 0x7F) < 32 */ + cost++; + *p_mode |= 0x10; } - if (ch <= 95) { - return 1; + + /* FNC4 */ + if (C128_A0B0(cset) == (ch >= 128)) { /* If A0/B0 and extended ASCII, or A1/B1 and ASCII */ + cost++; + *p_mode |= 0x20; } - if (ch <= 127) { - return charset == 2; - } - if (ch <= 159) { - return charset == 1; - } - if (ch <= 223) { - return 1; - } - return charset == 2; + + return cost; } -/* Whether `source[position]` can be encoded in code set C (for `c128_define_mode()` below) */ -static int c128_can_c(const unsigned char source[], const int length, const int position, const int check_fnc1) { - return (position + 1 < length && z_isdigit(source[position]) && z_isdigit(source[position + 1])) - || (check_fnc1 && source[position] == '\x1D'); -} +/* Calculate the cost of encoding from `i` starting in Code Set `prior_cset` (see `c128_set_values()` below) */ +static int c128_cost(const unsigned char source[], const int length, const int i, const int prior_cset, + const int start_idx, const char priority[C128_STATES], const char fncs[C128_MAX], + const char manuals[C128_MAX], short (*costs)[C128_STATES], char (*modes)[C128_STATES]) { -/* Calculate the cost of encoding from `position` starting in code set `charset` (for `c128_define_mode()` below) */ -static int c128_cost(const unsigned char source[], const int length, const int position, const int charset, - const int ab_only, const char manual_set[C128_MAX], const unsigned char fncs[C128_MAX], int (*costs)[4], - char (*modes)[4]) { + const unsigned char ch = source[i]; + const char *const latch_len = prior_cset == 0 ? c128_start_latch_len[start_idx] : c128_latch_len[prior_cset]; + const int is_fnc1 = ch == '\x1D' && fncs[i]; + const int can_c = is_fnc1 || (z_isdigit(ch) && z_isdigit(source[i + 1])); /* Assumes source NUL-terminated */ + const int manual_c_fail = !can_c && manuals[i] == C128_C0; /* C requested but not doable */ + int min_cost = 999999; /* Max possible cost less than 2 * 256 */ + int min_mode = 0; + int p; - /* Check if memoized */ - if (costs[position][charset]) { - return costs[position][charset]; - } else { - const int at_end = position + 1 >= length; - const int check_fnc1 = !fncs || fncs[position]; - const int can_c = c128_can_c(source, length, position, check_fnc1); - const int manual_c_fail = !can_c && manual_set && manual_set[position] == 3; /* C requested but not doable */ - int min_cost = 999999; /* Max possible cost 2 * 256 */ - int min_latch = 0; - int tryset; - - /* Try code set C first (preferring C over B over A as seems to better preserve previous encodation) */ - if (!ab_only && can_c && (!manual_set || !manual_set[position] || manual_set[position] == 3)) { - const int advance = source[position] == '\x1D' ? 1 : 2; - int cost = 1; - int latch = 0; /* Continue current `charset` */ - if (charset != 3) { - cost++; - latch = 3; - } - if (position + advance < length) { - cost += c128_cost(source, length, position + advance, 3, ab_only, manual_set, fncs, costs, modes); - } - if (cost < min_cost) { - min_cost = cost; - min_latch = latch; - } - } - /* Then code sets B and A */ - for (tryset = 2; tryset >= 1; tryset--) { - if (manual_set && manual_set[position] && manual_set[position] != tryset && !manual_c_fail) { - continue; - } - if (c128_can_aorb(source[position], tryset, check_fnc1)) { + for (p = 0; priority[p]; p++) { + const int cset = priority[p]; + if (C128_C0C1(cset)) { + if (can_c && (!manuals[i] || manuals[i] == C128_C0)) { + const int incr = is_fnc1 ? 1 : 2; + int mode = prior_cset; int cost = 1; - int latch = 0; /* Continue current `charset` */ - if (charset != tryset) { - cost++; - latch = tryset; + if (prior_cset != cset) { + cost += latch_len[cset]; + mode = cset; } - if (!at_end) { - cost += c128_cost(source, length, position + 1, tryset, ab_only, manual_set, fncs, costs, modes); + if (i + incr < length) { + /* Check if memoized */ + if (costs[i + incr][cset]) { + cost += costs[i + incr][cset]; + } else { + cost += c128_cost(source, length, i + incr, cset, 0 /*start_idx*/, priority, fncs, manuals, + costs, modes); + } } if (cost < min_cost) { min_cost = cost; - min_latch = latch; + min_mode = mode; } - if (charset != tryset && (charset == 1 || charset == 2)) { - cost = 2; - latch = 3 + charset; /* Shift A/B */ - if (!at_end) { - cost += c128_cost(source, length, position + 1, charset, ab_only, manual_set, fncs, costs, - modes); + } + } else { + if (!manuals[i] || manuals[i] == C128_AB(cset) || manual_c_fail) { + int mode = cset; + int cost = is_fnc1 ? 1 : c128_cost_ab(cset, ch, &mode); + if (prior_cset != cset) { + cost += latch_len[cset]; + } + if (i + 1 < length) { + /* Check if memoized */ + if (costs[i + 1][cset]) { + cost += costs[i + 1][cset]; + } else { + cost += c128_cost(source, length, i + 1, cset, 0 /*start_idx*/, priority, fncs, manuals, + costs, modes); } - if (cost < min_cost) { - min_cost = cost; - min_latch = latch; - } - } - } else if (manual_set && manual_set[position] == tryset) { - /* Manually set, requires shift */ - int cost = 2; - int latch = 3 + tryset; /* Shift A/B */ - if (charset != tryset) { - cost++; - } - if (!at_end) { - cost += c128_cost(source, length, position + 1, tryset, ab_only, manual_set, fncs, costs, modes); } if (cost < min_cost) { min_cost = cost; - min_latch = latch; + min_mode = mode; } } } - assert(min_cost != 999999); - - costs[position][charset] = min_cost; - modes[position][charset] = min_latch; - - return min_cost; } + assert(min_cost != 999999); + + costs[i][prior_cset] = min_cost; + modes[i][prior_cset] = min_mode; + + return min_cost; } /* Minimal encoding using Divide-And-Conquer with Memoization by Alex Geller - see https://github.com/zxing/zxing/commit/94fb277607003c070ffd1413754a782f3f87cbcd - (note minimal for non-extended characters only, which are dealt with non-optimally by `fset` logic) */ -static void c128_define_mode(char set[C128_MAX], const unsigned char source[], const int length, - const int ab_only, const char manual_set[C128_MAX], const unsigned char fncs[C128_MAX]) { - int (*costs)[4] = (int (*)[4]) z_alloca(sizeof(int) * 4 * length); - char (*modes)[4] = (char (*)[4]) z_alloca(4 * length); - int charset = 0; + Many ideas, especially enabling extended ASCII, taken from BWIPP minimal encoding by Bue Jensen - see + https://github.com/bwipp/postscriptbarcode/pull/278 */ +static int c128_set_values(const unsigned char source[], const int length, const int start_idx, + const char priority[C128_STATES], const char fncs[C128_MAX], const char manuals[C128_MAX], + int values[C128_VALUES_MAX], int *p_final_cset) { + + short (*costs)[C128_STATES] = (short (*)[C128_STATES]) z_alloca(sizeof(*costs) * length); + char (*modes)[C128_STATES] = (char (*)[C128_STATES]) z_alloca(sizeof(*modes) * length); + int glyph_count = 0; + int cset = 0; int i; - memset(costs, 0, sizeof(int) * 4 * length); - memset(modes, 0, 4 * length); + memset(costs, 0, sizeof(*costs) * length); - c128_cost(source, length, 0 /*position*/, 0 /*charset*/, ab_only, manual_set, fncs, costs, modes); + c128_cost(source, length, 0 /*i*/, 0 /*prior_cset*/, start_idx, priority, fncs, manuals, costs, modes); + if (costs[0][0] > C128_SYMBOL_MAX) { /* Total minimal cost (glyph count) */ + return costs[0][0]; + } + + /* Output codewords into `values` */ for (i = 0; i < length; i++) { - const int latch = modes[i][charset]; - if (latch >= 4 && latch <= 5) { - /* Shift A/B */ - charset = latch - 3; - set[i] = charset == 1 ? 'b' : 'a'; - } else { - if (latch >= 1 && latch <= 3) { - charset = latch; - } /* Else continue in same `charset` */ - assert(charset); - set[i] = '@' + charset; /* A, B or C */ - if (charset == 3 && source[i] != '\x1D') { - assert(i + 1 < length); /* Guaranteed by algorithm */ - set[++i] = 'C'; + const unsigned char ch = source[i]; + const int is_fnc1 = ch == '\x1D' && fncs[i]; + const int mode = modes[i][cset]; + const int prior_cset = cset; + + cset = mode & 0x0F; + assert(cset); + if (cset != prior_cset) { + int j; + if (prior_cset == 0) { + for (j = 0; j < c128_start_latch_len[start_idx][cset]; j++) { + values[glyph_count++] = c128_start_latch_seq[start_idx][cset][j]; + } + } else { + for (j = 0; j < c128_latch_len[prior_cset][cset]; j++) { + values[glyph_count++] = c128_latch_seq[prior_cset][cset][j]; + } } } - } -} - -/** - * Translate Code 128 Set A characters into barcodes. - * This set handles all control characters NUL to US. - */ -INTERNAL void c128_set_a(const unsigned char source, int values[], int *bar_chars) { - - if (source >= 128) { - if (source < 160) { - values[(*bar_chars)] = (source - 128) + 64; - } else { - values[(*bar_chars)] = (source - 128) - 32; + if (mode >= 0x30) { + /* Extended Shift A/B */ + values[glyph_count++] = 100 + C128_A0A1(cset); /* FNC4 */ + values[glyph_count++] = 98; /* SHIFT */ + } else if (mode >= 0x20) { + /* Extended A/B */ + values[glyph_count++] = 100 + C128_A0A1(cset); /* FNC4 */ + } else if (mode >= 0x10) { + /* Shift A/B */ + values[glyph_count++] = 98; /* SHIFT */ } - } else { - if (source < 32) { - values[(*bar_chars)] = source + 64; + if (is_fnc1) { + values[glyph_count++] = 102; /* FNC1 */ + } else if (C128_C0C1(cset)) { + assert(i + 1 < length); /* Guaranteed by algorithm */ + values[glyph_count++] = (ch - '0') * 10 + source[++i] - '0'; } else { - values[(*bar_chars)] = source - 32; + /* (ch & 0x7F) < 32 ? (ch & 0x7F) + 64 : (ch & 0x7F) - 32 */ + values[glyph_count++] = (ch & 0x7F) + 96 * !(ch & 0x60) - 32; } } - (*bar_chars)++; -} + assert(glyph_count == costs[0][0]); -/** - * Translate Code 128 Set B characters into barcodes. - * This set handles all characters which are not part of long numbers and not - * control characters. - */ -INTERNAL int c128_set_b(const unsigned char source, int values[], int *bar_chars) { - if (source >= 128 + 32) { - values[(*bar_chars)] = source - 32 - 128; - } else if (source >= 128) { /* Should never happen */ - return 0; /* Not reached */ - } else if (source >= 32) { - values[(*bar_chars)] = source - 32; - } else { /* Should never happen */ - return 0; /* Not reached */ + if (p_final_cset) { + *p_final_cset = cset; } - (*bar_chars)++; - return 1; -} -/* Translate Code 128 Set C characters into barcodes - * This set handles numbers in a compressed form - */ -INTERNAL void c128_set_c(const unsigned char source_a, const unsigned char source_b, int values[], int *bar_chars) { - values[(*bar_chars)] = 10 * (source_a - '0') + source_b - '0'; - (*bar_chars)++; + return glyph_count; } /* Helper to write out symbol, calculating check digit */ -static void c128_expand(struct zint_symbol *symbol, int values[C128_MAX], int bar_characters) { - char dest[640]; /* (1 (Start) + 2 (max initial extra) + 99 + 1 (check digit)) * 6 + 7 (Stop) == 625 */ +static void c128_expand(struct zint_symbol *symbol, int values[C128_VALUES_MAX], int glyph_count) { + char dest[640]; /* (102 + 1 (check digit)) * 6 + 7 (Stop) = 625 */ char *d = dest; int total_sum; int i; @@ -289,126 +305,80 @@ static void c128_expand(struct zint_symbol *symbol, int values[C128_MAX], int ba d += 6; total_sum = values[0]; - for (i = 1; i < bar_characters; i++, d += 6) { + for (i = 1; i < glyph_count; i++, d += 6) { memcpy(d, C128Table[values[i]], 6); - total_sum += values[i] * i; /* Note can't overflow as 106 * C128_SYMBOL_MAX * C128_SYMBOL_MAX = 1038906 */ + total_sum += values[i] * i; /* Note can't overflow as 106 * C128_SYMBOL_MAX * C128_SYMBOL_MAX = 1102824 */ } total_sum %= 103; memcpy(d, C128Table[total_sum], 6); d += 6; - values[bar_characters++] = total_sum; + values[glyph_count++] = total_sum; /* For debug/test */ /* Stop character */ memcpy(d, "2331112", 7); d += 7; - values[bar_characters++] = 106; + values[glyph_count++] = 106; /* For debug/test */ if (symbol->debug & ZINT_DEBUG_PRINT) { fputs("Codewords:", stdout); - for (i = 0; i < bar_characters; i++) { + for (i = 0; i < glyph_count; i++) { printf(" %d", values[i]); } - printf(" (%d)\n", bar_characters); + printf(" (%d)\n", glyph_count); printf("Barspaces: %.*s\n", (int) (d - dest), dest); printf("Checksum: %d\n", total_sum); } #ifdef ZINT_TEST if (symbol->debug & ZINT_DEBUG_TEST) { - debug_test_codeword_dump_int(symbol, values, bar_characters); + debug_test_codeword_dump_int(symbol, values, glyph_count); } #endif expand(symbol, dest, d - dest); } -/* Return codeword estimate (character encodation only) */ -static int c128_glyph_count(const unsigned char source[], const int length, const char set[C128_MAX], - const char fset[C128_MAX]) { - int glyph_count = 0; - char current_set = 0; - int f_state = 0; - int i; - - switch (set[0]) { - case 'A': - case 'b': /* Manual switching can cause immediate shift */ - current_set = 'A'; - break; - case 'B': - case 'a': - current_set = 'B'; - break; - case 'C': - current_set = 'C'; - break; +/* Helper to set `priority` array based on flags */ +static void c128_set_priority(char priority[C128_STATES], const int have_a, const int have_b, const int have_c, + const int have_extended) { + int i = 0; + if (have_c) { + priority[i++] = C128_C0; } - - for (i = 0; i < length; i++) { - if (set[i] != current_set) { - /* Latch different code set */ - switch (set[i]) { - case 'A': - case 'b': /* Manual switching can cause immediate shift */ - if (current_set != 'A') { - current_set = 'A'; - glyph_count++; - } - break; - case 'B': - case 'a': - if (current_set != 'B') { - current_set = 'B'; - glyph_count++; - } - break; - case 'C': - current_set = 'C'; - glyph_count++; - break; - } + if (have_b || !have_a) { + priority[i++] = C128_B0; + } + if (have_a) { + priority[i++] = C128_A0; + } + if (have_extended) { + if (have_c) { + priority[i++] = C128_C1; } - if (fset) { - if ((fset[i] == 'F' && f_state == 0) || (fset[i] == ' ' && f_state == 1)) { - /* Latch beginning/end of extended mode */ - f_state = !f_state; - glyph_count += 2; - } else if ((fset[i] == 'f' && f_state == 0) || (fset[i] == 'n' && f_state == 1)) { - /* Shift to or from extended mode */ - glyph_count++; - } + if (have_b || !have_a) { + priority[i++] = C128_B1; } - if ((set[i] == 'a') || (set[i] == 'b')) { - /* Insert shift character */ - glyph_count++; - } - - /* Actual character */ - glyph_count++; - - if (set[i] == 'C' && source[i] != '\x1D') { - i++; + if (have_a) { + priority[i++] = C128_A1; } } - - return glyph_count; + priority[i] = 0; } -/* Handle Code 128, 128B and HIBC 128 */ +/* Handle Code 128, 128AB and HIBC 128 */ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, j, k, read; + int i; int error_number; - int values[C128_MAX] = {0}, bar_characters = 0; + char manuals[C128_MAX] = {0}; + char fncs[C128_MAX] = {0}; /* Manual FNC1 positions */ + int have_fnc1 = 0; /* Whether have at least 1 manual FNC1 */ + int have_a = 0, have_b = 0, have_c = 0, have_extended = 0; + char priority[C128_STATES]; + int values[C128_VALUES_MAX] = {0}; + int glyph_count; unsigned char src_buf[C128_MAX + 1]; unsigned char *src = source; - char manual_set[C128_MAX] = {0}; - unsigned char fncs[C128_MAX] = {0}; /* Manual FNC1 positions */ - char set[C128_MAX] = {0}, fset[C128_MAX], current_set = 0; - int f_state = 0; - int have_fnc1 = 0; /* Whether have at least 1 manual FNC1 */ - char manual_ch = 0; - - /* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */ - assert(length > 0); + const int ab_only = symbol->symbology == BARCODE_CODE128AB; + const int start_idx = (symbol->output_options & READER_INIT) ? 2 : 0; if (length > C128_MAX) { /* This only blocks ridiculously long input - the actual length of the @@ -418,28 +388,29 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len /* Detect special Code Set escapes for Code 128 in extra escape mode only */ if ((symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128) { - j = 0; + char manual = 0; + int j = 0; for (i = 0; i < length; i++) { if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^' - && ((source[i + 2] >= 'A' && source[i + 2] <= 'C') || source[i + 2] == '1' + && ((source[i + 2] >= '@' && source[i + 2] <= 'C') || source[i + 2] == '1' || source[i + 2] == '^')) { if (source[i + 2] == '^') { /* Escape sequence '\^^' */ - manual_set[j] = manual_ch; + manuals[j] = manual; src_buf[j++] = source[i++]; - manual_set[j] = manual_ch; + manuals[j] = manual; src_buf[j++] = source[i++]; /* Drop second '^' */ } else if (source[i + 2] == '1') { /* FNC1 */ i += 2; fncs[j] = have_fnc1 = 1; - manual_set[j] = manual_ch; + manuals[j] = manual; src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */ - } else { /* Manual mode A/B/C */ + } else { /* Manual mode A/B/C/@ */ i += 2; - manual_ch = source[i] - '@'; /* 1 (A), 2 (B), 3 (C) */ + manual = source[i] == 'C' ? C128_C0 : source[i] - '@'; /* Assuming A0 = 1, B0 = 2 */ } } else { - manual_set[j] = manual_ch; + manuals[j] = manual; src_buf[j++] = source[i]; } } @@ -451,207 +422,67 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len src = src_buf; src[length] = '\0'; if (symbol->debug & ZINT_DEBUG_PRINT) { - fputs("MSet: ", stdout); - for (i = 0; i < length; i++) printf("%c", manual_set[i] + '@'); + fputs("Manuals: ", stdout); + for (i = 0; i < length; i++) { + printf("%c", manuals[i] == C128_C0 ? 'C' : '@' + manuals[i]); /* Assuming A0 = 1, B0 = 2 */ + } fputc('\n', stdout); } } } - c128_define_mode(set, src, length, symbol->symbology == BARCODE_CODE128AB /*ab_only*/, - manual_ch ? manual_set : NULL, have_fnc1 ? fncs : NULL); - - /* Detect extended ASCII characters */ - for (i = 0; i < length; i++) { - fset[i] = src[i] >= 128 ? 'f' : ' '; - } - - /* Decide when to latch to extended mode - ISO/IEC 15417:2007 Annex E note 3 */ - j = 0; - k = 0; - for (i = 0; i < length; i++) { - if (fset[i] == 'f') { - j++; - if (j >= 4) { - fset[i] = 'F'; - if (!k) { - fset[i - 1] = fset[i - 2] = fset[i - 3] = 'F'; - k = i; - } - } - } else { - j = 0; - k = 0; - } - } - if (j >= 3 && !k) { - fset[length - 1] = fset[length - 2] = fset[length - 3] = 'F'; - } - - /* Decide if it is worth reverting to ASCII encodation for a few characters as described in 4.3.4.2 (d) */ - for (i = 1; i < length; i++) { - if ((fset[i - 1] == 'F') && (fset[i] == ' ')) { - int c = set[i] == 'C'; /* Count code set C so can subtract when deciding below */ - /* Detected a change from extended to ASCII - count how long for */ - for (j = 1; i + j < length && fset[i + j] == ' '; j++) { - c += set[i + j] == 'C'; - } - /* Count how many extended beyond */ - for (k = i + j < length; i + j + k < length && fset[i + j + k] != ' '; k++); - if (j - c < 3 || (j - c < 5 && k > 2)) { - /* Change to shifting back rather than latching back */ - /* Inverts the same figures recommended by ISO/IEC 15417:2007 Annex E note 3 */ - for (k = 0; k < j; k++) { - fset[i + k] = 'n'; - } - } - } - } - - if (symbol->debug & ZINT_DEBUG_PRINT) { - printf("Data: %.*s (%d)\n", length, src, length); - printf(" Set: %.*s\n", length, set); - printf("FSet: %.*s\n", length, fset); - } - - /* Now we can calculate how long the barcode is going to be - and stop it from - being too long */ - if ((i = c128_glyph_count(source, length, set, fset)) > C128_SYMBOL_MAX) { - return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 341, - "Input too long, requires %d symbol characters (maximum " C128_SYMBOL_MAX_S ")", i); - } - - /* So now we know what start character to use - we can get on with it! */ - if (symbol->output_options & READER_INIT) { - /* Reader Initialisation mode */ - switch (set[0]) { - case 'A': /* Start A */ - case 'b': /* Manual switching can cause immediate shift */ - values[bar_characters++] = 103; - current_set = 'A'; - values[bar_characters++] = 96; /* FNC3 */ - break; - case 'B': /* Start B */ - case 'a': - values[bar_characters++] = 104; - current_set = 'B'; - values[bar_characters++] = 96; /* FNC3 */ - break; - case 'C': /* Start C */ - values[bar_characters++] = 104; /* Start B */ - values[bar_characters++] = 96; /* FNC3 */ - values[bar_characters++] = 99; /* Code C */ - current_set = 'C'; - break; + /* Classify data to detect which Code Set states are needed */ + if (ab_only) { + for (i = 0; i < length; i++) { + const unsigned char ch = src[i]; + const unsigned char mask_0x60 = ch & 0x60; /* 0 for (ch & 0x7F) < 32, 0x60 for (ch & 0x7F) >= 96 */ + have_extended |= ch & 0x80; + have_a |= !mask_0x60; + have_b |= mask_0x60 == 0x60; } } else { - /* Normal mode */ - switch (set[0]) { - case 'A': /* Start A */ - case 'b': /* Manual switching can cause immediate shift */ - values[bar_characters++] = 103; - current_set = 'A'; - break; - case 'B': /* Start B */ - case 'a': - values[bar_characters++] = 104; - current_set = 'B'; - break; - case 'C': /* Start C */ - values[bar_characters++] = 105; - current_set = 'C'; - break; + int prev_digit, digit = 0; + for (i = 0; i < length; i++) { + const unsigned char ch = src[i]; + const int is_fnc1 = ch == '\x1D' && fncs[i]; + if (!is_fnc1) { + const unsigned char mask_0x60 = ch & 0x60; /* 0 for (ch & 0x7F) < 32, 0x60 for (ch & 0x7F) >= 96 */ + const int manual = manuals[i]; + have_extended |= ch & 0x80; + have_a |= !mask_0x60 || manual == C128_A0; + have_b |= mask_0x60 == 0x60 || manual == C128_B0; + prev_digit = digit; + digit = z_isdigit(ch); + have_c |= prev_digit && digit; + } } } + c128_set_priority(priority, have_a, have_b, have_c, have_extended); - /* Encode the data */ - for (read = 0; read < length; read++) { - - if (set[read] != current_set) { - /* Latch different code set */ - switch (set[read]) { - case 'A': - case 'b': /* Manual switching can cause immediate shift */ - if (current_set != 'A') { - values[bar_characters++] = 101; - current_set = 'A'; - } - break; - case 'B': - case 'a': - if (current_set != 'B') { - values[bar_characters++] = 100; - current_set = 'B'; - } - break; - case 'C': - values[bar_characters++] = 99; - current_set = 'C'; - break; - } - } - - if ((fset[read] == 'F' && f_state == 0) || (fset[read] == ' ' && f_state == 1)) { - /* Latch beginning/end of extended mode */ - switch (current_set) { - case 'A': - values[bar_characters++] = 101; - values[bar_characters++] = 101; - f_state = !f_state; - break; - case 'B': - values[bar_characters++] = 100; - values[bar_characters++] = 100; - f_state = !f_state; - break; - } - } else if ((fset[read] == 'f' && f_state == 0) || (fset[read] == 'n' && f_state == 1)) { - /* Shift to or from extended mode */ - switch (current_set) { - case 'A': - values[bar_characters++] = 101; /* FNC4 */ - break; - case 'B': - values[bar_characters++] = 100; /* FNC4 */ - break; - } - } - - if ((set[read] == 'a') || (set[read] == 'b')) { - /* Insert shift character */ - values[bar_characters++] = 98; - } - - /* Encode data characters */ - if (!fncs[read]) { - switch (set[read]) { - case 'A': - case 'a': - c128_set_a(src[read], values, &bar_characters); - break; - case 'B': - case 'b': - (void) c128_set_b(src[read], values, &bar_characters); - break; - case 'C': - c128_set_c(src[read], src[read + 1], values, &bar_characters); - read++; - break; - } - } else { - values[bar_characters++] = 102; /* FNC1 in all modes */ - } + glyph_count = c128_set_values(src, length, start_idx, priority, fncs, manuals, values, NULL /*p_final_cset*/); + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Data (%d): %.*s", length, length >= 100 ? 1 : length >= 10 ? 2 : 3, " "); + debug_print_escape(src, length, NULL); + printf("\nGlyphs: %d\n", glyph_count); } - c128_expand(symbol, values, bar_characters); + /* Now we know how long the barcode is - stop it from being too long */ + if (glyph_count > C128_SYMBOL_MAX) { + return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 341, + "Input too long, requires %d symbol characters (maximum " C128_SYMBOL_MAX_S ")", glyph_count); + } + + /* Now we can get on with it! */ + c128_expand(symbol, values, glyph_count); /* ISO/IEC 15417:2007 leaves dimensions/height as application specification */ /* HRT */ if (have_fnc1) { /* Remove any manual FNC1 dummies ('\x1D') */ - for (i = 0, j = 0; i < length; i++) { + int j = 0; + for (i = 0; i < length; i++) { if (!fncs[i]) { src[j++] = src[i]; } @@ -663,14 +494,18 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len return error_number; } -/* Handle EAN-128 (Now known as GS1-128), and composite version if `cc_mode` set */ +/* Handle GS1-128 (formerly known as EAN-128), and composite version if `cc_mode` set */ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int length, const int cc_mode, const int cc_rows) { - int i, read; + int i; int error_number; - int values[C128_MAX] = {0}, bar_characters = 0; - char set[C128_MAX] = {0}; - int separator_row = 0, linkage_flag = 0; + const char manuals[C128_MAX] = {0}; /* Dummy */ + char fncs[C128_MAX]; /* Dummy, set to all 1s */ + char priority[C128_STATES]; + int values[C128_VALUES_MAX] = {0}; + int glyph_count; + int final_cset; + int separator_row = 0; int reduced_length; unsigned char *reduced = (unsigned char *) z_alloca(length + 1); @@ -680,7 +515,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 342, "Input length %d too long (maximum " C128_MAX_S ")", length); } - /* if part of a composite symbol make room for the separator pattern */ + /* If part of a composite symbol make room for the separator pattern */ if (symbol->symbology == BARCODE_GS1_128_CC) { separator_row = symbol->rows; symbol->row_height[symbol->rows] = 1; @@ -693,97 +528,61 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int } reduced_length = (int) ustrlen(reduced); + memset(fncs, 1, reduced_length); - c128_define_mode(set, reduced, reduced_length, 0 /*ab_only*/, NULL, NULL /*fncs*/); + /* Control and extended chars not allowed so only have B/C (+FNC1) */ + c128_set_priority(priority, 0 /*have_a*/, 1 /*have_b*/, 1 /*have_c*/, 0 /*have_extended*/); + + glyph_count = c128_set_values(reduced, reduced_length, 1 /*start_idx*/, priority, fncs, manuals, values, + &final_cset); if (symbol->debug & ZINT_DEBUG_PRINT) { - printf("Data: %s (%d)\n", reduced, reduced_length); - printf(" Set: %.*s\n", reduced_length, set); + printf("Data (%d): %.*s", reduced_length, reduced_length >= 100 ? 1 : reduced_length >= 10 ? 2 : 3, " "); + debug_print_escape(reduced, reduced_length, NULL); + printf("\nGlyphs: %d\n", glyph_count); } /* Now we can calculate how long the barcode is going to be - and stop it from being too long */ - if ((i = c128_glyph_count(reduced, reduced_length, set, NULL /*fset*/)) > C128_SYMBOL_MAX) { + if (glyph_count + (cc_mode != 0) > C128_SYMBOL_MAX) { return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 344, - "Input too long, requires %d symbol characters (maximum " C128_SYMBOL_MAX_S ")", i); + "Input too long, requires %d symbol characters (maximum " C128_SYMBOL_MAX_S ")", + glyph_count + (cc_mode != 0)); } - /* So now we know what start character to use - we can get on with it! */ - assert(set[0] == 'B' || set[0] == 'C'); - switch (set[0]) { - case 'B': /* Start B */ - values[bar_characters++] = 104; - break; - case 'C': /* Start C */ - values[bar_characters++] = 105; - break; - } - - values[bar_characters++] = 102; /* FNC1 */ - - /* Encode the data */ - for (read = 0; read < reduced_length; read++) { - assert(set[read] == 'B' || set[read] == 'C'); - - if ((read != 0) && (set[read] != set[read - 1])) { - /* Latch different code set */ - switch (set[read]) { - case 'B': - values[bar_characters++] = 100; - break; - case 'C': - values[bar_characters++] = 99; - break; - } - } - - if (reduced[read] != '\x1D') { - switch (set[read]) { /* Encode data characters */ - case 'B': - (void) c128_set_b(reduced[read], values, &bar_characters); - break; - case 'C': - c128_set_c(reduced[read], reduced[read + 1], values, &bar_characters); - read++; - break; - } - } else { - values[bar_characters++] = 102; /* FNC1 in all modes */ - } - } - - /* "...note that the linkage flag is an extra code set character between - the last data character and the Symbol Check Character" (GS1 Specification) */ + /* "...note that the linkage flag is an extra Code Set character between + the last data character and the Symbol Check Character" (GS1 Specification) */ /* Linkage flags in GS1-128 are determined by ISO/IEC 24723 section 7.4 */ + assert(final_cset == C128_B0 || final_cset == C128_C0); switch (cc_mode) { case 1: case 2: /* CC-A or CC-B 2D component */ - switch (set[reduced_length - 1]) { - case 'B': linkage_flag = 99; + switch (final_cset) { + case C128_B0: + values[glyph_count++] = 99; break; - case 'C': linkage_flag = 101; + case C128_C0: + values[glyph_count++] = 101; break; } break; case 3: /* CC-C 2D component */ - switch (set[reduced_length - 1]) { - case 'B': linkage_flag = 101; + switch (final_cset) { + case C128_B0: + values[glyph_count++] = 101; break; - case 'C': linkage_flag = 100; + case C128_C0: + values[glyph_count++] = 100; break; } break; } - if (linkage_flag != 0) { - values[bar_characters++] = linkage_flag; - } - - c128_expand(symbol, values, bar_characters); + c128_expand(symbol, values, glyph_count); /* Add the separator pattern for composite symbols */ if (symbol->symbology == BARCODE_GS1_128_CC) { @@ -826,6 +625,12 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int } } + /* If no other warnings flag use of READER_INIT in GS1_MODE */ + if (error_number == 0 && (symbol->output_options & READER_INIT)) { + error_number = errtxt(ZINT_WARN_INVALID_OPTION, symbol, 845, + "Cannot use Reader Initialisation in GS1 mode, ignoring"); + } + if (symbol->input_mode & GS1PARENS_MODE) { i = length < (int) sizeof(symbol->text) ? length : (int) sizeof(symbol->text); memcpy(symbol->text, source, i); @@ -853,19 +658,24 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int return error_number; } -/* Handle EAN-128 (Now known as GS1-128) */ +/* Handle GS1-128 (formerly known as EAN-128) */ INTERNAL int gs1_128(struct zint_symbol *symbol, unsigned char source[], int length) { return gs1_128_cc(symbol, source, length, 0 /*cc_mode*/, 0 /*cc_rows*/); } -/* Add check digit if encoding an NVE18 symbol */ -INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int length) { - int i; - int error_number, zeroes; +/* Helper to do NVE18 or EAN14 */ +static int nve18_or_ean14(struct zint_symbol *symbol, unsigned char source[], const int length, const int data_len) { + static const char prefix[2][2][5] = { + { "(01)", "[01]" }, /* EAN14 */ + { "(00)", "[00]" }, /* NVE18 */ + }; unsigned char ean128_equiv[23]; + int error_number, zeroes; + int i; - if (length > 17) { - return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 345, "Input length %d too long (maximum 17)", length); + if (length > data_len) { + return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 345, "Input length %1$d too long (maximum %2$d)", length, + data_len); } if ((i = not_sane(NEON_F, source, length))) { @@ -874,47 +684,33 @@ INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int lengt "Invalid character at position %d in input (digits only)", i); } - zeroes = 17 - length; - ustrcpy(ean128_equiv, symbol->input_mode & GS1PARENS_MODE ? "(00)" : "[00]"); + zeroes = data_len - length; + ustrcpy(ean128_equiv, prefix[data_len == 17][!(symbol->input_mode & GS1PARENS_MODE)]); memset(ean128_equiv + 4, '0', zeroes); ustrcpy(ean128_equiv + 4 + zeroes, source); - ean128_equiv[21] = gs1_check_digit(ean128_equiv + 4, 17); - ean128_equiv[22] = '\0'; + ean128_equiv[data_len + 4] = gs1_check_digit(ean128_equiv + 4, data_len); + ean128_equiv[data_len + 5] = '\0'; - error_number = gs1_128(symbol, ean128_equiv, 22); + error_number = gs1_128(symbol, ean128_equiv, data_len + 5); return error_number; } + +/* Add check digit if encoding an NVE18 symbol */ +INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int length) { + return nve18_or_ean14(symbol, source, length, 17 /*data_len*/); +} + /* EAN-14 - A version of EAN-128 */ INTERNAL int ean14(struct zint_symbol *symbol, unsigned char source[], int length) { - int i; - int error_number, zeroes; - unsigned char ean128_equiv[19]; - - if (length > 13) { - return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 347, "Input length %d too long (maximum 13)", length); - } - - if ((i = not_sane(NEON_F, source, length))) { - return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 348, - "Invalid character at position %d in input (digits only)", i); - } - - zeroes = 13 - length; - ustrcpy(ean128_equiv, symbol->input_mode & GS1PARENS_MODE ? "(01)" : "[01]"); - memset(ean128_equiv + 4, '0', zeroes); - ustrcpy(ean128_equiv + 4 + zeroes, source); - - ean128_equiv[17] = gs1_check_digit(ean128_equiv + 4, 13); - ean128_equiv[18] = '\0'; - - error_number = gs1_128(symbol, ean128_equiv, 18); - - return error_number; + return nve18_or_ean14(symbol, source, length, 13 /*data_len*/); } +static const char KRSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +#define KRSET_F (IS_NUM_F | IS_UPR_F) + /* DPD (Deutscher Paketdienst) Code */ /* Specification at https://esolutions.dpd.com/dokumente/DPD_Parcel_Label_Specification_2.4.1_EN.pdf * and identification tag info (Barcode ID) at https://esolutions.dpd.com/dokumente/DPD_Routing_Database_1.3_EN.pdf */ diff --git a/backend/code128.h b/backend/code128.h index 54118ef7..6efd9b75 100644 --- a/backend/code128.h +++ b/backend/code128.h @@ -42,10 +42,6 @@ extern "C" { INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length); -INTERNAL void c128_set_a(const unsigned char source, int values[], int *bar_chars); -INTERNAL int c128_set_b(const unsigned char source, int values[], int *bar_chars); -INTERNAL void c128_set_c(const unsigned char source_a, const unsigned char source_b, int values[], int *bar_chars); - INTERNAL_DATA_EXTERN const char C128Table[107][6]; #ifdef __cplusplus diff --git a/backend/code16k.c b/backend/code16k.c index 1c04677e..3cdd885b 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -39,14 +39,14 @@ #include "common.h" #include "code128.h" -/* Note these previously defined in "code128.h" - keeping `C128_` prefix for now */ -#define C128_LATCHA 'A' -#define C128_LATCHB 'B' -#define C128_LATCHC 'C' -#define C128_SHIFTA 'a' -#define C128_SHIFTB 'b' -#define C128_ABORC '9' -#define C128_AORB 'Z' +/* Note these previously defined in "code128.h" with `C128_` prefix */ +#define C16K_LATCHA 'A' +#define C16K_LATCHB 'B' +#define C16K_LATCHC 'C' +#define C16K_SHIFTA 'a' +#define C16K_SHIFTB 'b' +#define C16K_ABORC '9' +#define C16K_AORB 'Z' /* Note using C128Table with extra entry at 106 (Triple Shift) for C16KTable */ @@ -70,19 +70,19 @@ static int c16k_parunmodd(const unsigned char llyth, const int check_fnc1) { int modd; if (llyth <= 31) { - modd = check_fnc1 && llyth == '\x1D' ? C128_ABORC : C128_SHIFTA; + modd = check_fnc1 && llyth == '\x1D' ? C16K_ABORC : C16K_SHIFTA; } else if ((llyth >= 48) && (llyth <= 57)) { - modd = C128_ABORC; + modd = C16K_ABORC; } else if (llyth <= 95) { - modd = C128_AORB; + modd = C16K_AORB; } else if (llyth <= 127) { - modd = C128_SHIFTB; + modd = C16K_SHIFTB; } else if (llyth <= 159) { - modd = C128_SHIFTA; + modd = C16K_SHIFTA; } else if (llyth <= 223) { - modd = C128_AORB; + modd = C16K_AORB; } else { - modd = C128_SHIFTB; + modd = C16K_SHIFTB; } return modd; @@ -120,13 +120,13 @@ static void c16k_dxsmooth(int list[2][C128_MAX], int *p_indexliste) { const int indexliste = *p_indexliste; for (i = 0; i < indexliste; i++) { - int current = list[1][i]; /* Either C128_ABORC, C128_AORB, C128_SHIFTA or C128_SHIFTB */ + int current = list[1][i]; /* Either C16K_ABORC, C16K_AORB, C16K_SHIFTA or C16K_SHIFTB */ int length = list[0][i]; if (i == nextshift_i) { nextshift = 0; /* Set next shift to aid deciding between latching to A or B - taken from Okapi, props Daniel Gredler */ for (j = i + 1; j < indexliste; j++) { - if (list[1][j] == C128_SHIFTA || list[1][j] == C128_SHIFTB) { + if (list[1][j] == C16K_SHIFTA || list[1][j] == C16K_SHIFTB) { nextshift = list[1][j]; nextshift_i = j; break; @@ -135,72 +135,72 @@ static void c16k_dxsmooth(int list[2][C128_MAX], int *p_indexliste) { } if (i == 0) { /* first block */ - if (current == C128_ABORC) { + if (current == C16K_ABORC) { if ((indexliste == 1) && (length == 2)) { /* Rule 1a */ - list[1][i] = C128_LATCHC; - current = C128_LATCHC; + list[1][i] = C16K_LATCHC; + current = C16K_LATCHC; } else if (length >= 4) { /* Rule 1b */ - list[1][i] = C128_LATCHC; - current = C128_LATCHC; + list[1][i] = C16K_LATCHC; + current = C16K_LATCHC; } else { - current = C128_AORB; /* Determine below */ + current = C16K_AORB; /* Determine below */ } } - if (current == C128_AORB) { - if (nextshift == C128_SHIFTA) { + if (current == C16K_AORB) { + if (nextshift == C16K_SHIFTA) { /* Rule 1c */ - list[1][i] = C128_LATCHA; + list[1][i] = C16K_LATCHA; } else { /* Rule 1d */ - list[1][i] = C128_LATCHB; + list[1][i] = C16K_LATCHB; } - } else if (current == C128_SHIFTA) { + } else if (current == C16K_SHIFTA) { /* Rule 1c */ - list[1][i] = C128_LATCHA; - } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */ + list[1][i] = C16K_LATCHA; + } else if (current == C16K_SHIFTB) { /* Unless C16K_LATCHX set above, can only be C16K_SHIFTB */ /* Rule 1d */ - list[1][i] = C128_LATCHB; + list[1][i] = C16K_LATCHB; } } else { int last = list[1][i - 1]; - if (current == C128_ABORC) { + if (current == C16K_ABORC) { if (length >= 4) { /* Rule 3 - note Rule 3b (odd C blocks) dealt with later */ - list[1][i] = C128_LATCHC; - current = C128_LATCHC; + list[1][i] = C16K_LATCHC; + current = C16K_LATCHC; } else { - current = C128_AORB; /* Determine below */ + current = C16K_AORB; /* Determine below */ } } - if (current == C128_AORB) { - if (last == C128_LATCHA || last == C128_SHIFTB) { /* Maintain state */ - list[1][i] = C128_LATCHA; - } else if (last == C128_LATCHB || last == C128_SHIFTA) { /* Maintain state */ - list[1][i] = C128_LATCHB; - } else if (nextshift == C128_SHIFTA) { - list[1][i] = C128_LATCHA; + if (current == C16K_AORB) { + if (last == C16K_LATCHA || last == C16K_SHIFTB) { /* Maintain state */ + list[1][i] = C16K_LATCHA; + } else if (last == C16K_LATCHB || last == C16K_SHIFTA) { /* Maintain state */ + list[1][i] = C16K_LATCHB; + } else if (nextshift == C16K_SHIFTA) { + list[1][i] = C16K_LATCHA; } else { - list[1][i] = C128_LATCHB; + list[1][i] = C16K_LATCHB; } - } else if (current == C128_SHIFTA) { + } else if (current == C16K_SHIFTA) { if (length > 1) { /* Rule 4 */ - list[1][i] = C128_LATCHA; - } else if (last == C128_LATCHA || last == C128_SHIFTB) { /* Maintain state */ - list[1][i] = C128_LATCHA; - } else if (last == C128_LATCHC) { - list[1][i] = C128_LATCHA; + list[1][i] = C16K_LATCHA; + } else if (last == C16K_LATCHA || last == C16K_SHIFTB) { /* Maintain state */ + list[1][i] = C16K_LATCHA; + } else if (last == C16K_LATCHC) { + list[1][i] = C16K_LATCHA; } - } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */ + } else if (current == C16K_SHIFTB) { /* Unless C16K_LATCHX set above, can only be C16K_SHIFTB */ if (length > 1) { /* Rule 5 */ - list[1][i] = C128_LATCHB; - } else if (last == C128_LATCHB || last == C128_SHIFTA) { /* Maintain state */ - list[1][i] = C128_LATCHB; - } else if (last == C128_LATCHC) { - list[1][i] = C128_LATCHB; + list[1][i] = C16K_LATCHB; + } else if (last == C16K_LATCHB || last == C16K_SHIFTA) { /* Maintain state */ + list[1][i] = C16K_LATCHB; + } else if (last == C16K_LATCHC) { + list[1][i] = C16K_LATCHB; } } } /* Rule 2 is implemented elsewhere, Rule 6 is implied */ @@ -272,6 +272,55 @@ static void c16k_put_in_set(int list[2][C128_MAX], const int indexliste, char se } } +/** + * Translate Code 128 Set A characters into barcodes (was `c128_set_a()`). + * This set handles all control characters NUL to US + */ +static void c16k_set_a(const unsigned char source, int values[], int *bar_chars) { + + if (source >= 128) { + if (source < 160) { + values[(*bar_chars)] = (source - 128) + 64; + } else { + values[(*bar_chars)] = (source - 128) - 32; + } + } else { + if (source < 32) { + values[(*bar_chars)] = source + 64; + } else { + values[(*bar_chars)] = source - 32; + } + } + (*bar_chars)++; +} + +/** + * Translate Code 128 Set B characters into barcodes (was `c128_set_b()`). + * This set handles all characters which are not part of long numbers and not + * control characters + */ +static int c16k_set_b(const unsigned char source, int values[], int *bar_chars) { + if (source >= 128 + 32) { + values[(*bar_chars)] = source - 32 - 128; + } else if (source >= 128) { /* Should never happen */ + return 0; /* Not reached */ + } else if (source >= 32) { + values[(*bar_chars)] = source - 32; + } else { /* Should never happen */ + return 0; /* Not reached */ + } + (*bar_chars)++; + return 1; +} + +/* Translate Code 128 Set C characters into barcodes (was `c128_set_c()`). + * This set handles numbers in a compressed form + */ +static void c16k_set_c(const unsigned char source_a, const unsigned char source_b, int values[], int *bar_chars) { + values[(*bar_chars)] = 10 * (source_a - '0') + source_b - '0'; + (*bar_chars)++; +} + /* Code 16k EN 12323:2005 */ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int length) { char width_pattern[40]; /* 4 (start) + 1 (guard) + 5*6 (chars) + 4 (stop) + 1 */ @@ -421,14 +470,14 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len if (!gs1 || source[read] != '\x1D') { switch (set[read]) { /* Encode data characters */ case 'A': - case 'a': c128_set_a(source[read], values, &bar_characters); + case 'a': c16k_set_a(source[read], values, &bar_characters); read++; break; case 'B': - case 'b': (void) c128_set_b(source[read], values, &bar_characters); + case 'b': (void) c16k_set_b(source[read], values, &bar_characters); read++; break; - case 'C': c128_set_c(source[read], source[read + 1], values, &bar_characters); + case 'C': c16k_set_c(source[read], source[read + 1], values, &bar_characters); read += 2; break; } diff --git a/backend/common.c b/backend/common.c index 778ef88c..9f887216 100644 --- a/backend/common.c +++ b/backend/common.c @@ -46,14 +46,6 @@ INTERNAL int ctoi(const char source) { return -1; } -/* Converts an integer value to its hexadecimal character */ -INTERNAL char itoc(const int source) { - if ((source >= 0) && (source <= 9)) { - return ('0' + source); - } - return ('A' - 10 + source); -} - /* Converts decimal string of length <= 9 to integer value. Returns -1 if not numeric */ INTERNAL int to_int(const unsigned char source[], const int length) { int val = 0; @@ -219,17 +211,15 @@ INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int length) { int reader; - int writer, i; - int latch, num; + int writer = 0; + int latch = 1; const int row = symbol->rows; symbol->rows++; - writer = 0; - latch = 1; - for (reader = 0; reader < length; reader++) { - num = ctoi(data[reader]); + int i; + const int num = data[reader] - '0'; assert(num >= 0); for (i = 0; i < num; i++) { if (latch) { diff --git a/backend/common.h b/backend/common.h index 79248df1..e419aa73 100644 --- a/backend/common.h +++ b/backend/common.h @@ -145,12 +145,12 @@ typedef unsigned __int64 uint64_t; #define ustrcat(target, source) strcat((char *) (target), (const char *) (source)) #define ustrncat(target, source, count) strncat((char *) (target), (const char *) (source), (count)) +/* Converts an integer value to its value + '0' (so >= 10 becomes ':', ';' etc) */ +#define itoc(i) ((i) + '0') + /* Converts a character 0-9, A-F to its equivalent integer value */ INTERNAL int ctoi(const char source); -/* Converts an integer value to its hexadecimal character */ -INTERNAL char itoc(const int source); - /* Converts decimal string of length <= 9 to integer value. Returns -1 if not numeric */ INTERNAL int to_int(const unsigned char source[], const int length); diff --git a/backend/library.c b/backend/library.c index af9edac1..de0bc1ff 100644 --- a/backend/library.c +++ b/backend/library.c @@ -981,6 +981,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ int error_number, warn_number = 0; int total_len = 0; int have_zero_eci = 0; + int escape_mode; int i; unsigned char *local_source; struct zint_seg *local_segs; @@ -1012,6 +1013,9 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ } } + escape_mode = (symbol->input_mode & ESCAPE_MODE) + || ((symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128); + local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * (seg_count > 0 ? seg_count : 1)); /* Check segment lengths */ @@ -1039,7 +1043,8 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ } return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL); } - if (symbol->input_mode & ESCAPE_MODE) { /* Calculate de-escaped length for check against ZINT_MAX_DATA_LEN */ + /* Calculate de-escaped length for check against ZINT_MAX_DATA_LEN */ + if (escape_mode) { int escaped_len = local_segs[i].length; error_number = escape_char_process(symbol, local_segs[i].source, &escaped_len, NULL /*escaped_string*/); if (error_number != 0) { /* Only returns errors, not warnings */ @@ -1168,7 +1173,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ /* Copy input, de-escaping if required */ for (i = 0, local_source = local_sources; i < seg_count; i++) { local_segs[i].source = local_source; - if (symbol->input_mode & ESCAPE_MODE) { + if (escape_mode) { /* Checked already */ (void) escape_char_process(symbol, segs[i].source, &local_segs[i].length, local_segs[i].source); } else { @@ -1178,7 +1183,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ local_source += local_segs[i].length + 1; } - if ((symbol->input_mode & ESCAPE_MODE) && symbol->primary[0] && strchr(symbol->primary, '\\') != NULL) { + if (escape_mode && symbol->primary[0] && strchr(symbol->primary, '\\') != NULL) { char primary[sizeof(symbol->primary)]; int primary_len = (int) strlen(symbol->primary); if (primary_len >= (int) sizeof(symbol->primary)) { diff --git a/backend/plessey.c b/backend/plessey.c index 0d30d928..d7044b50 100644 --- a/backend/plessey.c +++ b/backend/plessey.c @@ -151,7 +151,7 @@ static char msi_check_digit_mod11(const unsigned char source[], const int length } } - return itoc((11 - x % 11) % 11); /* Will return 'A' for 10 */ + return itoc((11 - x % 11) % 11); /* Will return ':' for 10 */ } /* Plain MSI Plessey - does not calculate any check character */ @@ -241,7 +241,7 @@ static char *msi_plessey_mod11(struct zint_symbol *symbol, const unsigned char s /* Append check digit */ check_digit = msi_check_digit_mod11(source, length, wrap); - if (check_digit == 'A') { + if (check_digit == ':') { memcpy(d, MSITable[1], 8); d += 8; memcpy(d, MSITable[0], 8); @@ -254,7 +254,7 @@ static char *msi_plessey_mod11(struct zint_symbol *symbol, const unsigned char s symbol->text[0] = '\0'; ustrncat(symbol->text, source, length); if (!no_checktext) { - if (check_digit == 'A') { + if (check_digit == ':') { ustrcat(symbol->text, "10"); } else { symbol->text[length] = check_digit; @@ -279,7 +279,7 @@ static char *msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char /* Append first (mod 11) digit */ check_digit = msi_check_digit_mod11(source, length, wrap); - if (check_digit == 'A') { + if (check_digit == ':') { temp[temp_len++] = '1'; temp[temp_len++] = '0'; } else { diff --git a/backend/tests/README b/backend/tests/README index 62d527f9..e34a685b 100644 --- a/backend/tests/README +++ b/backend/tests/README @@ -1,4 +1,4 @@ -% backend/tests/README 2024-01-17 +% backend/tests/README 2024-11-18 Zint backend test suite ----------------------- @@ -67,6 +67,16 @@ To run a single test function within an individual test, use '-f ': backend/tests/test_common -f utf8_to_unicode backend/tests/test_dotcode -f input +To exclude a single test function, use '-n ': + + backend/tests/test_common -n utf8_to_unicode + backend/tests/test_dotcode -n input + +To run all test functions that match (i.e. contain) a string, use '-m ': + + backend/tests/test_common -m not_sane + backend/tests/test_dotcode -m encode + To run a single dataset item in a single test function, use '-i ': backend/tests/test_dotcode -f input -i 2 @@ -75,6 +85,10 @@ To run a range of dataset items in a single test function, use '-i - backend/tests/test_dotcode -f input -i 2-5 +The '' or '' can be left out: + + backend/tests/test_dotcode -f input -i 2- + To exclude a single dataset item in a single test function, use '-x ': backend/tests/test_dotcode -f input -x 4 @@ -113,7 +127,7 @@ To run a test against ZXing-C++ (if any), use '-d 512': (see also /backend/tests/tools/run_zxingcpp_tests.sh) -To generate test data, use '-g': +To generate test data (if available), use '-g': backend/tests/test_dotcode -f encode -g diff --git a/backend/tests/test_codablock.c b/backend/tests/test_codablock.c index 1317b40f..6fe1be09 100644 --- a/backend/tests/test_codablock.c +++ b/backend/tests/test_codablock.c @@ -60,8 +60,8 @@ static void test_large(const testCtx *const p_ctx) { /* 8*/ { -1, -1, "\351", 2726 / 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" }, /* 9*/ { -1, -1, "\001", 2726, 0, 44, 739, "" }, /* 10*/ { -1, -1, "\001", 2727, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" }, - /* 11*/ { 1, -1, "A", 99, 0, 1, 1124, "" }, /* CODE128 99 max */ - /* 12*/ { 1, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, + /* 11*/ { 1, -1, "A", 101, 0, 1, 1146, "" }, /* CODE128 102 max (including start code) */ + /* 12*/ { 1, -1, "A", 102, ZINT_ERROR_TOO_LONG, -1, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, /* 13*/ { 2, -1, "A", 122, 0, 2, 739, "" }, /* 14*/ { 2, 10, "A", 122, 0, 2, 739, "" }, /* Cols 10 -> 67 */ /* 15*/ { 2, 67, "A", 122, 0, 2, 739, "" }, diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index 417539aa..1ef3e258 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -38,6 +38,7 @@ static void test_large(const testCtx *const p_ctx) { struct item { int symbology; + int input_mode; int output_options; char *pattern; int length; @@ -50,34 +51,47 @@ static void test_large(const testCtx *const p_ctx) { */ /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_CODE128, -1, "A", 99, 0, 1124, "" }, - /* 1*/ { BARCODE_CODE128, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, - /* 2*/ { BARCODE_CODE128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, - /* 3*/ { BARCODE_CODE128, -1, "abcd\201\202\203\204", 58, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, - /* 4*/ { BARCODE_CODE128, READER_INIT, "A", 99, 0, 1135, "" }, - /* 5*/ { BARCODE_CODE128, READER_INIT, "A", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, - /* 6*/ { BARCODE_CODE128, READER_INIT, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, - /* 7*/ { BARCODE_CODE128, -1, "\351A", 66, 0, 1124, "" }, - /* 8*/ { BARCODE_CODE128, -1, "\351A", 67, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 101 symbol characters (maximum 99)" }, /* 67 chars (+ 34 shifts) */ - /* 9*/ { BARCODE_CODE128, -1, "\351", 97, 0, 1124, "" }, /* Less 2 FNC4s for latch */ - /* 10*/ { BARCODE_CODE128, -1, "\351", 98, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, - /* 11*/ { BARCODE_CODE128, -1, "0", 198, 0, 1124, "" }, - /* 12*/ { BARCODE_CODE128, -1, "0", 199, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 101 symbol characters (maximum 99)" }, - /* 13*/ { BARCODE_CODE128, -1, "0", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, - /* 14*/ { BARCODE_CODE128AB, -1, "A", 99, 0, 1124, "" }, - /* 15*/ { BARCODE_CODE128AB, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, - /* 16*/ { BARCODE_CODE128AB, -1, "0", 99, 0, 1124, "" }, - /* 17*/ { BARCODE_CODE128AB, -1, "0", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" }, - /* 18*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_WARN_HRT_TRUNCATED, 1135, "Warning 844: Human Readable Text truncated" }, /* 196 nos + 3 FNC1s */ - /* 19*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 101 symbol characters (maximum 99)" }, /* 196 nos + CodeA + single no. + 3 FNC1s */ - /* 20*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 100 symbol characters (maximum 99)" }, /* 198 nos + 3 FNC1s */ - /* 21*/ { BARCODE_GS1_128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 342: Input length 257 too long (maximum 256)" }, - /* 22*/ { BARCODE_EAN14, -1, "1234567890123", -1, 0, 134, "" }, - /* 23*/ { BARCODE_EAN14, -1, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1, "Error 347: Input length 14 too long (maximum 13)" }, - /* 24*/ { BARCODE_NVE18, -1, "12345678901234567", -1, 0, 156, "" }, - /* 25*/ { BARCODE_NVE18, -1, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)" }, - /* 26*/ { BARCODE_HIBC_128, -1, "1", 110, 0, 684, "" }, - /* 27*/ { BARCODE_HIBC_128, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1, "Error 202: Input length 111 too long for HIBC LIC (maximum 110)" }, + /* 0*/ { BARCODE_CODE128, -1, -1, "A", 101, 0, 1146, "" }, + /* 1*/ { BARCODE_CODE128, -1, -1, "A", 102, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 2*/ { BARCODE_CODE128, -1, -1, "A", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 257 symbol characters (maximum 102)" }, + /* 3*/ { BARCODE_CODE128, -1, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, + /* 4*/ { BARCODE_CODE128, -1, -1, "abcd\201\202\203\204", 60, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 5*/ { BARCODE_CODE128, -1, READER_INIT, "A", 100, 0, 1146, "" }, + /* 6*/ { BARCODE_CODE128, -1, READER_INIT, "A", 101, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 7*/ { BARCODE_CODE128, -1, READER_INIT, "A", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 258 symbol characters (maximum 102)" }, + /* 8*/ { BARCODE_CODE128, -1, READER_INIT, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, + /* 9*/ { BARCODE_CODE128, -1, -1, "\351A", 67, 0, 1146, "" }, + /* 10*/ { BARCODE_CODE128, -1, -1, "\351A", 68, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, /* 67 chars (+ 34 shifts) */ + /* 11*/ { BARCODE_CODE128, -1, -1, "\351A", 255, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 384 symbol characters (maximum 102)" }, + /* 12*/ { BARCODE_CODE128, -1, -1, "\351A", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 385 symbol characters (maximum 102)" }, + /* 13*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, READER_INIT, "\\^A\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 510 symbol characters (maximum 102)" }, + /* 14*/ { BARCODE_CODE128, -1, -1, "\351", 99, 0, 1146, "" }, /* Less 2 FNC4s for latch */ + /* 15*/ { BARCODE_CODE128, -1, -1, "\351", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 16*/ { BARCODE_CODE128, -1, -1, "\351", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 259 symbol characters (maximum 102)" }, + /* 17*/ { BARCODE_CODE128, -1, -1, "0", 199, 0, 1146, "" }, + /* 18*/ { BARCODE_CODE128, -1, -1, "0", 200, 0, 1135, "" }, + /* 19*/ { BARCODE_CODE128, -1, -1, "0", 201, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 20*/ { BARCODE_CODE128, -1, -1, "0", 202, 0, 1146, "" }, + /* 21*/ { BARCODE_CODE128, -1, -1, "0", 203, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 104 symbol characters (maximum 102)" }, + /* 22*/ { BARCODE_CODE128, -1, -1, "0", 204, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 23*/ { BARCODE_CODE128, -1, -1, "0", 256, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 129 symbol characters (maximum 102)" }, + /* 24*/ { BARCODE_CODE128, -1, -1, "0", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" }, + /* 25*/ { BARCODE_CODE128AB, -1, -1, "A", 101, 0, 1146, "" }, + /* 26*/ { BARCODE_CODE128AB, -1, -1, "A", 102, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 27*/ { BARCODE_CODE128AB, -1, -1, "0", 101, 0, 1146, "" }, + /* 28*/ { BARCODE_CODE128AB, -1, -1, "0", 102, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 103 symbol characters (maximum 102)" }, + /* 29*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_WARN_NONCOMPLIANT, 1135, "Warning 843: Input too long, requires 196 characters (maximum 48)" }, /* StartC + 194 nos + 3 FNC1s */ + /* 30*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 103 symbol characters (maximum 102)" }, /* StartC + 194 nos + CodeA + single no. + 3 FNC1s */ + /* 31*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, ZINT_WARN_NONCOMPLIANT, 1146, "Warning 843: Input too long, requires 198 characters (maximum 48)" }, /* StartC + 196 nos + 3 FNC1s */ + /* 32*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234[93]123", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 104 symbol characters (maximum 102)" }, /* StartC + 194 nos + CodeA + single no. + 3 FNC1s */ + /* 33*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345[93]1", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 132 symbol characters (maximum 102)" }, + /* 34*/ { BARCODE_GS1_128, -1, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345[93]12", -1, ZINT_ERROR_TOO_LONG, -1, "Error 342: Input length 257 too long (maximum 256)" }, + /* 35*/ { BARCODE_EAN14, -1, -1, "1234567890123", -1, 0, 134, "" }, + /* 36*/ { BARCODE_EAN14, -1, -1, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 14 too long (maximum 13)" }, + /* 37*/ { BARCODE_NVE18, -1, -1, "12345678901234567", -1, 0, 156, "" }, + /* 38*/ { BARCODE_NVE18, -1, -1, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)" }, + /* 39*/ { BARCODE_HIBC_128, -1, -1, "1", 110, 0, 684, "" }, + /* 40*/ { BARCODE_HIBC_128, -1, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1, "Error 202: Input length 111 too long for HIBC LIC (maximum 110)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -85,6 +99,15 @@ static void test_large(const testCtx *const p_ctx) { char data_buf[4096]; + char escaped[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ + testStartSymbol("test_large", &symbol); for (i = 0; i < data_size; i++) { @@ -101,7 +124,7 @@ static void test_large(const testCtx *const p_ctx) { strcpy(data_buf, data[i].pattern); } - length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data_buf, data[i].length, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, data[i].output_options, data_buf, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); @@ -110,6 +133,34 @@ static void test_large(const testCtx *const p_ctx) { if (ret < ZINT_ERROR) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); + + if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { + if (data[i].output_options != -1 && (data[i].output_options & READER_INIT)) { + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), "READER_INIT not supported"); + } else { + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, -1, -1, -1, data_buf, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); + } + } + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data_buf, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data_buf, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data_buf, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } } ZBarcode_Delete(symbol); @@ -142,7 +193,7 @@ static void test_hrt(const testCtx *const p_ctx) { /* 4*/ { BARCODE_CODE128, UNICODE_MODE, -1, "abcdé", -1, "abcdé" }, /* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "abcd\351", -1, "abcdé" }, /* 6*/ { BARCODE_CODE128, DATA_MODE, -1, "ab\240cd\351", -1, "ab\302\240cdé" }, /* NBSP */ - /* 7*/ { BARCODE_CODE128, ESCAPE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */ + /* 7*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678" }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */ /* 8*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "abcdé", -1, "abcdé" }, /* 9*/ { BARCODE_CODE128AB, DATA_MODE, -1, "abcd\351", -1, "abcdé" }, /* 10*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "1234567890", -1, "*+12345678900*" }, @@ -183,6 +234,15 @@ static void test_hrt(const testCtx *const p_ctx) { int i, length, ret; struct zint_symbol *symbol = NULL; + char escaped[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ + testStartSymbol("test_hrt", &symbol); for (i = 0; i < data_size; i++) { @@ -201,6 +261,37 @@ static void test_hrt(const testCtx *const p_ctx) { assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->text, data[i].expected); + if (ret < ZINT_ERROR) { + if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { + if (data[i].symbology == BARCODE_HIBC_128 + && not_sane(IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_PLS_F | IS_MNS_F | IS_SIL_F, (const unsigned char *) data[i].data, length)) { + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), "BWIPP does not uppercase input"); + } else { + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); + } + } + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } + } + ZBarcode_Delete(symbol); } @@ -222,19 +313,26 @@ static void test_reader_init(const testCtx *const p_ctx) { char *comment; }; static const struct item data[] = { - /* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartA FNC3 A" }, + /* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartB FNC3 A" }, /* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" }, - /* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" }, - /* 3*/ { BARCODE_GS1_128, GS1_MODE, READER_INIT, "[90]12", 0, 1, 68, "(6) 105 102 90 12 11 106", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, - /* 4*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", 0, 1, 134, "(12) 105 102 1 0 0 0 0 0 1 23 12 106", "StartC FNC1 01 00 (5) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, - /* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 23 58 106", "StartC FNC1 00 (8) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, - /* 6*/ { BARCODE_HIBC_128, UNICODE_MODE, READER_INIT, "A", 0, 1, 79, "(7) 104 96 11 33 24 5 106", "StartA FNC3 + A 8 (check) (Not sensible, use CODE128)" }, + /* 2*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "1234", 0, 1, 79, "(7) 104 96 99 12 34 55 106", "StartB FNC3 CodeC 12 34" }, + /* 3*/ { BARCODE_CODE128AB, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" }, + /* 4*/ { BARCODE_GS1_128, GS1_MODE, READER_INIT, "[90]12", ZINT_WARN_INVALID_OPTION, 1, 68, "Warning 845: Cannot use Reader Initialisation in GS1 mode, ignoring", "StartC FNC1 90 12 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, + /* 5*/ { BARCODE_EAN14, GS1_MODE, READER_INIT, "12", ZINT_WARN_INVALID_OPTION, 1, 134, "Warning 845: Cannot use Reader Initialisation in GS1 mode, ignoring", "StartC FNC1 01 00 (5) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, + /* 6*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", ZINT_WARN_INVALID_OPTION, 1, 156, "Warning 845: Cannot use Reader Initialisation in GS1 mode, ignoring", "StartC FNC1 00 (8) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" }, + /* 7*/ { BARCODE_HIBC_128, UNICODE_MODE, READER_INIT, "A", 0, 1, 79, "(7) 104 96 11 33 24 5 106", "StartB FNC3 + A 8 (check) (Not sensible, use CODE128)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; char escaped[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ testStartSymbol("test_reader_init", &symbol); @@ -258,11 +356,25 @@ static void test_reader_init(const testCtx *const p_ctx) { testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment); } else { + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); if (ret < ZINT_ERROR) { assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } } - assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } ZBarcode_Delete(symbol); @@ -298,127 +410,138 @@ static void test_input(const testCtx *const p_ctx) { /* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 204: Invalid character in input (ISO/IEC 8859-1 only)", "PAD not in ISO 8859-1" }, /* 1*/ { DATA_MODE, "\200", -1, 0, 57, 1, "(5) 103 101 64 23 106", "PAD ok using binary" }, /* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, 1, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" }, - /* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP no manual mode" }, - /* 4*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape ignored; BWIPP no manual mode" }, - /* 5*/ { UNICODE_MODE | ESCAPE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape ignored; BWIPP no manual mode" }, - /* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^C", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 842: No input data", "" }, - /* 7*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^^B\\^C", -1, 0, 68, 0, "(6) 103 60 62 34 80 106", "BWIPP no manual mode" }, - /* 8*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^^C", -1, 0, 68, 1, "(6) 104 60 62 35 84 106", "" }, - /* 9*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, - /* 10*/ { UNICODE_MODE | ESCAPE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, - /* 11*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A", -1, 0, 68, 1, "(6) 104 60 62 33 78 106", "" }, - /* 12*/ { GS1_MODE, "[90]12", -1, ZINT_ERROR_INVALID_OPTION, 0, 1, "Error 220: Selected symbology does not support GS1 mode", "" }, - /* 13*/ { UNICODE_MODE, "1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1" }, - /* 14*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1", -1, 0, 46, 0, "(4) 103 17 17 106", "StartA 1; BWIPP no manual mode" }, - /* 15*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (manual C ignored as odd); BWIPP no manual mode" }, - /* 16*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^A", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (escape at end ignored); BWIPP no manual mode" }, - /* 17*/ { UNICODE_MODE, "12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, - /* 18*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, - /* 19*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12", -1, 0, 57, 0, "(5) 104 17 18 54 106", "StartB 1 2; BWIPP no manual mode" }, - /* 20*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A12", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2; BWIPP no manual mode" }, - /* 21*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^B2", -1, 0, 68, 0, "(6) 103 17 100 18 65 106", "StartA 1 CodeB 2; BWIPP no manual mode" }, - /* 22*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^A2", -1, 0, 68, 0, "(6) 104 17 101 18 68 106", "StartB 1 CodeA 2; BWIPP no manual mode" }, - /* 23*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^C2", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2 (manual C ignored as odd); BWIPP no manual mode" }, - /* 24*/ { UNICODE_MODE, "123", -1, 0, 68, 0, "(6) 105 12 100 19 65 106", "StartC 12 CodeB; BWIPP StartB, same codeword count" }, - /* 25*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A123", -1, 0, 68, 0, "(6) 103 17 18 19 7 106", "StartA 1 2 3; BWIPP no manual mode" }, - /* 26*/ { UNICODE_MODE, "1234", -1, 0, 57, 1, "(5) 105 12 34 82 106", "StartC 12 34" }, - /* 27*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1234", -1, 0, 79, 0, "(7) 104 17 18 19 20 88 106", "StartB 1 2 3 4; BWIPP no manual mode" }, - /* 28*/ { UNICODE_MODE, "12345", -1, 0, 79, 1, "(7) 105 12 34 100 21 54 106", "StartC 12 34 CodeB 5" }, - /* 29*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^A5", -1, 0, 79, 0, "(7) 105 12 34 101 21 57 106", "StartC 12 34 CodeA 5; BWIPP no manual mode" }, - /* 30*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^C2345", -1, 0, 79, 0, "(7) 104 17 99 23 45 53 106", "StartB 1 CodeC 23 45; BWIPP no manual mode" }, - /* 31*/ { UNICODE_MODE, "\037", -1, 0, 46, 1, "(4) 103 95 95 106", "StartA US" }, - /* 32*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\037", -1, 0, 57, 0, "(5) 104 98 95 83 106", "StartB ShA ; BWIPP no manual mode" }, - /* 33*/ { UNICODE_MODE, "1\037", -1, 0, 57, 1, "(5) 103 17 95 1 106", "StartA 1 US" }, - /* 34*/ { UNICODE_MODE, "12\037", -1, 0, 68, 0, "(6) 105 12 101 95 89 106", "StartC 12 CodeA US; BWIPP StartA, same codeword count" }, - /* 35*/ { UNICODE_MODE, "a\037a", -1, 0, 79, 1, "(7) 104 65 98 95 65 86 106", "StartB a Shift US a" }, - /* 36*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aa\037a", -1, 0, 90, 0, "(8) 103 98 65 95 98 65 97 106", "StartA ShB a ShB a; BWIPP no manual mode" }, - /* 37*/ { UNICODE_MODE, "1234\037a", -1, 0, 101, 0, "(9) 105 12 34 101 95 100 65 7 106", "StartC 12 34 CodeA US CodeB a; BWIPP different encodation" }, - /* 38*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Ba", -1, 0, 101, 0, "(9) 105 12 34 101 95 100 65 7 106", "StartC 12 34 CodeA US CodeB a; BWIPP different encodation" }, - /* 39*/ { UNICODE_MODE, "\037AAa\037", -1, 0, 101, 1, "(9) 103 95 33 33 98 65 95 2 106", "StartA US A A Shift a US" }, - /* 40*/ { UNICODE_MODE, "\037AAaa\037", -1, 0, 123, 0, "(11) 103 95 100 33 33 65 65 101 95 30 106", "StartA US CodeB A A a a CodeA US; BWIPP different encodation" }, - /* 41*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\037AAaa\\^A\037", -1, 0, 123, 0, "(11) 103 95 100 33 33 65 65 101 95 30 106", "StartA CodeB A A a a CodeA ; BWIPP no manual mode" }, - /* 42*/ { UNICODE_MODE, "AAAa12345aAA", -1, 0, 167, 0, "(15) 104 33 33 33 65 99 12 34 100 21 65 33 33 57 106", "StartB A A A a CodeC 12 34 CodeB 5 a A A; BWIPP different encodation" }, - /* 43*/ { UNICODE_MODE, "a\037Aa\037\037a\037aa\037a", -1, 0, 222, 0, "(20) 104 65 101 95 33 98 65 95 95 100 65 98 95 65 65 98 95 65 42 106", "StartB a CodeA US A ShB a US US CodeB a ShA US a a ShA US a; BWIPP different encodation" }, - /* 44*/ { UNICODE_MODE, "\000\037ß", 4, 0, 79, 1, "(7) 103 64 95 101 63 88 106", "StartA NUL US FNC4 ß" }, - /* 45*/ { UNICODE_MODE, "\000\037é", 4, 0, 90, 1, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é" }, - /* 46*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\000\037\\^Bé", 7, 0, 90, 1, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é" }, - /* 47*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 1, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US CodeB FNC4 é a" }, - /* 48*/ { UNICODE_MODE, "abß", -1, 0, 79, 1, "(7) 104 65 66 100 63 29 106", "StartB a b FNC4 ß" }, - /* 49*/ { DATA_MODE, "\141\142\237", -1, 0, 90, 0, "(8) 104 65 66 101 101 95 41 106", "StartB a b CodeA FNC4 APC; BWIPP different encodation" }, - /* 50*/ { DATA_MODE, "\141\142\237\037", -1, 0, 101, 1, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b CodeA FNC4 APC US" }, - /* 51*/ { UNICODE_MODE, "ééé", -1, 0, 90, 1, "(8) 104 100 100 73 73 73 44 106", "StartB LatchFNC4 é é é" }, - /* 52*/ { UNICODE_MODE, "aéééb", -1, 0, 123, 1, "(11) 104 65 100 73 100 73 100 73 66 5 106", "StartB a FNC4 é (4) b" }, - /* 53*/ { UNICODE_MODE, "aééééb", -1, 0, 134, 1, "(12) 104 65 100 100 73 73 73 73 100 66 64 106", "StartB a Latch é (4) Shift b" }, - /* 54*/ { UNICODE_MODE, "aéééééb", -1, 0, 145, 1, "(13) 104 65 100 100 73 73 73 73 73 100 66 93 106", "StartB a Latch é (5) Shift b" }, - /* 55*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 0, "(15) 104 65 100 100 73 73 73 73 73 100 66 100 67 40 106", "StartB a Latch é (5) Shift b Shift c; BWIPP different encodation" }, - /* 56*/ { UNICODE_MODE, "aééééébcd", -1, 0, 178, 1, "(16) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 66 106", "StartB a Latch é (5) Unlatch b c d" }, - /* 57*/ { UNICODE_MODE, "aééééébcde", -1, 0, 189, 1, "(17) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 2 106", "StartB a Latch é (5) Unlatch b c d e" }, - /* 58*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 1, "(19) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 95 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é" }, - /* 59*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 1, "(21) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 100 73 19 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é (2)" }, - /* 60*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 0, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3); BWIPP different encodation" }, - /* 61*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, 1, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, - /* 62*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 211, 1, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "StartA FNC4 FNC4 PAD (5) FNC4 A CodeC 00 00 CodeA FNC4 A PAD" }, - /* 63*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 1, "(19) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 63 106", "Okapi code128/extended-mode-exit-before-code-set-c.png (chose different solution)" }, - /* 64*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 1, "(21) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 100 33 91 106", "Above with trailing non-shifted (as still latched) extended" }, - /* 65*/ { DATA_MODE, "@g(\202\202\202\202\2025555\202\202\202\202\202\202\202\202", -1, 0, 288, 1, "(26) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 101 66 66 66 66 66 66 66 66 10 106", "Okapi code128/extended-mode-with-short-embedded-code-set-c.png (chose different solution)" }, - /* 66*/ { DATA_MODE, "@g(\202\202\202\202\20255555\202\202\202\202\202\202\202", -1, 0, 299, 1, "(27) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 101 101 21 66 66 66 66 66 66 66 50 106", "Above with extra 5" }, - /* 67*/ { DATA_MODE, "@g(\202\202\202\202\202555555\202\202\202\202\202\202\202", -1, 0, 288, 1, "(26) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 55 101 66 66 66 66 66 66 66 86 106", "Above with extra 55, one less \\202" }, - /* 68*/ { DATA_MODE, "@g(\202\202\202\202\202555\202\202\202\202\202\202\202\202", -1, 0, 310, 0, "(28) 104 32 71 8 101 101 101 66 66 66 66 66 101 21 101 21 101 21 66 66 66 66 66 66 66 66 5", "Above less one 5; BWIPP different encodation (BWIPP 1 shorter)" }, - /* 69*/ { UNICODE_MODE, "±±±±1234AA", -1, 0, 189, 0, "(17) 104 100 100 17 17 17 17 99 12 34 100 100 33 100 33 89 106", "BWIPP different encodation" }, - /* 70*/ { UNICODE_MODE, "ÁÁèÁÁFç7Z", -1, 0, 189, 0, "(17) 104 100 100 33 33 72 33 33 100 38 71 100 100 23 58 95 106", "Okapi code128/extended-mode-shift.png; BWIPP different encodation" }, - /* 71*/ { UNICODE_MODE, "m\nm\nm", -1, 0, 112, 1, "(10) 104 77 98 74 77 98 74 77 11 106", "Okapi code128/code-set-b-a-b-a-b.png" }, - /* 72*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" }, - /* 73*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" }, - /* 74*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP different encodation, ShA instead of CodeA" }, - /* 75*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\012àa\\^A\0121\012\\^BàAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP different encodation, ShA instead of CodeA" }, - /* 76*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP different encodation" }, - /* 77*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ1234\012à\\^Aa\0121\012\\^C7890\\^BàAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 101 74 101 98 64 98 65 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP no manual mode" }, - /* 78*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 89 100 95 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation" }, - /* 79*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 89 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation" }, - /* 80*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 100 95 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33", "BWIPP different encodation" }, - /* 81*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 662, 0, "(60) 104 100 95 99 12 34 56 78 101 74 100 100 64 99 12 34 56 78 100 65 66 67 68 69 70 101", "BWIPP different encodation" }, - /* 82*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 200, 1, "(18) 104 0 100 100 1 1 1 1 100 0 1 1 1 1 100 0 91 106", "StartB Latch (4) FNC4 (4) FNC4 , adapted from BWIPP PR #272" }, - /* 83*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 222, 1, "(20) 104 0 100 100 1 1 1 1 100 0 100 0 1 1 1 1 100 0 63 106", "2 middle spaces" }, - /* 84*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 244, 1, "(22) 104 0 100 100 1 1 1 1 100 0 100 0 100 0 1 1 1 1 100 0 29 106", "3 middle spaces" }, - /* 85*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 266, 0, "(24) 104 0 100 100 1 1 1 1 100 0 100 0 100 0 100 0 1 1 1 1 100 0 92 106", "4 middle spaces (no unlatch); BWIPP different encodation" }, - /* 86*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 277, 0, "(25) 104 0 100 100 1 1 1 1 100 100 0 0 0 0 0 100 100 1 1 1 1 100 0 81 106", "5 middle spaces (unlatch); BWIPP different encodation" }, - /* 87*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 12\\^1 ", -1, 0, 90, 1, "(8) 104 0 17 18 102 0 85 106", "BWIPP PR #272" }, - /* 88*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 1234\\^1567", -1, 0, 123, 1, "(11) 104 0 99 12 34 102 56 100 23 41 106", "BWIPP PR #272" }, - /* 89*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^14567", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 67 84 106", "BWIPP PR #272" }, - /* 90*/ { DATA_MODE | ESCAPE_MODE | EXTRA_ESCAPE_MODE, "\\d031\\d031_\\d127\\d159\\d031\\d159\\d159\\d159\\d15912345``\\d255\\d000\\d127\\d255\\d224\\d224\\d159`", -1, 0, 442, 0, "(40) 103 95 95 63 98 95 101 95 95 101 101 95 95 95 95 99 12 34 100 100 100 21 64 64 100 95", "Code set limit chars; BWIPP different encodation" }, - /* 91*/ { DATA_MODE, "\200\200\200\200\200A0000A\200", -1, 0, 211, 1, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "" }, - /* 92*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^167\\^18", -1, 0, 145, 1, "(13) 105 12 102 34 100 21 102 22 23 102 24 49 106", "" }, - /* 93*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP no manual mode" }, - /* 94*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 100 33 34 35 99 12 101 74 36 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA ; BWIPP no manual mode" }, - /* 95*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF" }, - /* 96*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 0, "(13) 103 33 74 99 12 34 101 33 17 18 74 99 106", "StartA A CodeC 12 34 CodeA A 1 2 ; Okapi c128/improved-lookahead-mode-a.png; BWIPP different encodation" }, - /* 97*/ { UNICODE_MODE, "21*\015\012M0", -1, 0, 112, 0, "(10) 105 21 101 10 77 74 45 16 79 106", "StartC 21 CodeA * M 0; Okapi c128/improved-lookahead-rule-1c.png; BWIPP different encodation, same width" }, - /* 98*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^112345\\^11234\\^112345", -1, 0, 178, 1, "(16) 104 102 17 99 23 45 102 12 34 102 12 34 100 21 72 106", "Okapi code128/fnc1-mode-c-fnc1-in-middle.png" }, - /* 99*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^1SN123456789012", -1, 0, 145, 1, "(13) 104 102 51 46 99 12 34 56 78 90 12 65 106", "StartB FNC1 S N CodeC 12 34 56 78 90 12" }, - /*100*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1SN123456789012", -1, 0, 200, 0, "(18) 104 102 51 46 17 18 19 20 21 22 23 24 25 16 17 18 56 106", "StartB FNC1 S N 1 2 3 4 5 6 7 8 9 0 1 2; BWIPP no manual mode" }, - /*101*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^1BC\\^1DEF\\^1", -1, 0, 134, 1, "(12) 104 33 102 34 35 102 36 37 38 102 9 106", "StartB A FNC1 B C FNC1 D E F FNC1" }, - /*102*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP no manual mode" }, - /*103*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 0, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3; BWIPP different encodation, StartB so FNC1 not recognized as AIM" }, - /*104*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13\\^1", -1, 0, 90, 0, "(8) 105 12 102 100 19 102 74 106", "StartC 12 FNC1 CodeB 3 FNC1; BWIPP different encodation, StartB so FNC1 not recognized as AIM" }, - /*105*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^123", -1, 0, 79, 0, "(7) 104 17 99 102 23 99 106", "StartB 1 CodeC FNC1 23; BWIPP different encodation (same codeword count)" }, - /*106*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" }, - /*107*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134\\^1", -1, 0, 79, 1, "(7) 105 12 102 34 102 7 106", "StartC 12 FNC1 34 FNC1" }, - /*108*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^145\\^1", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 102 88 106", "StartB 1 CodeC 23 FNC1 45 FNC1" }, - /*109*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^1", -1, 0, 101, 1, "(9) 105 12 102 34 100 21 102 98 106", "StartC 12 FNC1 34 CodeB 5 FNC1" }, - /*110*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156\\^1", -1, 0, 90, 1, "(8) 105 12 34 102 56 102 92 106", "StartC 12 34 FNC1 56 FNC1" }, - /*111*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156789\\^101\\^11\\^1", -1, 0, 178, 1, "(16) 105 12 34 102 56 78 100 25 102 16 17 102 17 102 100 106", "StartC 12 34 FNC1 56 78 CodeB 9 FNC1 0 1 FNC1 1 FNC1" }, - /*112*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aaa\\^B\012\012", -1, 0, 134, 0, "(12) 103 98 65 98 65 100 98 74 98 74 27 106", "StartA ShB a ShB a CodeB ShA ShA ; BWIPP no manual mode" }, - /*113*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\\^B\202\202", -1, 0, 156, 0, "(14) 103 101 101 98 66 98 66 100 98 66 98 66 72 106", "StartA FNC4 FNC4 ShB 226(E2) ShB 226(E2) CodeB ShA 130(82) ShA 130(82); BWIPP no manual mode" }, - /*114*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\342\342\342\\^Baaaaa", -1, 0, 255, 0, "(23) 103 101 101 98 66 98 66 98 66 98 66 98 66 100 100 100 65 65 65 65 65 46 106", "BWIPP no manual mode" }, - /*115*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\012\342\342\342\\^B\202\342\012\012", -1, 0, 277, 0, "(25) 103 101 98 66 74 101 101 98 66 98 66 98 66 100 98 66 66 100 98 74 100 98 74 69 106", "BWIPP no manual mode" }, + /* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123456789", -1, 0, 101, 1, "(9) 105 12 34 56 78 100 25 79 106", "Ticket #204 ZPL example" }, + /* 4*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP as above" }, + /* 5*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" }, + /* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" }, + /* 7*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^C", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 842: No input data", "" }, + /* 8*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^^B\\^C", -1, 0, 68, 0, "(6) 103 60 62 34 80 106", "BWIPP different encodation" }, + /* 9*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^^C", -1, 0, 68, 1, "(6) 104 60 62 35 84 106", "" }, + /* 10*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, + /* 11*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, + /* 12*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A", -1, 0, 68, 1, "(6) 104 60 62 33 78 106", "" }, + /* 13*/ { GS1_MODE, "[90]12", -1, ZINT_ERROR_INVALID_OPTION, 0, 1, "Error 220: Selected symbology does not support GS1 mode", "" }, + /* 14*/ { UNICODE_MODE, "1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1" }, + /* 15*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1", -1, 0, 46, 0, "(4) 103 17 17 106", "StartA 1; BWIPP as above" }, + /* 16*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (manual C ignored as odd)" }, + /* 17*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^A", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (escape at end ignored)" }, + /* 18*/ { UNICODE_MODE, "12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, + /* 19*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, + /* 20*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12", -1, 0, 57, 0, "(5) 104 17 18 54 106", "StartB 1 2; BWIPP as above" }, + /* 21*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A12", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2; BWIPP as above" }, + /* 22*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^B2", -1, 0, 68, 0, "(6) 103 17 100 18 65 106", "StartA 1 CodeB 2; BWIPP as above" }, + /* 23*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^A2", -1, 0, 68, 0, "(6) 104 17 101 18 68 106", "StartB 1 CodeA 2; BWIPP as above" }, + /* 24*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^C2", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2 (manual C ignored as odd); BWIPP as above" }, + /* 25*/ { UNICODE_MODE, "123", -1, 0, 68, 0, "(6) 105 12 100 19 65 106", "StartC 12 CodeB; BWIPP StartB, same as below" }, + /* 26*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B123", -1, 0, 68, 1, "(6) 104 17 18 19 8 106", "StartB 1 2 3" }, + /* 27*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^@23", -1, 0, 68, 0, "(6) 104 17 99 23 79 106", "StartB 1 CodeC 23; BWIPP as above" }, + /* 28*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A123", -1, 0, 68, 0, "(6) 103 17 18 19 7 106", "StartA 1 2 3; BWIPP as above" }, + /* 29*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C123", -1, 0, 68, 0, "(6) 105 12 100 19 65 106", "StartC 12 CodeB 3; BWIPP as above" }, + /* 30*/ { UNICODE_MODE, "1234", -1, 0, 57, 1, "(5) 105 12 34 82 106", "StartC 12 34" }, + /* 31*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1234", -1, 0, 79, 0, "(7) 104 17 18 19 20 88 106", "StartB 1 2 3 4; BWIPP as above" }, + /* 32*/ { UNICODE_MODE, "12345", -1, 0, 79, 1, "(7) 105 12 34 100 21 54 106", "StartC 12 34 CodeB 5" }, + /* 33*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^A5", -1, 0, 79, 0, "(7) 105 12 34 101 21 57 106", "StartC 12 34 CodeA 5; BWIPP as above" }, + /* 34*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^C2345", -1, 0, 79, 0, "(7) 104 17 99 23 45 53 106", "StartB 1 CodeC 23 45; BWIPP as above" }, + /* 35*/ { UNICODE_MODE, "\037", -1, 0, 46, 1, "(4) 103 95 95 106", "StartA US" }, + /* 36*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\037", -1, 0, 57, 0, "(5) 104 98 95 83 106", "StartB ShA ; BWIPP as above" }, + /* 37*/ { UNICODE_MODE, "1\037", -1, 0, 57, 1, "(5) 103 17 95 1 106", "StartA 1 US" }, + /* 38*/ { UNICODE_MODE, "12\037", -1, 0, 68, 0, "(6) 105 12 101 95 89 106", "StartC 12 CodeA US; BWIPP StartA, same as below" }, + /* 39*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A12\037", -1, 0, 68, 1, "(6) 103 17 18 95 29 106", "StartA 1 2 US" }, + /* 40*/ { UNICODE_MODE, "a\037a", -1, 0, 79, 1, "(7) 104 65 98 95 65 86 106", "StartB a Shift US a" }, + /* 41*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aa\037a", -1, 0, 90, 0, "(8) 103 98 65 95 98 65 97 106", "StartA ShB a ShB a; BWIPP as above" }, + /* 42*/ { UNICODE_MODE, "1234\037a", -1, 0, 101, 1, "(9) 105 12 34 100 98 95 65 94 106", "StartC 12 34 CodeB Shift US a" }, + /* 43*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Ba", -1, 0, 101, 1, "(9) 105 12 34 100 98 95 65 94 106", "StartC 12 34 CodeB Shift US a" }, + /* 44*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Aa", -1, 0, 101, 0, "(9) 105 12 34 101 95 98 65 100 106", "StartC 12 34 CodeA US Shift a; BWIPP as above" }, + /* 45*/ { UNICODE_MODE, "\037AAa\037", -1, 0, 101, 1, "(9) 103 95 33 33 98 65 95 2 106", "StartA US A A Shift a US" }, + /* 46*/ { UNICODE_MODE, "\037AAaa\037", -1, 0, 123, 1, "(11) 104 98 95 33 33 65 65 98 95 3 106", "StartB Shift US A A a a Shift US" }, + /* 47*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\037AAaa\\^A\037", -1, 0, 123, 0, "(11) 104 98 95 33 33 65 65 101 95 24 106", "StartB Shift A A a a CodeA ; BWIPP as above" }, + /* 48*/ { UNICODE_MODE, "AAAa12345aAA", -1, 0, 167, 0, "(15) 104 33 33 33 65 99 12 34 100 21 65 33 33 57 106", "StartB A A A a CodeC 12 34 CodeB 5 a A A; BWIPP different encodation" }, + /* 49*/ { UNICODE_MODE, "a\037Aa\037\037a\037aa\037a", -1, 0, 222, 1, "(20) 104 65 98 95 33 65 98 95 98 95 65 98 95 65 65 98 95 65 48 106", "StartB a Shift US a Shift US a Shift US a a Shift US a" }, + /* 50*/ { UNICODE_MODE, "\000\037ß", 4, 0, 79, 1, "(7) 103 64 95 101 63 88 106", "StartA NUL US FNC4 ß" }, + /* 51*/ { UNICODE_MODE, "\000\037é", 4, 0, 90, 1, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é" }, + /* 52*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\000\037\\^Bé", 7, 0, 90, 1, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é" }, + /* 53*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 1, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US CodeB FNC4 é a" }, + /* 54*/ { UNICODE_MODE, "abß", -1, 0, 79, 1, "(7) 104 65 66 100 63 29 106", "StartB a b FNC4 ß" }, + /* 55*/ { DATA_MODE, "\141\142\237", -1, 0, 90, 1, "(8) 104 65 66 100 98 95 26 106", "StartB a b FNC4 Shift APC" }, + /* 56*/ { DATA_MODE, "\141\142\237\037", -1, 0, 101, 1, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b CodeA FNC4 APC US" }, + /* 57*/ { UNICODE_MODE, "ééé", -1, 0, 90, 1, "(8) 104 100 100 73 73 73 44 106", "StartB LatchFNC4 é é é" }, + /* 58*/ { UNICODE_MODE, "aéééb", -1, 0, 123, 1, "(11) 104 65 100 73 100 73 100 73 66 5 106", "StartB a FNC4 é (4) b" }, + /* 59*/ { UNICODE_MODE, "aééééb", -1, 0, 134, 1, "(12) 104 65 100 100 73 73 73 73 100 66 64 106", "StartB a Latch é (4) Shift b" }, + /* 60*/ { UNICODE_MODE, "aéééééb", -1, 0, 145, 1, "(13) 104 65 100 100 73 73 73 73 73 100 66 93 106", "StartB a Latch é (5) Shift b" }, + /* 61*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 1, "(15) 104 65 100 100 73 73 73 73 73 100 100 66 67 6 106", "StartB a Latch é (5) Unlatch b c" }, + /* 62*/ { UNICODE_MODE, "aééééébcd", -1, 0, 178, 1, "(16) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 66 106", "StartB a Latch é (5) Unlatch b c d" }, + /* 63*/ { UNICODE_MODE, "aééééébcde", -1, 0, 189, 1, "(17) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 2 106", "StartB a Latch é (5) Unlatch b c d e" }, + /* 64*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 1, "(19) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 95 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é" }, + /* 65*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 1, "(21) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 100 73 19 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é (2)" }, + /* 66*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 1, "(22) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 100 73 73 73 40 106", "StartB a Latch é (5) Unlatch b c d e Latch é (3)" }, + /* 67*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, 1, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, + /* 68*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 211, 1, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "StartA Latch PAD (5) FNC4 A CodeC 00 00 Unlatch A PAD" }, + /* 69*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 1, "(19) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 63 106", "Okapi code128/extended-mode-exit-before-code-set-c.png (chose different solution)" }, + /* 70*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 1, "(21) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 100 33 91 106", "Above with trailing non-shifted (as still latched) extended" }, + /* 71*/ { DATA_MODE, "@g(\202\202\202\202\2025555\202\202\202\202\202\202\202\202", -1, 0, 288, 1, "(26) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 101 66 66 66 66 66 66 66 66 10 106", "Okapi code128/extended-mode-with-short-embedded-code-set-c.png (chose different solution)" }, + /* 72*/ { DATA_MODE, "@g(\202\202\202\202\20255555\202\202\202\202\202\202\202", -1, 0, 299, 1, "(27) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 101 101 21 66 66 66 66 66 66 66 50 106", "Above with extra 5" }, + /* 73*/ { DATA_MODE, "@g(\202\202\202\202\202555555\202\202\202\202\202\202\202", -1, 0, 288, 1, "(26) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 55 55 101 66 66 66 66 66 66 66 86 106", "Above with extra 55, one less \\202" }, + /* 74*/ { DATA_MODE, "@g(\202\202\202\202\202555\202\202\202\202\202\202\202\202", -1, 0, 299, 1, "(27) 104 32 71 8 101 101 101 66 66 66 66 66 99 55 101 101 21 66 66 66 66 66 66 66 66 76 106", "Above less one 5" }, + /* 75*/ { UNICODE_MODE, "±±±±1234AA", -1, 0, 189, 0, "(17) 104 100 17 100 17 100 17 100 17 99 12 34 100 33 33 61 106", "BWIPP different encodation (no CodeC), same as beloew" }, + /* 76*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "±±±±\\^B1234AA", -1, 0, 189, 1, "(17) 104 100 17 100 17 100 17 100 17 17 18 19 20 33 33 9 106", "" }, + /* 77*/ { UNICODE_MODE, "ÁÁèÁÁFç7Z", -1, 0, 189, 1, "(17) 104 100 100 33 33 72 33 33 100 100 38 100 71 23 58 78 106", "Okapi code128/extended-mode-shift.png" }, + /* 78*/ { UNICODE_MODE, "m\nm\nm", -1, 0, 112, 1, "(10) 104 77 98 74 77 98 74 77 11 106", "Okapi code128/code-set-b-a-b-a-b.png" }, + /* 79*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" }, + /* 80*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" }, + /* 81*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 1, "(20) 104 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 61 106", "" }, + /* 82*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\012àa\\^A\0121\012\\^BàAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP as above" }, + /* 83*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP as below" }, + /* 84*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\\^B1234\\^@\012àa\0121\0127890àAàDà\012à", -1, 0, 376, 1, "(34) 104 100 95 17 18 19 20 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64 36", "Force BWIPP encodation" }, + /* 85*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 89 100 95 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation" }, + /* 86*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 89 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation" }, + /* 87*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 100 95 99 12 34 100 98 74 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100", "BWIPP different encodation" }, + /* 88*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 662, 0, "(60) 104 100 95 99 12 34 56 78 100 98 74 100 64 99 12 34 56 78 100 65 66 67 68 69 70 101 74", "BWIPP different encodation" }, + /* 89*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 200, 1, "(18) 104 0 100 100 1 1 1 1 100 0 1 1 1 1 100 0 91 106", "StartB Latch (4) FNC4 (4) FNC4 , adapted from BWIPP PR #272" }, + /* 90*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 222, 1, "(20) 104 0 100 100 1 1 1 1 100 0 100 0 1 1 1 1 100 0 63 106", "2 middle spaces" }, + /* 91*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 244, 1, "(22) 104 0 100 100 1 1 1 1 100 0 100 0 100 0 1 1 1 1 100 0 29 106", "3 middle spaces" }, + /* 92*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 266, 1, "(24) 104 0 100 1 100 1 100 1 100 1 0 0 0 0 100 100 1 1 1 1 100 0 94 106", "4 middle spaces then latch" }, + /* 93*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 277, 1, "(25) 104 0 100 1 100 1 100 1 100 1 0 0 0 0 0 100 100 1 1 1 1 100 0 89 106", "5 middle spaces then latch" }, + /* 94*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 12\\^1 ", -1, 0, 90, 1, "(8) 104 0 17 18 102 0 85 106", "BWIPP PR #272" }, + /* 95*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 1234\\^1567", -1, 0, 123, 1, "(11) 104 0 99 12 34 102 56 100 23 41 106", "BWIPP PR #272" }, + /* 96*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^14567", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 67 84 106", "BWIPP PR #272" }, + /* 97*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\d031\\d031_\\d127\\d159\\d031\\d159\\d159\\d159\\d15912345``\\d255\\d000\\d127\\d255\\d224\\d224\\d159`", -1, 0, 442, 1, "(40) 103 95 95 63 98 95 101 95 95 101 95 101 95 101 95 101 95 99 12 34 100 21 64 64 100 95", "Code set limit chars" }, + /* 98*/ { DATA_MODE, "\200\200\200\200\200A0000A\200", -1, 0, 211, 1, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "" }, + /* 99*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^167\\^18", -1, 0, 145, 1, "(13) 105 12 102 34 100 21 102 22 23 102 24 49 106", "" }, + /*100*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP different encodation" }, + /*101*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 101 33 34 35 99 12 101 74 39 106", "StartC 12 34 CodeA A B C CodeC 12 CodeA ; BWIPP different encodation" }, + /*102*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "" }, + /*103*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 0, "(13) 103 33 74 99 12 34 101 33 17 18 74 99 106", "StartA A CodeC 12 34 CodeA A 1 2 ; Okapi c128/improved-lookahead-mode-a.png; BWIPP different encodation" }, + /*104*/ { UNICODE_MODE, "21*\015\012M0", -1, 0, 112, 0, "(10) 105 21 101 10 77 74 45 16 79 106", "StartC 21 CodeA * M 0; Okapi c128/improved-lookahead-rule-1c.png; BWIPP different encodation" }, + /*105*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^112345\\^11234\\^112345", -1, 0, 178, 1, "(16) 104 102 17 99 23 45 102 12 34 102 12 34 100 21 72 106", "Okapi code128/fnc1-mode-c-fnc1-in-middle.png" }, + /*106*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^1SN123456789012", -1, 0, 145, 1, "(13) 104 102 51 46 99 12 34 56 78 90 12 65 106", "StartA FNC1 S N CodeC 12 34 56 78 90 12" }, + /*107*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1SN123456789012", -1, 0, 200, 0, "(18) 104 102 51 46 17 18 19 20 21 22 23 24 25 16 17 18 56 106", "StartB FNC1 S N 1 2 3 4 5 6 7 8 9 0 1 2; BWIPP as above" }, + /*108*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^1BC\\^1DEF\\^1", -1, 0, 134, 1, "(12) 104 33 102 34 35 102 36 37 38 102 9 106", "StartB A FNC1 B C FNC1 D E F FNC1" }, + /*109*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP different encodation" }, + /*110*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 0, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3, StartC so FNC1 recognized as AIM; BWIPP different encodation" }, + /*111*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^13", -1, 0, 79, 0, "(7) 105 12 102 100 19 79 106", "Force StartC to ensure FNC1 recognized as AIM; BWIPP different encodation" }, + /*112*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12\\^13", -1, 0, 79, 0, "(7) 104 17 18 102 19 24 106", "Force StartB to ensure FNC1 not recognized as AIM; BWIPP different encodation" }, + /*113*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13\\^1", -1, 0, 90, 0, "(8) 105 12 102 100 19 102 74 106", "StartC 12 FNC1 CodeB 3 FNC1, so FNC1 recognized as AIM; BWIPP different encodation" }, + /*114*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^123", -1, 0, 79, 0, "(7) 104 17 99 102 23 99 106", "StartB 1 CodeC FNC1 23; BWIPP different encodation" }, + /*115*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" }, + /*116*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134\\^1", -1, 0, 79, 1, "(7) 105 12 102 34 102 7 106", "StartC 12 FNC1 34 FNC1" }, + /*117*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^145\\^1", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 102 88 106", "StartB 1 CodeC 23 FNC1 45 FNC1" }, + /*118*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^1", -1, 0, 101, 1, "(9) 105 12 102 34 100 21 102 98 106", "StartC 12 FNC1 34 CodeB 5 FNC1" }, + /*119*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156\\^1", -1, 0, 90, 1, "(8) 105 12 34 102 56 102 92 106", "StartC 12 34 FNC1 56 FNC1" }, + /*120*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156789\\^101\\^11\\^1", -1, 0, 178, 1, "(16) 105 12 34 102 56 78 100 25 102 16 17 102 17 102 100 106", "StartC 12 34 FNC1 56 78 CodeB 9 FNC1 0 1 FNC1 1 FNC1" }, + /*121*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aaa\\^B\012\012", -1, 0, 134, 0, "(12) 103 98 65 98 65 100 98 74 98 74 27 106", "StartA ShB a ShB a CodeB ShA ShA ; BWIPP different encodation" }, + /*122*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\\^B\202\202", -1, 0, 156, 0, "(14) 103 101 101 98 66 98 66 100 98 66 98 66 72 106", "StartA FNC4 FNC4 ShB 226(E2) ShB 226(E2) CodeB ShA 130(82) ShA 130(82); BWIPP different encodation" }, + /*123*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\342\342\342\\^Baaaaa", -1, 0, 255, 0, "(23) 103 101 101 98 66 98 66 98 66 98 66 98 66 100 100 100 65 65 65 65 65 46 106", "BWIPP different encodation" }, + /*124*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\012\342\342\342\\^B\202\342\012\012", -1, 0, 277, 0, "(25) 103 101 98 66 74 101 101 98 66 98 66 98 66 100 98 66 66 100 100 98 74 98 74 41 106", "BWIPP different encodation" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; char escaped[1024]; + char escaped2[1024]; char cmp_buf[8192]; char cmp_msg[1024]; + char ret_buf[8192]; int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ @@ -446,7 +569,9 @@ static void test_input(const testCtx *const p_ctx) { assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (width %d)\n", i, symbol->errtxt, data[i].expected, symbol->width); if (ret < ZINT_ERROR) { - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", + i, symbol->width, data[i].expected_width, + testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { if (!data[i].bwipp_cmp) { @@ -469,9 +594,11 @@ static void test_input(const testCtx *const p_ctx) { ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); - ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); } } } @@ -495,43 +622,45 @@ static void test_gs1_128_input(const testCtx *const p_ctx) { char *comment; }; static const struct item data[] = { - /* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01; BWIPP different encodation (same width)" }, - /* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01; BWIPP different encodation (same width)" }, + /* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 9 0 1 FNC1 9 0 1; BWIPP different encodation (same width)" }, + /* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartB FNC1 9 0 1 FNC1 9 0 1; BWIPP different encodation (same width)" }, /* 2*/ { GS1_MODE, "[90]1[90]12", 0, 112, 1, "(10) 104 102 25 99 1 102 90 12 43 106", "StartB FNC1 9 CodeC 01 FNC1 90 12" }, - /* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, 0, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23; BWIPP different encodation" }, + /* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, 0, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartB FNC1 9 CodeC 01 FNC1 12 CodeB 3; BWIPP different encodation" }, /* 4*/ { GS1_MODE, "[90]12[90]1", 0, 112, 1, "(10) 105 102 90 12 102 90 100 17 43 106", "StartC FNC1 90 12 FNC1 90 CodeB 1" }, /* 5*/ { GS1_MODE, "[90]12[90]12", 0, 101, 1, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" }, /* 6*/ { GS1_MODE, "[90]12[90]123", 0, 123, 1, "(11) 105 102 90 12 102 90 12 100 19 42 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" }, - /* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, 0, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01; BWIPP different encodation (same width)" }, + /* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, 0, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 0 1; BWIPP different encodation (same width)" }, /* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 134, 1, "(12) 104 102 25 99 1 23 102 90 12 34 50 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34" }, - /* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 167, 0, "(15) 105 102 90 100 17 102 25 99 1 102 90 100 17 88 106", "StartC FNC1(GS1) 90 CodeB 1 FNC1(29) 9 CodeC 01 FNC1(29) 90 CodeB 1; BWIPP different encodation (same width)" }, + /* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 167, 0, "(15) 105 102 90 100 17 102 25 99 1 102 90 100 17 88 106", "StartB FNC1(GS1) 9 0 1 FNC1(29) 9 0 FNC1(29) 9 0 1; BWIPP different encodation (same width)" }, /* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 156, 1, "(14) 104 102 25 99 1 102 90 12 102 90 100 17 75 106", "StartB FNC1 9 CodeC 01 FNC1 90 12 FNC1 90 CodeB 1" }, - /* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 178, 0, "(16) 105 102 90 100 17 102 25 99 1 23 102 90 100 17 89 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 90 CodeB 1; BWIPP different encodation" }, - /* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 102 25 99 1 45 106", "StartC FNC1 90 12 FNC1 90 12 CodeB 3 FNC1 9 CodeC 01; BWIPP different encodation (same width)" }, - /* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 99 102 90 12 100 106", "StartC FNC1 90 12 FNC1 90 12 CodeB 3 CodeC FNC1 90 12; BWIPP different encodation (same width)" }, - /* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 178, 0, "(16) 105 102 90 12 100 19 102 25 99 1 102 90 100 17 66 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 90 CodeB 1; BWIPP different encodation (same width)" }, - /* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 167, 1, "(15) 104 102 25 99 1 23 102 90 12 102 90 100 17 85 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 FNC1 90 CodeB 1" }, - /* 16*/ { GS1_MODE, "[90]123[90]123[90]12", 0, 178, 1, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 23 FNC1 90 12" }, + /* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 178, 0, "(16) 105 102 90 100 17 102 25 99 1 23 102 90 100 17 89 106", "StartB FNC1 9 CodeC 01 FNC1 90 12 CodeB 3 FNC1 9 CodeC 01; BWIPP different encodation" }, + /* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 102 25 99 1 45 106", "BWIPP different encodation (same width)" }, + /* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 99 102 90 12 100 106", "BWIPP different encodation (same width)" }, + /* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 178, 0, "(16) 105 102 90 12 100 19 102 25 99 1 102 90 100 17 66 106", "BWIPP different encodation (same width)" }, + /* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 167, 1, "(15) 104 102 25 99 1 23 102 90 12 102 90 100 17 85 106", "" }, + /* 16*/ { GS1_MODE, "[90]123[90]123[90]12", 0, 178, 1, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "" }, /* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 178, 1, "(16) 104 102 25 99 1 23 102 90 12 34 102 90 100 17 82 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34 FNC1 90 CodeB 1" }, /* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 189, 1, "(17) 104 102 25 99 1 23 102 90 12 34 102 90 12 100 19 62 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34 FNC1 90 12 CodeB 3" }, /* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 189, 1, "(17) 104 102 25 99 1 23 45 102 90 12 34 102 90 100 17 75 106", "StartB FNC1 9 CodeC 01 23 45 FNC1 90 12 34 FNC1 90 CodeB 1" }, - /* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, 0, "(12) 105 102 90 100 17 33 102 25 99 1 36 106", "StartC FNC1 90 CodeB 1 A FNC1 9 CodeC 01; BWIPP different encodation (same width)" }, + /* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, 0, "(12) 105 102 90 100 17 33 102 25 99 1 36 106", "BWIPP different encodation (same width)" }, /* 21*/ { GS1_MODE, "[90]12A[90]123", 0, 145, 1, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" }, - /* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 222, 1, "(20) 105 102 90 12 100 19 102 25 16 33 18 99 34 102 90 12 100 19 50 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 0 A 2 CodeC 34 FNC1 90 12 CodeB 3" }, - /* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, 0, "(16) 105 102 90 12 34 100 21 33 99 12 34 100 21 33 8 106", "StartC FNC1 90 12 34 CodeB 5 A CodeC 12 34 CodeB 5 A; BWIPP different encodation (same width)" }, + /* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 222, 1, "(20) 105 102 90 12 100 19 102 25 16 33 18 99 34 102 90 12 100 19 50 106", "" }, + /* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, 0, "(16) 105 102 90 12 34 100 21 33 99 12 34 100 21 33 8 106", "BWIPP different encodation (same width)" }, /* 24*/ { GS1_MODE, "[01]12345678901231[90]12345678901234567890123456789", 0, 321, 1, "(29) 105 102 1 12 34 56 78 90 12 31 90 12 34 56 78 90 12 34 56 78 90 12 34 56 78 100 25 59", "Max length" }, /* 25*/ { GS1_MODE, "[01]12345678901231[90]123456789012345678901234567890[91]1", ZINT_WARN_NONCOMPLIANT, 354, 1, "Warning 843: Input too long, requires 52 characters (maximum 48)", "Over length" }, - /* 26*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]1234", ZINT_WARN_HRT_TRUNCATED, 1135, 1, "Warning 844: Human Readable Text truncated", "Max input" }, - /* 27*/ { GS1_MODE, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]567890[20]34[20]78", ZINT_WARN_HRT_TRUNCATED, 1135, 1, "Warning 844: Human Readable Text truncated", "HRT truncation warning trumps non-compliant (3100) warning" }, - /* 28*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, 1, "Error 344: Input too long, requires 101 symbol characters (maximum 99)", "" }, + /* 26*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]1234", ZINT_WARN_NONCOMPLIANT, 1135, 1, "Warning 843: Input too long, requires 195 characters (maximum 48)", "Max input" }, + /* 27*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, 1, "Error 344: Input too long, requires 103 symbol characters (maximum 102)", "" }, + /* 28*/ { GS1_MODE, "[10]12[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]567890[20]34", ZINT_WARN_NONCOMPLIANT, 1146, 1, "Warning (104) 105 102 10 12 102 0 34 56 78 90 12 34 56 78 90 0 34 56 78 90 12 34 56 78 90 0 34 56", "Was test showing HRT truncation warning trumps non-compliant but no longer doable with `text` 200 -> 256" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; char escaped[1024]; + char escaped2[1024]; char cmp_buf[8192]; char cmp_msg[1024]; + char ret_buf[8192]; int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ @@ -591,9 +720,11 @@ static void test_gs1_128_input(const testCtx *const p_ctx) { ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); - ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); } } } @@ -620,8 +751,8 @@ static void test_hibc_input(const testCtx *const p_ctx) { /* 1*/ { "A99912345/$$52001510X3", 0, 255, 0, "(23) 104 11 33 99 99 91 23 45 100 15 4 4 99 52 0 15 10 100 56 99 33 102 106", "Check digit 3; BWIPP different encodation, same width" }, /* 2*/ { "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", 0, 497, 1, "(45) 104 11 99 1 23 45 67 89 100 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51", "Check digit +" }, /* 3*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", 0, 695, 1, "(63) 104 11 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5", "Check digit Q" }, - /* 4*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", 0, 1124, 1, "(102) 104 11 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5", "" }, - /* 5*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", ZINT_ERROR_TOO_LONG, -1, 0, "Error 341: Input too long, requires 100 symbol characters (maximum 99)", "" }, + /* 4*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", 0, 1146, 1, "(104) 104 11 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5", "" }, + /* 5*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", ZINT_ERROR_TOO_LONG, -1, 0, "Error 341: Input too long, requires 103 symbol characters (maximum 102)", "" }, /* 6*/ { "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 0, 684, 1, "(62) 104 11 99 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "Check digit %" }, /* 7*/ { "09AZ-.19AZ-.29AZ-.39AZ-.49AZ-.59AZ-.69AZ-.79AZ-.89AZ-.99AZ", 0, 695, 1, "(63) 104 11 16 25 33 58 13 14 17 25 33 58 13 14 18 25 33 58 13 14 19 25 33 58 13 14 20 25", "Check digit -" }, }; @@ -630,8 +761,10 @@ static void test_hibc_input(const testCtx *const p_ctx) { struct zint_symbol *symbol = NULL; char escaped[1024]; + char escaped2[1024]; char cmp_buf[8192]; char cmp_msg[1024]; + char ret_buf[8192]; int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ @@ -682,9 +815,11 @@ static void test_hibc_input(const testCtx *const p_ctx) { ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); - ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); } } } @@ -762,8 +897,8 @@ static void test_ean14_input(const testCtx *const p_ctx) { char *comment; }; static const struct item data[] = { - /* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 347: Input length 14 too long (maximum 13)", "" }, - /* 1*/ { "123456789012A", ZINT_ERROR_INVALID_DATA, -1, "Error 348: Invalid character at position 13 in input (digits only)", "" }, + /* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 14 too long (maximum 13)", "" }, + /* 1*/ { "123456789012A", ZINT_ERROR_INVALID_DATA, -1, "Error 346: Invalid character at position 13 in input (digits only)", "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -814,47 +949,55 @@ static void test_dpd_input(const testCtx *const p_ctx) { int ret; int expected_width; float expected_height; + int bwipp_cmp; char *expected; char *comment; }; static const struct item data[] = { - /* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input length 26 wrong (27 or 28 only)", "" }, - /* 1*/ { 1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input length 26 wrong (27 only)", "" }, - /* 2*/ { -1, -1, "123456789012345678901234567", 0, 211, 50, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "27 chars ok now, ident tag prefixed" }, - /* 3*/ { -1, -1, "%123456789012345678901234567", 0, 211, 50, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "" }, - /* 4*/ { 1, -1, "123456789012345678901234567", 0, 200, 25, "(18) 105 12 34 56 78 90 12 34 56 78 90 12 34 56 100 23 102 106", "27 chars also ok (and necessary) for relabel" }, - /* 5*/ { -1, -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input length 29 wrong (27 or 28 only)", "" }, - /* 6*/ { 1, -1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input length 28 wrong (27 only)", "" }, - /* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 299: Invalid character at position 27 in input (alphanumerics only after first)", "Alphanumerics only in body" }, - /* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 300: Invalid character at position 27 in input (alphanumerics only)", "Alphanumerics only" }, - /* 9*/ { -1, -1, ",234567890123456789012345678", 0, 211, 50, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" }, - /* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char as DPD ident tag" }, - /* 11*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" }, - /* 12*/ { -1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 13*/ { -1, -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 14*/ { 1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, 25, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 15*/ { -1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 16*/ { -1, -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 17*/ { 1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, 25, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 18*/ { -1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 19*/ { -1, -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 20*/ { 1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 21*/ { -1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 22*/ { -1, -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 23*/ { 1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 24*/ { -1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 25*/ { -1, -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 26*/ { 1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, 25, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 27*/ { -1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 28*/ { -1, -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 29*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 30*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 349: DPD input length 26 wrong (27 or 28 only)", "" }, + /* 1*/ { 1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 830: DPD relabel input length 26 wrong (27 only)", "" }, + /* 2*/ { -1, -1, "123456789012345678901234567", 0, 211, 50, 1, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "27 chars ok now, ident tag prefixed" }, + /* 3*/ { -1, -1, "%123456789012345678901234567", 0, 211, 50, 1, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "" }, + /* 4*/ { 1, -1, "123456789012345678901234567", 0, 200, 25, 1, "(18) 105 12 34 56 78 90 12 34 56 78 90 12 34 56 100 23 102 106", "27 chars also ok (and necessary) for relabel" }, + /* 5*/ { -1, -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 349: DPD input length 29 wrong (27 or 28 only)", "" }, + /* 6*/ { 1, -1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, 0, 1, "Error 830: DPD relabel input length 28 wrong (27 only)", "" }, + /* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 299: Invalid character at position 27 in input (alphanumerics only after first)", "Alphanumerics only in body" }, + /* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 300: Invalid character at position 27 in input (alphanumerics only)", "Alphanumerics only" }, + /* 9*/ { -1, -1, ",234567890123456789012345678", 0, 211, 50, 1, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" }, + /* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char as DPD ident tag" }, + /* 11*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, 1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" }, + /* 12*/ { -1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 13*/ { -1, -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 14*/ { 1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 15*/ { -1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" }, + /* 16*/ { -1, -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, 0, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "BWIPP different encodation (same width)" }, + /* 17*/ { 1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 18*/ { -1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, + /* 19*/ { -1, -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, + /* 20*/ { 1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 21*/ { -1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, + /* 22*/ { -1, -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "BWIPP different encodation (same width)" }, + /* 23*/ { 1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 24*/ { -1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 25*/ { -1, -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 26*/ { 1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 27*/ { -1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" }, + /* 28*/ { -1, -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, 0, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "BWIPP different encodation (same width)" }, + /* 29*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 30*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, 1, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; char escaped[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ testStartSymbol("test_dpd_input", &symbol); @@ -873,16 +1016,44 @@ static void test_dpd_input(const testCtx *const p_ctx) { assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { - printf(" /*%3d*/ { %d, %s, \"%s\", %s, %d, %.8g, \"%s\", \"%s\" },\n", + printf(" /*%3d*/ { %d, %s, \"%s\", %s, %d, %.8g, %d, \"%s\", \"%s\" },\n", i, data[i].option_2, testUtilOutputOptionsName(data[i].output_options), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), symbol->width, symbol->height, symbol->errtxt, data[i].comment); + testUtilErrorName(data[i].ret), symbol->width, symbol->height, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); } else { + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); if (ret < ZINT_ERROR) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %.8g != %.8g (%s)\n", i, symbol->height, data[i].expected_height, data[i].data); + + if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, data[i].option_2, debug)) { + if (!data[i].bwipp_cmp) { + if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment); + } else { + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); + assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump); + } + } + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } } - assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } ZBarcode_Delete(symbol); @@ -929,6 +1100,11 @@ static void test_upu_s10_input(const testCtx *const p_ctx) { char escaped[1024]; char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ testStartSymbol("test_upu_s10_input", &symbol); @@ -950,10 +1126,24 @@ static void test_upu_s10_input(const testCtx *const p_ctx) { testUtilErrorName(data[i].ret), symbol->width, testUtilEscape(symbol->errtxt, (int) strlen(symbol->errtxt), escaped2, sizeof(escaped2)), data[i].comment); } else { + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); if (ret < ZINT_ERROR) { assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } } - assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } ZBarcode_Delete(symbol); @@ -997,8 +1187,8 @@ static void test_encode(const testCtx *const p_ctx) { /* 4*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\104\105\106\200\200\200\200\200", 0, 1, 178, 1, "", "1101000010010100011000100010110001000100011010110001000100011010001000110001011101011110111010111101010000110010100001100101000011001010000110010100001100110110110001100011101011" }, - /* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\144\012\105\061\062\063\110\111\112\064\065\066\067\114\115\120\141\127\012\130\131\132\141\142\012\012\145\012\012\146\147\012\175\061\062\012\012\064\065\066\012\202\302\012\012\342\061\062\012\012\012\012\061\062\063\012\012\012\012\012\012\061\062\063\064\012\012\012\012\342\342\342\061\062\063\064\342\342\342", 0, 1, 1124, 0, "BWIPP different encodation, BWIPP 3 shorter", - "11010010000101000110001000101100010001000110100001001101110101111010000110010100011010001001110011011001110010110010111001100010100011000100010101101110001011101111010111011000100001011001011110111010001101110101110110001110111011010010110000111010001101111010001010000110010111000101101110110100011101100010100101100001001000011011101011110100001100101000011001011110100010101100100001000011001010000110010101111011101011000010010011010000111010111101000011001011110100010101000111101001110011011001110010100001100101000011001011001001110110111001001100111010010000110010111010111101001000011011101011110100010110001000011001010000110010111010111101111010001010010000110100111001101100111001010000110010100001100101000011001010000110010100111001101100111001011001011100100001100101000011001010000110010100001100101000011001010000110010101110111101011001110010001011000111010111101000011001010000110010100001100101000011001010111101110101111011101001000011010111101110100100001101011110111010010000110101110111101011001110010001011000101111011101011110111010111101110100100001101001000011010010000110110001011101100011101011" + /* 5*/ { BARCODE_CODE128, DATA_MODE, -1, "\101\102\103\144\012\105\061\062\063\110\111\112\064\065\066\067\114\115\120\141\127\012\130\131\132\141\142\012\012\145\012\012\146\147\012\175\061\062\012\012\064\065\066\012\202\302\012\012\342\061\062\012\012\012\012\061\062\063\012\012\012\012\012\012\061\062\063\064\012\012\012\012\342\342\342\061\062\063\064\342\342\342", 0, 1, 1091, 0, "BWIPP different encodation", + "11010010000101000110001000101100010001000110100001001101111010001010000110010100011010001001110011011001110010110010111001100010100011000100010101101110001011101111010111011000100001011001011110111010001101110101110110001110111011010010110000111010001101111010001010000110010111000101101110110100011101100010100101100001001000011011101011110100001100101000011001011110100010101100100001000011001010000110010101111011101011000010010011010000111101000101000011001010100011110101110111101011001110011101011110100001100101000011001011001001110110111001001100111010010000110010111010111101001000011011101011110100010110001000011001010000110010111010111101111010001010010000110100111001101100111001010000110010100001100101000011001010000110010100111001101100111001011001011100100001100101000011001010000110010100001100101000011001010000110010101110111101011001110010001011000111010111101000011001010000110010100001100101000011001010111101110101111011101011110111010010000110100100001101001000011010111011110101100111001000101100010111101110100100001101001000011010010000110101111001001100011101011" }, /* 6*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1", "11010011100111101011101010011110011001110010101111010001100110110011001000100101110011001101100011011101101110101110110001000010110010010111100101111001001100011101011" @@ -1093,7 +1283,7 @@ static void test_encode(const testCtx *const p_ctx) { /* 36*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]ABCDEfGHI", 0, 1, 167, 0, "Shift A; BWIPP different encodation", "11010011100111101011101101111011010111101110101000110001000101100010001000110101100010001000110100010110000100110100010001100010100011000100010100010111101100011101011" }, - /* 37*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]121212[20]34[20]78", ZINT_WARN_HRT_TRUNCATED, 1, 1135, 1, "Max length", + /* 37*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]121212[20]34[20]78", ZINT_WARN_NONCOMPLIANT, 1, 1135, 1, "", "1101001110011110101110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110001101101100110010110011100101100111001011001110011001001110100010110001100100111011000010100100100110001100011101011" }, /* 38*/ { BARCODE_GS1_128, GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "(21)12345670[23]4931", 0, 1, 189, 1, "Ticket #319, square bracket treated as FNC1 in parens mode, props Moli Sojet", @@ -1147,8 +1337,10 @@ static void test_encode(const testCtx *const p_ctx) { struct zint_symbol *symbol = NULL; char escaped[1024]; + char escaped2[1024]; char cmp_buf[8192]; char cmp_msg[1024]; + char ret_buf[8192]; int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */ @@ -1203,9 +1395,11 @@ static void test_encode(const testCtx *const p_ctx) { ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len); assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); - ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len); - assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", - i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped); + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, ret_buf, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %s\nexpected: %s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); } } } diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index 558755aa..c106542a 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -686,21 +686,21 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) { /* 4*/ { "\241\242\243\244\257\260", -1, 0, "¡¢£¤¯°", "" }, /* 5*/ { "\276\277\300\337\377", -1, 0, "¾¿Àßÿ", "" }, /* 6*/ { "\351", -1, 0, "é", "" }, - /* 7*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "99 \241" }, - /* 8*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 99 \241" }, - /* 9*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", "99 \241 + a" }, - /* 10*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "100 \241 (truncated)" }, - /* 11*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 100 \241 (truncated)" }, - /* 12*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "100 \241 + a (truncated)" }, - /* 13*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "101 \241 (truncated)" }, - /* 14*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "99 \351" }, - /* 15*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 99 \351" }, - /* 16*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 0, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", "99 \351 + a" }, - /* 17*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "100 \351 (truncated)" }, - /* 18*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 100 \351 (truncated)" }, - /* 19*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "100 \351 + a (truncated)" }, - /* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "101 \351 (truncated)" }, - /* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "200 A (truncated)" }, + /* 7*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "127 \241" }, + /* 8*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 0, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 127 \241" }, + /* 9*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 0, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a", "127 \241 + a" }, + /* 10*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "128 \241 (truncated)" }, + /* 11*/ { "a\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "a¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "a + 128 \241 (truncated)" }, + /* 12*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241a", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "128 \241 + a (truncated)" }, + /* 13*/ { "\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241\241", -1, 1, "¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡", "129 \241 (truncated)" }, + /* 14*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "127 \351" }, + /* 15*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 0, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 127 \351" }, + /* 16*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 0, "éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééa", "127 \351 + a" }, + /* 17*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 (truncated)" }, + /* 18*/ { "a\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "aééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "a + 128 \351 (truncated)" }, + /* 19*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351a", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "128 \351 + a (truncated)" }, + /* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "129 \351 (truncated)" }, + /* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "256 A (truncated)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c index 74554088..c74a08eb 100644 --- a/backend/tests/test_composite.c +++ b/backend/tests/test_composite.c @@ -3416,14 +3416,16 @@ static void test_input(const testCtx *const p_ctx) { /*100*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_TOO_LONG, -1, -1, "Error 442: Input too long (2D component)" }, /* Overlarge linear and oversized CC-C input */ /*101*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" "JKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLM", ZINT_ERROR_TOO_LONG, -1, -1, "Error 446: 2D component input too long, requires 2991 characters (maximum 2990)" }, /* Reduced length 2291 */ /*102*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012" "345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[11]121212[20]12", 0, 32, 579, "" }, /* Reduced length 2372 digits (no FNC1s) with not recommended ECC 4 > 2361 digit limit given in ISO/IEC 24723:2010 4.1 (d)(2)(iii) */ - /*103*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, - /*104*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, - /*105*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 2, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, - /*106*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 3, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "" }, - /*107*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 4, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 200, "" }, - /*108*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 2, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "" }, - /*109*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 3, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, - /*110*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 4, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, + /*103*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", "[20]12", ZINT_WARN_NONCOMPLIANT, 5, 1146, "Warning 843: Input too long, requires 99 characters (maximum 48) (linear component)" }, + /*104*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[90]ABCDEFGHIJKLMNOPQRSTUVWXYXABCD[91]ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 344: Input too long, requires 103 symbol characters (maximum 102) (linear component)" }, + /*105*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, + /*106*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, + /*107*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 2, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, + /*108*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 3, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "" }, + /*109*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 4, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 200, "" }, + /*110*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 2, "[91]1234567890123456789012345678901234", "[20]12", 0, 9, 151, "" }, + /*111*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 3, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, + /*112*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 4, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, composite_length, ret; diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index fd6e93fc..75778243 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -259,6 +259,9 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) { char *optarg; char *func = NULL; char func_buf[256 + 5]; + char *func_not = NULL; + char func_not_buf[256 + 5]; + char *func_match = NULL; int exclude_idx = 0; testCtx ctx; @@ -287,17 +290,19 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) { for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-d") == 0) { if (i + 1 == argc) { - fprintf(stderr, "testRun: -d debug value missing, ignored\n"); + fprintf(stderr, "testRun: -d debug value missing, ignoring\n"); } else { + int d; /* Allow multiple debug flags, OR-ing */ optarg = argv[++i]; - if (!validate_int(optarg, &ctx.debug)) { - fprintf(stderr, "testRun: -d debug value invalid, ignored\n"); - ctx.debug = 0; + if (!validate_int(optarg, &d)) { + fprintf(stderr, "testRun: -d debug value invalid, ignoring\n"); + } else { + ctx.debug |= d; } } } else if (strcmp(argv[i], "-f") == 0) { if (i + 1 == argc) { - fprintf(stderr, "testRun: -f func value missing, ignored\n"); + fprintf(stderr, "testRun: -f func value missing, ignoring\n"); } else { optarg = argv[++i]; if (strlen(optarg) < 256) { @@ -309,38 +314,62 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) { } func = func_buf; } else { - fprintf(stderr, "testRun: -f func value too long, ignored\n"); + fprintf(stderr, "testRun: -f func value too long, ignoring\n"); func = NULL; } } + } else if (strcmp(argv[i], "-n") == 0) { + if (i + 1 == argc) { + fprintf(stderr, "testRun: -n func exclude value missing, ignoring\n"); + } else { + optarg = argv[++i]; + if (strlen(optarg) < 256) { + if (strncmp(optarg, "test_", 5) == 0) { + strcpy(func_not_buf, optarg); + } else { + strcpy(func_not_buf, "test_"); + strcat(func_not_buf, optarg); + } + func_not = func_not_buf; + } else { + fprintf(stderr, "testRun: -p func exclude value too long, ignoring\n"); + func_not = NULL; + } + } + } else if (strcmp(argv[i], "-m") == 0) { + if (i + 1 == argc) { + fprintf(stderr, "testRun: -m func match value missing, ignoring\n"); + } else { + func_match = argv[++i]; + } } else if (strcmp(argv[i], "-g") == 0) { ctx.generate = 1; } else if (strcmp(argv[i], "-i") == 0) { if (i + 1 == argc) { - fprintf(stderr, "testRun: -i index value missing, ignored\n"); + fprintf(stderr, "testRun: -i index value missing, ignoring\n"); } else { optarg = argv[++i]; if (!validate_int_range(optarg, &ctx.index, &ctx.index_end)) { - fprintf(stderr, "testRun: -i index value invalid, ignored\n"); + fprintf(stderr, "testRun: -i index value invalid, ignoring\n"); ctx.index = ctx.index_end = -1; } } } else if (strcmp(argv[i], "-x") == 0) { if (i + 1 == argc) { - fprintf(stderr, "testRun: -x exclude value missing, ignored\n"); + fprintf(stderr, "testRun: -x exclude value missing, ignoring\n"); } else { optarg = argv[++i]; if (exclude_idx + 1 == ZINT_TEST_CTX_EXC_MAX) { - fprintf(stderr, "testRun: too many -x exclude values, ignored\n"); + fprintf(stderr, "testRun: too many -x exclude values, ignoring\n"); } else if (!validate_int_range(optarg, &ctx.exclude[exclude_idx], &ctx.exclude_end[exclude_idx])) { - fprintf(stderr, "testRun: -x exclude value invalid, ignored\n"); + fprintf(stderr, "testRun: -x exclude value invalid, ignoring\n"); ctx.exclude[exclude_idx] = ctx.exclude_end[exclude_idx] = -1; } else { exclude_idx++; } } } else { - fprintf(stderr, "testRun: unknown arg '%s', ignored\n", argv[i]); + fprintf(stderr, "testRun: unknown arg '%s', ignoring\n", argv[i]); } } @@ -349,6 +378,12 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) { if (func && strcmp(func, funcs[i].name) != 0) { continue; } + if (func_not && strcmp(func_not, funcs[i].name) == 0) { + continue; + } + if (func_match && strstr(funcs[i].name, func_match) == NULL) { + continue; + } (*funcs[i].func)(&ctx); ran++; } @@ -356,6 +391,9 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) { if (func && !ran) { fprintf(stderr, "testRun: unknown -f func arg '%s'\n", func); } + if (func_match && !ran) { + fprintf(stderr, "testRun: no funcs matched -m arg '%s'\n", func_match); + } } /* Call in a dataset loop to determine if a datum should be tested according to -i & -x args */ @@ -2215,7 +2253,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol { "maxicode", BARCODE_MAXICODE, 57, 1, 1, 0, 0, 0, }, { "qrcode", BARCODE_QRCODE, 58, 1, 1, 1, 0, 0, }, { "", -1, 59, 0, 0, 0, 0, 0, }, - { "", BARCODE_CODE128AB, 60, 0, 0, 0, 0, 0, }, + { "code128", BARCODE_CODE128AB, 60, 0, 0, 0, 0, 0, }, { "", -1, 61, 0, 0, 0, 0, 0, }, { "", -1, 62, 0, 0, 0, 0, 0, }, { "auspost", BARCODE_AUSPOST, 63, 0, 0, 0, 0, 0, }, @@ -2524,7 +2562,7 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch sprintf(b, "^%03d", val); b += 4; } else { - if (*d == '^' && d + 1 < de && ((*(d + 1) >= 'A' && *(d + 1) <= 'C') || *(d + 1) == '1')) { + if (*d == '^' && d + 1 < de && ((*(d + 1) >= '@' && *(d + 1) <= 'C') || *(d + 1) == '1')) { d++; if (*d == '1') { if (b + 5 >= be) { @@ -2807,8 +2845,11 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int /* sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sdontlint", strlen(bwipp_opts_buf) ? " " : ""); */ } } else { - if (testUtilBwippEscape(bwipp_data, bwipp_data_size, data, data_len, - symbol->input_mode & (ESCAPE_MODE | EXTRA_ESCAPE_MODE), eci, &parse, &parsefnc) == NULL) { + const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) + && symbol->symbology == BARCODE_CODE128; + const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped; + if (testUtilBwippEscape(bwipp_data, bwipp_data_size, data, data_len, is_escaped, eci, &parse, &parsefnc) + == NULL) { return -1; } if (parse) { @@ -2945,6 +2986,9 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int memmove(bwipp_data + 2, bwipp_data, data_len + 1); memmove(bwipp_data, prefix, 2); } + } else if (symbology == BARCODE_CODE128AB) { + sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%ssuppressc", strlen(bwipp_opts_buf) ? " " : ""); + bwipp_opts = bwipp_opts_buf; } else if (symbology == BARCODE_DPD) { if (data_len == 27 && option_2 != 1) { memmove(bwipp_data + 1, bwipp_data, data_len + 1); @@ -3947,8 +3991,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in const char *expected, int expected_len, const char *primary, char *ret_buf, int *p_ret_len) { const int symbology = symbol->symbology; - const int is_dbar_exp = symbology == BARCODE_DBAR_EXP || symbology == BARCODE_DBAR_EXPSTK; - const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE || is_dbar_exp; + const int is_gs1_128_dbar_exp = symbology == BARCODE_GS1_128 || symbology == BARCODE_DBAR_EXP + || symbology == BARCODE_DBAR_EXPSTK; + const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE || is_gs1_128_dbar_exp; const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128; const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped; const int is_hibc = symbology >= BARCODE_HIBC_128 && symbology <= BARCODE_HIBC_AZTEC; @@ -3969,7 +4014,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in char *c25inter = have_c25inter ? (char *) z_alloca(expected_len + 13 + 1 + 1) : NULL; char *upcean = is_upcean ? (char *) z_alloca(expected_len + 1 + 1) : NULL; char *ean14_nve18 = symbology == BARCODE_EAN14 || symbology == BARCODE_NVE18 - ? (char *) z_alloca(expected_len + 3 + 1) : NULL; + ? (char *) z_alloca(expected_len + 3 + 19 + 1) : NULL; char *dpd = need_dpd_prefix ? (char *) z_alloca(28 + 1) : NULL; char *pzn = symbology == BARCODE_PZN ? (char *) z_alloca(expected_len + 1 + 1) : NULL; @@ -3985,30 +4030,32 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in } if (is_escaped) { - if (symbol->input_mode & ESCAPE_MODE) { - ret = escape_char_process_test(symbol, (unsigned char *) expected, &expected_len, - (unsigned char *) escaped); - if (ret != 0) { - sprintf(msg, "escape_char_process %d != 0", ret); - return 3; - } - } else { - memcpy(escaped, expected, expected_len); + ret = escape_char_process_test(symbol, (unsigned char *) expected, &expected_len, + (unsigned char *) escaped); + if (ret != 0) { + sprintf(msg, "escape_char_process %d != 0", ret); + return 3; } if (is_extra_escaped) { /* Remove any Code 128 special escapes */ int j = 0; + int have_manual_ab = 0; for (i = 0; i < expected_len; i++) { if (escaped[i] == '\\' && i + 2 < expected_len && escaped[i + 1] == '^' - && ((escaped[i + 2] >= 'A' && escaped[i + 2] <= 'C') || escaped[i + 2] == '1' + && ((escaped[i + 2] >= '@' && escaped[i + 2] <= 'C') || escaped[i + 2] == '1' || escaped[i + 2] == '^')) { if (escaped[i + 2] != '^') { i += 2; - if (escaped[i] == '1') { - /* FNC1 in 1st position treated as GS1 and in 2nd position AIM, neither transmitted */ + if (escaped[i] == 'A' || escaped[i] == 'B') { + have_manual_ab = 1; /* Hack to help guess if in Code Set C for AIM exception below */ + } else if (escaped[i] == '1') { + /* FNC1 in 1st position treated as GS1 and in 2nd position AIM, neither transmitted - + need to skip AIM (single alphabetic or Code Set C double digit) + TODO: guessing about whether in Code Set C for double digit */ if (j > 2 || (j == 1 && !(z_isupper(escaped[0]) || z_islower(escaped[0]))) - /* TODO: following exception only valid if in Code Set C */ - || (j == 2 && !(z_isdigit(escaped[0]) && z_isdigit(escaped[1])))) { + || (j == 2 && !(z_isdigit(escaped[0]) && z_isdigit(escaped[1]) + && !have_manual_ab))) { + /* Probably not AIM */ escaped[j++] = 29; /* GS */ } } @@ -4268,16 +4315,15 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in } } else if (symbology == BARCODE_EAN14 || symbology == BARCODE_NVE18) { + int len = symbology == BARCODE_NVE18 ? 17 : 13; + int zeroes = expected_len < len ? len - expected_len: 0; ean14_nve18[0] = '0'; ean14_nve18[1] = symbology == BARCODE_NVE18 ? '0' : '1'; - memcpy(ean14_nve18 + 2, expected, expected_len); - if (symbology == BARCODE_NVE18) { - ean14_nve18[19] = gs1_check_digit((unsigned char *) (ean14_nve18 + 2), 17); - } else { - ean14_nve18[15] = gs1_check_digit((unsigned char *) (ean14_nve18 + 2), 13); - } + memset(ean14_nve18 + 2, '0', zeroes); + memcpy(ean14_nve18 + 2 + zeroes, expected, expected_len); + ean14_nve18[len + 2] = gs1_check_digit((unsigned char *) (ean14_nve18 + 2), len); expected = ean14_nve18; - expected_len += 3; + expected_len += zeroes + 3; } else if (need_dpd_prefix) { dpd[0] = '%'; diff --git a/backend/tests/tools/run_bwipp_tests.sh b/backend/tests/tools/run_bwipp_tests.sh index ad74d7b9..3e4d3d96 100755 --- a/backend/tests/tools/run_bwipp_tests.sh +++ b/backend/tests/tools/run_bwipp_tests.sh @@ -28,10 +28,7 @@ run_bwipp_test "test_code" "encode" run_bwipp_test "test_code1" "encode" run_bwipp_test "test_code1" "encode_segs" run_bwipp_test "test_code1" "fuzz" -run_bwipp_test "test_code128" "input" -run_bwipp_test "test_code128" "gs1_128_input" -run_bwipp_test "test_code128" "hibc_input" -run_bwipp_test "test_code128" "encode" +run_bwipp_test "test_code128" run_bwipp_test "test_code16k" "input" run_bwipp_test "test_code16k" "encode" run_bwipp_test "test_code49" "input" diff --git a/backend/tests/tools/run_zxingcpp_tests.sh b/backend/tests/tools/run_zxingcpp_tests.sh index ca9fe8fb..9d459d13 100755 --- a/backend/tests/tools/run_zxingcpp_tests.sh +++ b/backend/tests/tools/run_zxingcpp_tests.sh @@ -23,10 +23,7 @@ run_zxingcpp_test "test_codablock" "input" run_zxingcpp_test "test_codablock" "encode" run_zxingcpp_test "test_codablock" "fuzz" run_zxingcpp_test "test_code" "encode" -run_zxingcpp_test "test_code128" "input" -run_zxingcpp_test "test_code128" "gs1_128_input" -run_zxingcpp_test "test_code128" "hibc_input" -run_zxingcpp_test "test_code128" "encode" +run_zxingcpp_test "test_code128" run_zxingcpp_test "test_code16k" "input" run_zxingcpp_test "test_code16k" "encode" run_zxingcpp_test "test_dmatrix" "input" diff --git a/backend/zint.h b/backend/zint.h index a688b36f..1c6001c3 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -120,7 +120,7 @@ extern "C" { struct zint_structapp structapp; /* Structured Append info. Default structapp.count 0 (none) */ int warn_level; /* Affects error/warning value returned by Zint API (see WARN_XXX below) */ int debug; /* Debugging flags */ - unsigned char text[200]; /* Human Readable Text (HRT) (if any), UTF-8, NUL-terminated (output only) */ + unsigned char text[256]; /* Human Readable Text (HRT) (if any), UTF-8, NUL-terminated (output only) */ int rows; /* Number of rows used by the symbol (output only) */ int width; /* Width of the generated symbol (output only) */ unsigned char encoded_data[200][144]; /* Encoded data (output only). Allows for rows of 1152 modules */ @@ -307,7 +307,7 @@ extern "C" { #define HEIGHTPERROW_MODE 0x0040 /* Interpret `height` as per-row rather than as overall height */ #define FAST_MODE 0x0080 /* Use faster if less optimal encodation or other shortcuts if available */ /* Note: affects DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only */ -#define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences */ +#define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences as well as others */ /* Note: currently Code 128 only */ /* Data Matrix specific options (`symbol->option_3`) */ diff --git a/docs/manual.html b/docs/manual.html index 17669edd..b4a3a853 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -332,7 +332,7 @@

Zint Barcode Generator and Zint Barcode Studio User Manual

Version 2.13.0.9

-

October 2024

+

November 2024