From 93c3e27fba9725703a97b13f0d9e4fc4b29d0b68 Mon Sep 17 00:00:00 2001
From: gitlost
Date: Sat, 7 Sep 2024 12:44:16 +0100
Subject: [PATCH] CODE128: Add minimal encodation algorithm (non-extended ASCII
only) from ZXing (props Alex Geller) - about 25-60% slower depending on
data & stack heavy but does improve some outcomes when FNC1s present
(GS1_MODE or manual) although not much else it appears (the previous
algorithm was very good), but has a logical clarity the other lacked -
funcs `c128_dxsmooth()` etc shared with CODE16K now moved there and renamed
as `c16k_`; also fix extended char latching when exactly 4 extended chars
at end also manual code set switching now honoured exactly even if
immediate shift required; manual: make explicit that AI "(00)" and "(01)"
prefixes added by Zint are HRT-only general: add `extern "C"` wrappers to a
few header files
---
backend/bmp.h | 4 +-
backend/code128.c | 1195 +++++++-----------
backend/code128.h | 12 -
backend/code16k.c | 225 +++-
backend/common.c | 6 +-
backend/common.h | 10 +-
backend/eci.h | 6 +-
backend/emf.h | 4 +-
backend/filemem.h | 8 +
backend/pcx.h | 4 +-
backend/pdf417.h | 8 +
backend/pdf417_tabs.h | 8 +
backend/tests/data/emf/upu_s10_cmyk_nobg.emf | Bin 1536 -> 1536 bytes
backend/tests/test_code128.c | 369 +++---
backend/tests/test_composite.c | 6 +-
backend/tif.h | 4 +-
backend/tif_lzw.h | 10 +-
docs/manual.html | 26 +-
docs/manual.pmd | 14 +-
docs/manual.txt | 20 +-
docs/zint.1 | 6 +-
docs/zint.1.pmd | 6 +-
frontend/tests/test_args.c | 24 +-
23 files changed, 1017 insertions(+), 958 deletions(-)
diff --git a/backend/bmp.h b/backend/bmp.h
index 4f1f3843..9e9e784a 100644
--- a/backend/bmp.h
+++ b/backend/bmp.h
@@ -35,7 +35,7 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif /* __cplusplus */
#ifdef OUT_USE_PRAGMA_PACK
#pragma pack(1)
@@ -75,7 +75,7 @@ extern "C" {
#ifdef __cplusplus
}
-#endif
+#endif /* __cplusplus */
/* vim: set ts=4 sw=4 et : */
#endif /* Z_BMP_H */
diff --git a/backend/code128.c b/backend/code128.c
index 1a18249f..4df55a11 100644
--- a/backend/code128.c
+++ b/backend/code128.c
@@ -75,167 +75,157 @@ 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'}
};
-/* Determine appropriate mode for a given character */
-INTERNAL int c128_parunmodd(const unsigned char llyth, const int check_fnc1) {
- int modd;
+/* 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) {
- if (llyth <= 31) {
- modd = check_fnc1 && llyth == '\x1D' ? C128_ABORC : C128_SHIFTA;
- } else if ((llyth >= 48) && (llyth <= 57)) {
- modd = C128_ABORC;
- } else if (llyth <= 95) {
- modd = C128_AORB;
- } else if (llyth <= 127) {
- modd = C128_SHIFTB;
- } else if (llyth <= 159) {
- modd = C128_SHIFTA;
- } else if (llyth <= 223) {
- modd = C128_AORB;
+ if (ch <= 31) {
+ return charset == 1 || (check_fnc1 && ch == '\x1D');
+ }
+ if (ch <= 95) {
+ return 1;
+ }
+ if (ch <= 127) {
+ return charset == 2;
+ }
+ if (ch <= 159) {
+ return charset == 1;
+ }
+ if (ch <= 223) {
+ return 1;
+ }
+ return charset == 2;
+}
+
+/* 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 `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]) {
+
+ /* Check if memoized */
+ if (costs[position][charset]) {
+ return costs[position][charset];
} else {
- modd = C128_SHIFTB;
- }
+ 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;
- return modd;
-}
-
-/**
- * Bring together same type blocks
- */
-static void c128_grwp(int list[2][C128_MAX], int *p_indexliste) {
-
- /* bring together same type blocks */
- if (*p_indexliste > 1) {
- int i = 1;
- while (i < *p_indexliste) {
- if (list[1][i - 1] == list[1][i]) {
- int j;
- /* bring together */
- list[0][i - 1] = list[0][i - 1] + list[0][i];
- j = i + 1;
-
- /* decrease the list */
- while (j < *p_indexliste) {
- list[0][j - 1] = list[0][j];
- list[1][j - 1] = list[1][j];
- j++;
- }
- *p_indexliste = *p_indexliste - 1;
- i--;
+ /* 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;
}
- i++;
}
- }
-}
-
-/**
- * Implements rules from ISO 15417 Annex E
- */
-INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *p_indexliste, const char *manual_set) {
- int i, j, nextshift = 0 /*Suppresses gcc -Wmaybe-uninitialized false positive*/, nextshift_i = 0;
- 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 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) {
- nextshift = list[1][j];
- nextshift_i = j;
- break;
+ /* 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)) {
+ int cost = 1;
+ int latch = 0; /* Continue current `charset` */
+ if (charset != tryset) {
+ cost++;
+ latch = tryset;
+ }
+ 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;
+ }
+ 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);
+ }
+ 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;
}
}
}
+ assert(min_cost != 999999);
- if (i == 0) { /* first block */
- if (current == C128_ABORC) {
- if (manual_set && manual_set[i]) {
- list[1][i] = manual_set[i];
- current = manual_set[i];
- } else if ((indexliste == 1) && (length == 2)) {
- /* Rule 1a */
- list[1][i] = C128_LATCHC;
- current = C128_LATCHC;
- } else if (length >= 4) {
- /* Rule 1b */
- list[1][i] = C128_LATCHC;
- current = C128_LATCHC;
- } else {
- current = C128_AORB; /* Determine below */
- }
- }
- if (current == C128_AORB) {
- if (manual_set && (manual_set[i] == 'A' || manual_set[i] == 'B')) {
- list[1][i] = manual_set[i];
- } else if (nextshift == C128_SHIFTA) {
- /* Rule 1c */
- list[1][i] = C128_LATCHA;
- } else {
- /* Rule 1d */
- list[1][i] = C128_LATCHB;
- }
- } else if (current == C128_SHIFTA) {
- /* Rule 1c */
- list[1][i] = C128_LATCHA;
- } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */
- /* Rule 1d */
- list[1][i] = C128_LATCHB;
- }
+ costs[position][charset] = min_cost;
+ modes[position][charset] = min_latch;
+
+ 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;
+ int i;
+
+ memset(costs, 0, sizeof(int) * 4 * length);
+ memset(modes, 0, 4 * length);
+
+ c128_cost(source, length, 0 /*position*/, 0 /*charset*/, ab_only, manual_set, fncs, costs, modes);
+
+ for (i = 0; i < length; i++) {
+ const int latch = modes[i][charset];
+ if (latch >= 1 && latch <= 3) {
+ charset = latch;
+ set[i] = '@' + latch; /* A, B or C */
+ } else if (latch >= 4 && latch <= 5) {
+ /* Shift A/B */
+ charset = latch - 3;
+ set[i] = charset == 1 ? 'b' : 'a';
} else {
- int last = list[1][i - 1];
- if (current == C128_ABORC) {
- if (manual_set && manual_set[i]) {
- list[1][i] = manual_set[i];
- current = manual_set[i];
- } else if (length >= 4) {
- /* Rule 3 - note Rule 3b (odd C blocks) dealt with later */
- list[1][i] = C128_LATCHC;
- current = C128_LATCHC;
- } else {
- current = C128_AORB; /* Determine below */
- }
- }
- if (current == C128_AORB) {
- if (manual_set && (manual_set[i] == 'A' || manual_set[i] == 'B')) {
- list[1][i] = manual_set[i];
- } else 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;
- } else {
- list[1][i] = C128_LATCHB;
- }
- } else if (current == C128_SHIFTA) {
- if (manual_set && manual_set[i] == 'A') {
- list[1][i] = C128_LATCHA;
- } else 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;
- }
- } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */
- if (manual_set && manual_set[i] == 'B') {
- list[1][i] = C128_LATCHB;
- } else 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;
- }
- }
- } /* Rule 2 is implemented elsewhere, Rule 6 is implied */
+ /* 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';
+ }
}
-
- c128_grwp(list, p_indexliste);
}
/**
@@ -283,455 +273,16 @@ INTERNAL int c128_set_b(const unsigned char source, int values[], int *bar_chars
* 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) {
- int weight;
-
- weight = (10 * ctoi(source_a)) + ctoi(source_b);
- values[(*bar_chars)] = weight;
+ values[(*bar_chars)] = 10 * (source_a - '0') + source_b - '0';
(*bar_chars)++;
}
-/* Put set data into set[]. If source given (GS1_MODE or manual FNC1s) then resolves odd C blocks */
-INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX],
- const unsigned char *source) {
- int read = 0;
- int i, j;
-
- for (i = 0; i < indexliste; i++) {
- for (j = 0; j < list[0][i]; j++) {
- set[read++] = list[1][i];
- }
- }
- if (source) {
- /* Watch out for odd-length Mode C blocks */
- int c_count = 0, have_nonc = 0;
- for (i = 0; i < read; i++) {
- if (set[i] == 'C') {
- if (source[i] == '\x1D') {
- if (c_count & 1) {
- have_nonc = 1;
- if (i > c_count) {
- set[i - c_count] = 'B';
- } else {
- set[i - 1] = 'B';
- }
- }
- c_count = 0;
- } else {
- c_count++;
- }
- } else {
- have_nonc = 1;
- if (c_count & 1) {
- if (i > c_count) {
- set[i - c_count] = 'B';
- } else {
- set[i - 1] = 'B';
- }
- }
- c_count = 0;
- }
- }
- if (c_count & 1) {
- if (i > c_count && have_nonc) {
- set[i - c_count] = 'B';
- if (c_count < 4) {
- /* Rule 1b */
- for (j = i - c_count + 1; j < i; j++) {
- set[j] = 'B';
- }
- }
- } else {
- set[i - 1] = 'B';
- }
- }
- for (i = 1; i < read - 1; i++) {
- if (set[i] == 'C' && set[i - 1] != 'C' && set[i + 1] != 'C') {
- set[i] = set[i + 1];
- }
- }
- if (read > 1 && set[read - 1] == 'C' && set[read - 2] != 'C') {
- set[read - 1] = set[read - 2];
- }
- }
-}
-
-/* Handle Code 128, 128B and HIBC 128 */
-INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length) {
- int i, j, k, values[C128_MAX] = {0}, bar_characters = 0, read, total_sum;
- int error_number, indexchaine, indexliste, f_state = 0;
- 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 */
- int list[2][C128_MAX] = {{0}};
- char set[C128_MAX] = {0}, fset[C128_MAX], mode, last_set, current_set = ' ';
- int have_fnc1 = 0; /* Whether have at least 1 manual FNC1 */
- int glyph_count = 0; /* Codeword estimate times 2 */
- char dest[1000];
+/* 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 */
char *d = dest;
-
- /* Suppresses clang-analyzer-core.UndefinedBinaryOperatorResult warning on fset which is fully set */
- assert(length > 0);
-
- if (length > C128_MAX) {
- /* This only blocks ridiculously long input - the actual length of the
- resulting barcode depends on the type of data, so this is trapped later */
- sprintf(symbol->errtxt, "340: Input too long (%d character maximum)", C128_MAX);
- return ZINT_ERROR_TOO_LONG;
- }
-
- /* Detect special Code Set escapes for Code 128 in extra escape mode only */
- if ((symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128) {
- char manual_ch = '\0';
- 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] == '^')) {
- if (source[i + 2] == '^') { /* Escape sequence '\^^' */
- manual_set[j] = manual_ch;
- src_buf[j++] = source[i++];
- manual_set[j] = manual_ch;
- 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;
- src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */
- } else { /* Manual mode A/B/C */
- i += 2;
- manual_ch = source[i];
- }
- } else {
- manual_set[j] = manual_ch;
- src_buf[j++] = source[i];
- }
- }
- if (j != length) {
- length = j;
- if (length == 0) {
- strcpy(symbol->errtxt, "842: No input data");
- return ZINT_ERROR_INVALID_DATA;
- }
- 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] ? manual_set[i] : '.');
- fputc('\n', stdout);
- }
- }
- }
-
- /* Detect extended ASCII characters */
- for (i = 0; i < length; i++) {
- fset[i] = src[i] >= 128 ? 'f' : ' ';
- }
-
- /* Decide when to latch to extended mode - Annex E note 3 */
- j = 0;
- for (i = 0; i < length; i++) {
- if (fset[i] == 'f') {
- j++;
- } else {
- j = 0;
- }
-
- if (j >= 5) {
- for (k = i; k > (i - 5); k--) {
- fset[k] = 'F';
- }
- }
-
- if ((j >= 3) && (i == (length - 1))) {
- for (k = i; k > (i - 3); k--) {
- fset[k] = 'F';
- }
- }
- }
-
- /* Decide if it is worth reverting to 646 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] == ' ')) {
- /* Detected a change from 8859-1 to 646 - count how long for */
- for (j = 0; ((i + j) < length) && (fset[i + j] == ' '); j++);
- /* Count how many 8859-1 beyond */
- k = 0;
- if (i + j < length) {
- for (k = 1; ((i + j + k) < length) && (fset[i + j + k] != ' '); k++);
- }
- if (j < 3 || (j < 5 && k > 2)) {
- /* Change to shifting back rather than latching back */
- /* Inverts the same figures recommended by Annex E note 3 */
- for (k = 0; k < j; k++) {
- fset[i + k] = 'n';
- }
- }
- }
- }
-
- /* Decide on mode using same system as PDF417 and rules of ISO 15417 Annex E */
- indexliste = 0;
- indexchaine = 0;
-
- mode = c128_parunmodd(src[indexchaine], fncs[indexchaine]);
- if (mode == C128_ABORC
- && (symbol->symbology == BARCODE_CODE128AB
- || manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B')) {
- mode = C128_AORB;
- }
-
- do {
- list[1][indexliste] = mode;
- while ((list[1][indexliste] == mode) && (indexchaine < length)) {
- list[0][indexliste]++;
- indexchaine++;
- if (indexchaine == length) {
- break;
- }
- mode = c128_parunmodd(src[indexchaine], fncs[indexchaine]);
- if (mode == C128_ABORC
- && (symbol->symbology == BARCODE_CODE128AB
- || manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B')) {
- mode = C128_AORB;
- }
- if (manual_set[indexchaine] != manual_set[indexchaine - 1]) {
- break;
- }
- }
- indexliste++;
- } while (indexchaine < length);
-
- if (src == src_buf) {
- /* Need to re-index `manual_set` to have sames indexes as `list` blocks for `c128_dxsmooth()` */
- j = 0;
- for (i = 1; i < indexliste; i++) {
- j += list[0][i - 1];
- manual_set[i] = manual_set[j];
- }
- }
- c128_dxsmooth(list, &indexliste, src == src_buf ? manual_set : NULL);
-
- if (!have_fnc1) {
- /* Resolve odd length C128_LATCHC blocks */
- if ((list[1][0] == C128_LATCHC) && (list[0][0] & 1)) {
- /* Rule 2 */
- list[0][1]++;
- list[0][0]--;
- if (indexliste == 1) {
- list[0][1] = 1;
- list[1][1] = C128_LATCHB;
- indexliste = 2;
- }
- }
- if (indexliste > 1) {
- for (i = 1; i < indexliste; i++) {
- if ((list[1][i] == C128_LATCHC) && (list[0][i] & 1)) {
- /* Rule 3b */
- list[0][i - 1]++;
- list[0][i]--;
- }
- }
- }
- }
-
- /* Put set data into set[]. Give NULL as source if no manual FNC1s as used to resolve odd C blocks
- which has been done above */
- c128_put_in_set(list, indexliste, set, have_fnc1 ? src : NULL);
-
- 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 */
- last_set = set[0];
- for (i = 0; i < length; i++) {
- if ((set[i] == 'a') || (set[i] == 'b')) {
- glyph_count += 2; /* 1 codeword */
- }
- if ((fset[i] == 'f') || (fset[i] == 'n')) {
- glyph_count += 2; /* May be overestimate if in latch */
- }
- if (((set[i] == 'A') || (set[i] == 'B')) || (set[i] == 'C')) {
- if (set[i] != last_set) {
- last_set = set[i];
- glyph_count += 2;
- }
- }
- if (i == 0) {
- if (fset[i] == 'F') {
- glyph_count += 4; /* 2 codewords */
- }
- } else {
- if ((fset[i] == 'F') && (fset[i - 1] != 'F')) {
- glyph_count += 4;
- } else if ((fset[i] != 'F') && (fset[i - 1] == 'F')) {
- glyph_count += 4;
- }
- }
-
- if (set[i] == 'C' && !fncs[i]) {
- glyph_count += 1; /* Half a codeword */
- } else {
- glyph_count += 2;
- }
- }
- if (glyph_count > C128_SYMBOL_MAX * 2) {
- sprintf(symbol->errtxt, "341: Input too long (%d symbol character maximum)", C128_SYMBOL_MAX);
- return ZINT_ERROR_TOO_LONG;
- }
-
- /* 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 */
- values[bar_characters++] = 103;
- current_set = 'A';
- values[bar_characters++] = 96; /* FNC3 */
- break;
- case 'B': /* Start B */
- 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;
- }
- } else {
- /* Normal mode */
- switch (set[0]) {
- case 'A': /* Start A */
- values[bar_characters++] = 103;
- current_set = 'A';
- break;
- case 'B': /* Start B */
- values[bar_characters++] = 104;
- current_set = 'B';
- break;
- case 'C': /* Start C */
- values[bar_characters++] = 105;
- current_set = 'C';
- break;
- }
- }
-
- if (fset[0] == 'F') {
- switch (current_set) {
- case 'A':
- values[bar_characters++] = 101;
- values[bar_characters++] = 101;
- f_state = 1;
- break;
- case 'B':
- values[bar_characters++] = 100;
- values[bar_characters++] = 100;
- f_state = 1;
- break;
- }
- }
-
- /* Encode the data */
- read = 0;
- do {
-
- if (read != 0) {
- if (set[read] != current_set) {
- /* Latch different code set */
- switch (set[read]) {
- case 'A':
- values[bar_characters++] = 101;
- current_set = 'A';
- break;
- case '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)) {
- /* Latch beginning of extended mode */
- switch (current_set) {
- case 'A':
- values[bar_characters++] = 101;
- values[bar_characters++] = 101;
- f_state = 1;
- break;
- case 'B':
- values[bar_characters++] = 100;
- values[bar_characters++] = 100;
- f_state = 1;
- break;
- }
- }
- if ((fset[read] == ' ') && (f_state == 1)) {
- /* Latch end of extended mode */
- switch (current_set) {
- case 'A':
- values[bar_characters++] = 101;
- values[bar_characters++] = 101;
- f_state = 0;
- break;
- case 'B':
- values[bar_characters++] = 100;
- values[bar_characters++] = 100;
- f_state = 0;
- break;
- }
- }
- }
-
- 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; /* FNC 4 */
- break;
- case 'B':
- values[bar_characters++] = 100; /* FNC 4 */
- break;
- }
- }
-
- if ((set[read] == 'a') || (set[read] == 'b')) {
- /* Insert shift character */
- values[bar_characters++] = 98;
- }
-
- if (!fncs[read]) {
- switch (set[read]) { /* Encode data characters */
- 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 += 2;
- break;
- }
- } else {
- values[bar_characters++] = 102; /* FNC1 in all modes */
- read++;
- }
-
- } while (read < length);
+ int total_sum;
+ int i;
/* Destination setting and check digit calculation */
memcpy(d, C128Table[values[0]], 6);
@@ -768,6 +319,336 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
#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 = ' ';
+ 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;
+ }
+
+ for (i = 0; i < length; i++) {
+ if (set[i] != current_set) {
+ /* Latch different code set */
+ switch (set[0]) {
+ 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 (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 ((set[i] == 'a') || (set[i] == 'b')) {
+ /* Insert shift character */
+ glyph_count++;
+ }
+
+ /* Actual character */
+ glyph_count++;
+
+ if (set[i] == 'C' && source[i] != '\x1D') {
+ i++;
+ }
+ }
+
+ return glyph_count;
+}
+
+/* Handle Code 128, 128B and HIBC 128 */
+INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length) {
+ int i, j, k, read;
+ int error_number;
+ int values[C128_MAX] = {0}, bar_characters = 0;
+ 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 = ' ';
+ 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);
+
+ if (length > C128_MAX) {
+ /* This only blocks ridiculously long input - the actual length of the
+ resulting barcode depends on the type of data, so this is trapped later */
+ sprintf(symbol->errtxt, "340: Input too long (%d character maximum)", C128_MAX);
+ return ZINT_ERROR_TOO_LONG;
+ }
+
+ /* 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;
+ 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] == '^')) {
+ if (source[i + 2] == '^') { /* Escape sequence '\^^' */
+ manual_set[j] = manual_ch;
+ src_buf[j++] = source[i++];
+ manual_set[j] = manual_ch;
+ 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;
+ src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */
+ } else { /* Manual mode A/B/C */
+ i += 2;
+ manual_ch = source[i] - '@'; /* 1 (A), 2 (B), 3 (C) */
+ }
+ } else {
+ manual_set[j] = manual_ch;
+ src_buf[j++] = source[i];
+ }
+ }
+ if (j != length) {
+ length = j;
+ if (length == 0) {
+ strcpy(symbol->errtxt, "842: No input data");
+ return ZINT_ERROR_INVALID_DATA;
+ }
+ 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] + '@');
+ 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 - Annex E note 3 */
+ j = 0;
+ for (i = 0; i < length; i++) {
+ if (fset[i] == 'f') {
+ j++;
+ } else {
+ j = 0;
+ }
+
+ if (j >= 5) {
+ for (k = i; k > (i - 5); k--) {
+ fset[k] = 'F';
+ }
+ }
+ }
+ if (j >= 3) {
+ for (k = length - 1; k > length - 1 - j; k--) {
+ fset[k] = 'F';
+ }
+ }
+
+ /* Decide if it is worth reverting to 646 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 = 0;
+ /* Detected a change from 8859-1 to 646 - count how long for */
+ for (j = 0; ((i + j) < length) && (fset[i + j] == ' '); j++) {
+ c += set[i + j] == 'C'; /* Count code set C so can subtract when deciding below */
+ }
+ /* Count how many 8859-1 beyond */
+ k = 0;
+ if (i + j < length) {
+ for (k = 1; ((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 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 (c128_glyph_count(source, length, set, fset) > C128_SYMBOL_MAX) {
+ sprintf(symbol->errtxt, "341: Input too long (%d symbol character maximum)", C128_SYMBOL_MAX);
+ return ZINT_ERROR_TOO_LONG;
+ }
+
+ /* 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;
+ }
+ } 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;
+ }
+ }
+
+ /* 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 */
+ }
+
+ }
+
+ c128_expand(symbol, values, bar_characters);
/* ISO/IEC 15417:2007 leaves dimensions/height as application specification */
@@ -789,13 +670,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
/* Handle EAN-128 (Now known as GS1-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, values[C128_MAX] = {0}, bar_characters = 0, read, total_sum;
- int error_number, indexchaine, indexliste;
- int list[2][C128_MAX] = {{0}};
- char set[C128_MAX] = {0}, mode, last_set;
- int glyph_count = 0; /* Codeword estimate times 2 */
- char dest[1000];
- char *d = dest;
+ int i, read;
+ int error_number;
+ int values[C128_MAX] = {0}, bar_characters = 0;
+ char set[C128_MAX] = {0};
int separator_row = 0, linkage_flag = 0;
int reduced_length;
unsigned char *reduced = (unsigned char *) z_alloca(length + 1);
@@ -821,29 +699,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
reduced_length = (int) ustrlen(reduced);
- /* Decide on mode using same system as PDF417 and rules of ISO 15417 Annex E */
- indexliste = 0;
- indexchaine = 0;
-
- mode = c128_parunmodd(reduced[indexchaine], 1 /*check_fnc1*/);
-
- do {
- list[1][indexliste] = mode;
- while ((list[1][indexliste] == mode) && (indexchaine < reduced_length)) {
- list[0][indexliste]++;
- indexchaine++;
- if (indexchaine == reduced_length) {
- break;
- }
- mode = c128_parunmodd(reduced[indexchaine], 1 /*check_fnc1*/);
- }
- indexliste++;
- } while (indexchaine < reduced_length);
-
- c128_dxsmooth(list, &indexliste, NULL /*manual_set*/);
-
- /* Put set data into set[], resolving odd C blocks */
- c128_put_in_set(list, indexliste, set, reduced);
+ c128_define_mode(set, reduced, reduced_length, 0 /*ab_only*/, NULL, NULL /*fncs*/);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Data: %s (%d)\n", reduced, reduced_length);
@@ -852,33 +708,14 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
/* Now we can calculate how long the barcode is going to be - and stop it from
being too long */
- last_set = set[0];
- for (i = 0; i < reduced_length; i++) {
- if ((set[i] == 'A') || (set[i] == 'B') || (set[i] == 'C')) {
- if (set[i] != last_set) {
- last_set = set[i];
- glyph_count += 2; /* 1 codeword */
- }
- } else if ((set[i] == 'a') || (set[i] == 'b')) {
- glyph_count += 2; /* Not reached */
- }
-
- if ((set[i] == 'C') && (reduced[i] != '\x1D')) {
- glyph_count += 1; /* Half a codeword */
- } else {
- glyph_count += 2;
- }
- }
- if (glyph_count > C128_SYMBOL_MAX * 2) {
+ if (c128_glyph_count(reduced, reduced_length, set, NULL /*fset*/) > C128_SYMBOL_MAX) {
sprintf(symbol->errtxt, "344: Input too long (%d symbol character maximum)", C128_SYMBOL_MAX);
return ZINT_ERROR_TOO_LONG;
}
/* 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 'A': /* Start A */
- values[bar_characters++] = 103; /* Not reached */
- break;
case 'B': /* Start B */
values[bar_characters++] = 104;
break;
@@ -890,14 +727,12 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
values[bar_characters++] = 102; /* FNC1 */
/* Encode the data */
- read = 0;
- do {
+ 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 */
+ if ((read != 0) && (set[read] != set[read - 1])) {
+ /* Latch different code set */
switch (set[read]) {
- case 'A':
- values[bar_characters++] = 101; /* Not reached */
- break;
case 'B':
values[bar_characters++] = 100;
break;
@@ -907,31 +742,20 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
}
}
- if ((set[read] == 'a') || (set[read] == 'b')) {
- /* Insert shift character */
- values[bar_characters++] = 98; /* Not reached */
- }
-
if (reduced[read] != '\x1D') {
switch (set[read]) { /* Encode data characters */
- case 'A':
- case 'a':
- c128_set_a(reduced[read++], values, &bar_characters); /* Not reached */
- break;
case 'B':
- case 'b':
- (void) c128_set_b(reduced[read++], values, &bar_characters);
+ (void) c128_set_b(reduced[read], values, &bar_characters);
break;
case 'C':
c128_set_c(reduced[read], reduced[read + 1], values, &bar_characters);
- read += 2;
+ read++;
break;
}
} else {
values[bar_characters++] = 102; /* FNC1 in all modes */
- read++;
}
- } while (read < reduced_length);
+ }
/* "...note that the linkage flag is an extra code set character between
the last data character and the Symbol Check Character" (GS1 Specification) */
@@ -943,8 +767,6 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
case 2:
/* CC-A or CC-B 2D component */
switch (set[reduced_length - 1]) {
- case 'A': linkage_flag = 100; /* Not reached */
- break;
case 'B': linkage_flag = 99;
break;
case 'C': linkage_flag = 101;
@@ -954,8 +776,6 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
case 3:
/* CC-C 2D component */
switch (set[reduced_length - 1]) {
- case 'A': linkage_flag = 99; /* Not reached */
- break;
case 'B': linkage_flag = 101;
break;
case 'C': linkage_flag = 100;
@@ -968,40 +788,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
values[bar_characters++] = linkage_flag;
}
- /* Destination setting and check digit calculation */
- memcpy(d, C128Table[values[0]], 6);
- d += 6;
- total_sum = values[0];
-
- for (i = 1; i < bar_characters; 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 %= 103;
- memcpy(d, C128Table[total_sum], 6);
- d += 6;
- values[bar_characters++] = total_sum;
-
- /* Stop character */
- memcpy(d, "2331112", 7);
- d += 7;
- values[bar_characters++] = 106;
-
- if (symbol->debug & ZINT_DEBUG_PRINT) {
- fputs("Codewords:", stdout);
- for (i = 0; i < bar_characters; i++) {
- printf(" %d", values[i]);
- }
- printf(" (%d)\n", bar_characters);
- printf("Barspaces: %.*s\n", (int) (d - dest), dest);
- }
-#ifdef ZINT_TEST
- if (symbol->debug & ZINT_DEBUG_TEST) {
- debug_test_codeword_dump_int(symbol, values, bar_characters);
- }
-#endif
-
- expand(symbol, dest, d - dest);
+ c128_expand(symbol, values, bar_characters);
/* Add the separator pattern for composite symbols */
if (symbol->symbology == BARCODE_GS1_128_CC) {
diff --git a/backend/code128.h b/backend/code128.h
index 3102eb60..78e09677 100644
--- a/backend/code128.h
+++ b/backend/code128.h
@@ -39,23 +39,11 @@ extern "C" {
/* Allow for a reasonable number of special Code Set escapes and for GS1 AI delimiters */
#define C128_MAX 256
-#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'
-
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length);
-INTERNAL int c128_parunmodd(const unsigned char llyth, const int check_fnc1);
-INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste, const char *manual_set);
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 void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX],
- const unsigned char *source);
INTERNAL_DATA_EXTERN const char C128Table[107][6];
diff --git a/backend/code16k.c b/backend/code16k.c
index bd757955..5e4bc672 100644
--- a/backend/code16k.c
+++ b/backend/code16k.c
@@ -39,6 +39,15 @@
#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 using C128Table with extra entry at 106 (Triple Shift) for C16KTable */
/* EN 12323 Table 3 and Table 4 - Start patterns and stop patterns */
@@ -56,6 +65,214 @@ static const unsigned char C16KStopValues[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3
};
+/* Determine appropriate mode for a given character (was `c128_parunmodd()`) */
+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;
+ } else if ((llyth >= 48) && (llyth <= 57)) {
+ modd = C128_ABORC;
+ } else if (llyth <= 95) {
+ modd = C128_AORB;
+ } else if (llyth <= 127) {
+ modd = C128_SHIFTB;
+ } else if (llyth <= 159) {
+ modd = C128_SHIFTA;
+ } else if (llyth <= 223) {
+ modd = C128_AORB;
+ } else {
+ modd = C128_SHIFTB;
+ }
+
+ return modd;
+}
+
+/* Bring together same type blocks (was `c128_grwp()`) */
+static void c16k_grwp(int list[2][C128_MAX], int *p_indexliste) {
+
+ if (*p_indexliste > 1) {
+ int i = 1;
+ while (i < *p_indexliste) {
+ if (list[1][i - 1] == list[1][i]) {
+ int j;
+ /* Bring together */
+ list[0][i - 1] = list[0][i - 1] + list[0][i];
+ j = i + 1;
+
+ /* Decrease the list */
+ while (j < *p_indexliste) {
+ list[0][j - 1] = list[0][j];
+ list[1][j - 1] = list[1][j];
+ j++;
+ }
+ *p_indexliste = *p_indexliste - 1;
+ i--;
+ }
+ i++;
+ }
+ }
+}
+
+/* Implements rules from ISO/IEC 15417:2007 Annex E (was `c128_dxsmooth()`) */
+static void c16k_dxsmooth(int list[2][C128_MAX], int *p_indexliste) {
+ int i, j, nextshift = 0 /*Suppresses gcc -Wmaybe-uninitialized false positive*/, nextshift_i = 0;
+ 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 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) {
+ nextshift = list[1][j];
+ nextshift_i = j;
+ break;
+ }
+ }
+ }
+
+ if (i == 0) { /* first block */
+ if (current == C128_ABORC) {
+ if ((indexliste == 1) && (length == 2)) {
+ /* Rule 1a */
+ list[1][i] = C128_LATCHC;
+ current = C128_LATCHC;
+ } else if (length >= 4) {
+ /* Rule 1b */
+ list[1][i] = C128_LATCHC;
+ current = C128_LATCHC;
+ } else {
+ current = C128_AORB; /* Determine below */
+ }
+ }
+ if (current == C128_AORB) {
+ if (nextshift == C128_SHIFTA) {
+ /* Rule 1c */
+ list[1][i] = C128_LATCHA;
+ } else {
+ /* Rule 1d */
+ list[1][i] = C128_LATCHB;
+ }
+ } else if (current == C128_SHIFTA) {
+ /* Rule 1c */
+ list[1][i] = C128_LATCHA;
+ } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */
+ /* Rule 1d */
+ list[1][i] = C128_LATCHB;
+ }
+ } else {
+ int last = list[1][i - 1];
+ if (current == C128_ABORC) {
+ if (length >= 4) {
+ /* Rule 3 - note Rule 3b (odd C blocks) dealt with later */
+ list[1][i] = C128_LATCHC;
+ current = C128_LATCHC;
+ } else {
+ current = C128_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;
+ } else {
+ list[1][i] = C128_LATCHB;
+ }
+ } else if (current == C128_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;
+ }
+ } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_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;
+ }
+ }
+ } /* Rule 2 is implemented elsewhere, Rule 6 is implied */
+ }
+
+ c16k_grwp(list, p_indexliste);
+}
+
+/* Put set data into set[]. Resolves odd C blocks (was `c128_put_in_set()`) */
+static void c16k_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX],
+ const unsigned char *source) {
+ int read = 0;
+ int i, j;
+ int c_count = 0, have_nonc = 0;
+
+ for (i = 0; i < indexliste; i++) {
+ for (j = 0; j < list[0][i]; j++) {
+ set[read++] = list[1][i];
+ }
+ }
+ /* Watch out for odd-length Mode C blocks */
+ for (i = 0; i < read; i++) {
+ if (set[i] == 'C') {
+ if (source[i] == '\x1D') {
+ if (c_count & 1) {
+ have_nonc = 1;
+ if (i > c_count) {
+ set[i - c_count] = 'B';
+ } else {
+ set[i - 1] = 'B';
+ }
+ }
+ c_count = 0;
+ } else {
+ c_count++;
+ }
+ } else {
+ have_nonc = 1;
+ if (c_count & 1) {
+ if (i > c_count) {
+ set[i - c_count] = 'B';
+ } else {
+ set[i - 1] = 'B';
+ }
+ }
+ c_count = 0;
+ }
+ }
+ if (c_count & 1) {
+ if (i > c_count && have_nonc) {
+ set[i - c_count] = 'B';
+ if (c_count < 4) {
+ /* Rule 1b */
+ for (j = i - c_count + 1; j < i; j++) {
+ set[j] = 'B';
+ }
+ }
+ } else {
+ set[i - 1] = 'B';
+ }
+ }
+ for (i = 1; i < read - 1; i++) {
+ if (set[i] == 'C' && set[i - 1] != 'C' && set[i + 1] != 'C') {
+ set[i] = set[i + 1];
+ }
+ }
+ if (read > 1 && set[read - 1] == 'C' && set[read - 2] != 'C') {
+ set[read - 1] = set[read - 2];
+ }
+}
+
+/* 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 */
int current_row, rows, looper, first_check, second_check;
@@ -90,7 +307,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
indexliste = 0;
indexchaine = 0;
- mode = c128_parunmodd(source[indexchaine], gs1 /*check_fnc1*/);
+ mode = c16k_parunmodd(source[indexchaine], gs1 /*check_fnc1*/);
do {
list[1][indexliste] = mode;
@@ -100,15 +317,15 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
if (indexchaine == length) {
break;
}
- mode = c128_parunmodd(source[indexchaine], gs1 /*check_fnc1*/);
+ mode = c16k_parunmodd(source[indexchaine], gs1 /*check_fnc1*/);
}
indexliste++;
} while (indexchaine < length);
- c128_dxsmooth(list, &indexliste, NULL /*manual_set*/);
+ c16k_dxsmooth(list, &indexliste);
/* Put set data into set[], resolving odd C blocks */
- c128_put_in_set(list, indexliste, set, source);
+ c16k_put_in_set(list, indexliste, set, source);
if (debug_print) {
printf("Data: %.*s\n", length, source);
diff --git a/backend/common.c b/backend/common.c
index 9267db49..890c3c58 100644
--- a/backend/common.c
+++ b/backend/common.c
@@ -185,6 +185,7 @@ INTERNAL int bin_append_posn(const int arg, const int length, char *binary, cons
}
#ifndef Z_COMMON_INLINE
+
/* Returns true (1) if a module is dark/black, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
return (symbol->encoded_data[y_coord][x_coord >> 3] >> (x_coord & 0x07)) & 1;
@@ -209,7 +210,8 @@ INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, c
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord) {
symbol->encoded_data[y_coord][x_coord >> 3] &= ~(1 << (x_coord & 0x07));
}
-#endif
+
+#endif /* Z_COMMON_INLINE */
/* Expands from a width pattern to a bit pattern */
INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int length) {
@@ -662,6 +664,6 @@ INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7
#pragma GCC diagnostic pop
#endif
-#endif /*ZINT_TEST*/
+#endif /* ZINT_TEST */
/* vim: set ts=4 sw=4 et : */
diff --git a/backend/common.h b/backend/common.h
index 2225fa48..5fe06341 100644
--- a/backend/common.h
+++ b/backend/common.h
@@ -53,6 +53,7 @@ typedef unsigned __int64 uint64_t;
#endif
/* Note if change following must also change "frontend/main.c" copy */
+
#define ARRAY_SIZE(x) ((int) (sizeof(x) / sizeof((x)[0])))
#ifdef _MSC_VER
@@ -67,6 +68,7 @@ typedef unsigned __int64 uint64_t;
# endif
# define z_alloca(nmemb) alloca(nmemb)
#endif
+
/* End of "frontend/main.c" copy */
#ifdef _MSC_VER
@@ -198,12 +200,15 @@ INTERNAL int bin_append_posn(const int arg, const int length, char *binary, cons
#define Z_COMMON_INLINE 1
#ifdef Z_COMMON_INLINE
+
# define module_is_set(s, y, x) (((s)->encoded_data[y][(x) >> 3] >> ((x) & 0x07)) & 1)
# define set_module(s, y, x) do { (s)->encoded_data[y][(x) >> 3] |= 1 << ((x) & 0x07); } while (0)
# define module_colour_is_set(s, y, x) ((s)->encoded_data[y][x])
# define set_module_colour(s, y, x, c) do { (s)->encoded_data[y][x] = (c); } while (0)
# define unset_module(s, y, x) do { (s)->encoded_data[y][(x) >> 3] &= ~(1 << ((x) & 0x07)); } while (0)
-#else
+
+#else /* Z_COMMON_INLINE */
+
/* Returns true (1) if a module is dark/black, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
@@ -219,8 +224,10 @@ INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, c
/* Sets a dark/black module to white (i.e. unsets) */
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
+
#endif /* Z_COMMON_INLINE */
+
/* Expands from a width pattern to a bit pattern */
INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int length);
@@ -282,6 +289,7 @@ INTERNAL void segs_cpy(const struct zint_symbol *symbol, const struct zint_seg s
struct zint_seg local_segs[]);
+/* Helper for ZINT_DEBUG_PRINT to put all but graphical ASCII in angle brackets */
INTERNAL char *debug_print_escape(const unsigned char *source, const int first_len, char *buf);
#ifdef ZINT_TEST
diff --git a/backend/eci.h b/backend/eci.h
index 272aad28..60d65fde 100644
--- a/backend/eci.h
+++ b/backend/eci.h
@@ -1,7 +1,7 @@
/* eci.c - Extended Channel Interpretations to Unicode tables */
/*
libzint - the open source barcode library
- Copyright (C) 2009-2022 Robin Stuart
+ Copyright (C) 2009-2024 Robin Stuart
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -35,7 +35,7 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif /* __cplusplus */
INTERNAL int is_eci_convertible(const int eci);
INTERNAL int is_eci_convertible_segs(const struct zint_seg segs[], const int seg_count, int convertible[]);
@@ -75,7 +75,7 @@ INTERNAL int gb18030_utf8_to_eci(const int eci, const unsigned char source[], in
#ifdef __cplusplus
}
-#endif
+#endif /* __cplusplus */
/* vim: set ts=4 sw=4 et : */
#endif /* Z_ECI_H */
diff --git a/backend/emf.h b/backend/emf.h
index ca197e7c..334003a0 100644
--- a/backend/emf.h
+++ b/backend/emf.h
@@ -35,7 +35,7 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif /* __cplusplus */
#ifdef OUT_USE_PRAGMA_PACK
#pragma pack(1)
@@ -243,7 +243,7 @@ extern "C" {
#ifdef __cplusplus
}
-#endif
+#endif /* __cplusplus */
/* vim: set ts=4 sw=4 et : */
#endif /* Z_EMF_H */
diff --git a/backend/filemem.h b/backend/filemem.h
index f63198cd..3af34d40 100644
--- a/backend/filemem.h
+++ b/backend/filemem.h
@@ -33,6 +33,10 @@
#ifndef Z_FILEMEM_H
#define Z_FILEMEM_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
#include
#include "common.h"
@@ -91,5 +95,9 @@ INTERNAL int fm_error(struct filemem *restrict const fmp);
NOTE: don't use, included only for libpng compatibility */
INTERNAL int fm_flush(struct filemem *restrict const fmp);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
/* vim: set ts=4 sw=4 et : */
#endif /* Z_FILEMEM_H */
diff --git a/backend/pcx.h b/backend/pcx.h
index 39b001ce..b1e43988 100644
--- a/backend/pcx.h
+++ b/backend/pcx.h
@@ -35,7 +35,7 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif /* __cplusplus */
#ifdef OUT_USE_PRAGMA_PACK
#pragma pack(1)
@@ -68,7 +68,7 @@ extern "C" {
#ifdef __cplusplus
}
-#endif
+#endif /* __cplusplus */
/* vim: set ts=4 sw=4 et : */
#endif /* Z_PCX_H */
diff --git a/backend/pdf417.h b/backend/pdf417.h
index 7cfcf7fc..748ac7a2 100644
--- a/backend/pdf417.h
+++ b/backend/pdf417.h
@@ -36,6 +36,10 @@
#ifndef Z_PDF417_H
#define Z_PDF417_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
/* PDF417 error correction coefficients from Grand Zebu */
INTERNAL_DATA_EXTERN const unsigned short pdf_coefrs[1022];
@@ -59,5 +63,9 @@ INTERNAL_DATA_EXTERN const unsigned short pdf_rap_centre[52];
INTERNAL void pdf_byteprocess(short *chainemc, int *p_mclength, const unsigned char chaine[], int start,
const int length, const int lastmode);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
/* vim: set ts=4 sw=4 et : */
#endif /* Z_PDF417_H */
diff --git a/backend/pdf417_tabs.h b/backend/pdf417_tabs.h
index 59722a97..b7c7e3ba 100644
--- a/backend/pdf417_tabs.h
+++ b/backend/pdf417_tabs.h
@@ -39,6 +39,10 @@
#ifndef Z_PDF417_TABS_H
#define Z_PDF417_TABS_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
/* PDF417 error correction coefficients from Grand Zebu */
INTERNAL_DATA const unsigned short pdf_coefrs[1022] = {
/* k = 2 */
@@ -510,5 +514,9 @@ INTERNAL_DATA const unsigned short pdf_rap_centre[52] = {
0x2DC, 0x2DE
};
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
/* vim: set ts=4 sw=4 et : */
#endif /* Z_PDF417_TABS_H */
diff --git a/backend/tests/data/emf/upu_s10_cmyk_nobg.emf b/backend/tests/data/emf/upu_s10_cmyk_nobg.emf
index cbd97acf595ce40dff05cb1049ad2e9a89c64cff..4ab2c371ba87b144d725c9f1168cf8cad8465b94 100644
GIT binary patch
delta 324
zcmZqRY2evl!KCTJz`&3K#M(eC0mN=V3<5qtj4bXqIgv?UG65t71ZhBwESoWTC6l~l
z5t?WTNGT9hOn%5D?$`umA?s-Y%P}x?p^5iE#rx32Cr!3wme-tvCb|HsdJ&rVvdN7=
z)tk^nw?I|zK@;CM`6RQv;2AX03zL5`%QN1XEXlH+QDE{#7I97~Mu-72n?JJfGXel`
C&L`;r
delta 324
zcmZqRY2evl!KCTNz`&3K#M(eC0mNQF3<5qtj4U27Igv?UG6pQiz>tI{n=*MNle}aB
znrH=7bX5
v>V0V9hbEt7mKQvMCVFb}PiA?>TazVOwlnfgzQ`iZDaHsfKx*?x7JfzmbHXR>
diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c
index da78c1d5..08ec977e 100644
--- a/backend/tests/test_code128.c
+++ b/backend/tests/test_code128.c
@@ -57,23 +57,25 @@ static void test_large(const testCtx *const p_ctx) {
/* 5*/ { BARCODE_CODE128, READER_INIT, "A", 257, ZINT_ERROR_TOO_LONG, -1 },
/* 6*/ { BARCODE_CODE128, -1, "\351A", 66, 0, 1124 },
/* 7*/ { BARCODE_CODE128, -1, "\351A", 67, ZINT_ERROR_TOO_LONG, -1 }, /* 67 chars (+ 34 shifts) */
- /* 8*/ { BARCODE_CODE128, -1, "0", 198, 0, 1124 },
- /* 9*/ { BARCODE_CODE128, -1, "0", 199, ZINT_ERROR_TOO_LONG, -1 },
- /* 10*/ { BARCODE_CODE128, -1, "0", 257, ZINT_ERROR_TOO_LONG, -1 },
- /* 11*/ { BARCODE_CODE128AB, -1, "A", 99, 0, 1124 },
- /* 12*/ { BARCODE_CODE128AB, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1 },
- /* 13*/ { BARCODE_CODE128AB, -1, "0", 99, 0, 1124 },
- /* 14*/ { BARCODE_CODE128AB, -1, "0", 100, ZINT_ERROR_TOO_LONG, -1 },
- /* 15*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_WARN_HRT_TRUNCATED, 1135 }, /* 196 nos + 3 FNC1s */
- /* 16*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1 }, /* 196 nos + CodeA + single no. + 3 FNC1s */
- /* 17*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, ZINT_ERROR_TOO_LONG, -1 }, /* 198 nos + 3 FNC1s */
- /* 18*/ { BARCODE_GS1_128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1 },
- /* 19*/ { BARCODE_EAN14, -1, "1234567890123", -1, 0, 134 },
- /* 20*/ { BARCODE_EAN14, -1, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1 },
- /* 21*/ { BARCODE_NVE18, -1, "12345678901234567", -1, 0, 156 },
- /* 22*/ { BARCODE_NVE18, -1, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1 },
- /* 23*/ { BARCODE_HIBC_128, -1, "1", 110, 0, 684 },
- /* 24*/ { BARCODE_HIBC_128, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1 },
+ /* 8*/ { BARCODE_CODE128, -1, "\351", 97, 0, 1124 }, /* Less 2 FNC4s for latch */
+ /* 9*/ { BARCODE_CODE128, -1, "\351", 98, ZINT_ERROR_TOO_LONG, -1 },
+ /* 10*/ { BARCODE_CODE128, -1, "0", 198, 0, 1124 },
+ /* 11*/ { BARCODE_CODE128, -1, "0", 199, ZINT_ERROR_TOO_LONG, -1 },
+ /* 12*/ { BARCODE_CODE128, -1, "0", 257, ZINT_ERROR_TOO_LONG, -1 },
+ /* 13*/ { BARCODE_CODE128AB, -1, "A", 99, 0, 1124 },
+ /* 14*/ { BARCODE_CODE128AB, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1 },
+ /* 15*/ { BARCODE_CODE128AB, -1, "0", 99, 0, 1124 },
+ /* 16*/ { BARCODE_CODE128AB, -1, "0", 100, ZINT_ERROR_TOO_LONG, -1 },
+ /* 17*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_WARN_HRT_TRUNCATED, 1135 }, /* 196 nos + 3 FNC1s */
+ /* 18*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1 }, /* 196 nos + CodeA + single no. + 3 FNC1s */
+ /* 19*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, ZINT_ERROR_TOO_LONG, -1 }, /* 198 nos + 3 FNC1s */
+ /* 20*/ { BARCODE_GS1_128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1 },
+ /* 21*/ { BARCODE_EAN14, -1, "1234567890123", -1, 0, 134 },
+ /* 22*/ { BARCODE_EAN14, -1, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1 },
+ /* 23*/ { BARCODE_NVE18, -1, "12345678901234567", -1, 0, 156 },
+ /* 24*/ { BARCODE_NVE18, -1, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1 },
+ /* 25*/ { BARCODE_HIBC_128, -1, "1", 110, 0, 684 },
+ /* 26*/ { BARCODE_HIBC_128, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1 },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -313,7 +315,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 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, 1, "(6) 104 17 18 19 8 106", "StartB 1 2 3" },
+ /* 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" },
@@ -321,68 +323,77 @@ static void test_input(const testCtx *const p_ctx) {
/* 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, "1\037", -1, 0, 57, 1, "(5) 103 17 95 1 106", "StartA 1 US" },
- /* 33*/ { UNICODE_MODE, "12\037", -1, 0, 68, 1, "(6) 103 17 18 95 29 106", "StartA 1 2 US" },
- /* 34*/ { UNICODE_MODE, "a\037a", -1, 0, 79, 1, "(7) 104 65 98 95 65 86 106", "StartB a Shift US a" },
- /* 35*/ { UNICODE_MODE, "1234\037a", -1, 0, 101, 0, "(9) 105 12 34 101 95 98 65 100 106", "StartC 12 34 CodeA US Shift a; BWIPP different encodation" },
- /* 36*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Ba", -1, 0, 101, 1, "(9) 105 12 34 101 95 100 65 7 106", "StartC 12 34 CodeA US CodeB a" },
- /* 37*/ { 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" },
- /* 38*/ { UNICODE_MODE, "\037AAaa\037", -1, 0, 123, 0, "(11) 103 95 33 33 100 65 65 98 95 40 106", "StartA US A A CodeB a a Shift US; BWIPP different encodation" },
- /* 39*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\037AAaa\\^A\037", -1, 0, 123, 1, "(11) 103 95 33 33 100 65 65 101 95 61 106", "StartA US A A CodeB a a CodeA US" },
- /* 40*/ { UNICODE_MODE, "AAAa12345aAA", -1, 0, 167, 1, "(15) 104 33 33 33 65 17 99 23 45 100 65 33 33 54 106", "StartB A (3) a 1 CodeC 23 45 CodeB a A A" },
- /* 41*/ { UNICODE_MODE, "a\037Aa\037\037a\037aa\037a", -1, 0, 222, 1, "(20) 104 65 98 95 33 65 101 95 95 98 65 95 100 65 65 98 95 65 96 106", "StartB a Shift US A a CodeA US US Shift a US CodeB a a Shift US a" },
- /* 42*/ { UNICODE_MODE, "\000\037ß", 4, 0, 79, 1, "(7) 103 64 95 101 63 88 106", "StartA NUL US FNC4 ß" },
- /* 43*/ { UNICODE_MODE, "\000\037é", 4, 0, 90, 0, "(8) 103 64 95 101 98 73 78 106", "StartA NUL US FNC4 Shift é; BWIPP different encodation (CodeB instead of Shift)" },
- /* 44*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\000\037\\^Bé", 7, 0, 90, 0, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é; BWIPP different encodation (FNC4 before CodeB)" },
- /* 45*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 0, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US CodeB FNC4 é a; BWIPP different encodation (FNC4 before CodeB)" },
- /* 46*/ { UNICODE_MODE, "abß", -1, 0, 79, 1, "(7) 104 65 66 100 63 29 106", "StartB a b FNC4 ß" },
- /* 47*/ { DATA_MODE, "\141\142\237", -1, 0, 90, 0, "(8) 104 65 66 100 98 95 26 106", "StartB a b FNC4 Shift APC; BWIPP different encodation" },
- /* 48*/ { DATA_MODE, "\141\142\237\037", -1, 0, 101, 0, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b CodeA FNC4 APC US; BWIPP different encodation" },
- /* 49*/ { UNICODE_MODE, "ééé", -1, 0, 90, 1, "(8) 104 100 100 73 73 73 44 106", "StartB LatchFNC4 é é é" },
- /* 50*/ { UNICODE_MODE, "aééééb", -1, 0, 145, 1, "(13) 104 65 100 73 100 73 100 73 100 73 66 49 106", "StartB a FNC4 é (4) b" },
- /* 51*/ { 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" },
- /* 52*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 1, "(15) 104 65 100 100 73 73 73 73 73 100 66 100 67 40 106", "StartB a Latch é (5) Shift b Shift c" },
- /* 53*/ { 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" },
- /* 54*/ { 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" },
- /* 55*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 0, "(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 é; BWIPP different encodation" },
- /* 56*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 0, "(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); BWIPP different encodation" },
- /* 57*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 1, "(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)" },
- /* 58*/ { 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)" },
- /* 59*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 222, 1, "(20) 103 101 101 64 64 64 64 64 101 101 33 99 0 0 101 33 101 64 73 106", "StartA Latch PAD (4) Unlatch A CodeC 00 00 CodeA A FNC4 PAD" },
- /* 60*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 0, "(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); BWIPP different encodation" },
- /* 61*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 0, "(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; BWIPP different encodation" },
- /* 62*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "@g(\302\302\302\302\3025555\302\302\302\302\302\302\302\302", -1, 0, 277, 0, "(25) 104 32 71 8 100 100 34 34 34 34 34 99 55 55 100 34 34 34 34 34 34 34 34 25 106", "Okapi code128/extended-mode-with-short-embedded-code-set-c.png (chose different solution); BWIPP different encodation" },
- /* 63*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "@g(\302\302\302\302\302555555\302\302\302\302\302\302\302", -1, 0, 277, 0, "(25) 104 32 71 8 100 100 34 34 34 34 34 99 55 55 55 100 34 34 34 34 34 34 34 76 106", "Above with extra 55 instead of \xC2; BWIPP different encodation" },
- /* 64*/ { 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" },
- /* 65*/ { 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" },
- /* 66*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" },
- /* 67*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" },
- /* 68*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 61 106", "BWIPP different encodation, ShA instead of CodeA" },
- /* 69*/ { 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, FNC4 before CodeB" },
- /* 70*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation, CodeA instead of ShA, shorter" },
- /* 71*/ { 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 different encodation, FNC4 before CodeB, same width" },
- /* 72*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 89 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", "BWIPP different encodation, CodeA instead of ShA, shorter" },
- /* 73*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 89 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", "BWIPP different encodation, CodeA instead of ShA, shorter" },
- /* 74*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 409, 0, "(37) 104 100 95 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33", "BWIPP different encodation, CodeA instead of ShA, shorter" },
- /* 75*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 684, 0, "(62) 104 100 95 99 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74", "BWIPP different encodation, CodeA instead of ShA, shorter" },
- /* 76*/ { 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" },
- /* 77*/ { 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 LF; BWIPP no manual mode" },
- /* 78*/ { 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" },
- /* 79*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 1, "(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" },
- /* 80*/ { UNICODE_MODE, "21*\015\012M0", -1, 0, 112, 1, "(10) 103 18 17 10 77 74 45 16 9 106", "StartA 2 1 * M 0; Okapi c128/improved-lookahead-rule-1c.png" },
- /* 81*/ { 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" },
- /* 82*/ { 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" },
- /* 83*/ { 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" },
- /* 84*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP no manual mode" },
- /* 85*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 1, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3" },
- /* 86*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13\\^1", -1, 0, 90, 1, "(8) 105 12 102 100 19 102 74 106", "StartC 12 FNC1 CodeB 3 FNC1" },
- /* 87*/ { 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)" },
- /* 88*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" },
- /* 89*/ { 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" },
- /* 90*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^145\\^1", -1, 0, 112, 0, "(10) 105 12 100 19 99 102 45 102 101 106", "StartC 12 CodeB 3 CodeC FNC1 45 FNC1; BWIPP different encodation (BWIPP 1 shorter)" },
- /* 91*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^1", -1, 0, 112, 0, "(10) 105 12 102 100 19 99 45 102 13 106", "StartC 12 FNC1 CodeB 3 CodeC 45 FNC1; BWIPP different encodation (BWIPP 1 shorter)" },
- /* 92*/ { 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" },
- /* 93*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156789\\^101\\^11\\^1", -1, 0, 189, 0, "(17) 105 12 34 102 100 21 99 67 89 102 1 102 100 17 102 48 106", "StartC 12 34 FNC1 56 78 CodeB 9 CodeC FNC1 01 FNC1 CodeB 1 FNC1; BWIPP different encodation (BWIPP 1 shorter)" },
+ /* 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, 1, "(9) 105 12 34 101 95 100 65 7 106", "StartC 12 34 CodeA US CodeB a" },
+ /* 38*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Ba", -1, 0, 101, 1, "(9) 105 12 34 101 95 100 65 7 106", "StartC 12 34 CodeA US CodeB a" },
+ /* 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, 0, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é; BWIPP different encodation (FNC4 before CodeB)" },
+ /* 46*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\000\037\\^Bé", 7, 0, 90, 0, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é; BWIPP different encodation (FNC4 before CodeB)" },
+ /* 47*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 0, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US CodeB FNC4 é a; BWIPP different encodation (FNC4 before CodeB)" },
+ /* 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, 0, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b CodeA FNC4 APC US; BWIPP different encodation" },
+ /* 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, 145, 1, "(13) 104 65 100 73 100 73 100 73 100 73 66 49 106", "StartB a FNC4 é (4) b" },
+ /* 53*/ { 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" },
+ /* 54*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 1, "(15) 104 65 100 100 73 73 73 73 73 100 66 100 67 40 106", "StartB a Latch é (5) Shift b Shift c" },
+ /* 55*/ { 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" },
+ /* 56*/ { 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" },
+ /* 57*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 0, "(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 é; BWIPP different encodation" },
+ /* 58*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 0, "(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); BWIPP different encodation" },
+ /* 59*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 1, "(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)" },
+ /* 60*/ { 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)" },
+ /* 61*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 211, 0, "(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; BWIPP different encodation (BWIPP 1 longer)" },
+ /* 62*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 0, "(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); BWIPP different encodation" },
+ /* 63*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 0, "(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; BWIPP different encodation" },
+ /* 64*/ { DATA_MODE, "@g(\202\202\202\202\2025555\202\202\202\202\202\202\202\202", -1, 0, 288, 0, "(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); BWIPP different encodation" },
+ /* 65*/ { DATA_MODE, "@g(\202\202\202\202\20255555\202\202\202\202\202\202\202", -1, 0, 299, 0, "(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; BWIPP different encodation" },
+ /* 66*/ { DATA_MODE, "@g(\202\202\202\202\202555555\202\202\202\202\202\202\202", -1, 0, 288, 0, "(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 \x82; BWIPP different encodation" },
+ /* 67*/ { 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" },
+ /* 68*/ { 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" },
+ /* 69*/ { 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" },
+ /* 70*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" },
+ /* 71*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" },
+ /* 72*/ { 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" },
+ /* 73*/ { 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, FNC4 before CodeB" },
+ /* 74*/ { 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, CodeA instead of ShA, same width" },
+ /* 75*/ { 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 different encodation, FNC4 before CodeB, same width" },
+ /* 76*/ { 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, CodeA instead of ShA, same width" },
+ /* 77*/ { 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, CodeA instead of ShA, same width" },
+ /* 78*/ { 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, CodeA instead of ShA, same width" },
+ /* 79*/ { 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, CodeA instead of ShA, same width" },
+ /* 80*/ { 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" },
+ /* 81*/ { 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" },
+ /* 82*/ { 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" },
+ /* 83*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 1, "(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" },
+ /* 84*/ { 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" },
+ /* 85*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^112345\\^11234\\^112345", -1, 0, 178, 0, "(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; BWIPP different encodation (BWIPP 2 longer)" },
+ /* 86*/ { 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" },
+ /* 87*/ { 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" },
+ /* 88*/ { 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" },
+ /* 89*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP no manual mode" },
+ /* 90*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 1, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3" },
+ /* 91*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13\\^1", -1, 0, 90, 1, "(8) 105 12 102 100 19 102 74 106", "StartC 12 FNC1 CodeB 3 FNC1" },
+ /* 92*/ { 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)" },
+ /* 93*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" },
+ /* 94*/ { 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" },
+ /* 95*/ { 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" },
+ /* 96*/ { 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" },
+ /* 97*/ { 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" },
+ /* 98*/ { 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" },
+ /* 99*/ { 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" },
+ /*100*/ { 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" },
+ /*101*/ { 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" },
+ /*102*/ { 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" },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -467,30 +478,30 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
char *comment;
};
struct item data[] = {
- /* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 1, "(11) 105 102 90 100 17 102 25 16 17 15 106", "StartC FNC1 90 CodeB 1 FNC1 9 0 1" },
- /* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, 1, "(11) 105 102 90 100 17 102 25 16 17 15 106", "StartC FNC1 90 CodeB 1 FNC1 9 0 1" },
- /* 2*/ { GS1_MODE, "[90]1[90]12", 0, 123, 0, "(11) 105 102 90 100 17 99 102 90 12 13 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12; BWIPP different encodation (same codeword count)" },
+ /* 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 codeword count)" },
+ /* 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 codeword count)" },
+ /* 2*/ { GS1_MODE, "[90]1[90]12", 0, 112, 0, "(10) 104 102 25 99 1 102 90 12 43 106", "StartB FNC1 9 CodeC 01 FNC1 90 12; BWIPP different encodation (BWIPP 1 longer)" },
/* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, 1, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23" },
/* 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, 1, "(12) 105 102 90 12 100 19 102 25 16 17 29 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 0 1" },
- /* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 145, 0, "(13) 105 102 90 12 100 19 99 102 90 12 34 98 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34; BWIPP different encodation (same codeword count)" },
- /* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 178, 0, "(16) 105 102 90 100 17 102 25 99 1 102 100 25 16 17 87 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 1 shorter)" },
- /* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 178, 0, "(16) 105 102 90 100 17 99 102 90 12 102 100 25 16 17 44 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12 FNC1 CodeB 9 0 1; BWIPP different encodation (same codeword count)" },
- /* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 189, 0, "(17) 105 102 90 100 17 102 25 99 1 23 102 100 25 16 17 39 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 1 shorter)" },
- /* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 189, 0, "(17) 105 102 90 12 102 100 25 99 1 23 102 100 25 16 17 2 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 2 shorter)" },
- /* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, 0, "(15) 105 102 90 12 102 100 25 99 1 23 102 90 12 11 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 90 12; BWIPP different encodation (same codeword count)" },
- /* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 189, 0, "(17) 105 102 90 12 100 19 102 25 99 1 102 100 25 16 17 16 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 1 shorter)" },
- /* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 189, 0, "(17) 105 102 90 12 100 19 99 102 90 12 102 100 25 16 17 49 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01; BWIPP different encodation (same codeword count)" },
+ /* 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 codeword count)" },
+ /* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 134, 0, "(12) 104 102 25 99 1 23 102 90 12 34 50 106", "StartB FNC1 9 CodeC 01 23 FNC1 90 12 34; BWIPP different encodation (BWIPP 1 longer)" },
+ /* 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 codeword count)" },
+ /* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 156, 0, "(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; BWIPP different encodation (BWIPP 2 longer)" },
+ /* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 178, 1, "(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" },
+ /* 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 codeword count)" },
+ /* 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 codeword count)" },
+ /* 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 codeword count)" },
+ /* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 167, 0, "(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; BWIPP different encodation (BWIPP 2 longer)" },
/* 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" },
- /* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 200, 0, "(18) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 16 17 31 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01; BWIPP different encodation (BWIPP 1 longer)" },
- /* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 211, 0, "(19) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 23 85 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01 23; BWIPP different encodation (BWIPP 1 longer)" },
- /* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 211, 0, "(19) 105 102 90 12 34 100 21 99 102 90 12 34 102 100 25 16 17 71 106", "StartC FNC1 90 12 34 CodeB 5 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01; BWIPP different encodation (BWIPP 1 longer)" },
- /* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, 0, "(12) 104 102 25 16 17 33 102 25 16 17 60 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01; BWIPP different encodation (same codeword count)" },
+ /* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 178, 0, "(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; BWIPP different encodation (BWIPP 3 longer)" },
+ /* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 189, 0, "(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; BWIPP different encodation (BWIPP 3 longer)" },
+ /* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 189, 0, "(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; BWIPP different encodation (BWIPP 3 longer)" },
+ /* 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 codeword count)" },
/* 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, 244, 0, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23; BWIPP different encodation (BWIPP 2 shorter)" },
- /* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, 1, "(16) 105 102 90 12 34 100 21 33 17 99 23 45 100 33 59 106", "StartC FNC1 90 12 34 CodeB 5 A 1 CodeC 23 45 CodeB A" },
+ /* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 222, 0, "(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; BWIPP different encodation (same codeword count)" },
+ /* 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 codeword count)" },
/* 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: GS1-128 input too long (48 character maximum)", "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" },
@@ -583,18 +594,19 @@ static void test_hibc_input(const testCtx *const p_ctx) {
char *data;
int ret;
int expected_width;
+ int bwipp_cmp;
char *expected;
char *comment;
};
struct item data[] = {
- /* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", "" },
- /* 1*/ { "A99912345/$$52001510X3", 0, 255, "(23) 104 11 33 99 99 91 23 45 100 15 4 4 99 52 0 15 10 100 56 19 19 53 106", "Check digit 3" },
- /* 2*/ { "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", 0, 497, "(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, "(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, "(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, "Error 341: Input too long (99 symbol character maximum)", "" },
- /* 6*/ { "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 0, 684, "(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, "(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 -" },
+ /* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", "" },
+ /* 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 (99 symbol character maximum)", "" },
+ /* 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 -" },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -624,23 +636,27 @@ static void test_hibc_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*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
+ printf(" /*%3d*/ { \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
- testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
+ testUtilErrorName(data[i].ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment);
} else {
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);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
- 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[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);
+ 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, -1, -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);
+ 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;
@@ -908,146 +924,149 @@ 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_GS1_128, GS1_MODE, -1, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1",
+ /* 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, same codeword count",
+ "11010010000101000110001000101100010001000110100001001101110101111010000110010100011010001001110011011001110010110010111001100010100011000100010101101110001011101111010111011000100001011001011110111010001101110101110110001110111011010010110000111010001101111010001010000110010111000101101110110100011101100010100101100001001000011011101011110100001100101000011001011110100010101100100001000011001010000110010101111011101011000010010011010000111010111101000011001011110100010101000111101001110011011001110010100001100101000011001011001001110110111001001100111010010000110010111010111101001000011011101011110100010110001000011001010000110010111010111101111010001010010000110100111001101100111001010000110010100001100101000011001010000110010100111001101100111001011001011100100001100101000011001010000110010100001100101000011001010000110010101110111101011001110010001011000111010111101000011001010000110010100001100101000011001010111101110101111011101001000011010111101110100100001101011110111010010000110101110111101011001110010001011000101111011101011110111010111101110100100001101001000011010010000110110001011101100011101011"
+ },
+ /* 6*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8018]950110153123456781", 0, 1, 167, 1, "GGS Figure 2.5.2-1",
"11010011100111101011101010011110011001110010101111010001100110110011001000100101110011001101100011011101101110101110110001000010110010010111100101111001001100011101011"
},
- /* 6*/ { BARCODE_GS1_128, GS1_MODE, -1, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top",
+ /* 7*/ { BARCODE_GS1_128, GS1_MODE, -1, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top",
"110100111001111010111011000100010111010001101100010001011101101110101110110001000010110011011011110100011001001101000100011000100100100110100001100110110011100101100100001001101100011101011"
},
- /* 7*/ { BARCODE_GS1_128, GS1_MODE, -1, "[12]010425[8020]ABC123", 0, 1, 189, 1, "GGS Figure 2.6.6-1 bottom",
- "110100111001111010111010110011100110011011001001000110011100101100101001111001100100111010111101110101000110001000101100010001000110100111001101100111001011001011100110010111001100011101011"
+ /* 8*/ { BARCODE_GS1_128, GS1_MODE, -1, "[12]010425[8020]ABC123", 0, 1, 189, 0, "GGS Figure 2.6.6-1 bottom **NOT SAME**, different encodation, same codeword count; BWIPP as standard",
+ "110100111001111010111010110011100110011011001001000110011100101100101001111001100100111010111101110101000110001000101100010001000110100111001101011101111011101101110111101000101100011101011"
},
- /* 8*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153005812345678901", 0, 1, 211, 1, "GGS Figure 2.6.9-1",
+ /* 9*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153005812345678901", 0, 1, 211, 0, "GGS Figure 2.6.9-1 **NOT SAME**, different encodation, same codeword count; BWIPP as standard",
"1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001110110001010110011100100010110001110001011011000010100110111101101011110111010011100110101110110001100011101011"
},
- /* 9*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2",
+ /* 10*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2",
"1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001001011000010000101100110110111101000100110010110001110110111001001100100100011110010100101110011001100011101011"
},
- /* 10*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]95011015300657654321", 0, 1, 189, 1, "GGS Figure 2.6.9-3",
+ /* 11*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]95011015300657654321", 0, 1, 189, 1, "GGS Figure 2.6.9-3",
"110100111001111010111011100101100110100010001100010111011000100100110011011001101110111011011001100100101100001100101000011101011000110001101101011110111010011100110111001001101100011101011"
},
- /* 11*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]9501101530065123456", 0, 1, 167, 1, "GGS Figure 2.6.9-4",
+ /* 12*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]9501101530065123456", 0, 1, 167, 1, "GGS Figure 2.6.9-4",
"11010011100111101011101110010110011010001000110001011101100010010011001101100110111011101101100110010010110000101100111001000101100011100010110100011110101100011101011"
},
- /* 12*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]10857674002017[10]1152KMB", 0, 1, 211, 1, "GGS Figure 4.15.1-1",
+ /* 13*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]10857674002017[10]1152KMB", 0, 1, 211, 1, "GGS Figure 4.15.1-1",
"1101001110011110101110110011011001100100010010011110010110010100001000011001011011001100110010011101001110011011001000100110001001001101110001010111101110101100011101011101100010001011000100111001101100011101011"
},
- /* 13*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]09501101530003", 0, 1, 134, 1, "GGS Figure 5.1-3",
+ /* 14*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]09501101530003", 0, 1, 134, 1, "GGS Figure 5.1-3",
"11010011100111101011101100110110011001001000110001011101100010010011001101100110111011101101100110010010011000100110100001100011101011"
},
- /* 14*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395123451234567895", 0, 1, 156, 1, "GGS Figure 5.4.2-1",
+ /* 15*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395123451234567895", 0, 1, 156, 1, "GGS Figure 5.4.2-1",
"110100111001111010111011011001100110100010001101110100011101101110101110110001011001110010001011000111000101101100001010010111101000101111000101100011101011"
},
- /* 15*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]006141411234567890", 0, 1, 156, 1, "GGS Figure 6.6.5-1. (and Figures 6.6.5-3 bottom, 6.6.5-4 bottom)",
+ /* 16*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]006141411234567890", 0, 1, 156, 1, "GGS Figure 6.6.5-1. (and Figures 6.6.5-3 bottom, 6.6.5-4 bottom)",
"110100111001111010111011011001100110110011001100100001011000100010110001000101011001110010001011000111000101101100001010011011110110110110110001100011101011"
},
- /* 16*/ { BARCODE_GS1_128, GS1_MODE, -1, "[403]402621[401]950110153B01001", 0, 1, 266, 0, "GGS Figure 6.6.5-2 top **NOT SAME**, different encodation for zint, BWIPP & standard, same codeword count",
- "11010011100111101011101100010100010001011000110011001101111000101010111101110100111001101011101111011110101110110001010001100101110011000101110110001001001100110110011011101110101111011101000101100010011101100101110111101100100010011001101100101001111001100011101011"
+ /* 17*/ { BARCODE_GS1_128, GS1_MODE, -1, "[403]402621[401]950110153B01001", 0, 1, 255, 0, "GGS Figure 6.6.5-2 top, same; BWIPP different encodation, same codeword count",
+ "110100100001111010111011001001110101110111101001001100011000101000111001001101101110010011110101110110001010001100101110011000101110110001001001100110110011011101110101111011101000101100010011101100101110111101100100010011001101100110001101101100011101011"
},
- /* 17*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom",
+ /* 18*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom",
"110100111001111010111011011001100110100010001100010111011000100100110011011001101110111011011001100110110011001101100110011000100100100011101101100011101011"
},
- /* 18*/ { BARCODE_GS1_128, GS1_MODE, -1, "[420]45458", 0, 1, 90, 1, "GGS Figure 6.6.5-3 top",
+ /* 19*/ { BARCODE_GS1_128, GS1_MODE, -1, "[420]45458", 0, 1, 90, 1, "GGS Figure 6.6.5-3 top",
"110100111001111010111010110111000100100011001110101100011101100010111100100101100011101011"
},
- /* 19*/ { BARCODE_GS1_128, GS1_MODE, -1, "[02]00614141000418[15]210228[10]451214[37]20", 0, 1, 255, 1, "GGS Figure 6.6.5-4 top",
+ /* 20*/ { BARCODE_GS1_128, GS1_MODE, -1, "[02]00614141000418[15]210228[10]451214[37]20", 0, 1, 255, 1, "GGS Figure 6.6.5-4 top",
"110100111001111010111011001100110110110011001100100001011000100010110001000101101100110010010001100110011100101011100110011011100100110011001101110011010011001000100101110110001011001110010011001110111101011101000110100011001001110100011110101100011101011"
},
- /* 20*/ { BARCODE_GS1_128, GS1_MODE, -1, "[420]87109", 0, 1, 90, 1, "GGS Figure 6.6.5-5 top",
+ /* 21*/ { BARCODE_GS1_128, GS1_MODE, -1, "[420]87109", 0, 1, 90, 1, "GGS Figure 6.6.5-5 top",
"110100111001111010111010110111000100011001001001101000011001001000111001001101100011101011"
},
- /* 21*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]1528", 0, 1, 79, 1, "GGS Figure 6.6.5-5 middle",
+ /* 22*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]1528", 0, 1, 79, 1, "GGS Figure 6.6.5-5 middle",
"1101001110011110101110110111101101011100110011100110100111001100101100011101011"
},
- /* 22*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]000521775138957172", 0, 1, 156, 1, "GGS Figure 6.6.5-5 bottom",
+ /* 23*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]000521775138957172", 0, 1, 156, 1, "GGS Figure 6.6.5-5 bottom",
"110100111001111010111011011001100110110011001000100110011011100100111101110101101110100010001100010101111010001001101000010011000010110011011001100011101011"
},
- /* 23*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6",
- "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011"
- },
/* 24*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6",
"110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011"
},
- /* 25*/ { BARCODE_GS1_128, GS1_MODE, -1, "[401]931234518430GR", 0, 1, 167, 1, "GGS Figure 6.6.5-7 top",
+ /* 25*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011010013000129", 0, 1, 156, 1, "GGS Figure 6.6.5-6",
+ "110100111001111010111011011001100110100010001100010111011000100100110011011001101100110010011011100110110011001100110110011100110010111101101101100011101011"
+ },
+ /* 26*/ { BARCODE_GS1_128, GS1_MODE, -1, "[401]931234518430GR", 0, 1, 167, 1, "GGS Figure 6.6.5-7 top",
"11010011100111101011101100010100011001011100110110001101110110111010111011000110011100101011000111010111101110100111011001101000100011000101110100110111001100011101011"
},
- /* 26*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]093123450000000012", 0, 1, 156, 1, "GGS Figure 6.6.5-7 bottom",
+ /* 27*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]093123450000000012", 0, 1, 156, 1, "GGS Figure 6.6.5-7 bottom",
"110100111001111010111011011001100110010010001101100011011101101110101110110001101100110011011001100110110011001101100110010110011100110111010001100011101011"
},
- /* 27*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]95012345678903", 0, 1, 134, 1, "GGS Figure 7.8.5.1-1 1st",
+ /* 28*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]95012345678903", 0, 1, 134, 1, "GGS Figure 7.8.5.1-1 1st",
"11010011100111101011101100110110010111101000110011011001110110111010111011000100001011001101101111010010011000110110001101100011101011"
},
- /* 28*/ { BARCODE_GS1_128, GS1_MODE, -1, "[3102]000400", 0, 1, 101, 1, "GGS Figure 7.8.5.1-1 2nd",
+ /* 29*/ { BARCODE_GS1_128, GS1_MODE, -1, "[3102]000400", 0, 1, 101, 1, "GGS Figure 7.8.5.1-1 2nd",
"11010011100111101011101101100011011001100110110110011001001000110011011001100110110111101100011101011"
},
- /* 29*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]95012345678903[3102]000400", 0, 1, 189, 1, "GGS Figure 7.8.5.1-2",
+ /* 30*/ { BARCODE_GS1_128, GS1_MODE, -1, "[01]95012345678903[3102]000400", 0, 1, 189, 1, "GGS Figure 7.8.5.1-2",
"110100111001111010111011001101100101111010001100110110011101101110101110110001000010110011011011110100100110001101100011011001100110110110011001001000110011011001100100100110001100011101011"
},
- /* 30*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8005]000365", 0, 1, 101, 1, "GGS Figure 7.8.5.2-1 1st",
+ /* 31*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8005]000365", 0, 1, 101, 1, "GGS Figure 7.8.5.2-1 1st",
"11010011100111101011101010011110010001001100110110011001001001100010010110000100100001101100011101011"
},
- /* 31*/ { BARCODE_GS1_128, GS1_MODE, -1, "[10]123456", 0, 1, 90, 1, "GGS Figure 7.8.5.2-1 2nd",
+ /* 32*/ { BARCODE_GS1_128, GS1_MODE, -1, "[10]123456", 0, 1, 90, 1, "GGS Figure 7.8.5.2-1 2nd",
"110100111001111010111011001000100101100111001000101100011100010110110010000101100011101011"
},
- /* 32*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8005]000365[10]123456", 0, 1, 156, 1, "GGS Figure 7.8.5.2-2",
+ /* 33*/ { BARCODE_GS1_128, GS1_MODE, -1, "[8005]000365[10]123456", 0, 1, 156, 1, "GGS Figure 7.8.5.2-2",
"110100111001111010111010100111100100010011001101100110010010011000100101100001111010111011001000100101100111001000101100011100010110101100001001100011101011"
},
- /* 33*/ { BARCODE_GS1_128, GS1_MODE, -1, "[403]27653113+99000900090010", 0, 1, 222, 1, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
+ /* 34*/ { BARCODE_GS1_128, GS1_MODE, -1, "[403]27653113+99000900090010", 0, 1, 222, 1, "DHL Leitcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
"110100111001111010111011000101000110001101101100101000011011101110110001001001011110111011001011100110001001001011101111010111011110110110011001100100100011011001100110010010001101100110011001000100110001000101100011101011"
},
- /* 34*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]340433935039756615", 0, 1, 156, 1, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
+ /* 35*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]340433935039756615", 0, 1, 156, 1, "DHL Identcode https://www.dhl.de/de/geschaeftskunden/paket/information/geschaeftskunden/abrechnung/leitcodierung.html",
"110100111001111010111011011001100100010110001001000110010100011000101000111101100010111011010001000110000100101001000011010111001100100111001101100011101011"
},
- /* 35*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]ABCDEfGHI", 0, 1, 167, 0, "Shift A; BWIPP different encodation, same codeword count",
- "11010010000111101011101110010110010011101100101000110001000101100010001000110101100010001000110100010110000100110100010001100010100011000100010110010011101100011101011"
+ /* 36*/ { BARCODE_GS1_128, GS1_MODE, -1, "[90]ABCDEfGHI", 0, 1, 167, 1, "Shift A",
+ "11010011100111101011101101111011010111101110101000110001000101100010001000110101100010001000110100010110000100110100010001100010100011000100010100010111101100011101011"
},
- /* 36*/ { 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_HRT_TRUNCATED, 1, 1135, 1, "Max length",
"1101001110011110101110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110011001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100110111101101101100110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011011011001100100010110001110001011011000010100110111101101011001110010001011000111000101101100001010011011110110110110001101101100110010110011100101100111001011001110011001001110100010110001100100111011000010100100100110001100011101011"
},
- /* 37*/ { 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",
+ /* 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",
"110100111001111010111011011100100101100111001000101100011100010110101100001001011110111011100011010110011100101100101110011001000010101110111101101000111011011000110100110111001100011101011"
},
- /* 38*/ { BARCODE_EAN14, GS1_MODE, -1, "4070071967072", 0, 1, 134, 1, "Verified manually against TEC-IT",
+ /* 39*/ { BARCODE_EAN14, GS1_MODE, -1, "4070071967072", 0, 1, 134, 1, "Verified manually against TEC-IT",
"11010011100111101011101100110110011000101000101100001001001100010011001011100100001011001001100010011001001110110111001001100011101011"
},
- /* 39*/ { BARCODE_NVE18, GS1_MODE, -1, "40700000071967072", 0, 1, 156, 1, "Verified manually against TEC-IT",
+ /* 40*/ { BARCODE_NVE18, GS1_MODE, -1, "40700000071967072", 0, 1, 156, 1, "",
"110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011"
},
- /* 40*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "83278F8G9H0J2G", 0, 1, 211, 1, "ANSI/HIBC 2.6 - 2016 Section 4.1, not same, uses different encoding (eg begins StartA instead of StartB)",
- "1101001000011000100100111010011001011101111011000110110110000101001011110111010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100111101010001100011101011"
+ /* 41*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "83278F8G9H0J2G", 0, 1, 211, 0, "ANSI/HIBC 2.6 - 2016 Section 4.1, same; BWIPP different encodation, same codeword count",
+ "1101001000011000100100101110111101011110010011101100100101111011101110100110010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100110100010001100011101011"
},
- /* 41*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same",
+ /* 42*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same",
"11010010000110001001001010001100010011100110110011100101100101110010001011000101101110001000100011011011100100101100010001100111010010001101000111011011101001110011011010001000110001101101100011101011"
},
- /* 42*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "$$52001510X3G", 0, 1, 178, 1, "ANSI/HIBC 2.6 - 2016 Figure 5, same",
+ /* 43*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "$$52001510X3G", 0, 1, 178, 1, "ANSI/HIBC 2.6 - 2016 Figure 5, same",
"1101001000011000100100100100011001001000110010111011110110111000101101100110010111001100110010001001011110111011100010110110010111001101000100010110001000100011110101100011101011"
},
- /* 43*/ { BARCODE_DPD, UNICODE_MODE, -1, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustrations 2, 7, 8, same; NOTE: correct HRT given by Illustration 7 only",
+ /* 44*/ { BARCODE_DPD, UNICODE_MODE, -1, "%000393206219912345678101040", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustrations 2, 7, 8, same; NOTE: correct HRT given by Illustration 7 only",
"1101001000010001001100100111011001011101111011011001100110100010001100011011010011001000110111001001011101111010110011100100010110001110001011011000010100110010001001100100010011000101000101011110001100011101011"
},
- /* 44*/ { BARCODE_DPD, UNICODE_MODE, -1, "%007110601782532948375101276", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against TEC-IT",
+ /* 45*/ { BARCODE_DPD, UNICODE_MODE, -1, "%007110601782532948375101276", 0, 1, 211, 1, "DPDAPPD 4.0.2 - Illustration 6 **NOT SAME** HRT incorrect, also uses CodeA and inefficient encoding; verified against TEC-IT",
"1101001000010001001100100111011001011101111010011000100110001001001001100100011001101100110000101001110010110011000110110100010111101011110010011000010010110010001001011001110011001010000100010111101100011101011"
},
- /* 45*/ { BARCODE_DPD, UNICODE_MODE, -1, "0123456789012345678901234567", 0, 1, 189, 1, "DPDAPPD 4.0.2 - Illustration 9, same (allowing for literal HRT)",
+ /* 46*/ { BARCODE_DPD, UNICODE_MODE, -1, "0123456789012345678901234567", 0, 1, 189, 1, "DPDAPPD 4.0.2 - Illustration 9, same (allowing for literal HRT)",
"110100111001100110110011101101110101110110001000010110011011011110110011011001110110111010111011000100001011001101101111011001101100111011011101011101100010000101100101011110001100011101011"
},
- /* 46*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020028101276", 0, 1, 211, 1, "DPDPLS Section 4, **NOT SAME**, figure switches to CodeC after 1st char (%), zint after 2nd (0)",
+ /* 47*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020028101276", 0, 1, 211, 1, "DPDPLS Section 4, **NOT SAME**, figure switches to CodeC after 1st char (%), zint after 2nd (0)",
"1101001000010001001100100111011001011101111010001100100110011100101110110010011001001000111101000101101100110011011001100110011001101101100110011100110100110010001001011001110011001010000101011110001100011101011"
},
- /* 47*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601632532948375179276", 0, 1, 211, 1, "DPDPLS Section 4.6, **NOT SAME**, figure StartA & switches as above, zint StartB & switches as above",
+ /* 48*/ { BARCODE_DPD, UNICODE_MODE, -1, "007110601632532948375179276", 0, 1, 211, 1, "DPDPLS Section 4.6, **NOT SAME**, figure StartA & switches as above, zint StartB & switches as above",
"1101001000010001001100100111011001011101111010011000100110001001001001100100011001101100101001100001110010110011000110110100010111101011110010011000010010100111001101010111100011001010000101100010001100011101011"
},
- /* 48*/ { BARCODE_DPD, UNICODE_MODE, -1, "001990009980000020084109203", 0, 1, 211, 1, "DPDPLS Section 5.1, **NOT SAME**, figure switches to CodeC after 1st char (%), zint after 2nd (0)",
+ /* 49*/ { BARCODE_DPD, UNICODE_MODE, -1, "001990009980000020084109203", 0, 1, 211, 1, "DPDPLS Section 5.1, **NOT SAME**, figure switches to CodeC after 1st char (%), zint after 2nd (0)",
"1101001000010001001100100111011001011101111011001101100101110111101101100110011001001000111101000101101100110011011001100110011001101101100110010011110100110010001001010111100010010011000100011010001100011101011"
},
- /* 49*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020029136276", 0, 1, 211, 1, "DPDPLS Section 6.1, **NOT SAME**, as above",
+ /* 50*/ { BARCODE_DPD, UNICODE_MODE, -1, "008182709980000020029136276", 0, 1, 211, 1, "DPDPLS Section 6.1, **NOT SAME**, as above",
"1101001000010001001100100111011001011101111010001100100110011100101110110010011001001000111101000101101100110011011001100110011001101101100110011100110010100110111001111000101011001010000100001101001100011101011"
},
- /* 50*/ { BARCODE_DPD, UNICODE_MODE, 1, "006376209980000020044118276", 0, 1, 200, 1, "DPDPLS Section 8.7.2 relabel, **NOT SAME**, figure begins StartB then immediate CodeC, zint just StartC",
+ /* 51*/ { BARCODE_DPD, UNICODE_MODE, 1, "006376209980000020044118276", 0, 1, 200, 1, "DPDPLS Section 8.7.2 relabel, **NOT SAME**, figure begins StartB then immediate CodeC, zint begins StartC (shorter)",
"11010011100110110011001010011000011001010000110010011101011101111010100111100110110011001101100110011001001110100100011001100010001011001110010111011001001011110111011001110100110111011101100011101011"
},
- /* 51*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", 0, 1, 156, 1, "",
- "110100100001000110100010001101000111010011001011101111011001010000111010110001100011011010011101100101111011101000100011010100011000111000101101100011101011"
+ /* 52*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", 0, 1, 156, 0, "BWIPP different encodation, same codeword count",
+ "110100100001000110100010001101000101110111101111001010010010110000101100011101101110010010111101110110011101001000100011010100011000100010011001100011101011"
},
};
int data_size = ARRAY_SIZE(data);
@@ -1188,6 +1207,7 @@ static void test_perf(const testCtx *const p_ctx) {
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 0
start = clock();
ret = ZBarcode_Buffer(symbol, 0 /*rotate_angle*/);
diff_buffer += clock() - start;
@@ -1205,12 +1225,15 @@ static void test_perf(const testCtx *const p_ctx) {
diff_print += clock() - start;
assert_zero(ret, "i:%d ZBarcode_Print ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
assert_zero(testUtilRemove(symbol->outfile), "i:%d testUtilRemove(%s) != 0\n", i, symbol->outfile);
+ #endif
ZBarcode_Delete(symbol);
}
- printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n", comment_max, data[i].comment,
- TEST_PERF_TIME(diff_encode), TEST_PERF_TIME(diff_buffer), TEST_PERF_TIME(diff_buf_inter), TEST_PERF_TIME(diff_print), TEST_PERF_TIME(diff_create));
+ printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n",
+ comment_max, data[i].comment,
+ TEST_PERF_TIME(diff_encode), TEST_PERF_TIME(diff_buffer), TEST_PERF_TIME(diff_buf_inter),
+ TEST_PERF_TIME(diff_print), TEST_PERF_TIME(diff_create));
total_create += diff_create;
total_encode += diff_encode;
@@ -1219,8 +1242,10 @@ static void test_perf(const testCtx *const p_ctx) {
total_print += diff_print;
}
if (p_ctx->index == -1) {
- printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n", comment_max, "totals",
- TEST_PERF_TIME(total_encode), TEST_PERF_TIME(total_buffer), TEST_PERF_TIME(total_buf_inter), TEST_PERF_TIME(total_print), TEST_PERF_TIME(total_create));
+ printf("%*s: encode % 8gms, buffer % 8gms, buf_inter % 8gms, print % 8gms, create % 8gms\n",
+ comment_max, "totals",
+ TEST_PERF_TIME(total_encode), TEST_PERF_TIME(total_buffer), TEST_PERF_TIME(total_buf_inter),
+ TEST_PERF_TIME(total_print), TEST_PERF_TIME(total_create));
}
}
diff --git a/backend/tests/test_composite.c b/backend/tests/test_composite.c
index 8aaf2130..4d5fb8fe 100644
--- a/backend/tests/test_composite.c
+++ b/backend/tests/test_composite.c
@@ -1769,13 +1769,13 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
};
/* Verified via bwipp_dump.ps against BWIPP except where noted, when shift verified manually (tec-it.com seems to be off by 2 for top shifts > 1) */
struct item data[] = {
- /* 0*/ { BARCODE_GS1_128_CC, -1, "[91]1", "[21]A1B2C3D4E5F6G7H8", 0, 6, 100, 0, "CC-A alignment, bottom shift 10, **NOT SAME** as BWIPP, Start B whereas BWIPP uses Start C, codeword count the same",
+ /* 0*/ { BARCODE_GS1_128_CC, -1, "[91]1", "[21]A1B2C3D4E5F6G7H8", 0, 6, 100, 1, "CC-A alignment, bottom shift 10",
"1101001000110100001000001101101011110111110010010001101010000010010000011101110100010000111011001010"
"1101011000110101111001100001111010001101100010010000101111000011001101011100101100001000110011001010"
"1101011100100011001100111101011000101110000010110000101001100110011110011011110011001110110111001010"
"1101011110111000111011011001110010001011100010111000101011000011100110010000100000100010110111101010"
- "0000000000001011011110000101000100011010011011000110010110001100101000100001010001110010011100010100"
- "0000000000110100100001111010111011100101100100111001101001110011010111011110101110001101100011101011"
+ "0000000000001011000110000101000100001001001010000100010110001100101000100001011000100110011100010100"
+ "0000000000110100111001111010111011110110110101111011101001110011010111011110100111011001100011101011"
},
/* 1*/ { BARCODE_GS1_128_CC, -1, "[91]12", "[21]A1B2C3D4E5F6G7H8", 0, 6, 99, 1, "CC-A alignment, bottom shift 12",
"110100100011010000100000110110101111011111001001000110101000001001000001110111010001000011101100101"
diff --git a/backend/tif.h b/backend/tif.h
index 6894b252..f13fd9cd 100644
--- a/backend/tif.h
+++ b/backend/tif.h
@@ -35,7 +35,7 @@
#ifdef __cplusplus
extern "C" {
-#endif
+#endif /* __cplusplus */
#ifdef OUT_USE_PRAGMA_PACK
#pragma pack(1)
@@ -66,7 +66,7 @@ extern "C" {
#ifdef __cplusplus
}
-#endif
+#endif /* __cplusplus */
/* vim: set ts=4 sw=4 et : */
#endif /* Z_TIF_H */
diff --git a/backend/tif_lzw.h b/backend/tif_lzw.h
index 75b73f3c..a8eaf51b 100644
--- a/backend/tif_lzw.h
+++ b/backend/tif_lzw.h
@@ -1,7 +1,7 @@
/* tif_lzw.h - LZW compression for TIFF */
/*
libzint - the open source barcode library
- Copyright (C) 2021-2022 Robin Stuart
+ Copyright (C) 2021-2024 Robin Stuart
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -33,6 +33,10 @@
#ifndef Z_TIF_LZW_H
#define Z_TIF_LZW_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
/*
* Adapted from TIFF Library 4.2.0 libtiff/tif_lzw.c */
/*
@@ -370,5 +374,9 @@ static void tif_lzw_init(tif_lzw_state *sp) {
sp->enc_hashtab = NULL;
}
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
/* vim: set ts=4 sw=4 et : */
#endif /* Z_TIF_LZW_H */
diff --git a/docs/manual.html b/docs/manual.html
index 68ab1f43..976cb10c 100644
--- a/docs/manual.html
+++ b/docs/manual.html
@@ -4894,8 +4894,8 @@ alt="zint -b EAN14 --compliantheight -d "9889876543210"" />
aria-hidden="true">zint -b EAN14 --compliantheight -d "9889876543210"
A shorter version of GS1-128 which encodes GTIN data only. A 13-digit
-number is required. The GTIN check digit and AI (01) are added by
-Zint.
+number is required. The GTIN check digit and HRT-only AI “(01)” are
+added by Zint.
6.1.10.5 NVE-18 (SSCC-18)