CODE128: reduce extended latch cut-off from 5 to 4 for better

encodation in certain cases (and no pessimizations found so far),
  props lyngklip (BWIPP);
  fix extended char latching when exactly 3 extended chars at end;
  count code set C (not digits) in loop deciding when to
  shift/latch to extended for better estimate
AZTEC: return warning if ECC < 5% (due to bit-stuffing when version
  given); return error if > 22 layers (Zint 26) for Reader
  Initialisation symbol requested for better error message
AZTEC/HANXIN/QRCODE: consolidate different ECC data size tables
  into one indexed by ECC
DBAR_EXP: check for reduced length <= 77 up front for better error
  message
HANXIN: use `malloc()` rather than `z_alloca()` for large binary
  array
QRCODE: `ecc_level` now 0-based (not 1-based)
MICROQR: consolidate different version end routines into one
  `microqr_end()` and use new `microqr_data` table to simplify code
MICROPDF417: use table for max codewords per column
library: centralize all error messages using new `errtxt()`,
  `errtxtf()`, `errtxt_adj()` funcs that protect `symbol->errtxt`
  from overflow, & try to make error messages more consistent
  thru-out, adding more feedback info to many, & use positional
  args "%n$" in prep for l10n (maybe);
  `is_sane/is_sane_lookup()` -> `not_sane/not_sane_lookup()`,
  returning 1-based position (zero on failure) instead of bool;
  `long` ints -> plain `int` (except those dealing with `ftell()`,
  `fread()` etc) as depend on int being 32-bits already
GUI: in "grpDATF.ui" use "PlainText" rather than "RichText" for
  tracker ratio examples as height of text messing up sometimes
manual: clarify Codablock-F length maximum & add examples
docs: README: pandoc 3.5, Ubuntu 24.04
CMake: use "-Wpedantic" for Clang only as GNU complains about
  `errtxtf()` positional args "%n$"
This commit is contained in:
gitlost 2024-10-27 21:33:33 +00:00
parent 752c1fae5d
commit 5e2044ff2e
104 changed files with 8102 additions and 7755 deletions

View file

@ -53,10 +53,13 @@ if(NOT MSVC) # Use default warnings if MSVC otherwise inundated
add_compile_options("-Wextra")
endif()
# gcc complains about "%n$" `errtxtf()` arguments if "-Wpedantic" used, so only use for clang
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
check_c_compiler_flag("-Wpedantic" C_COMPILER_FLAG_WPEDANTIC)
if(C_COMPILER_FLAG_WPEDANTIC)
add_compile_options("-Wpedantic")
endif()
endif()
check_c_compiler_flag("-Wundef" C_COMPILER_FLAG_WUNDEF)
if(C_COMPILER_FLAG_WUNDEF)

View file

@ -6,6 +6,8 @@ Version 2.13.0.9 (dev) not released yet
- New `memfile` & `memfile_size` fields in `symbol` for use with new output
option `BARCODE_MEMORY_FILE`
- Invalid `input_mode` now returns warning
- Aztec Code symbols that due to input length & user-requested version have less
than recommended 5% error correction codewords now return warning
- New CODE128-only special extra escape `\^1` for manually inserting FNC1s
Changes
@ -15,15 +17,30 @@ Changes
- Add `BARCODE_MEMORY_FILE` to `symbol->output_options` to allow outputting to
in-memory buffer `symbol->memfile` instead of to file `symbol->outfile`,
ticket #301
- CODE128: improve encodation on A/B shifting, props Daniel Gredler (Okapi)
- CODE16K (was for CODE128): improve encodation on A/B shifting, props Daniel
Gredler (Okapi)
- CODE128: add new extra escape `\^1` for manual insertion of FNC1s, ticket
#324, props Jim Shank;
add minimal encodation algorithm (non-extended ASCII only), props Alex Geller
(ZXing);
reduce extended latch cut-off from 5 to 4 for better encodation in certain
cases, props lyngklip (BWIPP)
- library: return warning on invalid `input_mode` reset
- GS1: new AIs 7250-7259 (GSCN 22-246), new linters `yyyymmdd()`, `iso5218()`,
`posinseqslash()`; remove old linter `iso3166list`;
iso4217: new ISO 4217 currency code 924
- library/CLI: expanded error messages
- GS1: new AIs 7250-7259 (GSCN 22-246);
iso4217: new ISO 4217 currency code 924;
new AIs 7041 (GSCN 23-272) (packagetype) and 716 (GSCN-24-157)
- AZTEC: workaround MSVC 2022 optimizer bug in `az_populate_map()` loops,
ticket #317, props Andre Maute
- CODE128: Add new extra escape `\^1` for manual insertion of FNC1s, ticket
#324, props Jim Shank
ticket #317, props Andre Maute;
return warning if ECC < 5% (due to bit-stuffing when version given)
- MAXICODE: zero-pad US postcodes that lack "+4" (Annex B.1.4a), from
OkapiBarcode, props Daniel Gredler
- GUI: use X11 (xcb) as platform instead of Wayland on Linux to avoid various
weird behaviours;
in "grpDATF.ui" use "PlainText" rather than "RichText" for tracker ratio
examples as height of text messing up sometimes
- manual: make explicit that AI "(00)" and "(01)" prefixes added by Zint are
HRT-only; clarify Codablock-F length maximum & add examples
Bugs
----
@ -37,8 +54,10 @@ Bugs
- ITF14/DPLEIT/DPIDENT: ignore `option_2` (check digit options)
- GUI: scalewindow: fix cropping of initial resolution and bound X-dim <= 10
- GUI: factory reset: reset preview background colour also
- GUI: cliwindow: `#if _WIN32` -> `#ifdef _WIN32`
- QZint: fix legacy width and security level getters/setters, MR #158, props
Philip Ye
- CODE128: fix extended char latching when exactly 3 extended chars at end
Version 2.13.0 (2023-12-18)

View file

@ -66,13 +66,14 @@ static int c25_common(struct zint_symbol *symbol, const unsigned char source[],
if (length > max) {
/* errtxt 301: 303: 305: 307: */
sprintf(symbol->errtxt, "%d: Input too long (%d character maximum)", error_base, max);
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, error_base, "Input length %1$d too long (maximum %2$d)", length,
max);
}
if (!is_sane(NEON_F, source, length)) {
if ((i = not_sane(NEON_F, source, length))) {
/* Note: for all "at position" error messages, escape sequences not accounted for */
/* errtxt 302: 304: 306: 308: */
sprintf(symbol->errtxt, "%d: Invalid character in data (digits only)", error_base + 1);
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, error_base + 1,
"Invalid character at position %d in input (digits only)", i);
}
ustrcpy(temp, source);
@ -147,12 +148,11 @@ static int c25_inter_common(struct zint_symbol *symbol, unsigned char source[],
const int have_checkdigit = checkdigit_option == 1 || checkdigit_option == 2;
if (length > 125) { /* 4 + (125 + 1) * 9 + 5 = 1143 */
strcpy(symbol->errtxt, "309: Input too long (125 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 309, "Input length %d too long (maximum 125)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "310: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 310,
"Invalid character at position %d in input (digits only)", i);
}
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
@ -233,13 +233,12 @@ INTERNAL int itf14(struct zint_symbol *symbol, unsigned char source[], int lengt
unsigned char localstr[16] = {0};
if (length > 13) {
strcpy(symbol->errtxt, "311: Input too long (13 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 311, "Input length %d too long (maximum 13)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "312: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 312,
"Invalid character at position %d in input (digits only)", i);
}
/* Add leading zeros as required */
@ -298,12 +297,11 @@ INTERNAL int dpleit(struct zint_symbol *symbol, unsigned char source[], int leng
count = 0;
if (length > 13) {
strcpy(symbol->errtxt, "313: Input wrong length (13 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 313, "Input length %d too long (maximum 13)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "314: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 314,
"Invalid character at position %d in input (digits only)", i);
}
zeroes = 13 - length;
@ -346,12 +344,11 @@ INTERNAL int dpident(struct zint_symbol *symbol, unsigned char source[], int len
count = 0;
if (length > 11) {
strcpy(symbol->errtxt, "315: Input wrong length (11 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 315, "Input length %d too long (maximum 11)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "316: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 316,
"Invalid character at position %d in input (digits only)", i);
}
zeroes = 11 - length;

View file

@ -110,6 +110,7 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
1 = Tracker and Ascender
2 = Tracker and Descender
3 = Tracker only */
int i;
int error_number;
int writer;
int loopey, reader;
@ -123,18 +124,17 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
/* Do all of the length checking first to avoid stack smashing */
if (symbol->symbology == BARCODE_AUSPOST) {
if (length != 8 && length != 13 && length != 16 && length != 18 && length != 23) {
strcpy(symbol->errtxt, "401: Input wrong length (8, 13, 16, 18 or 23 characters only)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 401, "Input length %d wrong (8, 13, 16, 18 or 23 only)",
length);
}
} else if (length > 8) {
strcpy(symbol->errtxt, "403: Input too long (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 403, "Input length %d too long (maximum 8)", length);
}
/* Check input immediately to catch nuls */
if (!is_sane(GDSET_F, source, length)) {
strcpy(symbol->errtxt, "404: Invalid character in data (alphanumerics, space and \"#\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(GDSET_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 404,
"Invalid character at position %d in input (alphanumerics, space and \"#\" only)", i);
}
localstr[0] = '\0';
@ -150,9 +150,10 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
break;
case 16:
strcpy(fcc, "59");
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "402: Invalid character in data (digits only for length 16)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 402,
"Invalid character at position %d in input (digits only for FCC 59 length 16)",
i);
}
break;
case 18:
@ -160,9 +161,10 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
break;
case 23:
strcpy(fcc, "62");
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "406: Invalid character in data (digits only for length 23)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 406,
"Invalid character at position %d in input (digits only for FCC 62 length 23)",
i);
}
break;
}
@ -192,9 +194,9 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
/* Verify that the first 8 characters are numbers */
memcpy(dpid, localstr, 8);
dpid[8] = '\0';
if (!is_sane(NEON_F, (unsigned char *) dpid, 8)) {
strcpy(symbol->errtxt, "405: Invalid character in DPID (first 8 characters) (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, (unsigned char *) dpid, 8))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 405,
"Invalid character at position %d in DPID (first 8 characters) (digits only)", i);
}
/* Start character */

View file

@ -37,10 +37,14 @@
#include "reedsol.h"
#define AZTEC_MAX_CAPACITY 19968 /* ISO/IEC 24778:2008 5.3 Table 1 Maximum Symbol Bit Capacity */
#define AZTEC_BIN_CAPACITY 17940 /* Above less 169 * 12 = 2028 bits (169 = 10% of 1664 + 3) */
/* Allow up to absolute minimum 3 ECC codewords, but now warn if results in less than the 5% minimum (ISO/IEC
24778:2008 4.1.e) - previously could go down to 3 ECC codewords anyway if version given, due to bit-stuffing */
#define AZTEC_BIN_CAPACITY 19932 /* AZTEC_MAX_CAPACITY less 3 * 12 = 36 */
#define AZTEC_MAP_SIZE 22801 /* AztecMap Version 32 151 x 151 */
#define AZTEC_MAP_POSN_MAX 20039 /* Maximum position index in AztecMap */
#define AZ_BIN_CAP_CWDS_S "1661" /* String version of (AZTEC_BIN_CAPACITY / 12) */
/* Count number of consecutive (. SP) or (, SP) Punct mode doubles for comparison against Digit mode encoding */
static int az_count_doubles(const unsigned char source[], int i, const int length) {
int c = 0;
@ -784,7 +788,7 @@ static void az_populate_map(short AztecMap[], const int layers) {
/* Helper to insert dummy '0' or '1's into runs of same bits. See ISO/IEC 24778:2008 7.3.1.2 */
static int az_bitrun_stuff(const char *binary_string, const int data_length, const int codeword_size,
char adjusted_string[AZTEC_MAX_CAPACITY]) {
const int data_maxsize, char adjusted_string[AZTEC_MAX_CAPACITY]) {
int i, j = 0, count = 0;
for (i = 0; i < data_length; i++) {
@ -796,7 +800,7 @@ static int az_bitrun_stuff(const char *binary_string, const int data_length, con
if (count == 0 || count == (codeword_size - 1)) {
/* Codeword of B-1 '0's or B-1 '1's */
if (j >= AZTEC_MAX_CAPACITY) {
if (j > data_maxsize) {
return 0; /* Fail */
}
adjusted_string[j++] = count == 0 ? '1' : '0';
@ -808,7 +812,7 @@ static int az_bitrun_stuff(const char *binary_string, const int data_length, con
} else if (binary_string[i] == '1') { /* Skip B so only counting B-1 */
count++;
}
if (j >= AZTEC_MAX_CAPACITY) {
if (j > data_maxsize) {
return 0; /* Fail */
}
adjusted_string[j++] = binary_string[i];
@ -864,23 +868,19 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
int error_number = 0;
int compact, data_length, data_maxsize, codeword_size, adjusted_length;
int remainder, padbits, adjustment_size;
int reader = 0;
int comp_loop = 4;
int bp = 0;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
const int debug_print = (symbol->debug & ZINT_DEBUG_PRINT);
const int reader_init = symbol->output_options & READER_INIT;
const int compact_loop_start = reader_init ? 1 : 4; /* Compact 2-4 excluded from Reader Initialisation */
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
rs_t rs;
rs_uint_t rs_uint;
unsigned int *data_part;
unsigned int *ecc_part;
if (symbol->output_options & READER_INIT) {
reader = 1;
comp_loop = 1;
}
if (gs1 && reader) {
strcpy(symbol->errtxt, "501: Cannot encode in GS1 and Reader Initialisation mode at the same time");
return ZINT_ERROR_INVALID_OPTION;
if (gs1 && reader_init) {
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 501,
"Cannot encode in GS1 and Reader Initialisation mode at the same time");
}
if (symbol->structapp.count) {
@ -890,19 +890,20 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
int id_len;
if (symbol->structapp.count < 2 || symbol->structapp.count > 26) {
strcpy(symbol->errtxt, "701: Structured Append count out of range (2-26)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 701,
"Structured Append count '%d' out of range (2 to 26)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "702: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 702,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
for (id_len = 0; id_len < 32 && symbol->structapp.id[id_len]; id_len++);
if (id_len && chr_cnt((const unsigned char *) symbol->structapp.id, id_len, ' ')) {
strcpy(symbol->errtxt, "703: Structured Append ID cannot contain spaces");
return ZINT_ERROR_INVALID_OPTION;
/* Note ID can contain any old chars apart from space so don't print in error message */
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 703, "Structured Append ID cannot contain spaces");
}
bp = bin_append_posn(29, 5, binary_string, bp); /* M/L */
@ -919,7 +920,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
sa_src[sa_len++] = 'A' + symbol->structapp.count - 1;
if (debug_print) {
printf("Structured Append Count: %d, Index: %d, ID: %.32s, String: %s\n",
symbol->structapp.count, symbol->structapp.count, symbol->structapp.id, sa_src);
symbol->structapp.count, symbol->structapp.index, symbol->structapp.id, sa_src);
}
(void) aztec_text_process(sa_src, sa_len, bp, binary_string, 0 /*gs1*/, 0 /*eci*/, NULL /*p_current_mode*/,
@ -928,32 +929,26 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
}
if (!aztec_text_process_segs(segs, seg_count, bp, binary_string, gs1, &data_length, debug_print)) {
strcpy(symbol->errtxt, "502: Input too long or too many extended ASCII characters");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 502,
"Input too long, requires too many codewords (maximum " AZ_BIN_CAP_CWDS_S ")");
}
assert(data_length > 0); /* Suppress clang-tidy warning: clang-analyzer-core.UndefinedBinaryOperatorResult */
if (!((symbol->option_1 >= -1) && (symbol->option_1 <= 4))) {
strcpy(symbol->errtxt, "503: Invalid error correction level - using default instead");
if (symbol->option_1 < -1 || symbol->option_1 > 4) {
errtxtf(0, symbol, 503, "Error correction level '%d' out of range (1 to 4)", symbol->option_1);
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
}
error_number = ZINT_WARN_INVALID_OPTION;
error_number = errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring");
symbol->option_1 = -1;
}
data_maxsize = 0; /* Keep compiler happy! */
adjustment_size = 0;
if (symbol->option_2 == 0) { /* The size of the symbol can be determined by Zint */
static const short *const full_sizes[5] = {
NULL, Aztec10DataSizes, Aztec23DataSizes, Aztec36DataSizes, Aztec50DataSizes
};
static const short *const comp_sizes[5] = {
NULL, AztecCompact10DataSizes, AztecCompact23DataSizes, AztecCompact36DataSizes, AztecCompact50DataSizes
};
int ecc_level = symbol->option_1;
if ((ecc_level == -1) || (ecc_level == 0)) {
if (ecc_level <= 0) {
ecc_level = 2;
}
@ -963,34 +958,43 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
layers = 0;
/* For each level of error correction work out the smallest symbol which the data will fit in */
for (i = comp_loop; i > 0; i--) {
if ((data_length + adjustment_size) < comp_sizes[ecc_level][i - 1]) {
for (i = compact_loop_start; i > 0; i--) {
if ((data_length + adjustment_size) <= AztecCompactDataSizes[ecc_level - 1][i - 1]) {
layers = i;
compact = 1;
data_maxsize = comp_sizes[ecc_level][i - 1];
data_maxsize = AztecCompactDataSizes[ecc_level - 1][i - 1];
}
}
if (!compact) {
for (i = 32; i > 0; i--) {
if ((data_length + adjustment_size) < full_sizes[ecc_level][i - 1]) {
if ((data_length + adjustment_size) <= AztecDataSizes[ecc_level - 1][i - 1]) {
layers = i;
compact = 0;
data_maxsize = full_sizes[ecc_level][i - 1];
data_maxsize = AztecDataSizes[ecc_level - 1][i - 1];
}
}
}
if (layers == 0) { /* Couldn't find a symbol which fits the data */
strcpy(symbol->errtxt, "504: Input too long (too many bits for selected ECC)");
return ZINT_ERROR_TOO_LONG;
if (adjustment_size == 0) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 707,
"Input too long for ECC level %1$d, requires too many codewords (maximum %2$d)",
ecc_level, AztecDataSizes[ecc_level - 1][31] / 12);
}
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 504,
"Input too long for ECC level %1$d, requires %2$d codewords (maximum %3$d)",
ecc_level, (data_length + adjustment_size + 11) / 12,
AztecDataSizes[ecc_level - 1][31] / 12);
}
codeword_size = az_codeword_size(layers);
adjusted_length = az_bitrun_stuff(binary_string, data_length, codeword_size, adjusted_string);
adjusted_length = az_bitrun_stuff(binary_string, data_length, codeword_size,
adjustment_size ? data_maxsize : AZTEC_BIN_CAPACITY, adjusted_string);
if (adjusted_length == 0) {
strcpy(symbol->errtxt, "705: Data too long for specified Aztec Code symbol size");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 705,
"Input too long for ECC level %1$d, requires too many codewords (maximum %2$d)",
ecc_level, (adjustment_size ? data_maxsize : AZTEC_BIN_CAPACITY) / codeword_size);
}
adjustment_size = adjusted_length - data_length;
@ -1003,10 +1007,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
}
if (debug_print) printf("Remainder: %d Pad bits: %d\n", remainder, padbits);
if (adjusted_length + padbits >= AZTEC_MAX_CAPACITY) { /* Probably can't happen */
strcpy(symbol->errtxt, "706: Data too long for specified Aztec Code symbol size");
return ZINT_ERROR_TOO_LONG;
}
assert(adjusted_length <= AZTEC_BIN_CAPACITY);
adjusted_length = az_add_padding(padbits, codeword_size, adjusted_string, adjusted_length);
@ -1019,11 +1020,19 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
} else { /* The size of the symbol has been specified by the user */
if ((symbol->option_2 < 0) || (symbol->option_2 > 36)) {
strcpy(symbol->errtxt, "510: Invalid Aztec Code size");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 510, "Version '%d' out of range (1 to 36)",
symbol->option_2);
}
if ((reader == 1) && ((symbol->option_2 >= 2) && (symbol->option_2 <= 4))) {
if (reader_init) {
/* For back-compatibility, silently ignore compact 2-4 requests but error on layers > 22 */
if (symbol->option_2 >= 2 && symbol->option_2 <= 4) {
symbol->option_2 = 5;
} else if (symbol->option_2 > 26) {
/* Caught below anyway but catch here also for better feedback */
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 709,
"Version '%d' out of range for Reader Initialisation symbols (maximum 26)",
symbol->option_2);
}
}
if (symbol->option_2 <= 4) {
compact = 1;
@ -1034,11 +1043,17 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
}
codeword_size = az_codeword_size(layers);
if (compact) {
data_maxsize = codeword_size * (AztecCompactSizes[layers - 1] - 3);
} else {
data_maxsize = codeword_size * (AztecSizes[layers - 1] - 3);
}
adjusted_length = az_bitrun_stuff(binary_string, data_length, codeword_size, adjusted_string);
adjusted_length = az_bitrun_stuff(binary_string, data_length, codeword_size, data_maxsize, adjusted_string);
if (adjusted_length == 0) {
strcpy(symbol->errtxt, "704: Data too long for specified Aztec Code symbol size");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 704,
"Input too long for Version %1$d, requires too many codewords (maximum %2$d)",
symbol->option_2, data_maxsize / codeword_size);
}
/* Add padding */
@ -1051,15 +1066,12 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
if (debug_print) printf("Remainder: %d Pad bits: %d\n", remainder, padbits);
/* Check if the data actually fits into the selected symbol size */
if (compact) {
data_maxsize = codeword_size * (AztecCompactSizes[layers - 1] - 3);
} else {
data_maxsize = codeword_size * (AztecSizes[layers - 1] - 3);
}
if (adjusted_length + padbits > data_maxsize) {
strcpy(symbol->errtxt, "505: Data too long for specified Aztec Code symbol size");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 505,
"Input too long for Version %1$d, requires %2$d codewords (maximum %3$d)",
symbol->option_2, (adjusted_length + padbits) / codeword_size,
data_maxsize / codeword_size);
}
adjusted_length = az_add_padding(padbits, codeword_size, adjusted_string, adjusted_length);
@ -1075,9 +1087,9 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
fputc('\n', stdout);
}
if (reader && (layers > 22)) {
strcpy(symbol->errtxt, "506: Data too long for reader initialisation symbol");
return ZINT_ERROR_TOO_LONG;
if (reader_init && (layers > 22)) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 506,
"Input too long for Reader Initialisation, requires %d layers (maximum 22)", layers);
}
data_blocks = adjusted_length / codeword_size;
@ -1090,6 +1102,11 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
} else {
ecc_blocks = AztecSizes[layers - 1] - data_blocks;
}
if (ecc_blocks < data_blocks / 20) {
error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 708,
"Number of ECC codewords %1$d less than %2$d (5%% of data codewords %3$d)",
ecc_blocks, data_blocks / 20, data_blocks);
}
if (debug_print) {
printf("Generating a %s symbol with %d layers\n", compact ? "compact" : "full-size", layers);
@ -1126,8 +1143,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
break;
case 10:
if (!rs_uint_init_gf(&rs_uint, 0x409, 1023)) { /* Can fail on malloc() */
strcpy(symbol->errtxt, "500: Insufficient memory for Reed-Solomon log tables");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 500, "Insufficient memory for Reed-Solomon log tables");
}
rs_uint_init_code(&rs_uint, ecc_blocks, 1);
rs_uint_encode(&rs_uint, data_blocks, data_part, ecc_part);
@ -1136,8 +1152,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
case 12:
if (!rs_uint_init_gf(&rs_uint, 0x1069, 4095)) { /* Can fail on malloc() */
/* Note using AUSPOST error nos range as out of 50x ones & 51x taken by CODEONE */
strcpy(symbol->errtxt, "700: Insufficient memory for Reed-Solomon log tables");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 700, "Insufficient memory for Reed-Solomon log tables");
}
rs_uint_init_code(&rs_uint, ecc_blocks, 1);
rs_uint_encode(&rs_uint, data_blocks, data_part, ecc_part);
@ -1168,7 +1183,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
descriptor[1] = ((layers - 1) & 0x01) ? '1' : '0';
/* The next 6 bits represent the number of data blocks minus 1 */
descriptor[2] = reader || ((data_blocks - 1) & 0x20) ? '1' : '0';
descriptor[2] = reader_init || ((data_blocks - 1) & 0x20) ? '1' : '0';
for (i = 3; i < 8; i++) {
descriptor[i] = ((data_blocks - 1) & (0x10 >> (i - 3))) ? '1' : '0';
}
@ -1180,7 +1195,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
}
/* The next 11 bits represent the number of data blocks minus 1 */
descriptor[5] = reader || ((data_blocks - 1) & 0x400) ? '1' : '0';
descriptor[5] = reader_init || ((data_blocks - 1) & 0x400) ? '1' : '0';
for (i = 6; i < 16; i++) {
descriptor[i] = ((data_blocks - 1) & (0x200 >> (i - 6))) ? '1' : '0';
}
@ -1274,12 +1289,11 @@ INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int leng
input_value = 0;
if (length > 3) {
strcpy(symbol->errtxt, "507: Input too large (3 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 507, "Input length %d too long (maximum 3)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "508: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 508,
"Invalid character at position %d in input (digits only)", i);
}
switch (length) {
case 3:
@ -1294,8 +1308,7 @@ INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int leng
}
if (input_value > 255) {
strcpy(symbol->errtxt, "509: Input out of range (0 to 255)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 509, "Input value out of range (0 to 255)");
}
bp = bin_append_posn(input_value, 8, binary_string, bp);

View file

@ -117,44 +117,38 @@ static const short AztecCompactSizes[4] = {
17, 40, 51, 64 /* 64 data blocks (Mode Message max) but 76 altogether */
};
static const short AztecDataSizes[4][32] = { {
/* Data bits per symbol maximum with 10% error correction */
static const short Aztec10DataSizes[32] = {
96, 246, 408, 616, 840, 1104, 1392, 1704, 2040, 2420, 2820, 3250, 3720, 4200, 4730, 5270,
5840, 6450, 7080, 7750, 8430, 9150, 9900, 10680, 11484, 12324, 13188, 14076, 15000, 15948, 16920, 17940
};
}, {
/* Data bits per symbol maximum with 23% error correction */
static const short Aztec23DataSizes[32] = {
84, 204, 352, 520, 720, 944, 1184, 1456, 1750, 2070, 2410, 2780, 3180, 3590, 4040, 4500,
5000, 5520, 6060, 6630, 7210, 7830, 8472, 9132, 9816, 10536, 11280, 12036, 12828, 13644, 14472, 15348
};
}, {
/* Data bits per symbol maximum with 36% error correction */
static const short Aztec36DataSizes[32] = {
66, 168, 288, 432, 592, 776, 984, 1208, 1450, 1720, 2000, 2300, 2640, 2980, 3350, 3740,
4150, 4580, 5030, 5500, 5990, 6500, 7032, 7584, 8160, 8760, 9372, 9996, 10656, 11340, 12024, 12744
};
}, {
/* Data bits per symbol maximum with 50% error correction */
static const short Aztec50DataSizes[32] = {
48, 126, 216, 328, 456, 600, 760, 936, 1120, 1330, 1550, 1790, 2050, 2320, 2610, 2910,
3230, 3570, 3920, 4290, 4670, 5070, 5484, 5916, 6360, 6828, 7308, 7800, 8316, 8844, 9384, 9948
}
};
static const short AztecCompact10DataSizes[4] = {
static const short AztecCompactDataSizes[4][4] = { {
/* Data bits per symbol maximum with 10% error correction */
78, 198, 336, 512 /* Max 64 * 8 */
};
static const short AztecCompact23DataSizes[4] = {
}, {
/* Data bits per symbol maximum with 23% error correction */
66, 168, 288, 440
};
static const short AztecCompact36DataSizes[4] = {
}, {
/* Data bits per symbol maximum with 36% error correction */
48, 138, 232, 360
};
static const short AztecCompact50DataSizes[4] = {
}, {
/* Data bits per symbol maximum with 50% error correction */
36, 102, 176, 280
}
};
/* Reference grid offsets */

View file

@ -73,9 +73,11 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
char *d = dest;
int error_number = 0;
if ((length < 7) || (length > 18)) {
strcpy(symbol->errtxt, "790: Input wrong length (should be between 7 and 18 characters)");
return ZINT_ERROR_TOO_LONG;
if (length > 18) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 790, "Input length %d too long (maximum 18)", length);
}
if (length < 7) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 792, "Input length %d too short (minimum 7)", length);
}
to_upper(source, length);
@ -87,9 +89,9 @@ INTERNAL int bc412(struct zint_symbol *symbol, unsigned char source[], int lengt
}
padded_source[length + 1] = 0;
if (!is_sane_lookup(BROMINE, 35, padded_source, length + 1, posns)) {
strcpy(symbol->errtxt, "791: Invalid character in data (alphanumerics only, excluding the letter \"O\")");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(BROMINE, 35, padded_source, length + 1, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 791,
"Invalid character at position %d in input (alphanumerics only, excluding \"O\")", i - 1);
}
for (i = 0; i <= length; i++) {

View file

@ -88,13 +88,11 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
/* Must fit in `uint32_t` field in header */
if (file_size != (uint32_t) file_size) {
strcpy(symbol->errtxt, "606: Output file size too large for BMP header");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 606, "Output size too large for file size field of BMP header");
}
if (!(rowbuf = (unsigned char *) malloc(row_size))) {
strcpy(symbol->errtxt, "602: Insufficient memory for BMP row buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 602, "Insufficient memory for BMP row buffer");
}
out_le_u16(file_header.header_field, 0x4d42); /* "BM" */
@ -117,7 +115,7 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
/* Open output file in binary mode */
if (!fm_open(fmp, symbol, "wb")) {
sprintf(symbol->errtxt, "601: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 601, "Could not open BMP output file (%1$d: %2$s)", fmp->err, strerror(fmp->err));
free(rowbuf);
return ZINT_ERROR_FILE_ACCESS;
}
@ -160,14 +158,14 @@ INTERNAL int bmp_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
free(rowbuf);
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "603: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 603, "Incomplete write of BMP output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "605: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 605, "Failure on closing BMP output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return 0;

View file

@ -1,7 +1,7 @@
/* codablock.c - Handles Codablock-F */
/*
libzint - the open source barcode library
Copyright (C) 2016-2023 Harald Oehlmann
Copyright (C) 2016-2024 Harald Oehlmann
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -577,14 +577,13 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
return error_number;
}
if (rows > 44) {
strcpy(symbol->errtxt, "410: Rows parameter not in 0..44");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 410, "Number of rows '%d' out of range (0 to 44)", rows);
}
/* option_2: (usable data) columns: <= 0: automatic, 9..67 (min 9 == 4 data, max 67 == 62 data) */
columns = symbol->option_2;
if (!(columns <= 0 || (columns >= 9 && columns <= 67))) {
strcpy(symbol->errtxt, "411: Columns parameter not in 0, 9..67");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 411, "Number of columns '%d' out of range (9 to 67)",
columns);
}
if (columns < 0) { /* Protect against negative overflow (ticket #300 (#9) Andre Maute) */
columns = 0;
@ -637,8 +636,8 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
error_number = Columns2Rows(symbol, T, dataLength, &rows, &useColumns, pSet, &fillings);
}
if (error_number != 0) {
strcpy(symbol->errtxt, "413: Data string too long");
return error_number;
return errtxt(error_number, symbol, 413,
"Input too long, requires too many symbol characters (maximum 2726)");
}
/* Suppresses clang-analyzer-core.VLASize warning */
assert(rows >= 2 && useColumns >= 4);

View file

@ -144,17 +144,16 @@ INTERNAL int code11(struct zint_symbol *symbol, unsigned char source[], int leng
assert(length > 0);
if (length > 140) { /* 8 (Start) + 140 * 8 + 2 * 8 (Check) + 7 (Stop) = 1151 */
strcpy(symbol->errtxt, "320: Input too long (140 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 320, "Input length %d too long (maximum 140)", length);
}
if (!is_sane(SODIUM_MNS_F, source, length)) {
strcpy(symbol->errtxt, "321: Invalid character in data (digits and \"-\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(SODIUM_MNS_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 321,
"Invalid character at position %d in input (digits and \"-\" only)", i);
}
if (symbol->option_2 < 0 || symbol->option_2 > 2) {
strcpy(symbol->errtxt, "339: Invalid check digit version (1, 2 only)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 339, "Invalid check digit version '%d' (1 or 2 only)",
symbol->option_2);
}
if (symbol->option_2 == 2) {
num_check_digits = 0;
@ -255,22 +254,19 @@ INTERNAL int code39(struct zint_symbol *symbol, unsigned char source[], int leng
/* LOGMARS MIL-STD-1189 Rev. B https://apps.dtic.mil/dtic/tr/fulltext/u2/a473534.pdf */
if ((symbol->symbology == BARCODE_LOGMARS) && (length > 30)) { /* MIL-STD-1189 Rev. B Section 5.2.6.2 */
strcpy(symbol->errtxt, "322: Input too long (30 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 322, "Input length %d too long (maximum 30)", length);
/* Prevent encoded_data out-of-bounds >= 143 for BARCODE_HIBC_39 due to wider 'wide' bars */
} else if ((symbol->symbology == BARCODE_HIBC_39) && (length > 70)) { /* 16 (Start) + 70*16 + 15 (Stop) = 1151 */
/* Note use 319 (2of5 range) as 340 taken by CODE128 */
strcpy(symbol->errtxt, "319: Input too long (68 character maximum)"); /* 70 less '+' and check */
return ZINT_ERROR_TOO_LONG;
/* 70 less '+' and check */
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 319, "Input length %d too long (maximum 68)", length - 2);
} else if (length > 86) { /* 13 (Start) + 86*13 + 12 (Stop) = 1143 */
strcpy(symbol->errtxt, "323: Input too long (86 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 323, "Input length %d too long (maximum 86)", length);
}
to_upper(source, length);
if (!is_sane_lookup(SILVER, 43 /* Up to "%" */, source, length, posns)) {
strcpy(symbol->errtxt, "324: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(SILVER, 43 /* Up to "%" */, source, length, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 324,
"Invalid character at position %d in input (alphanumerics, space and \"-.$/+%%\" only)", i);
}
/* Start character */
@ -370,16 +366,16 @@ INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length)
const int pzn7 = symbol->option_2 == 1;
if (length > 8 - pzn7) {
sprintf(symbol->errtxt, "325: Input wrong length (%d character maximum)", 8 - pzn7);
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 325, "Input length %1$d too long (maximum %2$d)", length,
8 - pzn7);
}
if (length == 8 - pzn7) {
have_check_digit = source[7 - pzn7];
length--;
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "326: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 326,
"Invalid character at position %d in input (digits only)", i);
}
localstr[0] = '-';
@ -400,12 +396,11 @@ INTERNAL int pzn(struct zint_symbol *symbol, unsigned char source[], int length)
}
if (check_digit == 10) {
strcpy(symbol->errtxt, "327: Invalid PZN, check digit is '10'");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 327, "Invalid PZN, check digit is '10'");
}
if (have_check_digit && ctoi(have_check_digit) != check_digit) {
sprintf(symbol->errtxt, "890: Invalid check digit '%c', expecting '%c'", have_check_digit, itoc(check_digit));
return ZINT_ERROR_INVALID_CHECK;
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 890, "Invalid check digit '%1$c', expecting '%2$c'",
have_check_digit, itoc(check_digit));
}
localstr[8 - pzn7] = itoc(check_digit);
@ -453,23 +448,22 @@ INTERNAL int excode39(struct zint_symbol *symbol, unsigned char source[], int le
int error_number;
if (length > 86) {
strcpy(symbol->errtxt, "328: Input too long (86 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 328, "Input length %d too long (maximum 86)", length);
}
/* Creates a buffer string and places control characters into it */
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "329: Invalid character in data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 329,
"Invalid character at position %d in input, extended ASCII not allowed", i + 1);
}
memcpy(b, EC39Ctrl[source[i]], 2);
b += EC39Ctrl[source[i]][1] ? 2 : 1;
}
if (b - buffer > 86) {
strcpy(symbol->errtxt, "317: Expanded input too long (86 symbol character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 317, "Input too long, requires %d symbol characters (maximum 86)",
(int) (b - buffer));
}
*b = '\0';
@ -515,16 +509,15 @@ INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int leng
assert(length > 0);
if (length > 123) { /* 9 (Start) + 123*9 + 2*9 (Checks) + 10 (Stop) = 1144 */
strcpy(symbol->errtxt, "330: Input too long (123 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 330, "Input length %d too long (maximum 123)", length);
}
/* Message Content */
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "331: Invalid character in data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 331,
"Invalid character at position %d in input, extended ASCII not allowed", i + 1);
}
memcpy(b, C93Ctrl[source[i]], 2);
b += C93Ctrl[source[i]][1] ? 2 : 1;
@ -534,8 +527,8 @@ INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int leng
/* Now we can check the true length of the barcode */
h = b - buffer;
if (h > 123) {
strcpy(symbol->errtxt, "332: Expanded input too long (123 symbol character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 332,
"Input too long, requires %d symbol characters (maximum 123)", h);
}
for (i = 0; i < h; i++) {
@ -607,7 +600,7 @@ INTERNAL int code93(struct zint_symbol *symbol, unsigned char source[], int leng
}
typedef const struct s_channel_precalc {
long value; unsigned char B[8]; unsigned char S[8]; unsigned char bmax[7]; unsigned char smax[7];
int value; unsigned char B[8]; unsigned char S[8]; unsigned char bmax[7]; unsigned char smax[7];
} channel_precalc;
#if 0
@ -617,7 +610,7 @@ typedef const struct s_channel_precalc {
#ifdef CHANNEL_GENERATE_PRECALCS
/* To generate precalc tables uncomment CHANNEL_GENERATE_PRECALCS define and run
"backend/tests/test_channel -f generate -g" and place result in "channel_precalcs.h" */
static void channel_generate_precalc(int channels, long value, int mod, int last, int B[8], int S[8], int bmax[7],
static void channel_generate_precalc(int channels, int value, int mod, int last, int B[8], int S[8], int bmax[7],
int smax[7]) {
int i;
if (value == mod) printf("static channel_precalc channel_precalcs%d[] = {\n", channels);
@ -631,7 +624,7 @@ static void channel_generate_precalc(int channels, long value, int mod, int last
#include "channel_precalcs.h"
#endif
static long channel_copy_precalc(channel_precalc *const precalc, int B[8], int S[8], int bmax[7], int smax[7]) {
static int channel_copy_precalc(channel_precalc *const precalc, int B[8], int S[8], int bmax[7], int smax[7]) {
int i;
for (i = 0; i < 7; i++) {
@ -656,7 +649,7 @@ static long channel_copy_precalc(channel_precalc *const precalc, int B[8], int S
specification is entirely in the public domain and free of all use restrictions,
licenses and fees. AIM USA, its member companies, or individual officers
assume no liability for the use of this document." */
static void CHNCHR(int channels, long target_value, int B[8], int S[8]) {
static void CHNCHR(int channels, int target_value, int B[8], int S[8]) {
/* Use of initial pre-calculations taken from Barcode Writer in Pure PostScript (BWIPP)
* Copyright (c) 2004-2020 Terry Burton (MIT/X-Consortium license) */
static channel_precalc initial_precalcs[6] = {
@ -674,7 +667,7 @@ static void CHNCHR(int channels, long target_value, int B[8], int S[8]) {
{ 8, 8, 8, 8, 8, 8, 8, }, },
};
int bmax[7], smax[7];
long value = 0;
int value = 0;
channel_copy_precalc(&initial_precalcs[channels - 3], B, S, bmax, smax);
@ -746,20 +739,20 @@ nb0: if (++B[0] <= bmax[0]) goto lb0;
INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int length) {
static const int max_ranges[] = { -1, -1, -1, 26, 292, 3493, 44072, 576688, 7742862 };
int S[8] = {0}, B[8] = {0};
long target_value = 0;
int target_value;
char dest[30];
char *d = dest;
int channels, i;
int error_number = 0, zeroes;
if (length > 7) {
strcpy(symbol->errtxt, "333: Input too long (7 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 333, "Input length %d too long (maximum 7)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "334: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 334,
"Invalid character at position %d in input (digits only)", i);
}
target_value = to_int(source, length);
if ((symbol->option_2 < 3) || (symbol->option_2 > 8)) {
channels = 0;
@ -767,11 +760,6 @@ INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int len
channels = symbol->option_2;
}
for (i = 0; i < length; i++) {
target_value *= 10;
target_value += ctoi((char) source[i]);
}
if (channels == 0) {
channels = length + 1;
if (target_value > 576688 && channels < 8) {
@ -792,12 +780,12 @@ INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int len
if (target_value > max_ranges[channels]) {
if (channels == 8) {
sprintf(symbol->errtxt, "318: Value out of range (0 to %d)", max_ranges[channels]);
} else {
sprintf(symbol->errtxt, "335: Value out of range (0 to %d) for %d channels",
max_ranges[channels], channels);
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 318, "Input value \"%1$d\" out of range (0 to %2$d)",
target_value, max_ranges[channels]);
}
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 335,
"Input value \"%1$d\" out of range (0 to %2$d for %3$d channels)",
target_value, max_ranges[channels], channels);
}
CHNCHR(channels, target_value, B, S);
@ -812,8 +800,7 @@ INTERNAL int channel(struct zint_symbol *symbol, unsigned char source[], int len
zeroes = channels - 1 - length;
if (zeroes < 0) {
zeroes = 0;
}
if (zeroes) {
} else if (zeroes) {
memset(symbol->text, '0', zeroes);
}
ustrcpy(symbol->text + zeroes, source);
@ -848,15 +835,13 @@ INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length)
/* Check length */
if (length != 17) {
strcpy(symbol->errtxt, "336: Input wrong length (17 characters required)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 336, "Input length %d wrong (17 only)", length);
}
/* Check input characters, I, O and Q are not allowed */
if (!is_sane(ARSENIC_F, source, length)) {
strcpy(symbol->errtxt,
"337: Invalid character in data (alphanumerics only, excluding \"I\", \"O\" and \"Q\")");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(ARSENIC_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 337,
"Invalid character at position %d in input (alphanumerics only, excluding \"IOQ\")", i);
}
to_upper(source, length);
@ -893,9 +878,8 @@ INTERNAL int vin(struct zint_symbol *symbol, unsigned char source[], int length)
}
if (input_check != output_check) {
sprintf(symbol->errtxt, "338: Invalid check digit '%c' (position 9), expecting '%c'",
input_check, output_check);
return ZINT_ERROR_INVALID_CHECK;
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 338,
"Invalid check digit '%1$c' (position 9), expecting '%2$c'", input_check, output_check);
}
}

View file

@ -30,6 +30,7 @@
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include "common.h"
@ -38,6 +39,7 @@
#include "large.h"
#define C1_MAX_CWS 1480 /* Max data codewords for Version H */
#define C1_MAX_CWS_S "1480" /* String version of above */
#define C1_MAX_ECCS 560 /* Max ECC codewords for Version H */
#define C1_ASCII 1
@ -1023,35 +1025,33 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
int row, col;
int sub_version = 0;
rs_t rs;
int error_number = 0;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
if ((symbol->option_2 < 0) || (symbol->option_2 > 10)) {
strcpy(symbol->errtxt, "513: Invalid symbol size");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 513, "Version '%d' out of range (1 to 10)",
symbol->option_2);
}
if (symbol->structapp.count) {
if (symbol->option_2 == 9) { /* Version S */
strcpy(symbol->errtxt, "714: Structured Append not available for Version S");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 714, "Structured Append not available for Version S");
}
if (gs1) {
strcpy(symbol->errtxt, "710: Cannot have Structured Append and GS1 mode at the same time");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 710,
"Cannot have Structured Append and GS1 mode at the same time");
}
if (symbol->structapp.count < 2 || symbol->structapp.count > 128) {
strcpy(symbol->errtxt, "711: Structured Append count out of range (2-128)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 711,
"Structured Append count '%d' out of range (2 to 128)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "712: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 712,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
strcpy(symbol->errtxt, "713: Structured Append ID not available for Code One");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 713, "Structured Append ID not available for Code One");
}
}
@ -1063,16 +1063,15 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
int block_width;
if (seg_count > 1) {
strcpy(symbol->errtxt, "715: Multiple segments not supported for Version S");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 715, "Multiple segments not supported for Version S");
}
if (segs[0].length > 18) {
strcpy(symbol->errtxt, "514: Input data too long for Version S");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 514, "Input length %d too long for Version S (maximum 18)",
segs[0].length);
}
if (!is_sane(NEON_F, segs[0].source, segs[0].length)) {
strcpy(symbol->errtxt, "515: Invalid input data (Version S encodes numeric input only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, segs[0].source, segs[0].length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 515,
"Invalid character at position %d in input (Version S encodes digits only)", i);
}
size = 9;
@ -1142,18 +1141,19 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
unsigned int ecc[22];
int data_length;
int data_cw, ecc_cw, block_width;
int last_mode;
int last_mode = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positive */
if (c1_total_length_segs(segs, seg_count) > 90) {
strcpy(symbol->errtxt, "519: Input data too long for Version T");
return ZINT_ERROR_TOO_LONG;
if ((i = c1_total_length_segs(segs, seg_count)) > 90) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 519, "Input length %d too long for Version T (maximum 90)",
i);
}
data_length = c1_encode_segs(symbol, segs, seg_count, gs1, target, &last_mode);
if (data_length == 0 || data_length > 38) {
strcpy(symbol->errtxt, "516: Input data too long for Version T");
return ZINT_ERROR_TOO_LONG;
assert(data_length); /* Can't exceed C1_MAX_CWS as input <= 90 */
if (data_length > 38) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 516,
"Input too long for Version T, requires %d codewords (maximum 38)", data_length);
}
size = 10;
@ -1234,8 +1234,8 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
data_length = c1_encode_segs(symbol, segs, seg_count, gs1, target, &last_mode);
if (data_length == 0) {
strcpy(symbol->errtxt, "517: Input data is too long");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 517,
"Input too long, requires too many codewords (maximum " C1_MAX_CWS_S ")");
}
for (i = 7; i >= 0; i--) {
@ -1249,8 +1249,9 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
}
if ((symbol->option_2 != 0) && (symbol->option_2 < size)) {
strcpy(symbol->errtxt, "518: Input too long for selected symbol size");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 518,
"Input too long for Version %1$c, requires %2$d codewords (maximum %3$d)",
'A' + symbol->option_2 - 1, data_length, c1_data_length[symbol->option_2 - 1]);
}
data_cw = c1_data_length[size - 1];
@ -1577,16 +1578,14 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
if (symbol->option_2 == 9) { /* Version S */
if (symbol->eci || gs1) {
sprintf(symbol->errtxt, "511: %s ignored for Version S",
return errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 511, "%s ignored for Version S",
symbol->eci && gs1 ? "ECI and GS1 mode" : symbol->eci ? "ECI" : "GS1 mode");
error_number = ZINT_WARN_INVALID_OPTION;
}
} else if (symbol->eci && gs1) {
strcpy(symbol->errtxt, "512: ECI ignored for GS1 mode");
error_number = ZINT_WARN_INVALID_OPTION;
return errtxt(ZINT_WARN_INVALID_OPTION, symbol, 512, "ECI ignored for GS1 mode");
}
return error_number;
return 0;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -38,6 +38,7 @@
#include "gs1.h"
#define C128_SYMBOL_MAX 99
#define C128_SYMBOL_MAX_S "99" /* String version of above */
static const char KRSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define KRSET_F (IS_NUM_F | IS_UPR_F)
@ -209,24 +210,23 @@ static void c128_define_mode(char set[C128_MAX], const unsigned char source[], c
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) {
if (latch >= 4 && latch <= 5) {
/* Shift A/B */
charset = latch - 3;
set[i] = charset == 1 ? 'b' : 'a';
} else {
/* Continue in same `charset` */
if (latch >= 1 && latch <= 3) {
charset = latch;
} /* Else continue in same `charset` */
assert(charset);
set[i] = '@' + charset; /* A, B or C */
}
if (charset == 3 && source[i] != '\x1D') {
assert(i + 1 < length); /* Guaranteed by algorithm */
set[++i] = 'C';
}
}
}
}
/**
* Translate Code 128 Set A characters into barcodes.
@ -413,8 +413,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
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;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 340, "Input length %d too long (maximum " C128_MAX_S ")", length);
}
/* Detect special Code Set escapes for Code 128 in extra escape mode only */
@ -447,8 +446,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
if (j != length) {
length = j;
if (length == 0) {
strcpy(symbol->errtxt, "842: No input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 842, "No input data");
}
src = src_buf;
src[length] = '\0';
@ -470,37 +468,36 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
/* Decide when to latch to extended mode - ISO/IEC 15417:2007 Annex E note 3 */
j = 0;
k = 0;
for (i = 0; i < length; i++) {
if (fset[i] == 'f') {
j++;
if (j >= 5) {
for (k = i; k > (i - 5); k--) {
fset[k] = 'F';
if (j >= 4) {
fset[i] = 'F';
if (!k) {
fset[i - 1] = fset[i - 2] = fset[i - 3] = 'F';
k = i;
}
}
} else {
j = 0;
k = 0;
}
}
if (j >= 3) {
for (k = length - 1; k > length - 1 - j; k--) {
fset[k] = 'F';
}
if (j >= 3 && !k) {
fset[length - 1] = fset[length - 2] = fset[length - 3] = 'F';
}
/* Decide if it is worth reverting to 646 encodation for a few characters as described in 4.3.4.2 (d) */
/* Decide if it is worth reverting to ASCII encodation for a few characters as described in 4.3.4.2 (d) */
for (i = 1; i < length; i++) {
if ((fset[i - 1] == 'F') && (fset[i] == ' ')) {
int c = 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++);
int c = set[i] == 'C'; /* Count code set C so can subtract when deciding below */
/* Detected a change from extended to ASCII - count how long for */
for (j = 1; i + j < length && fset[i + j] == ' '; j++) {
c += set[i + j] == 'C';
}
/* Count how many extended beyond */
for (k = i + j < length; i + j + k < length && fset[i + j + k] != ' '; k++);
if (j - c < 3 || (j - c < 5 && k > 2)) {
/* Change to shifting back rather than latching back */
/* Inverts the same figures recommended by ISO/IEC 15417:2007 Annex E note 3 */
@ -519,9 +516,9 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
/* 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;
if ((i = c128_glyph_count(source, length, set, fset)) > C128_SYMBOL_MAX) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 341,
"Input too long, requires %d symbol characters (maximum " C128_SYMBOL_MAX_S ")", i);
}
/* So now we know what start character to use - we can get on with it! */
@ -680,8 +677,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
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, "342: Input too long (%d character maximum)", C128_MAX);
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 342, "Input length %d too long (maximum " C128_MAX_S ")", length);
}
/* if part of a composite symbol make room for the separator pattern */
@ -707,9 +703,9 @@ 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 */
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;
if ((i = c128_glyph_count(reduced, reduced_length, set, NULL /*fset*/)) > C128_SYMBOL_MAX) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 344,
"Input too long, requires %d symbol characters (maximum " C128_SYMBOL_MAX_S ")", i);
}
/* So now we know what start character to use - we can get on with it! */
@ -800,8 +796,8 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
if (reduced_length > 48) { /* GS1 General Specifications 5.4.4.3 */
if (error_number == 0) { /* Don't overwrite any `gs1_verify()` warning */
strcpy(symbol->errtxt, "843: GS1-128 input too long (48 character maximum)");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 843,
"Input too long, requires %d characters (maximum 48)", reduced_length);
}
}
@ -849,8 +845,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
}
if (i == sizeof(symbol->text)) {
/* Trumps all other warnings */
strcpy(symbol->errtxt, "844: Human Readable Text truncated");
error_number = ZINT_WARN_HRT_TRUNCATED;
error_number = errtxt(ZINT_WARN_HRT_TRUNCATED, symbol, 844, "Human Readable Text truncated");
i--;
}
symbol->text[i] = '\0';
@ -865,17 +860,18 @@ INTERNAL int gs1_128(struct zint_symbol *symbol, unsigned char source[], int len
/* Add check digit if encoding an NVE18 symbol */
INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
int error_number, zeroes;
unsigned char ean128_equiv[23];
if (length > 17) {
strcpy(symbol->errtxt, "345: Input too long (17 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 345, "Input length %d too long (maximum 17)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "346: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
/* Note: for all "at position" error messages, escape sequences not accounted for */
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 346,
"Invalid character at position %d in input (digits only)", i);
}
zeroes = 17 - length;
@ -893,17 +889,17 @@ INTERNAL int nve18(struct zint_symbol *symbol, unsigned char source[], int lengt
/* EAN-14 - A version of EAN-128 */
INTERNAL int ean14(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
int error_number, zeroes;
unsigned char ean128_equiv[19];
if (length > 13) {
strcpy(symbol->errtxt, "347: Input too long (13 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 347, "Input length %d too long (maximum 13)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "348: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 348,
"Invalid character at position %d in input (digits only)", i);
}
zeroes = 13 - length;
@ -934,11 +930,9 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
if ((length != 27 && length != 28) || (length == 28 && relabel)) {
if (relabel) {
strcpy(symbol->errtxt, "830: DPD relabel input wrong length (27 characters required)");
} else {
strcpy(symbol->errtxt, "349: DPD input wrong length (27 or 28 characters required)");
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 830, "DPD relabel input length %d wrong (27 only)", length);
}
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 349, "DPD input length %d wrong (27 or 28 only)", length);
}
if (length == 27 && !relabel) {
@ -953,18 +947,18 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
ident_tag = local_source[0];
to_upper(local_source + !relabel, length - !relabel);
if (!is_sane(KRSET_F, local_source + !relabel, length - !relabel)) {
if ((i = not_sane(KRSET_F, local_source + !relabel, length - !relabel))) {
if (local_source == local_source_buf || relabel) {
strcpy(symbol->errtxt, "300: Invalid character in data (alphanumerics only)");
} else {
strcpy(symbol->errtxt, "299: Invalid character in data (alphanumerics only after first character)");
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 300,
"Invalid character at position %d in input (alphanumerics only)", i);
}
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 299,
"Invalid character at position %d in input (alphanumerics only after first)", i);
}
if ((ident_tag < 32) || (ident_tag > 127)) {
strcpy(symbol->errtxt, "343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 343,
"Invalid DPD identification tag (first character), ASCII values 32 to 127 only");
}
(void) code128(symbol, local_source, length); /* Only error returned is for large text which can't happen */
@ -1030,14 +1024,14 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
symbol->text[p] = '\0';
/* Some compliance checks */
if (!is_sane(NEON_F, local_source + length - 16, 16)) {
if (!is_sane(NEON_F, local_source + length - 3, 3)) { /* 3-digit Country Code (ISO 3166-1) */
strcpy(symbol->errtxt, "831: Destination Country Code (last 3 characters) should be numeric");
} else if (!is_sane(NEON_F, local_source + length - 6, 3)) { /* 3-digit Service Code */
strcpy(symbol->errtxt, "832: Service Code (characters 6-4 from end) should be numeric");
if (not_sane(NEON_F, local_source + length - 16, 16)) {
if (not_sane(NEON_F, local_source + length - 3, 3)) { /* 3-digit Country Code (ISO 3166-1) */
errtxt(0, symbol, 831, "Destination Country Code (last 3 characters) should be numeric");
} else if (not_sane(NEON_F, local_source + length - 6, 3)) { /* 3-digit Service Code */
errtxt(0, symbol, 832, "Service Code (characters 6-4 from end) should be numeric");
} else { /* Last 10 characters of Tracking No. */
strcpy(symbol->errtxt,
"833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric");
errtxt(0, symbol, 833,
"Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric");
}
error_number = ZINT_WARN_NONCOMPLIANT;
}
@ -1056,8 +1050,7 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
int error_number = 0;
if (length != 12 && length != 13) {
strcpy(symbol->errtxt, "834: Input must be 12 or 13 characters long");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 834, "Input length %d wrong (12 or 13 only)", length);
}
if (length == 13) { /* Includes check digit - remove for now */
have_check_digit = source[10];
@ -1069,17 +1062,17 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
to_upper(local_source, length);
if (!z_isupper(local_source[0]) || !z_isupper(local_source[1])) {
strcpy(symbol->errtxt, "835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 835,
"Invalid character in Service Indictor (first 2 characters) (alphabetic only)");
}
if (!is_sane(NEON_F, local_source + 2, 12 - 4) || (have_check_digit && !z_isdigit(have_check_digit))) {
sprintf(symbol->errtxt, "836: Invalid character in Serial Number (middle %d characters) (digits only)",
if (not_sane(NEON_F, local_source + 2, 12 - 4) || (have_check_digit && !z_isdigit(have_check_digit))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 836,
"Invalid character in Serial Number (middle %d characters) (digits only)",
have_check_digit ? 9 : 8);
return ZINT_ERROR_INVALID_DATA;
}
if (!z_isupper(local_source[10]) || !z_isupper(local_source[11])) {
strcpy(symbol->errtxt, "837: Invalid character in Country Code (last 2 characters) (alphabetic only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 837,
"Invalid character in Country Code (last 2 characters) (alphabetic only)");
}
check_digit = 0;
@ -1094,8 +1087,8 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
check_digit = 5;
}
if (have_check_digit && ctoi(have_check_digit) != check_digit) {
sprintf(symbol->errtxt, "838: Invalid check digit '%c', expecting '%c'", have_check_digit, itoc(check_digit));
return ZINT_ERROR_INVALID_CHECK;
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 838, "Invalid check digit '%1$c', expecting '%2$c'",
have_check_digit, itoc(check_digit));
}
/* Add in (back) check digit */
local_source[12] = local_source[11];
@ -1105,14 +1098,14 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
/* Do some checks on the Service Indicator (first char only) and Country Code */
if (strchr("JKSTW", local_source[0]) != NULL) { /* These are reserved & cannot be assigned */
strcpy(symbol->errtxt, "839: Invalid Service Indicator (first character should not be any of \"JKSTW\")");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 839,
"Invalid Service Indicator (first character should not be any of \"JKSTW\")");
} else if (strchr("FHIOXY", local_source[0]) != NULL) { /* These aren't allocated as of spec Oct 2017 */
strcpy(symbol->errtxt, "840: Non-standard Service Indicator (first 2 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 840,
"Non-standard Service Indicator (first 2 characters)");
} else if (!gs1_iso3166_alpha2(local_source + 11)) {
strcpy(symbol->errtxt, "841: Country code (last two characters) is not ISO 3166-1");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 841,
"Country code (last two characters) is not ISO 3166-1");
}
(void) code128(symbol, local_source, 13); /* Only error returned is for large text which can't happen */

View file

@ -38,6 +38,7 @@ extern "C" {
/* Allow for a reasonable number of special Code Set escapes and for GS1 AI delimiters */
#define C128_MAX 256
#define C128_MAX_S "256" /* String version of above */
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length);

View file

@ -288,13 +288,12 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
if (length > C128_MAX) {
strcpy(symbol->errtxt, "420: Input too long");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 420, "Input length %d too long (maximum " C128_MAX_S ")", length);
}
if (symbol->option_1 == 1 || symbol->option_1 > 16) {
strcpy(symbol->errtxt, "424: Minimum number of rows out of range (2 to 16)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 424, "Minimum number of rows '%d' out of range (2 to 16)",
symbol->option_1);
}
/* Detect extended ASCII characters */
@ -346,8 +345,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
if (symbol->output_options & READER_INIT) {
if (gs1) {
strcpy(symbol->errtxt, "422: Cannot use both GS1 mode and Reader Initialisation");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 422,
"Cannot use both GS1 mode and Reader Initialisation");
}
if (m == 2) {
m = 5;
@ -440,8 +439,8 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
}
if (bar_characters > 80 - 2) { /* Max rows 16 * 5 - 2 check chars */
strcpy(symbol->errtxt, "421: Input too long");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 421,
"Input too long, requires %d symbol characters (maximum 78)", bar_characters);
}
} while (read < length);

View file

@ -53,8 +53,7 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
int error_number = 0;
if (length > 81) {
strcpy(symbol->errtxt, "430: Input too long (81 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 430, "Input length %d too long (maximum 81)", length);
}
if ((symbol->input_mode & 0x07) == GS1_MODE) {
gs1 = 1;
@ -65,8 +64,8 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
for (i = 0; i < length; i++) {
if (source[i] > 127) {
strcpy(symbol->errtxt, "431: Invalid character in input data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 431,
"Invalid character at position %d in input, extended ASCII not allowed", i + 1);
}
if (gs1 && source[i] == '\x1D') {
*d++ = '*'; /* FNC1 */
@ -219,8 +218,8 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
}
if (codeword_count > 49) {
strcpy(symbol->errtxt, "432: Input too long (49 symbol character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 432, "Input too long, requires %d codewords (maximum 49)",
codeword_count);
}
/* Place codewords in code character array (c grid) */

View file

@ -31,6 +31,7 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include "common.h"
@ -87,7 +88,7 @@ INTERNAL int chr_cnt(const unsigned char source[], const int length, const unsig
return count;
}
/* Flag table for `is_chr()` and `is_sane()` */
/* Flag table for `is_chr()` and `not_sane()` */
#define IS_CLS_F (IS_CLI_F | IS_SIL_F)
static const unsigned short flgs[256] = {
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, /*00-1F*/
@ -126,21 +127,22 @@ INTERNAL int is_chr(const unsigned int flg, const unsigned int c) {
return c < 0x80 && (flgs[c] & flg) != 0;
}
/* Verifies that a string only uses valid characters */
INTERNAL int is_sane(const unsigned int flg, const unsigned char source[], const int length) {
/* Verifies if a string only uses valid characters, returning 1-based position in `source` if not, 0 for success */
INTERNAL int not_sane(const unsigned int flg, const unsigned char source[], const int length) {
int i;
for (i = 0; i < length; i++) {
if (!(flgs[source[i]] & flg)) {
return i + 1;
}
}
return 0;
}
}
return 1;
}
/* Replaces huge switch statements for looking up in tables */
/* Verifies that a string only uses valid characters, and returns `test_string` position of each in `posns` array */
INTERNAL int is_sane_lookup(const char test_string[], const int test_length, const unsigned char source[],
/* Verifies if a string only uses valid characters as above, but also returns `test_string` position of each in
`posns` array */
INTERNAL int not_sane_lookup(const char test_string[], const int test_length, const unsigned char source[],
const int length, int *posns) {
int i, j;
@ -153,11 +155,11 @@ INTERNAL int is_sane_lookup(const char test_string[], const int test_length, con
}
}
if (posns[i] == -1) {
return 0;
return i + 1;
}
}
return 1;
return 0;
}
/* Returns the position of `data` in `set_string` */
@ -244,6 +246,294 @@ INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int le
}
}
/* Helper for `errtxt()` & `errtxtf()` to set "err_id: " part of error message, returning length */
static int errtxt_id_str(char *errtxt, int num) {
int len = 0;
if (num == -1) {
errtxt[0] = '\0';
return 0;
}
if (num < 0 || num > 9999) { /* Restrict to 4 digits */
num = 9999;
}
if (num >= 1000) {
errtxt[len++] = '0' + (num / 1000);
num %= 1000;
}
errtxt[len++] = '0' + (num / 100);
num %= 100;
errtxt[len++] = '0' + (num / 10);
num %= 10;
errtxt[len++] = '0' + num;
errtxt[len++] = ':';
errtxt[len++] = ' ';
return len;
}
/* Set `symbol->errtxt` to "err_id: msg", returning `error_number`. If `err_id` is -1, the "err_id: " prefix is
omitted */
INTERNAL int errtxt(const int error_number, struct zint_symbol *symbol, const int err_id, const char *msg) {
const int max_len = (int) sizeof(symbol->errtxt) - 1;
const int id_len = errtxt_id_str(symbol->errtxt, err_id);
int msg_len = (int) strlen(msg);
if (id_len + msg_len > max_len) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); /* Catch truncations */
msg_len = max_len - id_len;
}
memcpy(symbol->errtxt + id_len, msg, msg_len);
symbol->errtxt[id_len + msg_len] = '\0';
return error_number;
}
static int errtxtf_dpad(const char *fmt); /* Forward reference */
/* Helper for `errtxtf()` to parse numbered specifier "n$" (where "n" 1-9), returning `fmt` advance increment */
static int errtxtf_num_arg(const char *fmt, int *p_arg) {
int ret = 0;
int arg = -2;
if (!errtxtf_dpad(fmt) && z_isdigit(fmt[0])) {
arg = fmt[1] == '$' ? fmt[0] - '0' - 1 : -1;
ret = 2;
}
if (p_arg) {
*p_arg = arg;
}
return ret;
}
/* Helper for `errtxtf()` to parse length precision, returning `fmt` advance increment */
static int errtxtf_slen(const char *fmt, const int arg, int *p_arg_cnt, int *p_len) {
int ret = 0;
int len = -1;
if (fmt[0] == '.') {
if (z_isdigit(fmt[1]) && fmt[1] != '0') {
len = fmt[1] - '0';
for (ret = 2; z_isdigit(fmt[ret]); ret++) {
len = len * 10 + fmt[ret] - '0';
}
if (fmt[ret] != 's') {
len = -1;
}
} else if (fmt[1] == '*' && fmt[2] == 's' && arg < 0) {
len = 0;
ret = 2;
} else if (fmt[1] == '*' && z_isdigit(fmt[2]) && fmt[3] == '$' && fmt[4] == 's') {
if (arg == -1 || arg == fmt[2] - '0') {
len = 0;
if (p_arg_cnt) {
(*p_arg_cnt)++;
}
}
ret = 4;
} else {
ret = 1;
}
}
if (p_len) {
*p_len = len;
}
return ret;
}
/* Helper for `errtxtf()` to parse zero-padded minimum field length for "%d", returning `fmt` advance increment */
static int errtxtf_dpad(const char *fmt) {
/* Allow one leading zero plus one or two digits only */
if (fmt[0] == '0' && z_isdigit(fmt[1])) {
if (fmt[1] != '0' && fmt[2] == 'd') {
return 2;
}
if (z_isdigit(fmt[1]) && fmt[1] != '0' && z_isdigit(fmt[2]) && fmt[3] == 'd') {
return 3;
}
}
return 0;
}
/* Set `symbol->errtxt` to "err_id: msg" with restricted subset of `printf()` formatting, returning `error_number`.
If `err_id` is -1, the "err_id: " prefix is omitted. Only the following specifiers are supported: "c", "d", "f",
"g" and "s", with no modifiers apart from "<n>$" numbering for l10n ("<n>" 1-9), in which case all specifiers must
be numbered, "%s" with length precisions: "%.*s", "%<n+1>$.*<n>$s", "%.<p>s" and "%<n>$.<p>s", and "%d" with
zero-padded minimum field lengths: "%0<m>d" or %<n>$0<m>d" ("<m>" 1-99) */
INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const int err_id, const char *fmt, ...) {
const int max_len = (int) sizeof(symbol->errtxt) - 1;
int p = errtxt_id_str(symbol->errtxt, err_id);
const char *f;
int i;
int arg_cnt = 0;
int have_num_arg = 0, have_unnum_arg = 0;
va_list ap;
int idxs[9] = {0}; /* Argument order */
char specs[9] = {0}; /* Format specifiers */
const char *ss[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; /* "%s" */
int slens[9] = {0}; /* "%s" length precisions */
int have_slens[9] = {0}; /* Bools for if "%s" has length precision */
char dpads[9][3] = {{0}}; /* 2-digit minimum field length */
char dfgs[9][100] = {{0}}; /* "%d", "%f" and "%g", allowing for padding up to 99 */
int cs[9] = {0}; /* "%c" */
/* Get argument order and specifiers */
for (f = fmt, i = 0; *f; f++) {
if (*f == '%') {
int inc, arg, len;
if (*++f == '%') {
continue;
}
if ((inc = errtxtf_num_arg(f, &arg))) {
if (arg == -1) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0);
return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0,
"Internal error: invalid numbered format specifer");
}
if (i >= 9) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0);
return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0,
"Internal error: too many format specifiers (9 maximum)");
}
f += inc;
have_num_arg = 1;
idxs[i] = arg;
} else {
if (i >= 9) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0);
return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0,
"Internal error: too many format specifiers (9 maximum)");
}
have_unnum_arg = 1;
idxs[i] = i;
}
if ((inc = errtxtf_slen(f, arg, &arg_cnt, &len))) {
if (len == -1) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0);
return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, "Internal error: invalid length precision");
}
slens[idxs[i]] = len == 0 ? -1 : len; /* TODO: keep `slens` separate else last mentioned trumps */
have_slens[idxs[i]] = 1;
f += inc;
}
if ((inc = errtxtf_dpad(f))) {
memcpy(dpads[idxs[i]], f + 1, inc - 1); /* TODO: keep `dpads` separate else last mentioned trumps */
dpads[idxs[i]][inc - 1] = '\0';
f += inc;
}
if (*f != 'c' && *f != 'd' && *f != 'f' && *f != 'g' && *f != 's') {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0);
return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0,
"Internal error: unknown format specifier ('%c','%d','%f','%g','%s' only)");
}
specs[idxs[i++]] = *f;
arg_cnt++;
}
}
if (have_num_arg && have_unnum_arg) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0);
return errtxt(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0,
"Internal error: mixed numbered and unnumbered format specifiers");
}
/* Get arguments */
va_start(ap, fmt);
for (i = 0; i < arg_cnt; i++) {
if (specs[i] == 'c') {
cs[i] = va_arg(ap, int);
} else if (specs[i] == 'd') {
if (dpads[i][0]) {
char dpad_fmt[30]; /* Make 30 to suppress GNU c "-Wformat-overflow=" false positive */
sprintf(dpad_fmt, "%%0%sd", dpads[i]); /* TODO: keep `dpads` separate else last mentioned trumps */
sprintf(dfgs[i], dpad_fmt, va_arg(ap, int));
} else {
sprintf(dfgs[i], "%d", va_arg(ap, int));
}
} else if (specs[i] == 'f' || specs[i] == 'g') {
sprintf(dfgs[i], specs[i] == 'f' ? "%f" : "%g", va_arg(ap, double));
} else if (specs[i] == 's') {
if (have_slens[i] && slens[i] == -1) {
slens[i] = va_arg(ap, int); /* TODO: keep `slens` separate else last mentioned trumps */
}
ss[i] = va_arg(ap, char *);
}
}
va_end(ap);
/* Populate `errtxt` */
for (f = fmt, i = 0; *f && p < max_len; f++) {
if (*f == '%') {
int idx;
if (*++f == '%') {
symbol->errtxt[p++] = '%';
continue;
}
f += errtxtf_num_arg(f, NULL /*p_arg*/);
f += errtxtf_slen(f, -1 /*arg*/, NULL /*arg_cnt*/, NULL /*p_len*/);
f += errtxtf_dpad(f);
idx = idxs[i];
if (specs[idx] == 'c') {
symbol->errtxt[p++] = cs[idx];
} else {
int len;
if (specs[idx] == 's') {
if (have_slens[idx]) {
const char *si = ss[idx];
for (len = 0; len < slens[idx] && si[len]; len++);
} else {
len = (int) strlen(ss[idx]);
}
} else {
len = (int) strlen(dfgs[idx]);
}
if (len) {
if (p + len > max_len) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); /* Catch truncations */
len = max_len - p;
}
memcpy(symbol->errtxt + p, specs[idx] == 's' ? ss[idx] : dfgs[idx], len);
p += len;
}
}
i++;
} else {
symbol->errtxt[p++] = *f;
}
}
if (*f) {
if (!(symbol->debug & ZINT_DEBUG_TEST)) assert(0); /* Catch truncations */
}
symbol->errtxt[p] = '\0';
return error_number;
}
/* Helper to prepend/append to existing `symbol->errtxt` by calling `errtxtf(fmt)` with 2 arguments (copy of `errtxt`
& `msg`) if `msg` not NULL, or 1 argument (just copy of `errtxt`) if `msg` NULL, returning `error_number` */
INTERNAL int errtxt_adj(const int error_number, struct zint_symbol *symbol, const char *fmt, const char *msg) {
char err_buf[sizeof(symbol->errtxt)];
err_buf[0] = '\0';
/* Suppress gcc 14 warning output may be truncated */
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 14
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
#endif
strncat(err_buf, symbol->errtxt, sizeof(symbol->errtxt) - 1);
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 14
#pragma GCC diagnostic pop
#endif
if (msg) {
errtxtf(0, symbol, -1, fmt, err_buf, msg);
} else {
errtxtf(0, symbol, -1, fmt, err_buf);
}
return error_number;
}
/* Whether `symbology` can have row binding */
INTERNAL int is_stackable(const int symbology) {
if (symbology < BARCODE_PHARMA_TWO && symbology != BARCODE_POSTNET) {
@ -489,7 +779,7 @@ INTERNAL int hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char s
symbol->text[j] = '\0';
if (warn_number) {
strcpy(symbol->errtxt, "249: Human Readable Text truncated");
errtxt(0, symbol, 249, "Human Readable Text truncated");
}
return warn_number;
}
@ -532,7 +822,7 @@ INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height,
if (stripf(row_height) < stripf(min_row_height)) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "247: Height not compliant with standards");
errtxt(0, symbol, 247, "Height not compliant with standards");
}
}
}
@ -544,7 +834,7 @@ INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height,
if (stripf(symbol->height) > stripf(max_height)) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "248: Height not compliant with standards");
errtxt(0, symbol, 248, "Height not compliant with standards");
}
}
}
@ -554,12 +844,15 @@ INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height,
/* Prevent inlining of `stripf()` which can optimize away its effect */
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
__attribute__((__noinline__))
#define ZINT_NOINLINE __attribute__((__noinline__))
#elif defined(_MSC_VER) && _MSC_VER >= 1310 /* MSVC 2003 (VC++ 7.1) */
__declspec(noinline)
#define ZINT_NOINLINE __declspec(noinline)
#else
#define ZINT_NOINLINE
#endif
/* Removes excess precision from floats - see https://stackoverflow.com/q/503436 */
INTERNAL float stripf(const float arg) {
INTERNAL ZINT_NOINLINE float stripf(const float arg) {
return *((volatile const float *) &arg);
}
@ -615,6 +908,7 @@ INTERNAL char *debug_print_escape(const unsigned char *source, const int first_l
/* Dumps hex-formatted codewords in symbol->errtxt (for use in testing) */
INTERNAL void debug_test_codeword_dump(struct zint_symbol *symbol, const unsigned char *codewords, const int length) {
int i, max = length, cnt_len = 0;
assert(sizeof(symbol->errtxt) >= 100);
if (length > 30) { /* 30*3 < errtxt 92 (100 - "Warning ") chars */
sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
cnt_len = (int) strlen(symbol->errtxt);
@ -630,6 +924,7 @@ INTERNAL void debug_test_codeword_dump(struct zint_symbol *symbol, const unsigne
INTERNAL void debug_test_codeword_dump_short(struct zint_symbol *symbol, const short *codewords, const int length) {
int i, max = 0, cnt_len, errtxt_len;
char temp[20];
assert(sizeof(symbol->errtxt) >= 100);
errtxt_len = sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
for (i = 0, cnt_len = errtxt_len; i < length; i++) {
cnt_len += sprintf(temp, "%d ", codewords[i]);
@ -648,6 +943,7 @@ INTERNAL void debug_test_codeword_dump_short(struct zint_symbol *symbol, const s
INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int *codewords, const int length) {
int i, max = 0, cnt_len, errtxt_len;
char temp[20];
assert(sizeof(symbol->errtxt) >= 100);
errtxt_len = sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
for (i = 0, cnt_len = errtxt_len; i < length; i++) {
cnt_len += sprintf(temp, "%d ", codewords[i]);

View file

@ -42,6 +42,13 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
/* Determine if C89 (excluding MSVC, which doesn't define __STDC_VERSION__) */
#ifndef _MSC_VER
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L
# define ZINT_IS_C89
# endif
#endif
#ifdef _MSC_VER
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
@ -49,7 +56,7 @@ typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#include <stdint.h> /* Introduced C99 */
#endif
/* Note if change following must also change "frontend/main.c" copy */
@ -79,6 +86,12 @@ typedef unsigned __int64 uint64_t;
# endif
#endif
#if defined(__GNUC__) && __GNUC__ >= 3
# define ZINT_FORMAT_PRINTF(fmt_idx, first_idx) __attribute__((__format__(printf, fmt_idx, first_idx)))
#else
# define ZINT_FORMAT_PRINTF(fmt_idx, first_idx)
#endif
#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(ZINT_TEST) && !defined(__MINGW32__)
# define INTERNAL __attribute__((__visibility__("hidden")))
#elif defined(ZINT_TEST)
@ -95,13 +108,6 @@ typedef unsigned __int64 uint64_t;
# define INTERNAL_DATA
#endif
/* Determine if C89 (excluding MSVC, which doesn't define __STDC_VERSION__) */
#ifndef _MSC_VER
# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199000L
# define ZINT_IS_C89
# endif
#endif
#ifdef _MSC_VER
# if _MSC_VER >= 1400 /* MSVC 2005 (C++ 8.0) */
# define restrict __restrict
@ -154,7 +160,7 @@ INTERNAL void to_upper(unsigned char source[], const int length);
/* Returns the number of times a character occurs in `source` */
INTERNAL int chr_cnt(const unsigned char source[], const int length, const unsigned char c);
/* `is_chr()` & `is_sane()` flags */
/* `is_chr()` & `not_sane()` flags */
#define IS_SPC_F 0x0001 /* Space */
#define IS_HSH_F 0x0002 /* Hash sign # */
#define IS_AST_F 0x0004 /* Asterisk sign * */
@ -181,11 +187,12 @@ INTERNAL int chr_cnt(const unsigned char source[], const int length, const unsig
/* Whether a character matches `flg` */
INTERNAL int is_chr(const unsigned int flg, const unsigned int c);
/* Verifies that a string only uses valid characters */
INTERNAL int is_sane(const unsigned int flg, const unsigned char source[], const int length);
/* Verifies if a string only uses valid characters, returning 1-based position in `source` if not, 0 for success */
INTERNAL int not_sane(const unsigned int flg, const unsigned char source[], const int length);
/* Verifies that a string only uses valid characters, and returns `test_string` position of each in `posns` array */
INTERNAL int is_sane_lookup(const char test_string[], const int test_length, const unsigned char source[],
/* Verifies if a string only uses valid characters as above, but also returns `test_string` position of each in
`posns` array */
INTERNAL int not_sane_lookup(const char test_string[], const int test_length, const unsigned char source[],
const int length, int *posns);
/* Returns the position of `data` in `set_string` */
@ -232,6 +239,23 @@ INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const
INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int length);
/* Set `symbol->errtxt` to "err_id: msg", returning `error_number`. If `err_id` is -1, the "err_id: " prefix is
omitted */
INTERNAL int errtxt(const int error_number, struct zint_symbol *symbol, const int err_id, const char *msg);
/* Set `symbol->errtxt` to "err_id: msg" with restricted subset of `printf()` formatting, returning `error_number`.
If `err_id` is -1, the "err_id: " prefix is omitted. Only the following specifiers are supported: "c", "d", "f",
"g" and "s", with no modifiers apart from "<n>$" numbering for l10n ("<n>" 1-9), in which case all specifiers must
be numbered, "%s" with length precisions: "%.*s", "%<n+1>$.*<n>$s", "%.<p>s" and "%<n>$.<p>s", and "%d" with
zero-padded minimum field lengths: "%0<m>d" or %<n>$0<m>d" ("<m>" 1-99) */
INTERNAL int errtxtf(const int error_number, struct zint_symbol *symbol, const int err_id, const char *fmt, ...)
ZINT_FORMAT_PRINTF(4, 5);
/* Helper to prepend/append to existing `symbol->errtxt` by calling `errtxtf(fmt)` with 2 arguments (copy of `errtxt`
& `msg`) if `msg` not NULL, or 1 argument (just copy of `errtxt`) if `msg` NULL, returning `error_number` */
INTERNAL int errtxt_adj(const int error_number, struct zint_symbol *symbol, const char *fmt, const char *msg);
/* Whether `symbology` can have row binding */
INTERNAL int is_stackable(const int symbology);

View file

@ -1128,8 +1128,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
if (!general_field_encode(general_field, j, &mode, &last_digit, binary_string, &bp)) {
/* Invalid character in input data */
strcpy(symbol->errtxt, "441: Invalid character in 2D component input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 441, "Invalid character in input (2D component)");
}
}
@ -1146,8 +1145,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
}
if (target_bitsize == 0) {
strcpy(symbol->errtxt, "442: Input too long for selected 2D component");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 442, "Input too long (2D component)");
}
remainder = target_bitsize - bp;
@ -1183,8 +1181,7 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
}
if (target_bitsize == 0) {
strcpy(symbol->errtxt, "444: Input too long for selected 2D component");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 444, "Input too long (2D component)");
}
if (bp < target_bitsize) {
@ -1236,7 +1233,6 @@ static int cc_linear_dummy_run(int input_mode, unsigned char *source, const int
}
INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int length) {
static const char in_linear_comp[] = " in linear component";
int error_number, cc_mode, cc_width = 0, ecc_level = 0;
int j, i, k;
/* Allow for 8 bits + 5-bit latch per char + 1000 bits overhead/padding */
@ -1254,20 +1250,20 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
error_number = 0;
pri_len = (int) strlen(symbol->primary);
if (pri_len == 0) {
strcpy(symbol->errtxt, "445: No primary (linear) message");
return ZINT_ERROR_INVALID_OPTION; /* TODO: change to more appropiate ZINT_ERROR_INVALID_DATA */
/* TODO: change to more appropiate ZINT_ERROR_INVALID_DATA */
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 445, "No primary (linear) message");
}
if (length > 2990) {
strcpy(symbol->errtxt, "446: 2D component input data too long");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 446,
"2D component input too long, requires %d characters (maximum 2990)", length);
}
cc_mode = symbol->option_1;
if ((cc_mode == 3) && (symbol->symbology != BARCODE_GS1_128_CC)) {
/* CC-C can only be used with a GS1-128 linear part */
strcpy(symbol->errtxt, "447: Invalid mode (CC-C only valid with GS1-128 linear component)");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 447,
"Invalid mode (CC-C only valid with GS1-128 linear component)");
}
if (symbol->symbology == BARCODE_GS1_128_CC) {
@ -1275,10 +1271,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
linear_width = cc_linear_dummy_run(symbol->input_mode, (unsigned char *) symbol->primary, pri_len,
symbol->debug, symbol->errtxt);
if (linear_width == 0) {
if (strlen(symbol->errtxt) + sizeof(in_linear_comp) <= sizeof(symbol->errtxt)) {
strcat(symbol->errtxt, in_linear_comp);
}
return ZINT_ERROR_INVALID_DATA;
return errtxt_adj(ZINT_ERROR_INVALID_DATA, symbol, "%1$s%2$s", " (linear component)");
}
if (debug_print) {
printf("GS1-128 linear width: %d\n", linear_width);
@ -1294,9 +1287,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
unsigned char padded_pri[21];
if (!ean_leading_zeroes(symbol, (unsigned char *) symbol->primary, padded_pri, &with_addon, NULL,
NULL)) {
sprintf(symbol->errtxt, "448: Input too long (%s) in linear component",
with_addon ? "5 character maximum for add-on" : "13 character maximum");
return ZINT_ERROR_TOO_LONG;
return errtxt_adj(ZINT_ERROR_TOO_LONG, symbol, "%1$s%2$s", " (linear component)");
}
padded_pri_len = (int) ustrlen(padded_pri);
if (padded_pri_len <= 7) { /* EAN-8 */
@ -1320,8 +1311,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
}
}
if (cc_width == 0) {
strcpy(symbol->errtxt, "449: Input wrong length in linear component");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 449, "Input length %d wrong (linear component)", pri_len);
}
break;
case BARCODE_GS1_128_CC: cc_width = 4;
@ -1443,10 +1433,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
}
if (error_number) {
strcpy(symbol->errtxt, linear->errtxt);
if (strlen(symbol->errtxt) + sizeof(in_linear_comp) <= sizeof(symbol->errtxt)) {
strcat(symbol->errtxt, in_linear_comp);
}
errtxtf(0, symbol, -1, "%1$s%2$s", linear->errtxt, " (linear component)");
if (error_number >= ZINT_ERROR) {
ZBarcode_Delete(linear);
return error_number;

View file

@ -1059,8 +1059,7 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
assert(length <= 10921); /* Can only handle (10921 + 1) * 6 = 65532 < 65536 (2*16) due to sizeof(previous) */
if (!dm_define_mode(symbol, modes, source, length, gs1, debug_print)) {
strcpy(symbol->errtxt, "728: Insufficient memory for mode buffers");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 728, "Insufficient memory for mode buffers");
}
while (sp < length) {
@ -1217,8 +1216,8 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
}
if (tp > 1558) {
strcpy(symbol->errtxt, "729: Data too long to fit in symbol");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 729,
"Input too long, requires too many codewords (maximum 1558)");
}
} /* while */
@ -1471,8 +1470,8 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
}
if (tp > 1558) {
strcpy(symbol->errtxt, "520: Data too long to fit in symbol");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 520,
"Input too long, requires too many codewords (maximum 1558)");
}
} /* while */
@ -1682,21 +1681,21 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
const struct zint_seg *last_seg = &segs[seg_count - 1];
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
if (segs_length(segs, seg_count) > 3116) { /* Max is 3166 digits */
strcpy(symbol->errtxt, "719: Data too long to fit in symbol");
return ZINT_ERROR_TOO_LONG;
if ((i = segs_length(segs, seg_count)) > 3116) { /* Max is 3166 digits */
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 719, "Input length %d too long (maximum 3116)", i);
}
if (symbol->structapp.count) {
int id1, id2;
if (symbol->structapp.count < 2 || symbol->structapp.count > 16) {
strcpy(symbol->errtxt, "720: Structured Append count out of range (2-16)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 720,
"Structured Append count '%d' out of range (2 to 16)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "721: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 721,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
int id, id_len, id1_err, id2_err;
@ -1704,14 +1703,13 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
for (id_len = 1; id_len < 7 && symbol->structapp.id[id_len]; id_len++);
if (id_len > 6) { /* ID1 * 1000 + ID2 */
strcpy(symbol->errtxt, "722: Structured Append ID too long (6 digit maximum)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 722,
"Structured Append ID length %d too long (6 digit maximum)", id_len);
}
id = to_int((const unsigned char *) symbol->structapp.id, id_len);
if (id == -1) {
strcpy(symbol->errtxt, "723: Invalid Structured Append ID (digits only)");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 723, "Invalid Structured Append ID (digits only)");
}
id1 = id / 1000;
id2 = id % 1000;
@ -1719,19 +1717,19 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
id2_err = id2 < 1 || id2 > 254;
if (id1_err || id2_err) {
if (id1_err && id2_err) {
sprintf(symbol->errtxt,
"724: Structured Append ID1 '%03d' and ID2 '%03d' out of range (001-254) (ID '%03d%03d')",
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 724,
"Structured Append ID1 '%1$03d' and ID2 '%2$03d' out of range (001 to 254)"
" (ID \"%3$03d%4$03d\")",
id1, id2, id1, id2);
} else if (id1_err) {
sprintf(symbol->errtxt,
"725: Structured Append ID1 '%03d' out of range (001-254) (ID '%03d%03d')",
id1, id1, id2);
} else {
sprintf(symbol->errtxt,
"726: Structured Append ID2 '%03d' out of range (001-254) (ID '%03d%03d')",
id2, id1, id2);
}
return ZINT_ERROR_INVALID_OPTION;
if (id1_err) {
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 725,
"Structured Append ID1 '%1$03d' out of range (001 to 254) (ID \"%2$03d%3$03d\")",
id1, id1, id2);
}
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 726,
"Structured Append ID2 '%1$03d' out of range (001 to 254) (ID \"%2$03d%3$03d\")",
id2, id1, id2);
}
} else {
id1 = id2 = 1;
@ -1761,12 +1759,12 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
if (symbol->output_options & READER_INIT) {
if (gs1) {
strcpy(symbol->errtxt, "521: Cannot encode in GS1 mode and Reader Initialisation at the same time");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 521,
"Cannot encode in GS1 mode and Reader Initialisation at the same time");
}
if (symbol->structapp.count) {
strcpy(symbol->errtxt, "727: Cannot have Structured Append and Reader Initialisation at the same time");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 727,
"Cannot have Structured Append and Reader Initialisation at the same time");
}
target[tp++] = 234; /* Reader Programming */
if (debug_print) fputs("RP ", stdout);
@ -1837,7 +1835,7 @@ static void dm_add_tail(unsigned char target[], int tp, const int tail_length) {
static int dm_ecc200(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) {
int i, skew = 0;
unsigned char binary[2200];
int binlen;
int binlen = 0; /* Suppress clang-tidy-20 uninitialized value false positive */
int symbolsize;
int taillength, error_number;
int H, W, FH, FW, datablock, bytes, rsblock;
@ -1854,11 +1852,12 @@ static int dm_ecc200(struct zint_symbol *symbol, struct zint_seg segs[], const i
if (binlen > dm_matrixbytes[symbolsize]) {
if ((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) {
/* The symbol size was given by --ver (option_2) */
strcpy(symbol->errtxt, "522: Input too long for selected symbol size");
} else {
strcpy(symbol->errtxt, "523: Data too long to fit in symbol");
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 522,
"Input too long for Version %1$d, requires %2$d codewords (maximum %3$d)",
symbol->option_2, binlen, dm_matrixbytes[symbolsize]);
}
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 523, "Input too long, requires %d codewords (maximum 1558)",
binlen);
}
H = dm_matrixH[symbolsize];
@ -1901,8 +1900,7 @@ static int dm_ecc200(struct zint_symbol *symbol, struct zint_seg segs[], const i
const int NR = H - 2 * (H / FH);
int x, y, *places;
if (!(places = (int *) calloc(NC * NR, sizeof(int)))) {
strcpy(symbol->errtxt, "718: Insufficient memory for placement array");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 718, "Insufficient memory for placement array");
}
dm_placement(places, NR, NC);
for (y = 0; y < H; y += FH) {
@ -1950,18 +1948,13 @@ static int dm_ecc200(struct zint_symbol *symbol, struct zint_seg segs[], const i
}
INTERNAL int datamatrix(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) {
int error_number;
if (symbol->option_1 <= 1) {
/* ECC 200 */
error_number = dm_ecc200(symbol, segs, seg_count);
} else {
/* ECC 000 - 140 */
strcpy(symbol->errtxt, "524: Older Data Matrix standards are no longer supported");
error_number = ZINT_ERROR_INVALID_OPTION;
return dm_ecc200(symbol, segs, seg_count);
}
return error_number;
/* ECC 000 - 140 */
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 524, "Older Data Matrix standards are no longer supported");
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1229,8 +1229,8 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
unsigned char *masked_codeword_array;
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "525: Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 525, "ECI code '%d' out of range (0 to 811799)",
symbol->eci);
}
user_mask = (symbol->option_3 >> 8) & 0x0F; /* User mask is mask + 1, so >= 1 and <= 8 */
@ -1240,16 +1240,16 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if (symbol->structapp.count) {
if (symbol->structapp.count < 2 || symbol->structapp.count > 35) {
strcpy(symbol->errtxt, "730: Structured Append count out of range (2-35)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 730,
"Structured Append count '%d' out of range (2 to 35)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "731: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 731,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
strcpy(symbol->errtxt, "732: Structured Append ID not available for DotCode");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 732, "Structured Append ID not available for DotCode");
}
}
@ -1258,14 +1258,14 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if (gs1 && warn_number == 0) {
for (i = 0; i < seg_count; i++) {
if (segs[i].eci) {
strcpy(symbol->errtxt, "733: Using ECI in GS1 mode not supported by GS1 standards");
warn_number = ZINT_WARN_NONCOMPLIANT;
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 733,
"Using ECI in GS1 mode not supported by GS1 standards");
break;
}
}
if (warn_number == 0 && symbol->structapp.count) {
strcpy(symbol->errtxt, "734: Using Structured Append in GS1 mode not supported by GS1 standards");
warn_number = ZINT_WARN_NONCOMPLIANT;
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 734,
"Using Structured Append in GS1 mode not supported by GS1 standards");
}
}
@ -1337,9 +1337,9 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if ((height > 200) || (width > 200)) {
if (height > 200 && width > 200) {
sprintf(symbol->errtxt, "526: Symbol size %dx%d (WxH) is too large", width, height);
errtxtf(0, symbol, 526, "Symbol size '%1$dx%2$d' (WxH) is too large", width, height);
} else {
sprintf(symbol->errtxt, "528: Symbol %s %d is too large",
errtxtf(0, symbol, 528, "Symbol %1$s '%2$d' is too large",
width > 200 ? "width" : "height", width > 200 ? width : height);
}
return ZINT_ERROR_INVALID_OPTION;
@ -1347,9 +1347,9 @@ INTERNAL int dotcode(struct zint_symbol *symbol, struct zint_seg segs[], const i
if ((height < 5) || (width < 5)) {
if (height < 5 && width < 5) { /* Won't happen as if width < 5, min height is 19 */
sprintf(symbol->errtxt, "527: Symbol size %dx%d (WxH) is too small", width, height); /* Not reached */
errtxtf(0, symbol, 527, "Symbol size '%1$dx%2$d' (WxH) is too small", width, height); /* Not reached */
} else {
sprintf(symbol->errtxt, "529: Symbol %s %d is too small",
errtxtf(0, symbol, 529, "Symbol %1$s '%2$d' is too small",
width < 5 ? "width" : "height", width < 5 ? width : height);
}
return ZINT_ERROR_INVALID_OPTION;

View file

@ -834,8 +834,7 @@ INTERNAL int sjis_utf8(struct zint_symbol *symbol, const unsigned char source[],
for (i = 0, length = *p_length; i < length; i++) {
if (!u_sjis_int(utfdata[i], ddata + i)) {
strcpy(symbol->errtxt, "800: Invalid character in input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 800, "Invalid character in input");
}
}
@ -929,8 +928,7 @@ INTERNAL int gb2312_utf8(struct zint_symbol *symbol, const unsigned char source[
ddata[i] = utfdata[i];
} else {
if (!u_gb2312_int(utfdata[i], ddata + i)) {
strcpy(symbol->errtxt, "810: Invalid character in input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 810, "Invalid character in input");
}
}
}
@ -1033,8 +1031,7 @@ INTERNAL int gb18030_utf8(struct zint_symbol *symbol, const unsigned char source
} else {
ret = u_gb18030_int(utfdata[i], ddata + j, ddata + j + 1);
if (ret == 0) { /* Should never happen, as GB 18030 is a UTF i.e. maps all Unicode codepoints */
strcpy(symbol->errtxt, "820: Invalid character in input data"); /* Not reached */
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 820, "Invalid character in input"); /* Not reached */
}
if (ret == 4) {
j++;

View file

@ -239,8 +239,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
const int ih_ultra_offset = symbol->symbology == BARCODE_ULTRA ? 8 : 0;
if (symbol->vector == NULL) {
strcpy(symbol->errtxt, "643: Vector header NULL");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 643, "Vector header NULL");
}
(void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, NULL /*alpha*/);
@ -640,8 +639,7 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
for (i = 0; i < this_text; i++) {
free(this_string[i]);
}
strcpy(symbol->errtxt, "641: Insufficient memory for EMF string buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 641, "Insufficient memory for EMF string buffer");
}
memset(this_string[this_text], 0, text_bumped_lens[this_text]);
out_le_u32(text[this_text].type, 0x00000054); /* EMR_EXTTEXTOUTW */
@ -703,8 +701,8 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
/* Send EMF data to file */
if (!fm_open(fmp, symbol, "wb")) {
sprintf(symbol->errtxt, "640: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_ACCESS;
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 640, "Could not open EMF output file (%1$d: %2$s)", fmp->err,
strerror(fmp->err));
}
fm_write(&emr_header, sizeof(emr_header_t), 1, fmp);
@ -822,14 +820,14 @@ INTERNAL int emf_plot(struct zint_symbol *symbol, int rotate_angle) {
fm_write(&emr_eof, sizeof(emr_eof_t), 1, fmp);
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "644: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 644, "Incomplete write of EMF output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "941: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 941, "Failure on closing EMF output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return error_number;
}

View file

@ -72,7 +72,7 @@ INTERNAL int fm_putc(const int ch, struct filemem *restrict const fmp);
INTERNAL int fm_puts(const char *str, struct filemem *restrict const fmp);
/* `fprintf()` to file or memory, returning 1 on success, 0 on failure */
INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *format, ...);
INTERNAL int fm_printf(struct filemem *restrict const fmp, const char *format, ...) ZINT_FORMAT_PRINTF(2, 3);
/* Output float without trailing zeroes to `fmp` with decimal pts `dp` (precision), returning 1 on success, 0 on
failure */

View file

@ -45,7 +45,7 @@ static int general_field_type(const char *general_field, const int i) {
if (z_isupper(general_field[i]) || posn(alphanum_puncs, general_field[i]) != -1) {
return ALPHANUMERIC;
}
if (is_sane(IS_ISOIEC_F, (const unsigned char *) general_field + i, 1)) {
if (!not_sane(IS_ISOIEC_F, (const unsigned char *) general_field + i, 1)) {
return ISOIEC;
}
return 0;

View file

@ -269,15 +269,14 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
State.OutLength = GIF_LZW_PAGE_SIZE;
}
if (!(State.pOut = (unsigned char *) malloc(State.OutLength))) {
strcpy(symbol->errtxt, "614: Insufficient memory for LZW buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 614, "Insufficient memory for GIF LZW buffer");
}
State.fmp = &fm;
/* Open output file in binary mode */
if (!fm_open(State.fmp, symbol, "wb")) {
sprintf(symbol->errtxt, "611: Could not open output file (%d: %.30s)", State.fmp->err,
errtxtf(0, symbol, 611, "Could not open GIF output file (%1$d: %2$s)", State.fmp->err,
strerror(State.fmp->err));
free(State.pOut);
return ZINT_ERROR_FILE_ACCESS;
@ -445,8 +444,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
if (!gif_lzw(&State, paletteBitSize)) {
free(State.pOut);
(void) fm_close(State.fmp, symbol);
strcpy(symbol->errtxt, "613: Insufficient memory for LZW buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 613, "Insufficient memory for GIF LZW buffer");
}
fm_write(State.pOut, 1, State.OutPosCur, State.fmp);
free(State.pOut);
@ -455,16 +453,15 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
fm_putc(';', State.fmp);
if (fm_error(State.fmp)) {
sprintf(symbol->errtxt, "615: Incomplete write to output (%d: %.30s)", State.fmp->err,
errtxtf(0, symbol, 615, "Incomplete write of GIF output (%1$d: %2$s)", State.fmp->err,
strerror(State.fmp->err));
(void) fm_close(State.fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(State.fmp, symbol)) {
sprintf(symbol->errtxt, "617: Failure on closing output file (%d: %.30s)", State.fmp->err,
strerror(State.fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 617, "Failure on closing GIF output file (%1$d: %2$s)",
State.fmp->err, strerror(State.fmp->err));
}
return 0;

View file

@ -1050,8 +1050,8 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
if (error_number == 0) {
done = 1;
} else {
sprintf(symbol->errtxt, "535: Invalid character in input data for ECI %d", local_segs[i].eci);
return error_number;
return errtxtf(error_number, symbol, 535, "Invalid character in input for ECI '%d'",
local_segs[i].eci);
}
}
if (!done) {
@ -1069,12 +1069,13 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
if (symbol->structapp.count) {
if (symbol->structapp.count < 2 || symbol->structapp.count > 16) {
strcpy(symbol->errtxt, "536: Structured Append count out of range (2-16)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 536,
"Structured Append count '%d' out of range (2 to 16)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "537: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 537,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
int id, id_len;
@ -1082,32 +1083,30 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
for (id_len = 1; id_len < 4 && symbol->structapp.id[id_len]; id_len++);
if (id_len > 3) { /* 255 (8 bits) */
strcpy(symbol->errtxt, "538: Structured Append ID too long (3 digit maximum)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 538,
"Structured Append ID length %d too long (3 digit maximum)", id_len);
}
id = to_int((const unsigned char *) symbol->structapp.id, id_len);
if (id == -1) {
strcpy(symbol->errtxt, "539: Invalid Structured Append ID (digits only)");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 539, "Invalid Structured Append ID (digits only)");
}
if (id > 255) {
sprintf(symbol->errtxt, "530: Structured Append ID '%d' out of range (0-255)", id);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 530,
"Structured Append ID value '%d' out of range (0 to 255)", id);
}
}
p_structapp = &symbol->structapp;
}
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "533: Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 533, "ECI code '%d' out of range (0 to 811799)",
symbol->eci);
}
error_number = gm_encode_segs(ddata, local_segs, seg_count, binary, reader, p_structapp, &bin_len, debug_print);
if (error_number != 0) {
strcpy(symbol->errtxt, "531: Input data too long");
return error_number;
return errtxt(error_number, symbol, 531, "Input too long, requires too many codewords (maximum 1313)");
}
/* Determine the size of the symbol */
@ -1132,8 +1131,9 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
if (symbol->option_2 >= min_layers) {
layers = symbol->option_2;
} else {
strcpy(symbol->errtxt, "534: Input data too long for selected symbol size");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 534,
"Input too long for Version %1$d, requires %2$d codewords (maximum %3$d)",
symbol->option_2, data_cw, gm_max_cw[symbol->option_2 - 1]);
}
}
@ -1189,8 +1189,12 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, struct zint_seg segs[], cons
}
if (data_cw > data_max) {
strcpy(symbol->errtxt, "532: Input data too long");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 532,
"Input too long for ECC level %1$d, requires %2$d codewords (maximum %3$d)",
ecc_level, data_cw, data_max);
}
if (debug_print) {
printf("Layers: %d, ECC level: %d, Data Codewords: %d\n", layers, ecc_level, data_cw);
}
gm_add_ecc(binary, data_cw, layers, ecc_level, word);

View file

@ -181,7 +181,7 @@ static int csum(const unsigned char *data, int data_len, int offset, int min, in
for (; d < de; d++) {
checksum += (*d - '0') * factor;
factor ^= 2; /* Toggles 1 and 3 */
factor ^= 0x02; /* Toggles 1 and 3 */
}
checksum = 10 - checksum % 10;
if (checksum == 10) {
@ -1624,50 +1624,44 @@ static int packagetype(const unsigned char *data, int data_len, int offset, int
/* Verify a GS1 input string */
INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[]) {
int i, j, last_ai, ai_latch;
int bracket_level, max_bracket_level, ai_length, max_ai_length, min_ai_length;
int ai_zero_len_no_data = 0, ai_single_digit = 0, ai_nonnumeric = 0;
int ai_count;
int i, j;
int error_value = 0;
char obracket = symbol->input_mode & GS1PARENS_MODE ? '(' : '[';
char cbracket = symbol->input_mode & GS1PARENS_MODE ? ')' : ']';
int ai_max = chr_cnt(source, length, obracket) + 1; /* Plus 1 so non-zero */
int bracket_level = 0, max_bracket_level = 0;
int ai_length, ai_latch;
int max_ai_length = 0, min_ai_length = 5;
int max_ai_pos = 0, min_ai_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positives */
int ai_zero_len_no_data = 0, ai_single_digit = 0, ai_nonnumeric = 0;
int ai_nonnumeric_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positive */
const char obracket = symbol->input_mode & GS1PARENS_MODE ? '(' : '[';
const char cbracket = symbol->input_mode & GS1PARENS_MODE ? ')' : ']';
const int ai_max = chr_cnt(source, length, obracket) + 1; /* Plus 1 so non-zero */
int *ai_value = (int *) z_alloca(sizeof(int) * ai_max);
int *ai_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_length = (int *) z_alloca(sizeof(int) * ai_max);
/* Detect extended ASCII characters */
/* Detect control and extended ASCII characters */
for (i = 0; i < length; i++) {
if (source[i] >= 128) {
strcpy(symbol->errtxt, "250: Extended ASCII characters are not supported by GS1");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 250, "Extended ASCII characters are not supported by GS1");
}
if (source[i] == '\0') {
strcpy(symbol->errtxt, "262: NUL characters not permitted in GS1 mode");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 262, "NUL characters not permitted in GS1 mode");
}
if (source[i] < 32) {
strcpy(symbol->errtxt, "251: Control characters are not supported by GS1");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 251, "Control characters are not supported by GS1");
}
if (source[i] == 127) {
strcpy(symbol->errtxt, "263: DEL characters are not supported by GS1");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 263, "DEL characters are not supported by GS1");
}
}
if (source[0] != obracket) {
strcpy(symbol->errtxt, "252: Data does not start with an AI");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 252, "Data does not start with an AI");
}
/* Check the position of the brackets */
bracket_level = 0;
max_bracket_level = 0;
/* Check the balance of the brackets & AI lengths */
ai_length = 0;
max_ai_length = 0;
min_ai_length = 5;
ai_latch = 0;
for (i = 0; i < length; i++) {
if (source[i] == obracket) {
@ -1680,9 +1674,11 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
bracket_level--;
if (ai_length > max_ai_length) {
max_ai_length = ai_length;
max_ai_pos = i - ai_length;
}
if (ai_length < min_ai_length) {
min_ai_length = ai_length;
min_ai_pos = i - ai_length;
}
/* Check zero-length AI has data */
if (ai_length == 0 && (i + 1 == length || source[i + 1] == obracket)) {
@ -1696,26 +1692,25 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
ai_length++;
if (!z_isdigit(source[i])) {
ai_nonnumeric = 1;
ai_nonnumeric_pos = i - ai_length + 1;
}
}
}
if (bracket_level != 0) {
/* Not all brackets are closed */
strcpy(symbol->errtxt, "253: Malformed AI in input data (brackets don\'t match)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 253, "Malformed AI in input (brackets don\'t match)");
}
if (max_bracket_level > 1) {
/* Nested brackets */
strcpy(symbol->errtxt, "254: Found nested brackets in input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 254, "Found nested brackets in input");
}
if (max_ai_length > 4) {
/* AI is too long */
strcpy(symbol->errtxt, "255: Invalid AI in input data (AI too long)");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 255, "Invalid AI at position %d in input (AI too long)",
max_ai_pos);
}
if (min_ai_length <= 1) {
@ -1723,19 +1718,19 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
- permits dummy "[]" workaround for ticket #204 data with no valid AI */
if (!(symbol->input_mode & GS1NOCHECK_MODE) || ai_single_digit || ai_zero_len_no_data) {
/* AI is too short */
strcpy(symbol->errtxt, "256: Invalid AI in input data (AI too short)");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 256, "Invalid AI at position %d in input (AI too short)",
min_ai_pos);
}
}
if (ai_nonnumeric) {
/* Non-numeric data in AI */
strcpy(symbol->errtxt, "257: Invalid AI in input data (non-numeric characters in AI)");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 257,
"Invalid AI at position %d in input (non-numeric characters in AI)", ai_nonnumeric_pos);
}
if (!(symbol->input_mode & GS1NOCHECK_MODE)) {
ai_count = 0;
int ai_count = 0;
for (i = 1; i < length; i++) {
if (source[i - 1] == obracket) {
ai_location[ai_count] = i;
@ -1761,8 +1756,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
}
if (data_length[i] == 0) {
/* No data for given AI */
strcpy(symbol->errtxt, "258: Empty data field in input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 258, "Empty data field in input");
}
}
@ -1773,11 +1767,11 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
char err_msg[50];
if (!gs1_lint(ai_value[i], source + data_location[i], data_length[i], &err_no, &err_posn, err_msg)) {
if (err_no == 1) {
sprintf(symbol->errtxt, "260: Invalid AI (%02d)", ai_value[i]);
errtxtf(0, symbol, 260, "Invalid AI (%02d)", ai_value[i]);
} else if (err_no == 2 || err_no == 4) { /* 4 is backward-incompatible bad length */
sprintf(symbol->errtxt, "259: Invalid data length for AI (%02d)", ai_value[i]);
errtxtf(0, symbol, 259, "Invalid data length for AI (%02d)", ai_value[i]);
} else {
sprintf(symbol->errtxt, "261: AI (%02d) position %d: %s", ai_value[i], err_posn, err_msg);
errtxtf(0, symbol, 261, "AI (%1$02d) position %2$d: %3$s", ai_value[i], err_posn, err_msg);
}
/* For backward compatibility only error on unknown AI or bad length */
if (err_no == 1 || err_no == 2) {
@ -1799,7 +1793,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
reduced[j++] = '\x1D';
}
if (i + 1 != length) {
last_ai = to_int(source + i + 1, 2);
int last_ai = to_int(source + i + 1, 2);
ai_latch = 0;
/* The following values from "GS1 General Specifications Release 21.0.1"
Figure 7.8.4-2 "Element strings with predefined length using GS1 Application Identifiers" */
@ -1836,7 +1830,7 @@ INTERNAL char gs1_check_digit(const unsigned char source[], const int length) {
for (i = 0; i < length; i++) {
count += factor * ctoi(source[i]);
factor ^= 2; /* Toggles 1 and 3 */
factor ^= 0x02; /* Toggles 1 and 3 */
}
return itoc((10 - (count % 10)) % 10);

View file

@ -1521,8 +1521,8 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
if (error_number == 0) {
done = 1;
} else if (local_segs[i].eci || seg_count > 1) {
sprintf(symbol->errtxt, "545: Invalid character in input data for ECI %d", local_segs[i].eci);
return error_number;
return errtxtf(error_number, symbol, 545, "Invalid character in input for ECI '%d'",
local_segs[i].eci);
}
}
if (!done) {
@ -1532,8 +1532,8 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
return error_number;
}
if (local_segs[i].eci != 32) {
strcpy(symbol->errtxt, "543: Converted to GB 18030 but no ECI specified");
warn_number = ZINT_WARN_NONCOMPLIANT;
warn_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 543,
"Converted to GB 18030 but no ECI specified");
}
}
dd += local_segs[i].length;
@ -1543,8 +1543,11 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
hx_define_mode_segs(mode, ddata, local_segs, seg_count, debug_print);
est_binlen = hx_calc_binlen_segs(mode, ddata, local_segs, seg_count);
if (debug_print) {
printf("Estimated binary length: %d\n", est_binlen);
}
binary = (char *) z_alloca((est_binlen + 1));
binary = (char *) malloc(est_binlen + 1);
if ((ecc_level <= 0) || (ecc_level >= 5)) {
ecc_level = 1;
@ -1561,40 +1564,16 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
version = 85;
for (i = 84; i > 0; i--) {
switch (ecc_level) {
case 1:
if (hx_data_codewords_L1[i - 1] >= codewords) {
if (hx_data_codewords[ecc_level - 1][i - 1] >= codewords) {
version = i;
data_codewords = hx_data_codewords_L1[i - 1];
}
break;
case 2:
if (hx_data_codewords_L2[i - 1] >= codewords) {
version = i;
data_codewords = hx_data_codewords_L2[i - 1];
}
break;
case 3:
if (hx_data_codewords_L3[i - 1] >= codewords) {
version = i;
data_codewords = hx_data_codewords_L3[i - 1];
}
break;
case 4:
if (hx_data_codewords_L4[i - 1] >= codewords) {
version = i;
data_codewords = hx_data_codewords_L4[i - 1];
}
break;
default: /* Not reached */
assert(0);
break;
data_codewords = hx_data_codewords[ecc_level - 1][i - 1];
}
}
if (version == 85) {
strcpy(symbol->errtxt, "541: Input too long for selected error correction level");
return ZINT_ERROR_TOO_LONG;
free(binary);
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 541, "Input too long, requires %d codewords (maximum 3264)",
codewords);
}
if ((symbol->option_2 < 0) || (symbol->option_2 > 84)) {
@ -1606,27 +1585,35 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
}
if ((symbol->option_2 != 0) && (symbol->option_2 < version)) {
strcpy(symbol->errtxt, "542: Input too long for selected symbol size");
return ZINT_ERROR_TOO_LONG;
free(binary);
if (ecc_level == 1) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 542,
"Input too long for Version %1$d, requires %2$d codewords (maximum %3$d)",
symbol->option_2, codewords, hx_data_codewords[ecc_level - 1][symbol->option_2 - 1]);
}
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 542,
"Input too long for Version %1$d, ECC %2$d, requires %3$d codewords (maximum %4$d)",
symbol->option_2, ecc_level, codewords,
hx_data_codewords[ecc_level - 1][symbol->option_2 - 1]);
}
/* If there is spare capacity, increase the level of ECC */
/* Unless explicitly specified (within min/max bounds) by user */
if (symbol->option_1 == -1 || symbol->option_1 != ecc_level) {
if ((ecc_level == 1) && (codewords <= hx_data_codewords_L2[version - 1])) {
if (ecc_level == 1 && codewords <= hx_data_codewords[1][version - 1]) {
ecc_level = 2;
data_codewords = hx_data_codewords_L2[version - 1];
data_codewords = hx_data_codewords[1][version - 1];
}
if ((ecc_level == 2) && (codewords <= hx_data_codewords_L3[version - 1])) {
if (ecc_level == 2 && codewords <= hx_data_codewords[2][version - 1]) {
ecc_level = 3;
data_codewords = hx_data_codewords_L3[version - 1];
data_codewords = hx_data_codewords[2][version - 1];
}
if ((ecc_level == 3) && (codewords <= hx_data_codewords_L4[version - 1])) {
if (ecc_level == 3 && codewords <= hx_data_codewords[3][version - 1]) {
ecc_level = 4;
data_codewords = hx_data_codewords_L4[version - 1];
data_codewords = hx_data_codewords[3][version - 1];
}
}
@ -1645,6 +1632,7 @@ INTERNAL int hanxin(struct zint_symbol *symbol, struct zint_seg segs[], const in
datastream[i >> 3] |= 0x80 >> (i & 0x07);
}
}
free(binary);
if (debug_print) {
printf("Datastream (%d):", data_codewords);

View file

@ -1,7 +1,7 @@
/* hanxin.h - definitions for Han Xin code */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2016 Zoe Stuart
Redistribution and use in source and binary forms, with or without
@ -35,56 +35,63 @@
#define Z_HANXIN_H
/* Data from table B1: Data capacity of Han Xin Code */
static const unsigned short hx_total_codewords[] = {
25, 37, 50, 54, 69, 84, 100, 117, 136, 155, 161, 181, 203, 225, 249,
273, 299, 325, 353, 381, 411, 422, 453, 485, 518, 552, 587, 623, 660,
698, 737, 754, 794, 836, 878, 922, 966, 1011, 1058, 1105, 1126, 1175,
1224, 1275, 1327, 1380, 1434, 1489, 1513, 1569, 1628, 1686, 1745, 1805,
1867, 1929, 1992, 2021, 2086, 2151, 2218, 2286, 2355, 2425, 2496, 2528,
2600, 2673, 2749, 2824, 2900, 2977, 3056, 3135, 3171, 3252, 3334, 3416,
3500, 3585, 3671, 3758, 3798, 3886
static const unsigned short hx_total_codewords[84] = {
25, 37, 50, 54, 69, 84, 100, 117, 136, 155,
161, 181, 203, 225, 249, 273, 299, 325, 353, 381,
411, 422, 453, 485, 518, 552, 587, 623, 660, 698,
737, 754, 794, 836, 878, 922, 966, 1011, 1058, 1105,
1126, 1175, 1224, 1275, 1327, 1380, 1434, 1489, 1513, 1569,
1628, 1686, 1745, 1805, 1867, 1929, 1992, 2021, 2086, 2151,
2218, 2286, 2355, 2425, 2496, 2528, 2600, 2673, 2749, 2824,
2900, 2977, 3056, 3135, 3171, 3252, 3334, 3416, 3500, 3585,
3671, 3758, 3798, 3886
};
static const unsigned short hx_data_codewords_L1[] = {
21, 31, 42, 46, 57, 70, 84, 99, 114, 131, 135, 153, 171, 189, 209, 229,
251, 273, 297, 321, 345, 354, 381, 407, 436, 464, 493, 523, 554, 586, 619,
634, 666, 702, 738, 774, 812, 849, 888, 929, 946, 987, 1028, 1071, 1115,
1160, 1204, 1251, 1271, 1317, 1368, 1416, 1465, 1517, 1569, 1621, 1674,
1697, 1752, 1807, 1864, 1920, 1979, 2037, 2096, 2124, 2184, 2245, 2309,
2372, 2436, 2501, 2568, 2633, 2663, 2732, 2800, 2870, 2940, 3011,
static const unsigned short hx_data_codewords[4][84] = { {
21, 31, 42, 46, 57, 70, 84, 99, 114, 131,
135, 153, 171, 189, 209, 229, 251, 273, 297, 321,
345, 354, 381, 407, 436, 464, 493, 523, 554, 586,
619, 634, 666, 702, 738, 774, 812, 849, 888, 929,
946, 987, 1028, 1071, 1115, 1160, 1204, 1251, 1271, 1317,
1368, 1416, 1465, 1517, 1569, 1621, 1674, 1697, 1752, 1807,
1864, 1920, 1979, 2037, 2096, 2124, 2184, 2245, 2309, 2372,
2436, 2501, 2568, 2633, 2663, 2732, 2800, 2870, 2940, 3011,
3083, 3156, 3190, 3264
};
static const unsigned short hx_data_codewords_L2[] = {
17, 25, 34, 38, 49, 58, 70, 81, 96, 109, 113, 127, 143, 157, 175, 191, 209,
227, 247, 267, 287, 296, 317, 339, 362, 386, 411, 437, 462, 488, 515, 528,
556, 586, 614, 646, 676, 707, 740, 773, 788, 823, 856, 893, 929, 966, 1004,
1043, 1059, 1099, 1140, 1180, 1221, 1263, 1307, 1351, 1394, 1415, 1460,
1505, 1552, 1600, 1649, 1697, 1748, 1770, 1820, 1871, 1925, 1976, 2030,
2083, 2140, 2195, 2219, 2276, 2334, 2392, 2450, 2509, 2569, 2630, 2658,
2720
};
static const unsigned short hx_data_codewords_L3[] = {
13, 19, 26, 30, 37, 46, 54, 63, 74, 83, 87, 97, 109, 121, 135, 147, 161,
175, 191, 205, 221, 228, 245, 261, 280, 298, 317, 337, 358, 376, 397, 408,
428, 452, 474, 498, 522, 545, 572, 597, 608, 635, 660, 689, 717, 746, 774,
805, 817, 847, 880, 910, 943, 975, 1009, 1041, 1076, 1091, 1126, 1161, 1198,
1234, 1271, 1309, 1348, 1366, 1404, 1443, 1485, 1524, 1566, 1607, 1650, 1693,
1713, 1756, 1800, 1844, 1890, 1935, 1983, 2030, 2050, 2098
};
static const unsigned short hx_data_codewords_L4[] = {
9, 15, 20, 22, 27, 34, 40, 47, 54, 61, 65, 73, 81, 89, 99, 109, 119, 129,
141, 153, 165, 168, 181, 195, 208, 220, 235, 251, 264, 280, 295, 302, 318,
334, 352, 368, 386, 405, 424, 441, 450, 469, 490, 509, 531, 552, 574, 595, 605,
627, 652, 674, 697, 721, 747, 771, 796, 809, 834, 861, 892, 914, 941, 969, 998,
1012, 1040, 1069, 1099, 1130, 1160, 1191, 1222, 1253, 1269, 1300, 1334,
1366, 1400, 1433, 1469, 1504, 1520, 1554
}, {
17, 25, 34, 38, 49, 58, 70, 81, 96, 109,
113, 127, 143, 157, 175, 191, 209, 227, 247, 267,
287, 296, 317, 339, 362, 386, 411, 437, 462, 488,
515, 528, 556, 586, 614, 646, 676, 707, 740, 773,
788, 823, 856, 893, 929, 966, 1004, 1043, 1059, 1099,
1140, 1180, 1221, 1263, 1307, 1351, 1394, 1415, 1460, 1505,
1552, 1600, 1649, 1697, 1748, 1770, 1820, 1871, 1925, 1976,
2030, 2083, 2140, 2195, 2219, 2276, 2334, 2392, 2450, 2509,
2569, 2630, 2658, 2720
}, {
13, 19, 26, 30, 37, 46, 54, 63, 74, 83,
87, 97, 109, 121, 135, 147, 161, 175, 191, 205,
221, 228, 245, 261, 280, 298, 317, 337, 358, 376,
397, 408, 428, 452, 474, 498, 522, 545, 572, 597,
608, 635, 660, 689, 717, 746, 774, 805, 817, 847,
880, 910, 943, 975, 1009, 1041, 1076, 1091, 1126, 1161,
1198, 1234, 1271, 1309, 1348, 1366, 1404, 1443, 1485, 1524,
1566, 1607, 1650, 1693, 1713, 1756, 1800, 1844, 1890, 1935,
1983, 2030, 2050, 2098
}, {
9, 15, 20, 22, 27, 34, 40, 47, 54, 61,
65, 73, 81, 89, 99, 109, 119, 129, 141, 153,
165, 168, 181, 195, 208, 220, 235, 251, 264, 280,
295, 302, 318, 334, 352, 368, 386, 405, 424, 441,
450, 469, 490, 509, 531, 552, 574, 595, 605, 627,
652, 674, 697, 721, 747, 771, 796, 809, 834, 861,
892, 914, 941, 969, 998, 1012, 1040, 1069, 1099, 1130,
1160, 1191, 1222, 1253, 1269, 1300, 1334, 1366, 1400, 1433,
1469, 1504, 1520, 1554
}
};
/* Value 'k' from Annex A */
static const char hx_module_k[] = {
static const char hx_module_k[84] = {
0, 0, 0, 14, 16, 16, 17, 18, 19, 20,
14, 15, 16, 16, 17, 17, 18, 19, 20, 20,
21, 16, 17, 17, 18, 18, 19, 19, 20, 20,
@ -97,7 +104,7 @@ static const char hx_module_k[] = {
};
/* Value 'r' from Annex A */
static const char hx_module_r[] = {
static const char hx_module_r[84] = {
0, 0, 0, 15, 15, 17, 18, 19, 20, 21,
15, 15, 15, 17, 17, 19, 19, 19, 19, 21,
21, 17, 16, 18, 17, 19, 18, 20, 19, 21,
@ -110,7 +117,7 @@ static const char hx_module_r[] = {
};
/* Value of 'm' from Annex A */
static const char hx_module_m[] = {
static const char hx_module_m[84] = {
0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 3, 3,
@ -413,7 +420,7 @@ static const unsigned char hx_table_d1[] = {
31, 66, 28, 1, 37, 26, 0, 0, 0,
48, 33, 28, 1, 23, 26, 0, 0, 0,
53, 20, 30, 6, 19, 28, 1, 17, 28,
20, 115, 22, 2, 134, 24, 0, 0, 0, /* verdion 73 */
20, 115, 22, 2, 134, 24, 0, 0, 0, /* version 73 */
29, 66, 28, 2, 56, 26, 2, 57, 26,
45, 36, 30, 2, 15, 28, 0, 0, 0,
59, 20, 30, 2, 21, 32, 0, 0, 0,

View file

@ -259,12 +259,11 @@ INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int
int zip_len, len;
if (length > 32) {
strcpy(symbol->errtxt, "450: Input too long (32 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 450, "Input length %d too long (maximum 32)", length);
}
if (!is_sane(SODIUM_MNS_F, source, length)) {
strcpy(symbol->errtxt, "451: Invalid character in data (digits and \"-\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(SODIUM_MNS_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 451,
"Invalid character at position %d in input (digits and \"-\" only)", i);
}
/* separate the tracking code from the routing code */
@ -296,18 +295,18 @@ INTERNAL int usps_imail(struct zint_symbol *symbol, unsigned char source[], int
}
if (strlen(tracker) != 20) {
strcpy(symbol->errtxt, "452: Invalid length for tracking code (20 characters required)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 452,
"Invalid length for tracking code (20 characters required)");
}
if (tracker[1] > '4') {
strcpy(symbol->errtxt, "454: Barcode Identifier (second character) out of range (0 to 4)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 454,
"Barcode Identifier (second character) out of range (0 to 4)");
}
zip_len = (int) strlen(zip);
if (zip_len != 0 && zip_len != 5 && zip_len != 9 && zip_len != 11) {
strcpy(symbol->errtxt, "453: Invalid length for ZIP code (5, 9 or 11 characters required)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 453,
"Invalid length for ZIP code (5, 9 or 11 characters required)");
}
/* *** Step 1 - Conversion of Data Fields into Binary Data *** */

View file

@ -243,12 +243,12 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_
INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_type);
/* Prefix error message with Error/Warning */
static int error_tag(struct zint_symbol *symbol, int error_number, const char *error_string) {
static int error_tag(int error_number, struct zint_symbol *symbol, const int err_id, const char *error_string) {
if (error_number != 0) {
const char *const error_arg = error_string ? error_string : symbol->errtxt;
char error_buffer[100];
if (error_string) {
errtxt(0, symbol, err_id, error_string);
}
if (error_number < ZINT_ERROR && symbol->warn_level == WARN_FAIL_ALL) {
/* Convert to error equivalent */
if (error_number == ZINT_WARN_NONCOMPLIANT) {
@ -265,19 +265,19 @@ static int error_tag(struct zint_symbol *symbol, int error_number, const char *e
}
}
if (error_number >= ZINT_ERROR) {
sprintf(error_buffer, "Error %.93s", error_arg); /* Truncate if too long */
errtxt_adj(0, symbol, "Error %s", NULL);
} else {
sprintf(error_buffer, "Warning %.91s", error_arg); /* Truncate if too long */
errtxt_adj(0, symbol, "Warning %s", NULL);
}
strcpy(symbol->errtxt, error_buffer);
}
return error_number;
}
#ifdef ZINT_TEST /* Wrapper for direct testing */
INTERNAL int error_tag_test(struct zint_symbol *symbol, int error_number, const char *error_string) {
return error_tag(symbol, error_number, error_string);
INTERNAL int error_tag_test(int error_number, struct zint_symbol *symbol, const int err_id,
const char *error_string) {
return error_tag(error_number, symbol, err_id, error_string);
}
#endif
@ -298,8 +298,7 @@ static int dump_plot(struct zint_symbol *symbol) {
f = fopen(symbol->outfile, "w");
#endif
if (!f) {
strcpy(symbol->errtxt, "201: Could not open output file");
return ZINT_ERROR_FILE_ACCESS;
return errtxt(ZINT_ERROR_FILE_ACCESS, symbol, 201, "Could not open output file");
}
}
@ -336,7 +335,7 @@ static int dump_plot(struct zint_symbol *symbol) {
}
if (ferror(f)) {
sprintf(symbol->errtxt, "795: Incomplete write to output (%d: %.30s)", errno, strerror(errno));
errtxtf(0, symbol, 795, "Incomplete write to output (%1$d: %2$s)", errno, strerror(errno));
if (!output_to_stdout) {
(void) fclose(f);
}
@ -345,13 +344,13 @@ static int dump_plot(struct zint_symbol *symbol) {
if (output_to_stdout) {
if (fflush(f) != 0) {
sprintf(symbol->errtxt, "796: Incomplete flush to output (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 796, "Incomplete flush to output (%1$d: %2$s)",
errno, strerror(errno));
}
} else {
if (fclose(f) != 0) {
sprintf(symbol->errtxt, "792: Failure on closing output file (%d: %.30s)", errno, strerror(errno));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 792, "Failure on closing output file (%1$d: %2$s)",
errno, strerror(errno));
}
}
@ -373,13 +372,13 @@ static int hibc(struct zint_symbol *symbol, struct zint_seg segs[], const int se
/* without "+" and check: max 110 characters in HIBC 2.6 */
if (length > 110) {
strcpy(symbol->errtxt, "202: Data too long for HIBC LIC (110 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 202, "Input length %d too long for HIBC LIC (maximum 110)",
length);
}
to_upper(source, length);
if (!is_sane_lookup(TECHNETIUM, sizeof(TECHNETIUM) - 1, source, length, posns)) {
strcpy(symbol->errtxt, "203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(TECHNETIUM, sizeof(TECHNETIUM) - 1, source, length, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 203,
"Invalid character at position %d in input (alphanumerics, space and \"-.$/+%%\" only)", i);
}
counter = 41;
@ -657,11 +656,10 @@ static int reduced_charset(struct zint_symbol *symbol, struct zint_seg segs[], c
&local_segs[i].length);
if (error_number != 0) {
if (local_segs[i].eci) {
sprintf(symbol->errtxt, "244: Invalid character in input data for ECI %d", local_segs[i].eci);
} else {
strcpy(symbol->errtxt, "204: Invalid character in input data (ISO/IEC 8859-1 only)");
return errtxtf(error_number, symbol, 244, "Invalid character in input for ECI '%d'",
local_segs[i].eci);
}
return error_number;
return errtxt(error_number, symbol, 204, "Invalid character in input (ISO/IEC 8859-1 only)");
}
local_segs[i].source = preprocessed;
preprocessed += local_segs[i].length + 1;
@ -714,8 +712,7 @@ static int esc_base(struct zint_symbol *symbol, const unsigned char *input_strin
int val = -1;
if (in_posn + min_len > length) {
sprintf(symbol->errtxt, "232: Incomplete '\\%c' escape sequence in input data", base);
return -1;
return errtxtf(-1, symbol, 232, "Incomplete '\\%c' escape sequence in input", base);
}
c1 = ctoi(input_string[in_posn]);
c2 = ctoi(input_string[in_posn + 1]);
@ -736,16 +733,14 @@ static int esc_base(struct zint_symbol *symbol, const unsigned char *input_strin
}
if (val == -1) {
sprintf(symbol->errtxt, "233: Invalid character in escape sequence '\\%c%.*s' in input data (%s only)",
base, base == 'x' ? 2 : 3, input_string + in_posn,
return errtxtf(-1, symbol, 238, "Invalid character in escape sequence '%2$.*1$s' in input (%3$s only)",
base == 'x' ? 4 : 5, input_string + in_posn - 2,
base == 'd' ? "decimal" : base == 'o' ? "octal" : "hexadecimal");
return -1;
}
if (val > 255) {
assert(base != 'x');
sprintf(symbol->errtxt, "237: Value of escape sequence '\\%c%.3s' in input data out of range (000-%s)",
base, input_string + in_posn, base == 'd' ? "255" : "377");
return -1;
return errtxtf(-1, symbol, 237, "Value of escape sequence '%1$.5s' in input out of range (000 to %2$s)",
input_string + in_posn - 2, base == 'd' ? "255" : "377");
}
return val;
@ -762,14 +757,13 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
unsigned char ch;
int val;
int i;
unsigned long unicode;
unsigned int unicode;
const int extra_escape_mode = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128;
do {
if (input_string[in_posn] == '\\') {
if (in_posn + 1 >= length) {
strcpy(symbol->errtxt, "236: Incomplete escape character in input data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 236, "Incomplete escape character in input");
}
ch = input_string[in_posn + 1];
/* NOTE: if add escape character, must also update regex in "frontend_qt/datawindow.php" */
@ -792,8 +786,8 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
break;
case '^': /* CODE128 specific */
if (!extra_escape_mode) {
strcpy(symbol->errtxt, "798: Escape '\\^' only valid for Code 128 in extra escape mode");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 798,
"Escape '\\^' only valid for Code 128 in extra escape mode");
}
/* Pass thru unaltered */
if (escaped_string) {
@ -824,16 +818,15 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
case 'u':
case 'U':
if (in_posn + 6 > length || (ch == 'U' && in_posn + 8 > length)) {
sprintf(symbol->errtxt, "209: Incomplete '\\%c' escape sequence in input data", ch);
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 209,
"Incomplete '\\%c' escape sequence in input", ch);
}
unicode = 0;
for (i = 0; i < 6; i++) {
if ((val = ctoi(input_string[in_posn + i + 2])) == -1) {
sprintf(symbol->errtxt,
"211: Invalid character for '\\%c' escape sequence in input data (hexadecimal only)",
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 211,
"Invalid character for '\\%c' escape sequence in input (hexadecimal only)",
ch);
return ZINT_ERROR_INVALID_DATA;
}
unicode = (unicode << 4) | val;
if (i == 3 && ch == 'u') {
@ -842,9 +835,9 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
}
/* Exclude reversed BOM and surrogates and out-of-range */
if (unicode == 0xfffe || (unicode >= 0xd800 && unicode < 0xe000) || unicode > 0x10ffff) {
sprintf(symbol->errtxt, "246: Value of escape sequence '%.*s' in input data out of range",
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 246,
"Value of escape sequence '%.*s' in input out of range",
ch == 'u' ? 6 : 8, input_string + in_posn);
return ZINT_ERROR_INVALID_DATA;
}
if (unicode < 0x80) {
if (escaped_string) escaped_string[out_posn] = (unsigned char) unicode;
@ -876,8 +869,8 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
in_posn += 6 + (ch == 'U') * 2;
break;
default:
sprintf(symbol->errtxt, "234: Unrecognised escape character '\\%c' in input data", ch);
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 234,
"Unrecognised escape character '\\%c' in input", ch);
break;
}
} else {
@ -941,17 +934,17 @@ static int map_invalid_symbology(struct zint_symbol *symbol) {
if (symbol->symbology == 19) {
/* Has specific error message */
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "207: Codabar 18 not supported");
warn_number = error_tag(ZINT_WARN_INVALID_OPTION, symbol, 207, "Codabar 18 not supported");
if (warn_number >= ZINT_ERROR) {
return warn_number;
}
symbol->symbology = BARCODE_CODABAR;
} else if (symbol->symbology == 27) {
/* Not mapped */
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "208: UPCD1 not supported");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 208, "UPCD1 not supported");
} else if (symbol->symbology <= 0 || symbol->symbology > LIB_ID_MAP_LAST || id_map[symbol->symbology] == 0) {
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "206: Symbology out of range");
warn_number = error_tag(ZINT_WARN_INVALID_OPTION, symbol, 206, "Symbology out of range");
if (warn_number >= ZINT_ERROR) {
return warn_number;
}
@ -962,7 +955,7 @@ static int map_invalid_symbology(struct zint_symbol *symbol) {
if (symbol->symbology == orig_symbology) { /* Should never happen */
assert(0); /* Not reached */
return error_tag(symbol, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error");
return error_tag(ZINT_ERROR_ENCODING_PROBLEM, symbol, 0, "Internal error");
}
return warn_number;
@ -994,16 +987,16 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (!symbol) return ZINT_ERROR_INVALID_DATA;
if (segs == NULL) {
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "200: Input segments NULL");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 200, "Input segments NULL");
}
/* `seg_count` zero dealt with via `total_len` zero below */
if (seg_count > ZINT_MAX_SEG_COUNT) {
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "771: Too many input segments (max 256)");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 771, "Too many input segments (maximum 256)");
}
if ((symbol->input_mode & 0x07) > 2) {
symbol->input_mode = DATA_MODE; /* Reset completely */
warn_number = error_tag(symbol, ZINT_WARN_INVALID_OPTION, "212: Invalid input mode - reset to DATA_MODE");
warn_number = error_tag(ZINT_WARN_INVALID_OPTION, symbol, 212, "Invalid input mode - reset to DATA_MODE");
if (warn_number >= ZINT_ERROR) {
return warn_number;
}
@ -1023,8 +1016,8 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
for (i = 0; i < seg_count; i++) {
local_segs[i] = segs[i];
if (local_segs[i].source == NULL) {
sprintf(symbol->errtxt, "772: Input segment %d source NULL", i);
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
errtxtf(0, symbol, 772, "Input segment %d source NULL", i);
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
if (local_segs[i].length <= 0) {
local_segs[i].length = (int) ustrlen(local_segs[i].source);
@ -1033,36 +1026,37 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (i == 0) {
if (is_composite(symbol->symbology)
&& ((symbol->input_mode & 0x07) == GS1_MODE || check_force_gs1(symbol->symbology))) {
strcpy(symbol->errtxt, "779: No composite data in 2D component");
errtxt(0, symbol, 779, "No composite data (2D component)");
} else if (supports_eci(symbol->symbology)) {
errtxt(0, symbol, 228, "No input data (segment 0 empty)");
} else {
sprintf(symbol->errtxt, "778: No input data%s",
supports_eci(symbol->symbology) ? " (segment 0 empty)" : "");
errtxt(0, symbol, 778, "No input data");
}
} else {
sprintf(symbol->errtxt, "773: Input segment %d empty", i);
errtxtf(0, symbol, 773, "Input segment %d empty", i);
}
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
if (symbol->input_mode & ESCAPE_MODE) { /* Calculate de-escaped length for check against ZINT_MAX_DATA_LEN */
int escaped_len = local_segs[i].length;
error_number = escape_char_process(symbol, local_segs[i].source, &escaped_len, NULL /*escaped_string*/);
if (error_number != 0) { /* Only returns errors, not warnings */
return error_tag(symbol, error_number, NULL);
return error_tag(error_number, symbol, -1, NULL);
}
if (escaped_len > ZINT_MAX_DATA_LEN) {
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "797: Input data too long");
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 797, "Input too long");
}
total_len += escaped_len;
} else {
if (local_segs[i].length > ZINT_MAX_DATA_LEN) {
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "777: Input data too long");
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 777, "Input too long");
}
total_len += local_segs[i].length;
}
}
if (total_len == 0) {
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "205: No input data");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 205, "No input data");
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
@ -1085,15 +1079,15 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
if (total_len > ZINT_MAX_DATA_LEN) {
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "243: Input data too long");
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 243, "Input too long");
}
/* Reconcile symbol ECI and first segment ECI if both set */
if (symbol->eci != local_segs[0].eci) {
if (symbol->eci && local_segs[0].eci) {
sprintf(symbol->errtxt, "774: Symbol ECI %d must match segment zero ECI %d", symbol->eci,
local_segs[0].eci);
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, NULL);
errtxtf(0, symbol, 774, "Symbol ECI '%1$d' must match segment zero ECI '%2$d'",
symbol->eci, local_segs[0].eci);
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, -1, NULL);
}
if (symbol->eci) {
local_segs[0].eci = symbol->eci;
@ -1103,19 +1097,20 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
if (seg_count > 1 && !supports_eci(symbol->symbology)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "775: Symbology does not support multiple segments");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 775, "Symbology does not support multiple segments");
}
/* Check ECI(s) */
for (i = 0; i < seg_count; i++) {
if (local_segs[i].eci) {
if (!supports_eci(symbol->symbology)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "217: Symbology does not support ECI switching");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 217, "Symbology does not support ECI switching");
}
if (local_segs[i].eci < 0 || local_segs[i].eci == 1 || local_segs[i].eci == 2 || local_segs[i].eci == 14
|| local_segs[i].eci == 19 || local_segs[i].eci > 999999) {
sprintf(symbol->errtxt, "218: Invalid ECI code %d", local_segs[i].eci);
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, NULL);
errtxtf(0, symbol, 218, "ECI code '%d' out of range (0 to 999999, excluding 1, 2, 14 and 19)",
local_segs[i].eci);
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, -1, NULL);
}
} else {
have_zero_eci = 1;
@ -1124,52 +1119,52 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
/* Check other symbol fields */
if ((symbol->scale < 0.01f) || (symbol->scale > 200.0f)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "227: Scale out of range (0.01 to 200)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 227, "Scale out of range (0.01 to 200)");
}
if ((symbol->dot_size < 0.01f) || (symbol->dot_size > 20.0f)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "221: Dot size out of range (0.01 to 20)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 221, "Dot size out of range (0.01 to 20)");
}
if ((symbol->height < 0.0f) || (symbol->height > 2000.0f)) { /* Allow for 44 row CODABLOCKF at 45X each */
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "765: Height out of range (0 to 2000)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 765, "Height out of range (0 to 2000)");
}
if ((symbol->guard_descent < 0.0f) || (symbol->guard_descent > 50.0f)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "769: Guard bar descent out of range (0 to 50)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 769, "Guard bar descent out of range (0 to 50)");
}
if ((symbol->text_gap < -5.0f) || (symbol->text_gap > 10.0f)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "219: Text gap out of range (-5 to 10)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 219, "Text gap out of range (-5 to 10)");
}
if ((symbol->whitespace_width < 0) || (symbol->whitespace_width > 100)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "766: Whitespace width out of range (0 to 100)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 766, "Whitespace width out of range (0 to 100)");
}
if ((symbol->whitespace_height < 0) || (symbol->whitespace_height > 100)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "767: Whitespace height out of range (0 to 100)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 767, "Whitespace height out of range (0 to 100)");
}
if ((symbol->border_width < 0) || (symbol->border_width > 100)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "768: Border width out of range (0 to 100)");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 768, "Border width out of range (0 to 100)");
}
if (symbol->rows >= 200) { /* Check for stacking too many symbols */
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "770: Too many stacked symbols");
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 770, "Too many stacked symbols");
}
if (symbol->rows < 0) { /* Silently defend against out-of-bounds access */
symbol->rows = 0;
}
if ((symbol->input_mode & 0x07) == GS1_MODE && !gs1_compliant(symbol->symbology)) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "220: Selected symbology does not support GS1 mode");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 220, "Selected symbology does not support GS1 mode");
}
if (seg_count > 1) {
/* Note: GS1_MODE not currently supported when using multiple segments */
if ((symbol->input_mode & 0x07) == GS1_MODE) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "776: GS1 mode not supported for multiple segments");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 776, "GS1 mode not supported for multiple segments");
}
}
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
for (i = 0; i < seg_count; i++) {
if (!is_valid_utf8(local_segs[i].source, local_segs[i].length)) {
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "245: Invalid UTF-8 in input data");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 245, "Invalid UTF-8 in input");
}
}
}
@ -1193,13 +1188,13 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
char primary[sizeof(symbol->primary)];
int primary_len = (int) strlen(symbol->primary);
if (primary_len >= (int) sizeof(symbol->primary)) {
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "799: Invalid primary string");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 799, "Invalid primary string");
}
ustrcpy(primary, symbol->primary);
error_number = escape_char_process(symbol, (unsigned char *) primary, &primary_len,
(unsigned char *) symbol->primary);
if (error_number != 0) { /* Only returns errors, not warnings */
return error_tag(symbol, error_number, NULL);
return error_tag(error_number, symbol, -1, NULL);
}
}
@ -1216,12 +1211,10 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1);
error_number = gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced);
if (error_number) {
static const char in_2d_comp[] = " in 2D component";
if (is_composite(symbol->symbology)
&& strlen(symbol->errtxt) + sizeof(in_2d_comp) <= sizeof(symbol->errtxt)) {
strcat(symbol->errtxt, in_2d_comp);
if (is_composite(symbol->symbology)) {
errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)");
}
error_number = error_tag(symbol, error_number, NULL);
error_number = error_tag(error_number, symbol, -1, NULL);
if (error_number >= ZINT_ERROR) {
return error_number;
}
@ -1231,7 +1224,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
local_segs[0].length = (int) ustrlen(reduced);
}
} else {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "210: Selected symbology does not support GS1 mode");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 210, "Selected symbology does not support GS1 mode");
}
}
@ -1246,7 +1239,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (error_number < ZINT_ERROR) {
error_number = ZINT_WARN_USES_ECI;
if (!(symbol->debug & ZINT_DEBUG_TEST)) {
sprintf(symbol->errtxt, "222: Encoded data includes ECI %d", first_eci_set);
errtxtf(0, symbol, 222, "Encoded data includes ECI %d", first_eci_set);
}
if (symbol->debug & ZINT_DEBUG_PRINT) printf("Added ECI %d\n", first_eci_set);
}
@ -1255,7 +1248,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (error_number == 0) {
error_number = warn_number; /* Already tagged */
} else {
error_number = error_tag(symbol, error_number, NULL);
error_number = error_tag(error_number, symbol, -1, NULL);
}
if (error_number < ZINT_ERROR) {
@ -1279,12 +1272,12 @@ static int check_output_args(struct zint_symbol *symbol, int rotate_angle) {
case 270:
break;
default:
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "223: Invalid rotation angle");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 223, "Invalid rotation angle");
break;
}
if ((symbol->output_options & BARCODE_DOTTY_MODE) && !(is_dotty(symbol->symbology))) {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "224: Selected symbology cannot be rendered as dots");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 224, "Selected symbology cannot be rendered as dots");
}
return 0;
@ -1339,13 +1332,13 @@ int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle) {
error_number = dump_plot(symbol);
}
} else {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "225: Unknown output format");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 225, "Unknown output format");
}
} else {
return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "226: Unknown output format");
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 226, "Unknown output format");
}
return error_tag(symbol, error_number, NULL);
return error_tag(error_number, symbol, -1, NULL);
}
/* Output a previously encoded symbol to memory as raster (`symbol->bitmap`) */
@ -1357,7 +1350,7 @@ int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle) {
}
error_number = plot_raster(symbol, rotate_angle, OUT_BUFFER);
return error_tag(symbol, error_number, NULL);
return error_tag(error_number, symbol, -1, NULL);
}
/* Output a previously encoded symbol to memory as vector (`symbol->vector`) */
@ -1369,7 +1362,7 @@ int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle) {
}
error_number = plot_vector(symbol, rotate_angle, OUT_BUFFER);
return error_tag(symbol, error_number, NULL);
return error_tag(error_number, symbol, -1, NULL);
}
/* Encode and output a symbol to file `symbol->outfile` */
@ -1474,7 +1467,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
if (!symbol) return ZINT_ERROR_INVALID_DATA;
if (!filename) {
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "239: Filename NULL");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 239, "Filename NULL");
}
if (strcmp(filename, "-") == 0) {
@ -1487,16 +1480,16 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
file = fopen(filename, "rb");
#endif
if (!file) {
sprintf(symbol->errtxt, "229: Unable to read input file (%d: %.30s)", errno, strerror(errno));
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
errtxtf(0, symbol, 229, "Unable to read input file (%1$d: %2$s)", errno, strerror(errno));
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
file_opened = 1;
/* Get file length */
if (fseek(file, 0, SEEK_END) != 0) {
sprintf(symbol->errtxt, "797: Unable to seek input file (%d: %.30s)", errno, strerror(errno));
errtxtf(0, symbol, 797, "Unable to seek input file (%1$d: %2$s)", errno, strerror(errno));
(void) fclose(file);
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
fileLen = ftell(file);
@ -1504,17 +1497,17 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
/* On many Linux distros `ftell()` returns LONG_MAX not -1 on error */
if (fileLen <= 0 || fileLen == LONG_MAX) {
(void) fclose(file);
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, "235: Input file empty or unseekable");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 235, "Input file empty or unseekable");
}
if (fileLen > ZINT_MAX_DATA_LEN) {
(void) fclose(file);
return error_tag(symbol, ZINT_ERROR_TOO_LONG, "230: Input file too long");
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 230, "Input file too long");
}
if (fseek(file, 0, SEEK_SET) != 0) {
sprintf(symbol->errtxt, "793: Unable to seek input file (%d: %.30s)", errno, strerror(errno));
errtxtf(0, symbol, 793, "Unable to seek input file (%1$d: %2$s)", errno, strerror(errno));
(void) fclose(file);
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
}
@ -1524,7 +1517,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
if (file_opened) {
(void) fclose(file);
}
return error_tag(symbol, ZINT_ERROR_MEMORY, "231: Insufficient memory for file read buffer");
return error_tag(ZINT_ERROR_MEMORY, symbol, 231, "Insufficient memory for file read buffer");
}
/* Read file contents into buffer */
@ -1532,21 +1525,21 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) {
do {
n = fread(buffer + nRead, 1, fileLen - nRead, file);
if (ferror(file)) {
sprintf(symbol->errtxt, "241: Input file read error (%d: %.30s)", errno, strerror(errno));
errtxtf(0, symbol, 241, "Input file read error (%1$d: %2$s)", errno, strerror(errno));
free(buffer);
if (file_opened) {
(void) fclose(file);
}
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
nRead += n;
} while (!feof(file) && (0 < n) && ((long) nRead < fileLen));
if (file_opened) {
if (fclose(file) != 0) {
sprintf(symbol->errtxt, "794: Failure on closing input file (%d: %.30s)", errno, strerror(errno));
errtxtf(0, symbol, 794, "Failure on closing input file (%1$d: %2$s)", errno, strerror(errno));
free(buffer);
return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL);
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, -1, NULL);
}
}
ret = ZBarcode_Encode(symbol, buffer, (int) nRead);

View file

@ -194,16 +194,14 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
int error_number = 0;
if (length > 26) {
strcpy(symbol->errtxt, "580: Input too long (26 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 580, "Input length %d too long (maximum 26)", length);
}
ustrcpy(local_source, source);
if (length < 22) {
if (length < 14) {
strcpy(symbol->errtxt, "588: Input too short (14 character minimum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 588, "Input length %d too short (minimum 14)", length);
}
for (i = length; i <= 22; i++) {
strcat(local_source, " ");
@ -222,30 +220,27 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
printf("Producing 4-state Mailmark (%d): %s<end>\n", length, local_source);
}
if (!is_sane(RUBIDIUM_F, (unsigned char *) local_source, length)) {
strcpy(symbol->errtxt, "581: Invalid character in data (alphanumerics and space only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(RUBIDIUM_F, (unsigned char *) local_source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 581,
"Invalid character at position %d in input (alphanumerics and space only)", i);
}
/* Format is in the range 0-4 */
format = ctoi(local_source[0]);
if ((format < 0) || (format > 4)) {
strcpy(symbol->errtxt, "582: Format (1st character) out of range (0 to 4)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 582, "Format (1st character) out of range (0 to 4)");
}
/* Version ID is in the range 1-4 */
version_id = ctoi(local_source[1]) - 1;
if ((version_id < 0) || (version_id > 3)) {
strcpy(symbol->errtxt, "583: Version ID (2nd character) out of range (1 to 4)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 583, "Version ID (2nd character) out of range (1 to 4)");
}
/* Class is in the range 0-9,A-E */
mail_class = ctoi(local_source[2]);
if ((mail_class < 0) || (mail_class > 14)) {
strcpy(symbol->errtxt, "584: Class (3rd character) out of range (0 to 9 and A to E)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 584, "Class (3rd character) out of range (0 to 9 and A to E)");
}
/* Supply Chain ID is 2 digits for barcode C and 6 digits for barcode L */
@ -255,8 +250,8 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
supply_chain_id *= 10;
supply_chain_id += ctoi(local_source[i]);
} else {
sprintf(symbol->errtxt, "585: Invalid Supply Chain ID at character %d (digits only)", i);
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 585,
"Invalid Supply Chain ID at character %d (digits only)", i);
}
}
@ -267,8 +262,7 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
item_id *= 10;
item_id += ctoi(local_source[i]);
} else {
sprintf(symbol->errtxt, "586: Invalid Item ID at character %d (digits only)", i);
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 586, "Invalid Item ID at character %d (digits only)", i);
}
}
@ -278,8 +272,7 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
}
postcode[9] = '\0';
if (mailmark_verify_postcode(postcode, &postcode_type) != 0) {
sprintf(symbol->errtxt, "587: Invalid postcode \"%s\"", postcode);
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 587, "Invalid postcode \"%s\"", postcode);
}
/* Convert postcode to internal user field */
@ -526,13 +519,11 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
struct zint_seg segs[1];
if (length > 90) {
strcpy(symbol->errtxt, "589: Input too long (90 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 589, "Input length %d too long (maximum 90)", length);
}
if (length < 28) { /* After adding prefix (4), blank Return to Sender Post Code (7), Reserved (6): 28 + 17 = 45 */
strcpy(symbol->errtxt, "860: Input too short (28 character minimum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 860, "Input length %d too short (minimum 28)", length);
}
/* Add prefix if missing */
@ -540,8 +531,7 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
to_upper(local_source, 3);
if (memcmp(local_source, "JGB ", 4) != 0) {
if (length > 86) {
strcpy(symbol->errtxt, "861: Input too long (86 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 861, "Input length %d too long (maximum 86)", length);
}
ustrcpy(local_source, "JGB ");
ustrcpy(local_source + 4, source);
@ -551,8 +541,7 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
}
if (length < 32) {
strcpy(symbol->errtxt, "862: Input too short (32 character minimum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 862, "Input length %d too short (minimum 32)", length);
}
if (length < 39) { /* Space-pad Return to Sender Post Code */
memset(local_source + length, ' ', 39 - length);
@ -570,18 +559,18 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
/* 8: 24 x 24, 10: 32 x 32, 30: 16 x 48 */
if (symbol->option_2) {
if (symbol->option_2 != 8 && symbol->option_2 != 10 && symbol->option_2 != 30) {
strcpy(symbol->errtxt, "863: Invalid symbol size selected (8, 10, 30 only)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 863, "Invalid Version '%d' (8, 10 or 30 only)",
symbol->option_2);
}
if (symbol->option_2 == 8) {
if (length > 51) {
strcpy(symbol->errtxt, "864: Input too long for selected size (51 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 864,
"Input length %d too long for Version 8 (maximum 51)", length);
}
} else if (symbol->option_2 == 30) {
if (length > 70) {
strcpy(symbol->errtxt, "865: Input too long for selected size (70 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 865,
"Input length %d too long for Version 30 (maximum 70)", length);
}
}
} else {
@ -598,38 +587,32 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
printf("Producing 2D Mailmark %d (%d): %s<end>\n", symbol->option_2, length, local_source);
}
if (!is_sane(RUBIDIUM_F, local_source, 45)) {
strcpy(symbol->errtxt,
"866: Invalid character in data (alphanumerics and space only in first 45 characters)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(RUBIDIUM_F, local_source, 45))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 866,
"Invalid character at position %d in input (alphanumerics and space only in first 45)", i);
}
/* Information Type ID */
/* Not checking that matches values listed in Mailmark Definition Document as contradicted by Mailmark Mailing
Requirements Section 5.7 which says 'P' for poll card is valid, which isn't listed */
if (local_source[4] == ' ') {
strcpy(symbol->errtxt, "867: Invalid Information Type ID (cannot be space)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 867, "Invalid Information Type ID (cannot be space)");
}
/* Version ID */
if (local_source[5] != '1') {
strcpy(symbol->errtxt, "868: Invalid Version ID (\"1\" only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 868, "Invalid Version ID (\"1\" only)");
}
/* Class */
if (local_source[6] == ' ') {
strcpy(symbol->errtxt, "869: Invalid Class (cannot be space)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 869, "Invalid Class (cannot be space)");
}
/* Supply Chain ID */
if (cnt_digits(local_source, length, 7, 7) != 7) {
strcpy(symbol->errtxt, "870: Invalid Supply Chain ID (7 digits only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 870, "Invalid Supply Chain ID (7 digits only)");
}
/* Item ID */
if (cnt_digits(local_source, length, 14, 8) != 8) {
strcpy(symbol->errtxt, "871: Invalid Item ID (8 digits only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 871, "Invalid Item ID (8 digits only)");
}
/* Destination Post Code plus DPS field */
@ -638,14 +621,12 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
}
postcode[9] = '\0';
if (mailmark_verify_postcode(postcode, NULL) != 0) {
strcpy(symbol->errtxt, "872: Invalid Destination Post Code plus DPS");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 872, "Invalid Destination Post Code plus DPS");
}
/* Service Type */
if (local_source[31] < '0' || local_source[31] > '6') {
strcpy(symbol->errtxt, "873: Invalid Service Type (\"0\" to \"6\" only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 873, "Invalid Service Type (\"0\" to \"6\" only)");
}
/* Return to Sender Post Code */
@ -663,15 +644,13 @@ INTERNAL int mailmark_2d(struct zint_symbol *symbol, unsigned char source[], int
}
postcode[9] = '\0';
if (mailmark_verify_postcode(postcode, NULL) != 0) {
strcpy(symbol->errtxt, "874: Invalid Return to Sender Post Code");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 874, "Invalid Return to Sender Post Code");
}
}
/* Reserved */
if (memcmp(local_source + 39, " ", 6) != 0) {
strcpy(symbol->errtxt, "875: Invalid Reserved field (must be spaces only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 875, "Invalid Reserved field (must be spaces only)");
}
segs[0].eci = 0;

View file

@ -557,8 +557,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
lp = (int) strlen(symbol->primary);
if (lp == 0) {
if (mode == 0) { /* Require primary message to auto-determine between 2 and 3 */
strcpy(symbol->errtxt, "554: Primary Message empty");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 554, "Primary Message empty");
}
mode = 4;
} else {
@ -573,8 +572,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
}
if ((mode < 2) || (mode > 6)) { /* Only codes 2 to 6 supported */
strcpy(symbol->errtxt, "550: Invalid MaxiCode Mode");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 550, "Mode '%d' out of range (2 to 6)", mode);
}
if ((mode == 2) || (mode == 3)) { /* Modes 2 and 3 need data in symbol->primary */
@ -586,8 +584,11 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
lp = (int) strlen(symbol->primary);
}
if (lp < 7 || lp > 15) { /* 1 to 9 character postcode + 3 digit country code + 3 digit service class */
strcpy(symbol->errtxt, "551: Invalid length for Primary Message");
return ZINT_ERROR_INVALID_DATA;
if (lp == 0) {
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 548, "Primary Message empty");
}
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 551, "Primary Message length %d wrong (7 to 15 only)",
lp);
}
postcode_len = lp - 6;
@ -595,8 +596,8 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
service = to_int((const unsigned char *) (symbol->primary + postcode_len + 3), 3);
if (countrycode == -1 || service == -1) { /* check that country code and service are numeric */
strcpy(symbol->errtxt, "552: Non-numeric country code or service class in Primary Message");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 552,
"Non-numeric country code or service class in Primary Message");
}
memcpy(postcode, symbol->primary, postcode_len);
@ -609,8 +610,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
postcode_len = i;
break;
} else if (!z_isdigit(postcode[i])) {
strcpy(symbol->errtxt, "555: Non-numeric postcode in Primary Message");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 555, "Non-numeric postcode in Primary Message");
}
}
if (countrycode == 840 && postcode_len == 5) {
@ -631,8 +631,8 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
for (i = 0; i < 6; i++) {
/* Don't allow Code Set A control characters CR, RS, GS and RS */
if (postcode[i] < ' ' || maxiCodeSet[postcode[i]] > 1) {
strcpy(symbol->errtxt, "556: Invalid character in postcode in Primary Message");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 556,
"Invalid character in postcode in Primary Message");
}
}
maxi_do_primary_3(maxi_codeword, postcode, countrycode, service);
@ -640,8 +640,8 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
if (symbol->option_2) { /* Check for option_2 = vv + 1, where vv is version of SCM prefix "[)>\R01\Gvv" */
if (symbol->option_2 < 0 || symbol->option_2 > 100) {
strcpy(symbol->errtxt, "557: Invalid SCM prefix version");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 557,
"SCM prefix version '%d' out of range (1 to 100)", symbol->option_2);
}
scm_vv = symbol->option_2 - 1;
}
@ -659,24 +659,23 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
if (symbol->structapp.count) {
if (symbol->structapp.count < 2 || symbol->structapp.count > 8) {
strcpy(symbol->errtxt, "558: Structured Append count out of range (2-8)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 558,
"Structured Append count '%d' out of range (2 to 8)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "559: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 559,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
strcpy(symbol->errtxt, "549: Structured Append ID not available for MaxiCode");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 549, "Structured Append ID not available for MaxiCode");
}
structapp_cw = (symbol->structapp.count - 1) | ((symbol->structapp.index - 1) << 3);
}
error_number = maxi_text_process_segs(maxi_codeword, mode, segs, seg_count, structapp_cw, scm_vv, debug_print);
if (error_number == ZINT_ERROR_TOO_LONG) {
strcpy(symbol->errtxt, "553: Input data too long");
return error_number;
return errtxt(error_number, symbol, 553, "Input too long, requires too many codewords (maximum 144)");
}
/* All the data is sorted - now do error correction */

View file

@ -63,6 +63,7 @@ INTERNAL int pharma(struct zint_symbol *symbol, unsigned char source[], int leng
the specification at http://www.laetus.com/laetus.php?request=file&id=69
(http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf) */
int i;
int tester;
int counter, error_number = 0, h;
char inter[18] = {0}; /* 131070 -> 17 bits */
@ -71,18 +72,16 @@ INTERNAL int pharma(struct zint_symbol *symbol, unsigned char source[], int leng
char *d = dest;
if (length > 6) {
strcpy(symbol->errtxt, "350: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 350, "Input length %d too long (maximum 6)", length);
}
tester = to_int(source, length);
if (tester == -1) {
strcpy(symbol->errtxt, "351: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 351,
"Invalid character at position %d in input (digits only)", i);
}
tester = to_int(source, length);
if ((tester < 3) || (tester > 131070)) {
strcpy(symbol->errtxt, "352: Data out of range (3 to 131070)");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 352, "Input value '%d' out of range (3 to 131070)", tester);
}
do {
@ -152,6 +151,7 @@ static int pharma_two_calc(int tester, char *d) {
INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int length) {
/* Draws the patterns for two track pharmacode */
int i;
int tester;
char height_pattern[200];
unsigned int loopey, h;
@ -159,17 +159,16 @@ INTERNAL int pharma_two(struct zint_symbol *symbol, unsigned char source[], int
int error_number = 0;
if (length > 8) {
strcpy(symbol->errtxt, "354: Input too long (8 character maximum");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 354, "Input length %d too long (maximum 8)", length);
}
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 355,
"Invalid character at position %d in input (digits only)", i);
}
tester = to_int(source, length);
if (tester == -1) {
strcpy(symbol->errtxt, "355: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
}
if ((tester < 4) || (tester > 64570080)) {
strcpy(symbol->errtxt, "353: Data out of range (4 to 64570080)");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 353, "Input value '%d' out of range (4 to 64570080)", tester);
}
h = pharma_two_calc(tester, height_pattern);
@ -209,36 +208,32 @@ INTERNAL int codabar(struct zint_symbol *symbol, unsigned char source[], int len
int d_chars = 0;
if (length > 103) { /* No stack smashing please (103 + 1) * 11 = 1144 */
strcpy(symbol->errtxt, "356: Input too long (103 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 356, "Input length %d too long (maximum 103)", length);
}
/* BS EN 798:1995 4.2 "'Codabar' symbols shall consist of ... b) start character;
c) one or more symbol characters representing data ... d) stop character ..." */
if (length < 3) {
strcpy(symbol->errtxt, "362: Input too short (3 character minimum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 362, "Input length %d too short (minimum 3)", length);
}
to_upper(source, length);
/* Codabar must begin and end with the characters A, B, C or D */
if ((source[0] != 'A') && (source[0] != 'B') && (source[0] != 'C')
&& (source[0] != 'D')) {
strcpy(symbol->errtxt, "358: Does not begin with \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 358, "Does not begin with \"A\", \"B\", \"C\" or \"D\"");
}
if ((source[length - 1] != 'A') && (source[length - 1] != 'B') &&
(source[length - 1] != 'C') && (source[length - 1] != 'D')) {
strcpy(symbol->errtxt, "359: Does not end with \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 359, "Does not end with \"A\", \"B\", \"C\" or \"D\"");
}
if (!is_sane_lookup(CALCIUM, sizeof(CALCIUM) - 1, source, length, posns)) {
sprintf(symbol->errtxt, "357: Invalid character in data (\"%s\" only)", CALCIUM);
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(CALCIUM, sizeof(CALCIUM) - 1, source, length, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 357,
"Invalid character at position %1$d in input (\"%2$s\" only)", i, CALCIUM);
}
/* And must not use A, B, C or D otherwise (BS EN 798:1995 4.3.2) */
if (!is_sane(CALCIUM_INNER_F, source + 1, length - 2)) {
strcpy(symbol->errtxt, "363: Cannot contain \"A\", \"B\", \"C\" or \"D\"");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(CALCIUM_INNER_F, source + 1, length - 2))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 363,
"Invalid character at position %d in input (cannot contain \"A\", \"B\", \"C\" or \"D\")", i);
}
/* Add check character: 1 don't show to HRT, 2 do show to HRT
@ -301,17 +296,16 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
static const char TABELLA[] = "0123456789BCDFGHJKLMNPQRSTUVWXYZ";
int i, zeroes, error_number = 0, checksum, checkpart, checkdigit;
char localstr[10], risultante[7];
long int pharmacode, devisor;
unsigned int pharmacode, devisor;
int codeword[6];
/* Validate the input */
if (length > 8) {
strcpy(symbol->errtxt, "360: Input too long (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 360, "Input length %d too long (maximum 8)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "361: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 361,
"Invalid character at position %d in input (digits only)", i);
}
/* Add leading zeros as required */
@ -343,7 +337,7 @@ INTERNAL int code32(struct zint_symbol *symbol, unsigned char source[], int leng
/* Convert from decimal to base-32 */
devisor = 33554432;
for (i = 5; i >= 0; i--) {
long int remainder;
unsigned int remainder;
codeword[i] = pharmacode / devisor;
remainder = pharmacode % devisor;
pharmacode = remainder;

View file

@ -52,12 +52,12 @@ static int out_check_colour(struct zint_symbol *symbol, const char *colour, cons
if ((comma1 = strchr(colour, ',')) == NULL) {
const int len = (int) strlen(colour);
if ((len != 6) && (len != 8)) {
sprintf(symbol->errtxt, "880: Malformed %s RGB colour (6 or 8 characters only)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 880, "Malformed %s RGB colour (6 or 8 characters only)",
name);
}
if (!is_sane(OUT_SSET_F, (unsigned char *) colour, len)) {
sprintf(symbol->errtxt, "881: Malformed %s RGB colour '%s' (hexadecimal only)", name, colour);
return ZINT_ERROR_INVALID_OPTION;
if (not_sane(OUT_SSET_F, (unsigned char *) colour, len)) {
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 881,
"Malformed %1$s RGB colour '%2$s' (hexadecimal only)", name, colour);
}
return 0;
@ -66,29 +66,29 @@ static int out_check_colour(struct zint_symbol *symbol, const char *colour, cons
/* CMYK comma-separated percentages */
if ((comma2 = strchr(comma1 + 1, ',')) == NULL || (comma3 = strchr(comma2 + 1, ',')) == NULL
|| strchr(comma3 + 1, ',') != NULL) {
sprintf(symbol->errtxt, "882: Malformed %s CMYK colour (4 decimal numbers, comma-separated)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 882,
"Malformed %s CMYK colour (4 decimal numbers, comma-separated)", name);
}
if (comma1 - colour > 3 || comma2 - (comma1 + 1) > 3 || comma3 - (comma2 + 1) > 3 || strlen(comma3 + 1) > 3) {
sprintf(symbol->errtxt, "883: Malformed %s CMYK colour (3 digit maximum per number)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 883,
"Malformed %s CMYK colour (3 digit maximum per number)", name);
}
if ((val = to_int((const unsigned char *) colour, (int) (comma1 - colour))) == -1 || val > 100) {
sprintf(symbol->errtxt, "884: Malformed %s CMYK colour C (decimal 0-100 only)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 884, "Malformed %s CMYK colour C (decimal 0 to 100 only)",
name);
}
if ((val = to_int((const unsigned char *) (comma1 + 1), (int) (comma2 - (comma1 + 1)))) == -1 || val > 100) {
sprintf(symbol->errtxt, "885: Malformed %s CMYK colour M (decimal 0-100 only)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 885, "Malformed %s CMYK colour M (decimal 0 to 100 only)",
name);
}
if ((val = to_int((const unsigned char *) (comma2 + 1), (int) (comma3 - (comma2 + 1)))) == -1 || val > 100) {
sprintf(symbol->errtxt, "886: Malformed %s CMYK colour Y (decimal 0-100 only)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 886, "Malformed %s CMYK colour Y (decimal 0 to 100 only)",
name);
}
if ((val = to_int((const unsigned char *) (comma3 + 1), (int) strlen(comma3 + 1))) == -1 || val > 100) {
sprintf(symbol->errtxt, "887: Malformed %s CMYK colour K (decimal 0-100 only)", name);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 887, "Malformed %s CMYK colour K (decimal 0 to 100 only)",
name);
}
return 0;

View file

@ -86,8 +86,8 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
/* Open output file in binary mode */
if (!fm_open(fmp, symbol, "wb")) {
sprintf(symbol->errtxt, "621: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_ACCESS;
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 621, "Could not open PCX output file (%1$d: %2$s)", fmp->err,
strerror(fmp->err));
}
fm_write(&header, sizeof(pcx_header_t), 1, fmp);
@ -151,14 +151,14 @@ INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
}
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "622: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 622, "Incomplete write of PCX output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "624: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 624, "Failure on closing PCX output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return 0;

View file

@ -146,10 +146,12 @@ static const char pdf_MicroAutosize[56] = {
/* ISO/IEC 15438:2015 5.1.1 c) 3) Max possible number of characters at error correction level 0
(Numeric Compaction mode) */
#define PDF_MAX_LEN 2710
#define PDF_MAX_LEN_S "2710" /* String version of above */
#define PDF_MAX_STREAM_LEN (PDF_MAX_LEN * 3) /* Allow for tripling up due to shifts/latches (ticket #300 (#7)) */
/* ISO/IEC 24728:2006 5.1.1 c) 3) Max possible number of characters (Numeric Compaction mode) */
#define MICRO_PDF_MAX_LEN 366
#define MICRO_PDF_MAX_LEN_S "366" /* String version of above */
/* 866 */
/* Initial non-compressed categorization of input */
@ -1024,8 +1026,7 @@ static int pdf_initial(struct zint_symbol *symbol, const unsigned char chaine[],
pdf_appendix_d_encode(chaine, liste, &indexliste);
} else {
if (!pdf_define_mode(liste, &indexliste, chaine, length, *p_lastmode, debug_print)) {
strcpy(symbol->errtxt, "749: Insufficient memory for mode buffers");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 749, "Insufficient memory for mode buffers");
}
}
@ -1051,8 +1052,8 @@ static int pdf_initial(struct zint_symbol *symbol, const unsigned char chaine[],
if (eci != 0) {
if (eci > 811799) {
strcpy(symbol->errtxt, "472: Invalid ECI");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 472, "ECI code '%d' out of range (0 to 811799)",
symbol->eci);
}
/* Encoding ECI assignment number, according to Table 8 */
if (eci <= 899) {
@ -1125,12 +1126,13 @@ static int pdf_initial_segs(struct zint_symbol *symbol, struct zint_seg segs[],
int id_cnt = 0, ids[10];
if (symbol->structapp.count < 2 || symbol->structapp.count > 99999) {
strcpy(symbol->errtxt, "740: Structured Append count out of range (2-99999)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 740,
"Structured Append count '%d' out of range (2 to 99999)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "741: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 741,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
if (symbol->structapp.id[0]) {
int id_len;
@ -1138,21 +1140,21 @@ static int pdf_initial_segs(struct zint_symbol *symbol, struct zint_seg segs[],
for (id_len = 1; id_len < 31 && symbol->structapp.id[id_len]; id_len++);
if (id_len > 30) { /* 10 triplets */
strcpy(symbol->errtxt, "742: Structured Append ID too long (30 digit maximum)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 742,
"Structured Append ID length %d too long (30 digit maximum)", id_len);
}
for (i = 0; i < id_len; i += 3, id_cnt++) {
const int triplet_len = i + 3 < id_len ? 3 : id_len - i;
ids[id_cnt] = to_int((const unsigned char *) (symbol->structapp.id + i), triplet_len);
if (ids[id_cnt] == -1) {
strcpy(symbol->errtxt, "743: Invalid Structured Append ID (digits only)");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 743,
"Invalid Structured Append ID (digits only)");
}
if (ids[id_cnt] > 899) {
sprintf(symbol->errtxt, "744: Structured Append ID triplet %d '%03d' out of range (000-899)",
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 744,
"Structured Append ID triplet %1$d value '%2$03d' out of range (000 to 899)",
id_cnt + 1, ids[id_cnt]);
return ZINT_ERROR_INVALID_OPTION;
}
}
}
@ -1204,9 +1206,8 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
static const short ecc_num_cws[] = { 2, 4, 8, 16, 32, 64, 128, 256, 512 };
if (segs_length(segs, seg_count) > PDF_MAX_LEN) {
strcpy(symbol->errtxt, "463: Input string too long");
return ZINT_ERROR_TOO_LONG;
if ((i = segs_length(segs, seg_count)) > PDF_MAX_LEN) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 463, "Input length %d too long (maximum " PDF_MAX_LEN_S ")", i);
}
error_number = pdf_initial_segs(symbol, segs, seg_count, 0 /*is_micro*/, chainemc, &mclength, structapp_cws,
@ -1250,8 +1251,7 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
if (longueur > 928) {
/* Enforce maximum codeword limit */
strcpy(symbol->errtxt, "464: Input string too long");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 464, "Input too long, requires too many codewords (maximum 928)");
}
cols = symbol->option_2;
@ -1268,21 +1268,20 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
/* Increase rows if multiple too big */
for (; cols >= 1 && rows < 90 && rows * cols > 928; rows++, cols = (longueur + rows - 1) / rows);
if (rows * cols > 928) {
strcpy(symbol->errtxt, "465: Data too long for specified number of rows");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 465,
"Input too long, requires too many codewords (maximum 928)");
}
}
} else { /* Cols given */
/* Increase rows if multiple too big */
for (; rows <= 90 && rows * cols < longueur; rows++);
if (rows > 90 || rows * cols > 928) {
strcpy(symbol->errtxt, "745: Data too long for specified number of columns");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 745, "Input too long for number of columns '%d'", cols);
}
}
if (rows != symbol->option_3) {
sprintf(symbol->errtxt, "746: Rows increased from %d to %d", symbol->option_3, rows);
error_number = ZINT_WARN_INVALID_OPTION;
error_number = errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 746,
"Number of rows increased from %1$d to %2$d", symbol->option_3, rows);
}
} else { /* Rows automatic, cols automatic or given */
if (cols < 1) { /* Cols automatic */
@ -1299,12 +1298,12 @@ static int pdf_enc(struct zint_symbol *symbol, struct zint_seg segs[], const int
/* Increase cols if multiple too big */
for (; rows >= 3 && cols < 30 && rows * cols > 928; cols++, rows = (longueur + cols - 1) / cols);
if (rows * cols > 928) {
strcpy(symbol->errtxt, "747: Data too long for specified number of columns");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 747,
"Input too long, requires too many codewords (maximum 928)");
}
if (symbol->option_2 && cols != symbol->option_2) { /* Note previously did not warn if cols auto-upped */
sprintf(symbol->errtxt, "748: Columns increased from %d to %d", symbol->option_2, cols);
error_number = ZINT_WARN_INVALID_OPTION;
error_number = errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 748,
"Number of columns increased from %1$d to %2$d", symbol->option_2, cols);
}
}
}
@ -1450,30 +1449,28 @@ INTERNAL int pdf417(struct zint_symbol *symbol, struct zint_seg segs[], const in
error_number = 0;
if ((symbol->option_1 < -1) || (symbol->option_1 > 8)) {
errtxtf(0, symbol, 460, "Error correction level '%d' out of range (0 to 8)", symbol->option_1);
if (symbol->warn_level == WARN_FAIL_ALL) {
strcpy(symbol->errtxt, "462: Security value out of range (0 to 8)");
return ZINT_ERROR_INVALID_OPTION;
}
strcpy(symbol->errtxt, "460: Security value out of range (0 to 8), ignored");
error_number = errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring");
symbol->option_1 = -1;
error_number = ZINT_WARN_INVALID_OPTION;
}
if ((symbol->option_2 < 0) || (symbol->option_2 > 30)) {
errtxtf(0, symbol, 461, "Number of columns '%d' out of range (1 to 30)", symbol->option_2);
if (symbol->warn_level == WARN_FAIL_ALL) {
strcpy(symbol->errtxt, "473: Number of columns out of range (1 to 30)");
return ZINT_ERROR_INVALID_OPTION;
}
strcpy(symbol->errtxt, "461: Number of columns out of range (1 to 30), ignored");
error_number = errtxt_adj(ZINT_WARN_INVALID_OPTION, symbol, "%1$s%2$s", ", ignoring");
symbol->option_2 = 0;
error_number = ZINT_WARN_INVALID_OPTION;
}
if (symbol->option_3 && (symbol->option_3 < 3 || symbol->option_3 > 90)) {
strcpy(symbol->errtxt, "466: Number of rows out of range (3 to 90)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 466, "Number of rows '%d' out of range (3 to 90)",
symbol->option_3);
}
if (symbol->option_2 && symbol->option_3 && symbol->option_2 * symbol->option_3 > 928) {
strcpy(symbol->errtxt, "475: Columns x rows out of range (1 to 928)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 475, "Columns x rows value '%d' out of range (1 to 928)",
symbol->option_2 * symbol->option_3);
}
/* 349 */
@ -1500,14 +1497,15 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
int variant;
int LeftRAP, CentreRAP, RightRAP, Cluster, loop;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
/* From ISO/IEC 24728:2006 Table 1 — MicroPDF417 version characteristics */
static char col_max_codewords[5] = { 0, 20, 37, 82, 126 };
if (segs_length(segs, seg_count) > MICRO_PDF_MAX_LEN) {
strcpy(symbol->errtxt, "474: Input data too long");
return ZINT_ERROR_TOO_LONG;
if ((i = segs_length(segs, seg_count)) > MICRO_PDF_MAX_LEN) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 474, "Input length %d too long (maximum " MICRO_PDF_MAX_LEN_S ")",
i);
}
if (symbol->option_3) {
strcpy(symbol->errtxt, "476: Cannot specify rows for MicroPDF417");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 476, "Cannot specify rows for MicroPDF417");
}
/* Encoding starts out the same as PDF417, so use the same code */
@ -1521,16 +1519,17 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
/* This is where it all changes! */
if (mclength + structapp_cp > 126) {
strcpy(symbol->errtxt, "467: Input data too long");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 467, "Input too long, requires %d codewords (maximum 126)",
mclength + structapp_cp);
}
if (symbol->option_2 > 4) {
strcpy(symbol->errtxt, "468: Specified width out of range");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 471, "Number of columns '%d' out of range (1 to 4)",
symbol->option_2);
}
error_number = errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 468,
"Number of columns '%d' out of range (1 to 4), ignoring", symbol->option_2);
symbol->option_2 = 0;
error_number = ZINT_WARN_INVALID_OPTION;
}
if (debug_print) {
@ -1545,34 +1544,16 @@ INTERNAL int micropdf417(struct zint_symbol *symbol, struct zint_seg segs[], con
variant = 0;
if ((symbol->option_2 == 1) && (mclength + structapp_cp > 20)) {
/* the user specified 1 column but the data doesn't fit - go to automatic */
strcpy(symbol->errtxt, "469: Specified symbol size too small for data");
if (symbol->option_2 >= 1 && mclength + structapp_cp > col_max_codewords[symbol->option_2]) {
/* The user specified the column but the data doesn't fit - go to automatic */
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 469,
"Input too long for number of columns '%1$d', requires %2$d codewords (maximum %3$d)",
symbol->option_2, mclength + structapp_cp, col_max_codewords[symbol->option_2]);
}
error_number = errtxtf(ZINT_WARN_INVALID_OPTION, symbol, 470,
"Input too long for number of columns '%d', ignoring", symbol->option_2);
symbol->option_2 = 0;
error_number = ZINT_WARN_INVALID_OPTION;
}
if ((symbol->option_2 == 2) && (mclength + structapp_cp > 37)) {
/* the user specified 2 columns but the data doesn't fit - go to automatic */
strcpy(symbol->errtxt, "470: Specified symbol size too small for data");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
}
symbol->option_2 = 0;
error_number = ZINT_WARN_INVALID_OPTION;
}
if ((symbol->option_2 == 3) && (mclength + structapp_cp > 82)) {
/* the user specified 3 columns but the data doesn't fit - go to automatic */
strcpy(symbol->errtxt, "471: Specified symbol size too small for data");
if (symbol->warn_level == WARN_FAIL_ALL) {
return ZINT_ERROR_INVALID_OPTION;
}
symbol->option_2 = 0;
error_number = ZINT_WARN_INVALID_OPTION;
}
if (symbol->option_2 == 1) {

View file

@ -62,12 +62,11 @@ INTERNAL int plessey(struct zint_symbol *symbol, unsigned char source[], int len
int error_number = 0;
if (length > 67) { /* 16 + 67 * 16 + 4 * 8 + 19 = 1139 */
strcpy(symbol->errtxt, "370: Input too long (67 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 370, "Input length %d too long (maximum 67)", length);
}
if (!is_sane(SSET_F, source, length)) {
strcpy(symbol->errtxt, "371: Invalid character in data (digits and \"ABCDEF\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(SSET_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 371,
"Invalid character at position %d in input (digits and \"ABCDEF\" only)", i);
}
/* Start character */
@ -308,18 +307,18 @@ static char *msi_plessey_mod1110(struct zint_symbol *symbol, const unsigned char
INTERNAL int msi_plessey(struct zint_symbol *symbol, unsigned char source[], int length) {
int error_number = 0;
int i;
char dest[766]; /* 2 + 92 * 8 + 3 * 8 + 3 + 1 = 766 */
char *d = dest;
int check_option = symbol->option_2;
int no_checktext = 0;
if (length > 92) { /* 3 (Start) + 92 * 12 + 3 * 12 + 4 (Stop) = 1147 */
strcpy(symbol->errtxt, "372: Input too long (92 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 372, "Input length %d too long (maximum 92)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "377: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 377,
"Invalid character at position %d in input (digits only)", i);
}
if (check_option >= 11 && check_option <= 16) { /* +10 means don't print check digits in HRT */

View file

@ -1,7 +1,7 @@
/* png.c - Handles output to PNG file */
/*
libzint - the open source barcode library
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -61,7 +61,7 @@ static void wpng_error_handler(png_structp png_ptr, png_const_charp msg) {
fflush(stderr);
return; /* libpng will call abort() */
}
sprintf(wpng_error_ptr->symbol->errtxt, "635: libpng error: %.60s", msg ? msg : "<NULL>");
errtxtf(0, wpng_error_ptr->symbol, 635, "libpng error: %s", msg ? msg : "<NULL>");
longjmp(wpng_error_ptr->jmpbuf, 1);
}
@ -212,24 +212,22 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
/* Open output file in binary mode */
if (!fm_open(fmp, symbol, "wb")) {
sprintf(symbol->errtxt, "632: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_ACCESS;
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 632, "Could not open PNG output file (%1$d: %2$s)", fmp->err,
strerror(fmp->err));
}
/* Set up error handling routine as proc() above */
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &wpng_error, wpng_error_handler, NULL);
if (!png_ptr) {
strcpy(symbol->errtxt, "633: Insufficient memory for PNG write structure buffer");
(void) fm_close(fmp, symbol);
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 633, "Insufficient memory for PNG write structure buffer");
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_write_struct(&png_ptr, NULL);
strcpy(symbol->errtxt, "634: Insufficient memory for PNG info structure buffer");
(void) fm_close(fmp, symbol);
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 634, "Insufficient memory for PNG info structure buffer");
}
/* catch jumping here */
@ -314,14 +312,14 @@ INTERNAL int png_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
png_destroy_write_struct(&png_ptr, &info_ptr);
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "638: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 638, "Incomplete write of PNG output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "960: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 960, "Failure on closing PNG output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return 0;

View file

@ -125,7 +125,7 @@ static int usps_set_height(struct zint_symbol *symbol, const int no_errtxt) {
if (symbol->height < 4.6f || symbol->height > 9.0f) {
error_number = ZINT_WARN_NONCOMPLIANT;
if (!no_errtxt) {
strcpy(symbol->errtxt, "498: Height not compliant with standards");
errtxt(0, symbol, 498, "Height not compliant with standards");
}
}
}
@ -143,24 +143,23 @@ static int postnet_enc(struct zint_symbol *symbol, const unsigned char source[],
int error_number = 0;
if (length > 38) {
strcpy(symbol->errtxt, "480: Input too long (38 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 480, "Input length %d too long (maximum 38)", length);
}
if (symbol->symbology == BARCODE_CEPNET) {
if (length != 8) {
strcpy(symbol->errtxt, "780: Input is wrong length (should be 8 digits)");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 780, "Input length %d wrong (should be 8 digits)",
length);
}
} else {
if (length != 5 && length != 9 && length != 11) {
strcpy(symbol->errtxt, "479: Input length is not standard (5, 9 or 11 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 479,
"Input length %d is not standard (5, 9 or 11)", length);
}
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "481: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 481,
"Invalid character at position %d in input (digits only)", i);
}
sum = 0;
@ -187,7 +186,8 @@ static int postnet_enc(struct zint_symbol *symbol, const unsigned char source[],
/* Puts POSTNET barcodes into the pattern matrix */
INTERNAL int postnet(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
/* Suppress clang-tidy-20 garbage value false positive by initializing (see "vector.c" `vection_add_rect()`) */
char height_pattern[256] = {0}; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
unsigned int loopey, h;
int writer;
int error_number, warn_number;
@ -219,16 +219,15 @@ static int planet_enc(struct zint_symbol *symbol, const unsigned char source[],
int error_number = 0;
if (length > 38) {
strcpy(symbol->errtxt, "482: Input too long (38 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 482, "Input length %d too long (maximum 38)", length);
}
if (length != 11 && length != 13) {
strcpy(symbol->errtxt, "478: Input length is not standard (11 or 13 characters)");
error_number = ZINT_WARN_NONCOMPLIANT;
error_number = errtxtf(ZINT_WARN_NONCOMPLIANT, symbol, 478, "Input length %d is not standard (11 or 13)",
length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "483: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 483,
"Invalid character at position %d in input (digits only)", i);
}
sum = 0;
@ -255,7 +254,8 @@ static int planet_enc(struct zint_symbol *symbol, const unsigned char source[],
/* Puts PLANET barcodes into the pattern matrix */
INTERNAL int planet(struct zint_symbol *symbol, unsigned char source[], int length) {
char height_pattern[256]; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
/* Suppress clang-tidy-20 garbage value false positive by initializing (see "vector.c" `vection_add_rect()`) */
char height_pattern[256] = {0}; /* 5 + 38 * 5 + 5 + 5 + 1 = 206 */
unsigned int loopey, h;
int writer;
int error_number, warn_number;
@ -283,27 +283,26 @@ INTERNAL int planet(struct zint_symbol *symbol, unsigned char source[], int leng
/* Korean Postal Authority */
INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int length) {
int total, loop, check, zeroes, error_number = 0;
int total, i, check, zeroes, error_number = 0;
char localstr[8], dest[80];
char *d = dest;
int posns[6];
if (length > 6) {
strcpy(symbol->errtxt, "484: Input too long (6 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 484, "Input length %d too long (maximum 6)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "485: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 485,
"Invalid character at position %d in input (digits only)", i);
}
zeroes = 6 - length;
memset(localstr, '0', zeroes);
ustrcpy(localstr + zeroes, source);
total = 0;
for (loop = 0; loop < 6; loop++) {
posns[loop] = ctoi(localstr[loop]);
total += posns[loop];
for (i = 0; i < 6; i++) {
posns[i] = ctoi(localstr[i]);
total += posns[i];
}
check = 10 - (total % 10);
if (check == 10) {
@ -312,8 +311,8 @@ INTERNAL int koreapost(struct zint_symbol *symbol, unsigned char source[], int l
localstr[6] = itoc(check);
localstr[7] = '\0';
for (loop = 5; loop >= 0; loop--) {
const char *const entry = KoreaTable[posns[loop]];
for (i = 5; i >= 0; i--) {
const char *const entry = KoreaTable[posns[i]];
memcpy(d, entry, 10);
d += entry[8] ? 10 : 8;
}
@ -335,8 +334,7 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
int error_number = 0;
if (length > 1) {
strcpy(symbol->errtxt, "486: Input too long (1 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 486, "Input length %d too long (maximum 1)", length);
}
switch ((char) source[0]) {
@ -361,8 +359,8 @@ INTERNAL int fim(struct zint_symbol *symbol, unsigned char source[], int length)
expand(symbol, "1317131", 7);
break;
default:
strcpy(symbol->errtxt, "487: Invalid character in data (\"A\", \"B\", \"C\", \"D\" or \"E\" only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 487,
"Invalid character in input (\"A\", \"B\", \"C\", \"D\" or \"E\" only)");
break;
}
@ -406,8 +404,7 @@ INTERNAL int daft_set_height(struct zint_symbol *symbol, const float min_height,
if (symbol->output_options & COMPLIANT_HEIGHT) {
if ((min_height && symbol->height < min_height) || (max_height && symbol->height > max_height)) {
error_number = ZINT_WARN_NONCOMPLIANT;
strcpy(symbol->errtxt, "499: Height not compliant with standards");
error_number = errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 499, "Height not compliant with standards");
}
}
@ -453,6 +450,7 @@ static void rm4scc_enc(const struct zint_symbol *symbol, const int *posns, char
/* Puts RM4SCC into the data matrix */
INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
char height_pattern[210];
int posns[50];
int loopey, h;
@ -460,13 +458,12 @@ INTERNAL int rm4scc(struct zint_symbol *symbol, unsigned char source[], int leng
int error_number = 0;
if (length > 50) {
strcpy(symbol->errtxt, "488: Input too long (50 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 488, "Input length %d too long (maximum 50)", length);
}
to_upper(source, length);
if (!is_sane_lookup(KRSET, 36, source, length, posns)) {
strcpy(symbol->errtxt, "489: Invalid character in data (alphanumerics only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(KRSET, 36, source, length, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 489,
"Invalid character at position %d in input (alphanumerics only)", i);
}
rm4scc_enc(symbol, posns, height_pattern, length);
@ -519,13 +516,12 @@ INTERNAL int kix(struct zint_symbol *symbol, unsigned char source[], int length)
int error_number = 0;
if (length > 18) {
strcpy(symbol->errtxt, "490: Input too long (18 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 490, "Input length %d too long (maximum 18)", length);
}
to_upper(source, length);
if (!is_sane_lookup(KRSET, 36, source, length, posns)) {
strcpy(symbol->errtxt, "491: Invalid character in data (alphanumerics only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(KRSET, 36, source, length, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 491,
"Invalid character at position %d in input (alphanumerics only)", i);
}
/* Encode data */
@ -567,19 +563,19 @@ INTERNAL int kix(struct zint_symbol *symbol, unsigned char source[], int length)
/* Handles DAFT Code symbols */
INTERNAL int daft(struct zint_symbol *symbol, unsigned char source[], int length) {
int i;
int posns[576];
int loopey;
int writer;
if (length > 576) { /* 576 * 2 = 1152 */
strcpy(symbol->errtxt, "492: Input too long (576 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 492, "Input length %d too long (maximum 576)", length);
}
to_upper(source, length);
if (!is_sane_lookup(DAFTSET, 4, source, length, posns)) {
strcpy(symbol->errtxt, "493: Invalid character in data (\"D\", \"A\", \"F\" and \"T\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane_lookup(DAFTSET, 4, source, length, posns))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 493,
"Invalid character at position %d in input (\"D\", \"A\", \"F\" and \"T\" only)", i);
}
writer = 0;
@ -617,21 +613,20 @@ INTERNAL int daft(struct zint_symbol *symbol, unsigned char source[], int length
/* Flattermarken - Not really a barcode symbology! */
INTERNAL int flat(struct zint_symbol *symbol, unsigned char source[], int length) {
int loop, error_number = 0;
int i, error_number = 0;
char dest[512]; /* 128 * 4 = 512 */
char *d = dest;
if (length > 128) { /* 128 * 9 = 1152 */
strcpy(symbol->errtxt, "494: Input too long (128 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 494, "Input length %d too long (maximum 128)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "495: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 495,
"Invalid character at position %d in input (digits only)", i);
}
for (loop = 0; loop < length; loop++) {
const char *const entry = FlatTable[source[loop] - '0'];
for (i = 0; i < length; i++) {
const char *const entry = FlatTable[source[i] - '0'];
memcpy(d, entry, 4);
d += entry[2] ? 4 : 2;
}
@ -653,15 +648,14 @@ INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int l
char inter[20 + 1];
if (length > 20) {
strcpy(symbol->errtxt, "496: Input too long (20 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 496, "Input length %d too long (maximum 20)", length);
}
to_upper(source, length);
if (!is_sane(SHKASUTSET_F, source, length)) {
strcpy(symbol->errtxt, "497: Invalid character in data (alphanumerics and \"-\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(SHKASUTSET_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 497,
"Invalid character at position %d in input (alphanumerics and \"-\" only)", i);
}
memset(inter, 'd', 20); /* Pad character CC4 */
inter[20] = '\0';
@ -689,8 +683,8 @@ INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int l
} while ((i < length) && (inter_posn < 20));
if (i != length || inter[20] != '\0') {
strcpy(symbol->errtxt, "477: Input too long (20 symbol character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxt(ZINT_ERROR_TOO_LONG, symbol, 477,
"Input too long, requires too many symbol characters (maximum 20)");
}
memcpy(d, "13", 2); /* Start */

View file

@ -178,7 +178,6 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
float red_paper = 0.0f, green_paper = 0.0f, blue_paper = 0.0f;
float cyan_ink = 0.0f, magenta_ink = 0.0f, yellow_ink = 0.0f, black_ink = 0.0f;
float cyan_paper = 0.0f, magenta_paper = 0.0f, yellow_paper = 0.0f, black_paper = 0.0f;
int error_number = 0;
float previous_diameter;
float radius;
int colour_rect_flag;
@ -196,12 +195,11 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
const int is_rgb = (symbol->output_options & CMYK_COLOUR) == 0;
if (symbol->vector == NULL) {
strcpy(symbol->errtxt, "646: Vector header NULL");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 646, "Vector header NULL");
}
if (!fm_open(fmp, symbol, "w")) {
sprintf(symbol->errtxt, "645: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_ACCESS;
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 645, "Could not open EPS output file (%1$d: %2$s)", fmp->err,
strerror(fmp->err));
}
if (is_rgb) {
@ -509,17 +507,17 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
}
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "647: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 647, "Incomplete write of EPS output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "649: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 649, "Failure on closing EPS output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return error_number;
return 0;
}
/* vim: set ts=4 sw=4 et : */

File diff suppressed because it is too large Load diff

View file

@ -43,32 +43,27 @@ static const signed char qr_alphanumeric[59] = {
};
/* From ISO/IEC 18004:2015 Table 7 - Number of symbol characters and input data capacity for QR Code */
static const unsigned short qr_data_codewords_L[40] = {
19, 34, 55, 80, 108, 136, 156, 194, 232, 274,
static const unsigned short qr_data_codewords[4][40] = { {
19, 34, 55, 80, 108, 136, 156, 194, 232, 274, /* L */
324, 370, 428, 461, 523, 589, 647, 721, 795, 861,
932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631, 1735,
1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
};
static const unsigned short qr_data_codewords_M[40] = {
16, 28, 44, 64, 86, 108, 124, 154, 182, 216,
}, {
16, 28, 44, 64, 86, 108, 124, 154, 182, 216, /* M */
254, 290, 334, 365, 415, 453, 507, 563, 627, 669,
714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267, 1373,
1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
};
static const unsigned short qr_data_codewords_Q[40] = {
13, 22, 34, 48, 62, 76, 88, 110, 132, 154,
}, {
13, 22, 34, 48, 62, 76, 88, 110, 132, 154, /* Q */
180, 206, 244, 261, 295, 325, 367, 397, 445, 485,
512, 568, 614, 664, 718, 754, 808, 871, 911, 985,
1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
};
static const unsigned short qr_data_codewords_H[40] = {
9, 16, 26, 36, 46, 60, 66, 86, 100, 122,
}, {
9, 16, 26, 36, 46, 60, 66, 86, 100, 122, /* H */
140, 158, 180, 197, 223, 253, 283, 313, 341, 385,
406, 442, 464, 514, 538, 596, 628, 661, 701, 745,
793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
}
};
/* From ISO/IEC 18004:2015 Table 1 - Codeword capacity of all versions of QRCode */
@ -99,22 +94,21 @@ static const unsigned char rmqr_width[32] = {
};
/* From ISO/IEC 23941:2022 Table 6 - Number of data codewords and input data capacity for rMQR */
static const unsigned char rmqr_data_codewords_M[32] = {
6, 12, 20, 28, 44, /* R7x */
static const unsigned char rmqr_data_codewords[2][32] = { {
6, 12, 20, 28, 44, /* R7x */ /* M */
12, 21, 31, 42, 63, /* R9x */
7, 19, 31, 43, 57, 84, /* R11x */
12, 27, 38, 53, 73, 106, /* R13x */
33, 48, 67, 88, 127, /* R15x */
39, 56, 78, 100, 152 /* R17x */
};
static const unsigned char rmqr_data_codewords_H[32] = {
3, 7, 10, 14, 24, /* R7x */
}, {
3, 7, 10, 14, 24, /* R7x */ /* H */
7, 11, 17, 22, 33, /* R9x */
5, 11, 15, 23, 29, 42, /* R11x */
7, 13, 20, 29, 35, 54, /* R13x */
15, 26, 31, 48, 69, /* R15x */
21, 28, 38, 56, 76 /* R17x */
}
};
/* Highest index in `rmqr_total_codewords` for each given row (R7x, R9x etc) */
@ -170,51 +164,45 @@ static const unsigned char rmqr_kanji_cci[32] = {
};
/* From ISO/IEC 18004:2015 Table 9 - Error correction characteristics for QR Code */
static const char qr_blocks_L[40] = {
1, 1, 1, 1, 1, 2, 2, 2, 2, 4,
static const char qr_blocks[4][40] = { {
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, /* L */
4, 4, 4, 4, 6, 6, 6, 6, 7, 8,
8, 9, 9, 10, 12, 12, 12, 13, 14, 15,
16, 17, 18, 19, 19, 20, 21, 22, 24, 25
};
static const char qr_blocks_M[40] = {
1, 1, 1, 2, 2, 4, 4, 4, 5, 5,
}, {
1, 1, 1, 2, 2, 4, 4, 4, 5, 5, /* M */
5, 8, 9, 9, 10, 10, 11, 13, 14, 16,
17, 17, 18, 20, 21, 23, 25, 26, 28, 29,
31, 33, 35, 37, 38, 40, 43, 45, 47, 49
};
static const char qr_blocks_Q[40] = {
1, 1, 2, 2, 4, 4, 6, 6, 8, 8,
}, {
1, 1, 2, 2, 4, 4, 6, 6, 8, 8, /* Q */
8, 10, 12, 16, 12, 17, 16, 18, 21, 20,
23, 23, 25, 27, 29, 34, 34, 35, 38, 40,
43, 45, 48, 51, 53, 56, 59, 62, 65, 68
};
static const char qr_blocks_H[40] = {
1, 1, 2, 4, 4, 4, 5, 6, 8, 8,
}, {
1, 1, 2, 4, 4, 4, 5, 6, 8, 8, /* H */
11, 11, 16, 16, 18, 16, 19, 21, 25, 25,
25, 34, 30, 32, 35, 37, 40, 42, 45, 48,
51, 54, 57, 60, 63, 66, 70, 74, 77, 81
}
};
/* From ISO/IEC 23941:2022 Table 8 - Error correction characteristics for rMQR */
static const char rmqr_blocks_M[32] = {
1, 1, 1, 1, 1, /* R7x */
static const char rmqr_blocks[2][32] = { {
1, 1, 1, 1, 1, /* R7x */ /* M */
1, 1, 1, 1, 2, /* R9x */
1, 1, 1, 1, 2, 2, /* R11x */
1, 1, 1, 2, 2, 3, /* R13x */
1, 1, 2, 2, 3, /* R15x */
1, 2, 2, 3, 4 /* R17x */
};
static const char rmqr_blocks_H[32] = {
1, 1, 1, 1, 2, /* R7x */
}, {
1, 1, 1, 1, 2, /* R7x */ /* H */
1, 1, 2, 2, 3, /* R9x */
1, 1, 2, 2, 2, 3, /* R11x */
1, 1, 2, 2, 3, 4, /* R13x */
2, 2, 3, 4, 5, /* R15x */
2, 2, 3, 4, 6 /* R17x */
}
};
/* From ISO/IEC 18004:2015 Table 1 - Codeword capacity of all versions of QR Code */
@ -225,10 +213,22 @@ static const unsigned char qr_sizes[40] = {
141, 145, 149, 153, 157, 161, 165, 169, 173, 177
};
static const char micro_qr_sizes[4] = {
static const char microqr_sizes[4] = {
11, 13, 15, 17
};
/* From ISO/IEC 18004:2015 Table 7 - Number of symbol characters and input data capacity for QR Code and
Table 9 Error correction characteristics for QR Code, M1-4 only, indexed by ecc_level & version as
{ data bits, data codewords, ecc codewords } */
static const unsigned char microqr_data[3][4][3] = { {
{ 20, 3, 2 }, { 40, 5, 5 }, { 84, 11, 6 }, { 128, 16, 8 } /* L */
}, {
{ 0, 0, 0 }, { 32, 4, 6 }, { 68, 9, 8 }, { 112, 14, 10 } /* M */
}, {
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 80, 10, 14 } /* Q */
}
};
/* No. of entries in `qr_table_e1` (Table E.1) per version */
static const char qr_align_loopsize[40] = {
0, 2, 2, 2, 2, 2, 3, 3, 3, 3,

View file

@ -113,15 +113,13 @@ static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf
}
if (!(symbol->bitmap = (unsigned char *) raster_malloc(bm_bitmap_size, 0 /*prev_size*/))) {
strcpy(symbol->errtxt, "661: Insufficient memory for bitmap buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 661, "Insufficient memory for bitmap buffer");
}
if (plot_alpha) {
const size_t alpha_size = (size_t) symbol->bitmap_width * symbol->bitmap_height;
if (!(symbol->alphamap = (unsigned char *) raster_malloc(alpha_size, bm_bitmap_size))) {
strcpy(symbol->errtxt, "662: Insufficient memory for alphamap buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 662, "Insufficient memory for alphamap buffer");
}
for (row = 0; row < symbol->bitmap_height; row++) {
size_t p = (size_t) symbol->bitmap_width * row;
@ -182,8 +180,7 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, const int image
if (rotate_angle) {
if (!(rotated_pixbuf = (unsigned char *) raster_malloc((size_t) image_width * image_height,
0 /*prev_size*/))) {
strcpy(symbol->errtxt, "650: Insufficient memory for pixel buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 650, "Insufficient memory for pixel buffer");
}
}
@ -783,16 +780,14 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang
image_size = (size_t) image_width * image_height;
if (!(pixelbuf = (unsigned char *) raster_malloc(image_size, 0 /*prev_size*/))) {
strcpy(symbol->errtxt, "655: Insufficient memory for pixel buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 655, "Insufficient memory for pixel buffer");
}
memset(pixelbuf, DEFAULT_PAPER, image_size);
hex_size = (size_t) hex_width * hex_height;
if (!(scaled_hexagon = (unsigned char *) raster_malloc(hex_size, image_size))) {
strcpy(symbol->errtxt, "656: Insufficient memory for pixel buffer");
free(pixelbuf);
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 656, "Insufficient memory for pixel buffer");
}
memset(scaled_hexagon, DEFAULT_PAPER, hex_size);
@ -828,8 +823,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang
const float max_ratio = 1.177984f; /* 27.93 / 23.71 */
const float size_ratio = (float) hex_image_width / hex_image_height;
if (size_ratio < min_ratio || size_ratio > max_ratio) {
strcpy(symbol->errtxt, "663: Size not within the minimum/maximum ranges");
error_number = ZINT_WARN_NONCOMPLIANT;
return errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 663, "Size not within the minimum/maximum ranges");
}
}
return error_number;
@ -879,8 +873,7 @@ static int plot_raster_dotty(struct zint_symbol *symbol, const int rotate_angle,
/* Apply scale options by creating pixel buffer */
if (!(scaled_pixelbuf = (unsigned char *) raster_malloc(scale_size, 0 /*prev_size*/))) {
strcpy(symbol->errtxt, "657: Insufficient memory for pixel buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 657, "Insufficient memory for pixel buffer");
}
memset(scaled_pixelbuf, DEFAULT_PAPER, scale_size);
@ -1045,8 +1038,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
image_size = (size_t) image_width * image_height;
if (!(pixelbuf = (unsigned char *) raster_malloc(image_size, 0 /*prev_size*/))) {
strcpy(symbol->errtxt, "658: Insufficient memory for pixel buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 658, "Insufficient memory for pixel buffer");
}
memset(pixelbuf, DEFAULT_PAPER, image_size);
@ -1373,8 +1365,7 @@ static int plot_raster_default(struct zint_symbol *symbol, const int rotate_angl
/* Apply scale options by creating another pixel buffer */
if (!(scaled_pixelbuf = (unsigned char *) raster_malloc((size_t) scale_width * scale_height, image_size))) {
free(pixelbuf);
strcpy(symbol->errtxt, "659: Insufficient memory for scaled pixel buffer");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 659, "Insufficient memory for scaled pixel buffer");
}
memset(scaled_pixelbuf, DEFAULT_PAPER, (size_t) scale_width * scale_height);
@ -1414,8 +1405,7 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_
#ifdef ZINT_NO_PNG
if (file_type == OUT_PNG_FILE) {
strcpy(symbol->errtxt, "660: PNG format disabled at compile time");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 660, "PNG format disabled at compile time");
}
#endif /* ZINT_NO_PNG */
@ -1424,8 +1414,7 @@ INTERNAL int plot_raster(struct zint_symbol *symbol, int rotate_angle, int file_
return error;
}
if (symbol->rows <= 0) {
strcpy(symbol->errtxt, "664: No rows");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 664, "No rows");
}
if (symbol->symbology == BARCODE_MAXICODE) {

View file

@ -247,7 +247,6 @@ static void dbar_omn_separator(struct zint_symbol *symbol, int width, const int
/* Set Databar Stacked height, maintaining 5:7 ratio of the 2 main row heights */
INTERNAL int dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_row) {
int error_number = 0;
float fixed_height = 0.0f;
int second_row = first_row + 2; /* 2 row separator */
int i;
@ -274,12 +273,11 @@ INTERNAL int dbar_omnstk_set_height(struct zint_symbol *symbol, const int first_
if (symbol->output_options & COMPLIANT_HEIGHT) {
if (symbol->row_height[first_row] < 5.0f || symbol->row_height[second_row] < 7.0f) {
error_number = ZINT_WARN_NONCOMPLIANT;
strcpy(symbol->errtxt, "379: Height not compliant with standards");
return errtxt(ZINT_WARN_NONCOMPLIANT, symbol, 379, "Height not compliant with standards");
}
}
return error_number;
return 0;
}
/* GS1 DataBar Omnidirectional/Truncated/Stacked, allowing for composite if `cc_rows` set */
@ -296,19 +294,17 @@ INTERNAL int dbar_omn_cc(struct zint_symbol *symbol, unsigned char source[], int
separator_row = 0;
if (length > 14) { /* Allow check digit to be specified (will be verified and ignored) */
strcpy(symbol->errtxt, "380: Input too long (14 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 380, "Input length %d too long (maximum 14)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "381: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 381,
"Invalid character at position %d in input (digits only)", i);
}
if (length == 14) { /* Verify check digit */
if (gs1_check_digit(source, 13) != source[13]) {
sprintf(symbol->errtxt, "388: Invalid check digit '%c', expecting '%c'",
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 388, "Invalid check digit '%1$c', expecting '%2$c'",
source[13], gs1_check_digit(source, 13));
return ZINT_ERROR_INVALID_CHECK;
}
length--; /* Ignore */
}
@ -633,27 +629,24 @@ INTERNAL int dbar_ltd_cc(struct zint_symbol *symbol, unsigned char source[], int
separator_row = 0;
if (length > 14) { /* Allow check digit to be specified (will be verified and ignored) */
strcpy(symbol->errtxt, "382: Input too long (14 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 382, "Input length %d too long (maximum 14)", length);
}
if (!is_sane(NEON_F, source, length)) {
strcpy(symbol->errtxt, "383: Invalid character in data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(NEON_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 383,
"Invalid character at position %d in input (digits only)", i);
}
if (length == 14) { /* Verify check digit */
if (gs1_check_digit(source, 13) != source[13]) {
sprintf(symbol->errtxt, "389: Invalid check digit '%c', expecting '%c'",
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 389, "Invalid check digit '%1$c', expecting '%2$c'",
source[13], gs1_check_digit(source, 13));
return ZINT_ERROR_INVALID_CHECK;
}
length--; /* Ignore */
}
if (length == 13) {
if ((source[0] != '0') && (source[0] != '1')) {
strcpy(symbol->errtxt, "384: Input out of range (0 to 1999999999999)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 384, "Input value out of range (0 to 1999999999999)");
}
}
@ -842,6 +835,11 @@ static int dbar_exp_binary_string(struct zint_symbol *symbol, const unsigned cha
int remainder, d1, d2;
int cdf_bp_start; /* Compressed data field start - debug only */
if (length > 77) { /* ISO/IEC 24724:2011 4.2.d.2 */
/* Caught below anyway but catch here also for better feedback */
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 378, "Processed input length %d too long (maximum 77)", length);
}
/* Decide whether a compressed data field is required and if so what
method to use - method 2 = no compressed data field */
@ -968,8 +966,8 @@ static int dbar_exp_binary_string(struct zint_symbol *symbol, const unsigned cha
if (!z_isdigit(source[i])) {
if (source[i] != '\x1D') {
/* Something is wrong */
strcpy(symbol->errtxt, "385: Invalid character in Compressed Field data (digits only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 385,
"Invalid character in Compressed Field data (digits only)");
}
}
}
@ -1064,8 +1062,7 @@ static int dbar_exp_binary_string(struct zint_symbol *symbol, const unsigned cha
if (j != 0) { /* If general field not empty */
if (!general_field_encode(general_field, j, &mode, &last_digit, binary_string, &bp)) {
/* Will happen if character not in CSET 82 + space */
strcpy(symbol->errtxt, "386: Invalid character in General Field data");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 386, "Invalid character in General Field data");
}
}
@ -1134,8 +1131,8 @@ static int dbar_exp_binary_string(struct zint_symbol *symbol, const unsigned cha
}
if (bp > 252) { /* 252 = (21 * 12) */
strcpy(symbol->errtxt, "387: Input too long"); /* TODO: Better error message */
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 387, /* TODO: Better error message */
"Input too long, requires %d symbol characters (maximum 21)", (bp + 11) / 12);
}
if (min_cols_per_row && min_cols_per_row > *p_cols_per_row) {

View file

@ -1,7 +1,7 @@
/* svg.c - Scalable Vector Graphics */
/*
libzint - the open source barcode library
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -117,7 +117,6 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
static const char upcean_font_family[] = "OCRB";
struct filemem fm;
struct filemem *const fmp = &fm;
int error_number = 0;
float previous_diameter;
float radius, half_radius, half_sqrt3_radius;
int i;
@ -173,12 +172,11 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
/* Check for no created vector set */
/* E-Mail Christian Schmitz 2019-09-10: reason unknown Ticket #164 */
if (symbol->vector == NULL) {
strcpy(symbol->errtxt, "681: Vector header NULL");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 681, "Vector header NULL");
}
if (!fm_open(fmp, symbol, "w")) {
sprintf(symbol->errtxt, "680: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_ACCESS;
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 680, "Could not open SVG output file (%1$d: %2$s)", fmp->err,
strerror(fmp->err));
}
/* Start writing the header */
@ -346,17 +344,17 @@ INTERNAL int svg_plot(struct zint_symbol *symbol) {
"</svg>\n", fmp);
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "682: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 682, "Incomplete write to SVG output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "684: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 684, "Failure on closing SVG output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return error_number;
return 0;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1,7 +1,7 @@
/* telepen.c - Handles Telepen and Telepen numeric */
/*
libzint - the open source barcode library
Copyright (C) 2008-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -86,7 +86,7 @@ static const char TeleLens[128] = {
12, 10, 8, 14, 10, 12, 12, 12, 10, 14, 12, 12, 14, 12, 12, 16
};
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src_len) {
INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int length) {
int i, count, check_digit;
int error_number;
char dest[1145]; /* 12 (Start) + 69 * 16 (max for DELs) + 16 (Check) + 12 (stop) + 1 = 1145 */
@ -96,19 +96,18 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src
count = 0;
if (src_len > 69) { /* 16 (Start) + 69 * 16 + 16 (Check) + 16 (Stop) = 1152 */
strcpy(symbol->errtxt, "390: Input too long (69 character maximum)");
return ZINT_ERROR_TOO_LONG;
if (length > 69) { /* 16 (Start) + 69 * 16 + 16 (Check) + 16 (Stop) = 1152 */
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 390, "Input length %d too long (maximum 69)", length);
}
/* Start character */
memcpy(d, TeleTable['_'], 12);
d += 12;
for (i = 0; i < src_len; i++) {
for (i = 0; i < length; i++) {
if (source[i] > 127) {
/* Cannot encode extended ASCII */
strcpy(symbol->errtxt, "391: Invalid character in input data, extended ASCII not allowed");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 391,
"Invalid character at position %d in input, extended ASCII not allowed", i + 1);
}
memcpy(d, TeleTable[source[i]], TeleLens[source[i]]);
d += TeleLens[source[i]];
@ -138,18 +137,18 @@ INTERNAL int telepen(struct zint_symbol *symbol, unsigned char source[], int src
(void) set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/);
}
for (i = 0; i < src_len; i++) {
for (i = 0; i < length; i++) {
if (source[i] == '\0') {
symbol->text[i] = ' ';
} else {
symbol->text[i] = source[i];
}
}
symbol->text[src_len] = '\0';
symbol->text[length] = '\0';
return error_number;
}
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len) {
INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int length) {
int count, check_digit, glyph;
int error_number = 0;
int i;
@ -159,33 +158,32 @@ INTERNAL int telepen_num(struct zint_symbol *symbol, unsigned char source[], int
count = 0;
if (src_len > 136) { /* 68*2 */
strcpy(symbol->errtxt, "392: Input too long (136 character maximum)");
return ZINT_ERROR_TOO_LONG;
if (length > 136) { /* 68*2 */
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 392, "Input length %d too long (maximum 136)", length);
}
if (!is_sane(SODIUM_X_F, source, src_len)) {
strcpy(symbol->errtxt, "393: Invalid character in data (digits and \"X\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(SODIUM_X_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 393,
"Invalid character at position %d in input (digits and \"X\" only)", i);
}
/* Add a leading zero if required */
if (src_len & 1) {
memcpy(temp + 1, source, src_len++);
if (length & 1) {
memcpy(temp + 1, source, length++);
temp[0] = '0';
} else {
memcpy(temp, source, src_len);
memcpy(temp, source, length);
}
temp[src_len] = '\0';
to_upper(temp, src_len);
temp[length] = '\0';
to_upper(temp, length);
/* Start character */
memcpy(d, TeleTable['_'], 12);
d += 12;
for (i = 0; i < src_len; i += 2) {
for (i = 0; i < length; i += 2) {
if (temp[i] == 'X') {
strcpy(symbol->errtxt, "394: Invalid position of X in Telepen data");
return ZINT_ERROR_INVALID_DATA;
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 394, "Invalid odd position %d of \"X\" in Telepen data",
i + 1);
}
if (temp[i + 1] == 'X') {

View file

@ -42,37 +42,38 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, -1, "1", 112, 0, 1, 1137 },
/* 1*/ { BARCODE_C25STANDARD, -1, "1", 113, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_C25STANDARD, 1, "1", 112, 0, 1, 1147 },
/* 3*/ { BARCODE_C25STANDARD, 1, "1", 113, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_C25INTER, -1, "1", 125, 0, 1, 1143 },
/* 5*/ { BARCODE_C25INTER, -1, "1", 126, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_C25INTER, 1, "1", 125, 0, 1, 1143 },
/* 7*/ { BARCODE_C25INTER, 1, "1", 126, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_C25IATA, -1, "1", 80, 0, 1, 1129 },
/* 9*/ { BARCODE_C25IATA, -1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { BARCODE_C25IATA, 1, "1", 80, 0, 1, 1143 },
/* 11*/ { BARCODE_C25IATA, 1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { BARCODE_C25LOGIC, -1, "1", 113, 0, 1, 1139 },
/* 13*/ { BARCODE_C25LOGIC, -1, "1", 114, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_C25LOGIC, 1, "1", 113, 0, 1, 1149 },
/* 15*/ { BARCODE_C25LOGIC, 1, "1", 114, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { BARCODE_C25IND, -1, "1", 79, 0, 1, 1125 },
/* 17*/ { BARCODE_C25IND, -1, "1", 80, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { BARCODE_C25IND, 1, "1", 79, 0, 1, 1139 },
/* 19*/ { BARCODE_C25IND, 1, "1", 80, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { BARCODE_DPLEIT, -1, "1", 13, 0, 1, 135 },
/* 21*/ { BARCODE_DPLEIT, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 22*/ { BARCODE_DPIDENT, -1, "1", 11, 0, 1, 117 },
/* 23*/ { BARCODE_DPIDENT, -1, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 24*/ { BARCODE_ITF14, -1, "1", 13, 0, 1, 135 },
/* 25*/ { BARCODE_ITF14, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, -1, "1", 112, 0, 1, 1137, "" },
/* 1*/ { BARCODE_C25STANDARD, -1, "1", 113, ZINT_ERROR_TOO_LONG, -1, -1, "Error 301: Input length 113 too long (maximum 112)" },
/* 2*/ { BARCODE_C25STANDARD, 1, "1", 112, 0, 1, 1147, "" },
/* 3*/ { BARCODE_C25STANDARD, 1, "1", 113, ZINT_ERROR_TOO_LONG, -1, -1, "Error 301: Input length 113 too long (maximum 112)" },
/* 4*/ { BARCODE_C25INTER, -1, "1", 125, 0, 1, 1143, "" },
/* 5*/ { BARCODE_C25INTER, -1, "1", 126, ZINT_ERROR_TOO_LONG, -1, -1, "Error 309: Input length 126 too long (maximum 125)" },
/* 6*/ { BARCODE_C25INTER, 1, "1", 125, 0, 1, 1143, "" },
/* 7*/ { BARCODE_C25INTER, 1, "1", 126, ZINT_ERROR_TOO_LONG, -1, -1, "Error 309: Input length 126 too long (maximum 125)" },
/* 8*/ { BARCODE_C25IATA, -1, "1", 80, 0, 1, 1129, "" },
/* 9*/ { BARCODE_C25IATA, -1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1, "Error 305: Input length 81 too long (maximum 80)" },
/* 10*/ { BARCODE_C25IATA, 1, "1", 80, 0, 1, 1143, "" },
/* 11*/ { BARCODE_C25IATA, 1, "1", 81, ZINT_ERROR_TOO_LONG, -1, -1, "Error 305: Input length 81 too long (maximum 80)" },
/* 12*/ { BARCODE_C25LOGIC, -1, "1", 113, 0, 1, 1139, "" },
/* 13*/ { BARCODE_C25LOGIC, -1, "1", 114, ZINT_ERROR_TOO_LONG, -1, -1, "Error 307: Input length 114 too long (maximum 113)" },
/* 14*/ { BARCODE_C25LOGIC, 1, "1", 113, 0, 1, 1149, "" },
/* 15*/ { BARCODE_C25LOGIC, 1, "1", 114, ZINT_ERROR_TOO_LONG, -1, -1, "Error 307: Input length 114 too long (maximum 113)" },
/* 16*/ { BARCODE_C25IND, -1, "1", 79, 0, 1, 1125, "" },
/* 17*/ { BARCODE_C25IND, -1, "1", 80, ZINT_ERROR_TOO_LONG, -1, -1, "Error 303: Input length 80 too long (maximum 79)" },
/* 18*/ { BARCODE_C25IND, 1, "1", 79, 0, 1, 1139, "" },
/* 19*/ { BARCODE_C25IND, 1, "1", 80, ZINT_ERROR_TOO_LONG, -1, -1, "Error 303: Input length 80 too long (maximum 79)" },
/* 20*/ { BARCODE_DPLEIT, -1, "1", 13, 0, 1, 135, "" },
/* 21*/ { BARCODE_DPLEIT, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1, "Error 313: Input length 14 too long (maximum 13)" },
/* 22*/ { BARCODE_DPIDENT, -1, "1", 11, 0, 1, 117, "" },
/* 23*/ { BARCODE_DPIDENT, -1, "1", 12, ZINT_ERROR_TOO_LONG, -1, -1, "Error 315: Input length 12 too long (maximum 11)" },
/* 24*/ { BARCODE_ITF14, -1, "1", 13, 0, 1, 135, "" },
/* 25*/ { BARCODE_ITF14, -1, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1, "Error 311: Input length 14 too long (maximum 13)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -94,6 +95,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -116,7 +119,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, -1, "123456789", "123456789" },
/* 1*/ { BARCODE_C25STANDARD, 1, "123456789", "1234567895" },
/* 2*/ { BARCODE_C25STANDARD, 2, "123456789", "123456789" }, /* Suppresses printing of check digit */
@ -142,7 +145,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 22*/ { BARCODE_ITF14, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
/* 23*/ { BARCODE_ITF14, -1, "1234567890123", "12345678901231" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -173,23 +176,28 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
char *data;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 1*/ { BARCODE_C25INTER, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_C25IATA, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 3*/ { BARCODE_C25LOGIC, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_C25IND, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 5*/ { BARCODE_DPLEIT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 6*/ { BARCODE_DPIDENT, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 7*/ { BARCODE_ITF14, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 302: Invalid character at position 1 in input (digits only)" },
/* 1*/ { BARCODE_C25STANDARD, -1, "1234A6", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 302: Invalid character at position 5 in input (digits only)" },
/* 2*/ { BARCODE_C25STANDARD, ESCAPE_MODE, "\\d049234A6", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 302: Invalid character at position 5 in input (digits only)" }, /* TODO (maybe): position doesn't account for escapes */
/* 3*/ { BARCODE_C25INTER, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 310: Invalid character at position 1 in input (digits only)" },
/* 4*/ { BARCODE_C25IATA, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 306: Invalid character at position 1 in input (digits only)" },
/* 5*/ { BARCODE_C25LOGIC, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 308: Invalid character at position 1 in input (digits only)" },
/* 6*/ { BARCODE_C25IND, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 304: Invalid character at position 1 in input (digits only)" },
/* 7*/ { BARCODE_DPLEIT, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 314: Invalid character at position 1 in input (digits only)" },
/* 8*/ { BARCODE_DPIDENT, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 316: Invalid character at position 1 in input (digits only)" },
/* 9*/ { BARCODE_DPIDENT, -1, "1234567890A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 316: Invalid character at position 11 in input (digits only)" },
/* 10*/ { BARCODE_ITF14, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 312: Invalid character at position 1 in input (digits only)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -202,10 +210,12 @@ static void test_input(const testCtx *const p_ctx) {
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1 /*option_2*/, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -233,7 +243,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *expected;
};
/* BARCODE_ITF14 examples verified manually against GS1 General Specifications 21.0.1 */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_C25STANDARD, -1, "87654321", 0, 1, 97, "Standard Code 2 of 5; note zint uses 4X start/end wides while BWIPP uses 3X",
"1111010101110100010101000111010001110101110111010101110111011100010101000101110111010111011110101"
},
@ -319,13 +329,13 @@ static void test_encode(const testCtx *const p_ctx) {
"101010100011101110001011101011100010001011100010101011100010001011101110100011100010001110101010101110001110001011101010001000111011101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[4096];
char cmp_msg[1024];
int i, length, ret;
struct zint_symbol *symbol = NULL;
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
@ -408,13 +418,13 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_C25INTER, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 1, 819, "C25INTER 90" },
/* 1*/ { BARCODE_C25INTER, -1, "1234567890", 0, 1, 99, "C25INTER 10" },
/* 2*/ { BARCODE_C25STANDARD, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 1, 817, "C25STANDARD 80" },
/* 3*/ { BARCODE_C25STANDARD, -1, "1234567890", 0, 1, 117, "C25STANDARD 10" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -43,7 +43,7 @@ static void test_large(const testCtx *const p_ctx) {
int expected_width;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "1", 23, 0, 3, 133 },
/* 1*/ { BARCODE_AUSPOST, "1", 24, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_AUSPOST, "1", 18, 0, 3, 133 },
@ -61,13 +61,13 @@ static void test_large(const testCtx *const p_ctx) {
/* 14*/ { BARCODE_AUSREDIRECT, "1", 8, 0, 3, 73 },
/* 15*/ { BARCODE_AUSREDIRECT, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char data_buf[64];
testStart("test_large");
testStartSymbol("test_large", &symbol);
for (i = 0; i < data_size; i++) {
@ -105,14 +105,14 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "12345678901234567890123", "" }, /* None */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_hrt");
testStartSymbol("test_hrt", &symbol);
for (i = 0; i < data_size; i++) {
@ -146,39 +146,39 @@ static void test_input(const testCtx *const p_ctx) {
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73, "" },
/* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character in DPID (first 8 characters) (digits only)" },
/* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (first 8 characters) (digits only)" },
/* 2*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character in data (alphanumerics, space and \"#\" only)" },
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" },
/* 4*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
/* 5*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" },
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character in data (digits only for length 16)" },
/* 6*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 16 in input (digits only for FCC 59 length 16)" },
/* 7*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133, "" }, /* Length 18 */
/* 8*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" },
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character in data (digits only for length 23)" },
/* 10*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input wrong length (8, 13, 16, 18 or 23 characters only)" }, /* No leading zeroes added */
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 23 in input (digits only for FCC 62 length 23)" },
/* 10*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input length 7 wrong (8, 13, 16, 18 or 23 only)" }, /* No leading zeroes added */
/* 11*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" },
/* 12*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, /* Leading zeroes added */
/* 13*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input too long (8 character maximum)" },
/* 13*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
/* 14*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" },
/* 15*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" },
/* 16*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input too long (8 character maximum)" },
/* 16*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
/* 17*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" },
/* 18*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" },
/* 19*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" },
/* 20*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input too long (8 character maximum)" },
/* 20*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char cmp_buf[8192];
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -191,6 +191,8 @@ static void test_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -207,7 +209,6 @@ static void test_input(const testCtx *const p_ctx) {
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
}
}
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
ZBarcode_Delete(symbol);
}
@ -233,7 +234,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "96184209", 0, 3, 73, "AusPost Tech Specs Diagram 1; verified manually against TEC-IT",
"1000101010100010001010100000101010001010001000001010000010001000001000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
@ -310,9 +311,9 @@ static void test_encode(const testCtx *const p_ctx) {
"0000001010100010101010001010001000000010101000000000001010101000001010000"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char bwipp_buf[8192];
@ -320,7 +321,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {
@ -378,7 +379,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AUSROUTE, "A\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
/* 1*/ { BARCODE_AUSROUTE, "1\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
/* 2*/ { BARCODE_AUSREPLY, "A\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
@ -386,11 +387,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
/* 4*/ { BARCODE_AUSREDIRECT, "A\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
/* 5*/ { BARCODE_AUSREDIRECT, "1\000\000\000", 4, ZINT_ERROR_INVALID_DATA },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_fuzz");
testStartSymbol("test_fuzz", &symbol);
for (i = 0; i < data_size; i++) {

View file

@ -46,124 +46,134 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
const char *ret_errtxt;
const char *expected_errtxt;
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\xFF", 2053, 0, 151, 151, "" },
/* 1*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\xFF", 2054, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 2*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\xFF", 2237, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 3*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\xFF", 2238, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
/* 4*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "1", 3835, 0, 151, 151, "" },
/* 5*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "1", 3836, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 6*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "A", 3069, 0, 151, 151, "" },
/* 7*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "A", 3070, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 8*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "\xFF", 1756, 0, 151, 151, "" },
/* 9*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "\xFF", 1757, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 10*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "1", 3184, 0, 151, 151, "" },
/* 11*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "1", 3185, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 12*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "A", 2548, 0, 151, 151, "" },
/* 13*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "A", 2549, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 14*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "\xFF", 1457, 0, 151, 151, "" },
/* 15*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "\xFF", 1458, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 16*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "1", 2485, 0, 151, 151, "" },
/* 17*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "1", 2486, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 18*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "A", 1989, 0, 151, 151, "" },
/* 19*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "A", 1990, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 20*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "\xFF", 1137, 0, 151, 151, "" },
/* 21*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "\xFF", 1138, ZINT_ERROR_TOO_LONG, -1, -1, "Error 504: Input too long (too many bits for selected ECC)" },
/* 22*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "\xFF", 7, 0, 15, 15, "" },
/* 23*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "\xFF", 8, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 24*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "\xFF", 2078, ZINT_ERROR_TOO_LONG, -1, -1, "Error 704: Data too long for specified Aztec Code symbol size" },
/* 25*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\xFF", 22, 0, 19, 19, "" },
/* 26*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\xFF", 23, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 27*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\xFF", 2077, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 28*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\xFF", 2078, ZINT_ERROR_TOO_LONG, -1, -1, "Error 704: Data too long for specified Aztec Code symbol size" },
/* 29*/ { BARCODE_AZTEC, -1, -1, 3, -1, { 0, 0, "" }, "\xFF", 39, 0, 23, 23, "" },
/* 30*/ { BARCODE_AZTEC, -1, -1, 3, -1, { 0, 0, "" }, "\xFF", 40, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 31*/ { BARCODE_AZTEC, -1, -1, 4, -1, { 0, 0, "" }, "\xFF", 51, 0, 27, 27, "" },
/* 32*/ { BARCODE_AZTEC, -1, -1, 4, -1, { 0, 0, "" }, "\xFF", 52, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 33*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "\xFF", 10, 0, 19, 19, "" },
/* 34*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "\xFF", 11, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 35*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "\xFF", 2077, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 36*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "\xFF", 2078, ZINT_ERROR_TOO_LONG, -1, -1, "Error 704: Data too long for specified Aztec Code symbol size" },
/* 37*/ { BARCODE_AZTEC, -1, -1, 6, -1, { 0, 0, "" }, "\xFF", 27, 0, 23, 23, "" },
/* 38*/ { BARCODE_AZTEC, -1, -1, 6, -1, { 0, 0, "" }, "\xFF", 28, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 39*/ { BARCODE_AZTEC, -1, -1, 7, -1, { 0, 0, "" }, "\xFF", 47, 0, 27, 27, "" },
/* 40*/ { BARCODE_AZTEC, -1, -1, 7, -1, { 0, 0, "" }, "\xFF", 48, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 41*/ { BARCODE_AZTEC, -1, -1, 8, -1, { 0, 0, "" }, "\xFF", 72, 0, 31, 31, "" },
/* 42*/ { BARCODE_AZTEC, -1, -1, 8, -1, { 0, 0, "" }, "\xFF", 73, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 43*/ { BARCODE_AZTEC, -1, -1, 9, -1, { 0, 0, "" }, "\xFF", 100, 0, 37, 37, "" },
/* 44*/ { BARCODE_AZTEC, -1, -1, 9, -1, { 0, 0, "" }, "\xFF", 101, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 45*/ { BARCODE_AZTEC, -1, -1, 10, -1, { 0, 0, "" }, "\xFF", 131, 0, 41, 41, "" },
/* 46*/ { BARCODE_AZTEC, -1, -1, 10, -1, { 0, 0, "" }, "\xFF", 132, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 47*/ { BARCODE_AZTEC, -1, -1, 11, -1, { 0, 0, "" }, "\xFF", 166, 0, 45, 45, "" },
/* 48*/ { BARCODE_AZTEC, -1, -1, 11, -1, { 0, 0, "" }, "\xFF", 167, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 49*/ { BARCODE_AZTEC, -1, -1, 12, -1, { 0, 0, "" }, "\xFF", 205, 0, 49, 49, "" },
/* 50*/ { BARCODE_AZTEC, -1, -1, 12, -1, { 0, 0, "" }, "\xFF", 206, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 51*/ { BARCODE_AZTEC, -1, -1, 13, -1, { 0, 0, "" }, "\xFF", 253, 0, 53, 53, "" },
/* 52*/ { BARCODE_AZTEC, -1, -1, 13, -1, { 0, 0, "" }, "\xFF", 254, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 53*/ { BARCODE_AZTEC, -1, -1, 14, -1, { 0, 0, "" }, "\xFF", 300, 0, 57, 57, "" },
/* 54*/ { BARCODE_AZTEC, -1, -1, 14, -1, { 0, 0, "" }, "\xFF", 301, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 55*/ { BARCODE_AZTEC, -1, -1, 15, -1, { 0, 0, "" }, "\xFF", 349, 0, 61, 61, "" },
/* 56*/ { BARCODE_AZTEC, -1, -1, 15, -1, { 0, 0, "" }, "\xFF", 350, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 57*/ { BARCODE_AZTEC, -1, -1, 16, -1, { 0, 0, "" }, "\xFF", 403, 0, 67, 67, "" },
/* 58*/ { BARCODE_AZTEC, -1, -1, 16, -1, { 0, 0, "" }, "\xFF", 404, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 59*/ { BARCODE_AZTEC, -1, -1, 17, -1, { 0, 0, "" }, "\xFF", 462, 0, 71, 71, "" },
/* 60*/ { BARCODE_AZTEC, -1, -1, 17, -1, { 0, 0, "" }, "\xFF", 463, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 61*/ { BARCODE_AZTEC, -1, -1, 18, -1, { 0, 0, "" }, "\xFF", 523, 0, 75, 75, "" },
/* 62*/ { BARCODE_AZTEC, -1, -1, 18, -1, { 0, 0, "" }, "\xFF", 524, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 63*/ { BARCODE_AZTEC, -1, -1, 19, -1, { 0, 0, "" }, "\xFF", 588, 0, 79, 79, "" },
/* 64*/ { BARCODE_AZTEC, -1, -1, 19, -1, { 0, 0, "" }, "\xFF", 589, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 65*/ { BARCODE_AZTEC, -1, -1, 20, -1, { 0, 0, "" }, "\xFF", 655, 0, 83, 83, "" },
/* 66*/ { BARCODE_AZTEC, -1, -1, 20, -1, { 0, 0, "" }, "\xFF", 656, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 67*/ { BARCODE_AZTEC, -1, -1, 21, -1, { 0, 0, "" }, "\xFF", 727, 0, 87, 87, "" },
/* 68*/ { BARCODE_AZTEC, -1, -1, 21, -1, { 0, 0, "" }, "\xFF", 728, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 69*/ { BARCODE_AZTEC, -1, -1, 22, -1, { 0, 0, "" }, "\xFF", 804, 0, 91, 91, "" },
/* 70*/ { BARCODE_AZTEC, -1, -1, 22, -1, { 0, 0, "" }, "\xFF", 805, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 71*/ { BARCODE_AZTEC, -1, -1, 23, -1, { 0, 0, "" }, "\xFF", 883, 0, 95, 95, "" },
/* 72*/ { BARCODE_AZTEC, -1, -1, 23, -1, { 0, 0, "" }, "\xFF", 884, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 73*/ { BARCODE_AZTEC, -1, -1, 24, -1, { 0, 0, "" }, "\xFF", 966, 0, 101, 101, "" },
/* 74*/ { BARCODE_AZTEC, -1, -1, 24, -1, { 0, 0, "" }, "\xFF", 967, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 75*/ { BARCODE_AZTEC, -1, -1, 25, -1, { 0, 0, "" }, "\xFF", 1051, 0, 105, 105, "" },
/* 76*/ { BARCODE_AZTEC, -1, -1, 25, -1, { 0, 0, "" }, "\xFF", 1052, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 77*/ { BARCODE_AZTEC, -1, -1, 26, -1, { 0, 0, "" }, "\xFF", 1141, 0, 109, 109, "" },
/* 78*/ { BARCODE_AZTEC, -1, -1, 26, -1, { 0, 0, "" }, "\xFF", 1142, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 79*/ { BARCODE_AZTEC, -1, -1, 27, -1, { 0, 0, "" }, "\xFF", 1258, 0, 113, 113, "" },
/* 80*/ { BARCODE_AZTEC, -1, -1, 27, -1, { 0, 0, "" }, "\xFF", 1259, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 81*/ { BARCODE_AZTEC, -1, -1, 28, -1, { 0, 0, "" }, "\xFF", 1357, 0, 117, 117, "" },
/* 82*/ { BARCODE_AZTEC, -1, -1, 28, -1, { 0, 0, "" }, "\xFF", 1358, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 83*/ { BARCODE_AZTEC, -1, -1, 29, -1, { 0, 0, "" }, "\xFF", 1459, 0, 121, 121, "" },
/* 84*/ { BARCODE_AZTEC, -1, -1, 29, -1, { 0, 0, "" }, "\xFF", 1460, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 85*/ { BARCODE_AZTEC, -1, -1, 30, -1, { 0, 0, "" }, "\xFF", 1566, 0, 125, 125, "" },
/* 86*/ { BARCODE_AZTEC, -1, -1, 30, -1, { 0, 0, "" }, "\xFF", 1567, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 87*/ { BARCODE_AZTEC, -1, -1, 31, -1, { 0, 0, "" }, "\xFF", 1676, 0, 131, 131, "" },
/* 88*/ { BARCODE_AZTEC, -1, -1, 31, -1, { 0, 0, "" }, "\xFF", 1677, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 89*/ { BARCODE_AZTEC, -1, -1, 32, -1, { 0, 0, "" }, "\xFF", 1789, 0, 135, 135, "" },
/* 90*/ { BARCODE_AZTEC, -1, -1, 32, -1, { 0, 0, "" }, "\xFF", 1790, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 91*/ { BARCODE_AZTEC, -1, -1, 33, -1, { 0, 0, "" }, "\xFF", 1907, 0, 139, 139, "" },
/* 92*/ { BARCODE_AZTEC, -1, -1, 33, -1, { 0, 0, "" }, "\xFF", 1908, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 93*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "\xFF", 2028, 0, 143, 143, "" },
/* 94*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "\xFF", 2029, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 95*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "\xFF", 2149, 0, 147, 147, "" },
/* 96*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "\xFF", 2150, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 97*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "\xFF", 2237, 0, 151, 151, "" },
/* 98*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "\xFF", 2238, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
/* 97*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "\xFF", 2205, 0, 151, 151, "" },
/* 99*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "1", 4429, 0, 143, 143, "" },
/*100*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "1", 4430, ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/*101*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "1", 4483, 0, 147, 147, "" },
/*102*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "1", 4484, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
/*103*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "1", 4483, 0, 151, 151, "" },
/*104*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "1", 4484, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
/*105*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 0, 0, "" }, "\xFF", 2234, 0, 151, 151, "" },
/*106*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 0, 0, "" }, "\xFF", 2235, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
/*107*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 2, 3, "1234567890123456789012" }, "\xFF", 2221, 0, 151, 151, "" },
/*108*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 2, 3, "1234567890123456789012" }, "\xFF", 2222, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
/*109*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 2, 3, "1234567890123456789012" }, "\xFF", 2218, 0, 151, 151, "" },
/*110*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 2, 3, "1234567890123456789012" }, "\xFF", 2219, ZINT_ERROR_TOO_LONG, -1, -1, "Error 502: Input too long or too many extended ASCII characters" },
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\377", 2053, 0, 151, 151, "", "" },
/* 1*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\377", 2054, ZINT_ERROR_TOO_LONG, 0, 0, "Error 504: Input too long for ECC level 1, requires 1496 codewords (maximum 1495)", "" },
/* 2*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\377", 2237, ZINT_ERROR_TOO_LONG, 0, 0, "Error 504: Input too long for ECC level 1, requires 1631 codewords (maximum 1495)", "" },
/* 3*/ { BARCODE_AZTEC, -1, 1, -1, -1, { 0, 0, "" }, "\377", 2238, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 1, requires too many codewords (maximum 1495)", "" },
/* 4*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "1", 3835, 0, 151, 151, "", "" },
/* 5*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "1", 3836, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 2, requires too many codewords (maximum 1279)", "" },
/* 6*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "A", 3069, 0, 151, 151, "", "" },
/* 7*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "A", 3070, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 2, requires too many codewords (maximum 1279)", "" },
/* 8*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "\377", 1756, 0, 151, 151, "", "" },
/* 9*/ { BARCODE_AZTEC, -1, 2, -1, -1, { 0, 0, "" }, "\377", 1757, ZINT_ERROR_TOO_LONG, 0, 0, "Error 504: Input too long for ECC level 2, requires 1280 codewords (maximum 1279)", "" },
/* 10*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "1", 3184, 0, 151, 151, "", "" },
/* 11*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "1", 3185, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 3, requires too many codewords (maximum 1062)", "" },
/* 12*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "A", 2548, 0, 151, 151, "", "" },
/* 13*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "A", 2549, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 3, requires too many codewords (maximum 1062)", "" },
/* 14*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "\377", 1457, 0, 151, 151, "", "" },
/* 15*/ { BARCODE_AZTEC, -1, 3, -1, -1, { 0, 0, "" }, "\377", 1458, ZINT_ERROR_TOO_LONG, 0, 0, "Error 504: Input too long for ECC level 3, requires 1063 codewords (maximum 1062)", "" },
/* 16*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "1", 2485, 0, 151, 151, "", "" },
/* 17*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "1", 2486, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 4, requires too many codewords (maximum 829)", "" },
/* 18*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "A", 1989, 0, 151, 151, "", "" },
/* 19*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "A", 1990, ZINT_ERROR_TOO_LONG, 0, 0, "Error 707: Input too long for ECC level 4, requires too many codewords (maximum 829)", "" },
/* 20*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "\377", 1137, 0, 151, 151, "", "" },
/* 21*/ { BARCODE_AZTEC, -1, 4, -1, -1, { 0, 0, "" }, "\377", 1138, ZINT_ERROR_TOO_LONG, 0, 0, "Error 504: Input too long for ECC level 4, requires 830 codewords (maximum 829)", "" },
/* 22*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "\377", 7, 0, 15, 15, "", "4 ECC codewords" },
/* 23*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "\377", 8, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 1, requires too many codewords (maximum 14)", "" },
/* 24*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "\377", 2078, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 1, requires too many codewords (maximum 14)", "" },
/* 25*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\377", 22, 0, 19, 19, "", "3 ECC codewords" },
/* 26*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\377", 23, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 2, requires too many codewords (maximum 37)", "" },
/* 27*/ { BARCODE_AZTEC, -1, -1, 2, -1, { 0, 0, "" }, "\377", 1866, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 2, requires too many codewords (maximum 37)", "" },
/* 28*/ { BARCODE_AZTEC, -1, -1, 3, -1, { 0, 0, "" }, "\377", 39, 0, 23, 23, "", "3 ECC codewords" },
/* 29*/ { BARCODE_AZTEC, -1, -1, 3, -1, { 0, 0, "" }, "\377", 40, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 3, requires too many codewords (maximum 48)", "" },
/* 30*/ { BARCODE_AZTEC, -1, -1, 4, -1, { 0, 0, "" }, "\377", 51, 0, 27, 27, "", "15 ECC codewords (Version 4 (compact) spare 12 ECC blocks bonus)" },
/* 31*/ { BARCODE_AZTEC, -1, -1, 4, -1, { 0, 0, "" }, "\377", 52, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 4, requires too many codewords (maximum 61)", "" },
/* 32*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "\377", 10, 0, 19, 19, "", "3 ECC codewords" },
/* 33*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "\377", 11, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 5, requires too many codewords (maximum 18)", "" },
/* 34*/ { BARCODE_AZTEC, -1, -1, 6, -1, { 0, 0, "" }, "\377", 27, 0, 23, 23, "", "3 ECC codewords" },
/* 35*/ { BARCODE_AZTEC, -1, -1, 6, -1, { 0, 0, "" }, "\377", 28, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 6, requires too many codewords (maximum 45)", "" },
/* 36*/ { BARCODE_AZTEC, -1, -1, 7, -1, { 0, 0, "" }, "\377", 47, 0, 27, 27, "", "3 ECC codewords" },
/* 37*/ { BARCODE_AZTEC, -1, -1, 7, -1, { 0, 0, "" }, "\377", 48, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 7, requires too many codewords (maximum 57)", "" },
/* 38*/ { BARCODE_AZTEC, -1, -1, 8, -1, { 0, 0, "" }, "\377", 71, 0, 31, 31, "", "4 ECC codewords" },
/* 39*/ { BARCODE_AZTEC, -1, -1, 8, -1, { 0, 0, "" }, "\377", 72, ZINT_WARN_NONCOMPLIANT, 31, 31, "Warning 708: Number of ECC codewords 3 less than 4 (5% of data codewords 85)", "" },
/* 40*/ { BARCODE_AZTEC, -1, -1, 8, -1, { 0, 0, "" }, "\377", 73, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 8, requires too many codewords (maximum 85)", "" },
/* 41*/ { BARCODE_AZTEC, -1, -1, 9, -1, { 0, 0, "" }, "\377", 98, 0, 37, 37, "", "5 ECC codewords" },
/* 42*/ { BARCODE_AZTEC, -1, -1, 9, -1, { 0, 0, "" }, "\377", 100, ZINT_WARN_NONCOMPLIANT, 37, 37, "Warning 708: Number of ECC codewords 3 less than 5 (5% of data codewords 117)", "" },
/* 43*/ { BARCODE_AZTEC, -1, -1, 9, -1, { 0, 0, "" }, "\377", 101, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 9, requires too many codewords (maximum 117)", "" },
/* 44*/ { BARCODE_AZTEC, -1, -1, 10, -1, { 0, 0, "" }, "\377", 128, 0, 41, 41, "", "7 ECC codewords" },
/* 45*/ { BARCODE_AZTEC, -1, -1, 10, -1, { 0, 0, "" }, "\377", 129, ZINT_WARN_NONCOMPLIANT, 41, 41, "Warning 708: Number of ECC codewords 6 less than 7 (5% of data codewords 150)", "" },
/* 46*/ { BARCODE_AZTEC, -1, -1, 10, -1, { 0, 0, "" }, "\377", 131, ZINT_WARN_NONCOMPLIANT, 41, 41, "Warning 708: Number of ECC codewords 3 less than 7 (5% of data codewords 153)", "" },
/* 47*/ { BARCODE_AZTEC, -1, -1, 10, -1, { 0, 0, "" }, "\377", 132, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 10, requires too many codewords (maximum 153)", "" },
/* 48*/ { BARCODE_AZTEC, -1, -1, 11, -1, { 0, 0, "" }, "\377", 166, ZINT_WARN_NONCOMPLIANT, 45, 45, "Warning 708: Number of ECC codewords 3 less than 9 (5% of data codewords 193)", "" },
/* 49*/ { BARCODE_AZTEC, -1, -1, 11, -1, { 0, 0, "" }, "\377", 167, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 11, requires too many codewords (maximum 193)", "" },
/* 50*/ { BARCODE_AZTEC, -1, -1, 12, -1, { 0, 0, "" }, "\377", 205, ZINT_WARN_NONCOMPLIANT, 49, 49, "Warning 708: Number of ECC codewords 3 less than 11 (5% of data codewords 237)", "" },
/* 51*/ { BARCODE_AZTEC, -1, -1, 12, -1, { 0, 0, "" }, "\377", 206, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 12, requires too many codewords (maximum 237)", "" },
/* 52*/ { BARCODE_AZTEC, -1, -1, 13, -1, { 0, 0, "" }, "\377", 253, ZINT_WARN_NONCOMPLIANT, 53, 53, "Warning 708: Number of ECC codewords 3 less than 11 (5% of data codewords 227)", "" },
/* 53*/ { BARCODE_AZTEC, -1, -1, 13, -1, { 0, 0, "" }, "\377", 254, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 13, requires too many codewords (maximum 227)", "" },
/* 54*/ { BARCODE_AZTEC, -1, -1, 14, -1, { 0, 0, "" }, "\377", 300, ZINT_WARN_NONCOMPLIANT, 57, 57, "Warning 708: Number of ECC codewords 3 less than 13 (5% of data codewords 269)", "" },
/* 55*/ { BARCODE_AZTEC, -1, -1, 14, -1, { 0, 0, "" }, "\377", 301, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 14, requires too many codewords (maximum 269)", "" },
/* 56*/ { BARCODE_AZTEC, -1, -1, 15, -1, { 0, 0, "" }, "\377", 349, ZINT_WARN_NONCOMPLIANT, 61, 61, "Warning 708: Number of ECC codewords 3 less than 15 (5% of data codewords 313)", "" },
/* 57*/ { BARCODE_AZTEC, -1, -1, 15, -1, { 0, 0, "" }, "\377", 350, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 15, requires too many codewords (maximum 313)", "" },
/* 58*/ { BARCODE_AZTEC, -1, -1, 16, -1, { 0, 0, "" }, "\377", 403, ZINT_WARN_NONCOMPLIANT, 67, 67, "Warning 708: Number of ECC codewords 3 less than 18 (5% of data codewords 361)", "" },
/* 59*/ { BARCODE_AZTEC, -1, -1, 16, -1, { 0, 0, "" }, "\377", 404, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 16, requires too many codewords (maximum 361)", "" },
/* 60*/ { BARCODE_AZTEC, -1, -1, 17, -1, { 0, 0, "" }, "\377", 462, ZINT_WARN_NONCOMPLIANT, 71, 71, "Warning 708: Number of ECC codewords 3 less than 20 (5% of data codewords 413)", "" },
/* 61*/ { BARCODE_AZTEC, -1, -1, 17, -1, { 0, 0, "" }, "\377", 463, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 17, requires too many codewords (maximum 413)", "" },
/* 62*/ { BARCODE_AZTEC, -1, -1, 18, -1, { 0, 0, "" }, "\377", 501, 0, 75, 75, "", "22 ECC codewords (448 data codewords)" },
/* 63*/ { BARCODE_AZTEC, -1, -1, 18, -1, { 0, 0, "" }, "\377", 502, ZINT_WARN_NONCOMPLIANT, 75, 75, "Warning 708: Number of ECC codewords 21 less than 22 (5% of data codewords 449)", "" },
/* 64*/ { BARCODE_AZTEC, -1, -1, 18, -1, { 0, 0, "" }, "\377", 523, ZINT_WARN_NONCOMPLIANT, 75, 75, "Warning 708: Number of ECC codewords 3 less than 23 (5% of data codewords 467)", "" },
/* 65*/ { BARCODE_AZTEC, -1, -1, 18, -1, { 0, 0, "" }, "\377", 524, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 18, requires too many codewords (maximum 467)", "" },
/* 66*/ { BARCODE_AZTEC, -1, -1, 19, -1, { 0, 0, "" }, "\377", 588, ZINT_WARN_NONCOMPLIANT, 79, 79, "Warning 708: Number of ECC codewords 3 less than 26 (5% of data codewords 525)", "" },
/* 67*/ { BARCODE_AZTEC, -1, -1, 19, -1, { 0, 0, "" }, "\377", 589, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 19, requires too many codewords (maximum 525)", "" },
/* 68*/ { BARCODE_AZTEC, -1, -1, 20, -1, { 0, 0, "" }, "\377", 655, ZINT_WARN_NONCOMPLIANT, 83, 83, "Warning 708: Number of ECC codewords 3 less than 29 (5% of data codewords 585)", "" },
/* 69*/ { BARCODE_AZTEC, -1, -1, 20, -1, { 0, 0, "" }, "\377", 656, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 20, requires too many codewords (maximum 585)", "" },
/* 70*/ { BARCODE_AZTEC, -1, -1, 21, -1, { 0, 0, "" }, "\377", 727, ZINT_WARN_NONCOMPLIANT, 87, 87, "Warning 708: Number of ECC codewords 3 less than 32 (5% of data codewords 649)", "" },
/* 71*/ { BARCODE_AZTEC, -1, -1, 21, -1, { 0, 0, "" }, "\377", 728, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 21, requires too many codewords (maximum 649)", "" },
/* 72*/ { BARCODE_AZTEC, -1, -1, 22, -1, { 0, 0, "" }, "\377", 804, ZINT_WARN_NONCOMPLIANT, 91, 91, "Warning 708: Number of ECC codewords 3 less than 35 (5% of data codewords 717)", "" },
/* 73*/ { BARCODE_AZTEC, -1, -1, 22, -1, { 0, 0, "" }, "\377", 805, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 22, requires too many codewords (maximum 717)", "" },
/* 74*/ { BARCODE_AZTEC, -1, -1, 23, -1, { 0, 0, "" }, "\377", 883, ZINT_WARN_NONCOMPLIANT, 95, 95, "Warning 708: Number of ECC codewords 3 less than 39 (5% of data codewords 787)", "" },
/* 75*/ { BARCODE_AZTEC, -1, -1, 23, -1, { 0, 0, "" }, "\377", 884, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 23, requires too many codewords (maximum 787)", "" },
/* 76*/ { BARCODE_AZTEC, -1, -1, 24, -1, { 0, 0, "" }, "\377", 966, ZINT_WARN_NONCOMPLIANT, 101, 101, "Warning 708: Number of ECC codewords 3 less than 43 (5% of data codewords 861)", "" },
/* 77*/ { BARCODE_AZTEC, -1, -1, 24, -1, { 0, 0, "" }, "\377", 967, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 24, requires too many codewords (maximum 861)", "" },
/* 78*/ { BARCODE_AZTEC, -1, -1, 25, -1, { 0, 0, "" }, "\377", 1051, ZINT_WARN_NONCOMPLIANT, 105, 105, "Warning 708: Number of ECC codewords 3 less than 46 (5% of data codewords 937)", "" },
/* 79*/ { BARCODE_AZTEC, -1, -1, 25, -1, { 0, 0, "" }, "\377", 1052, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 25, requires too many codewords (maximum 937)", "" },
/* 80*/ { BARCODE_AZTEC, -1, -1, 26, -1, { 0, 0, "" }, "\377", 1091, 0, 109, 109, "", "48 ecc codewords (972 data codewords)" },
/* 81*/ { BARCODE_AZTEC, -1, -1, 26, -1, { 0, 0, "" }, "\377", 1092, ZINT_WARN_NONCOMPLIANT, 109, 109, "Warning 708: Number of ECC codewords 47 less than 48 (5% of data codewords 973)", "" },
/* 82*/ { BARCODE_AZTEC, -1, -1, 26, -1, { 0, 0, "" }, "\377", 1141, ZINT_WARN_NONCOMPLIANT, 109, 109, "Warning 708: Number of ECC codewords 3 less than 50 (5% of data codewords 1017)", "" },
/* 83*/ { BARCODE_AZTEC, -1, -1, 26, -1, { 0, 0, "" }, "\377", 1142, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 26, requires too many codewords (maximum 1017)", "" },
/* 84*/ { BARCODE_AZTEC, -1, -1, 27, -1, { 0, 0, "" }, "\377", 1258, ZINT_WARN_NONCOMPLIANT, 113, 113, "Warning 708: Number of ECC codewords 3 less than 45 (5% of data codewords 917)", "" },
/* 85*/ { BARCODE_AZTEC, -1, -1, 27, -1, { 0, 0, "" }, "\377", 1259, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 27, requires too many codewords (maximum 917)", "" },
/* 86*/ { BARCODE_AZTEC, -1, -1, 28, -1, { 0, 0, "" }, "\377", 1357, ZINT_WARN_NONCOMPLIANT, 117, 117, "Warning 708: Number of ECC codewords 3 less than 49 (5% of data codewords 989)", "" },
/* 87*/ { BARCODE_AZTEC, -1, -1, 28, -1, { 0, 0, "" }, "\377", 1358, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 28, requires too many codewords (maximum 989)", "" },
/* 88*/ { BARCODE_AZTEC, -1, -1, 29, -1, { 0, 0, "" }, "\377", 1459, ZINT_WARN_NONCOMPLIANT, 121, 121, "Warning 708: Number of ECC codewords 3 less than 53 (5% of data codewords 1063)", "" },
/* 89*/ { BARCODE_AZTEC, -1, -1, 29, -1, { 0, 0, "" }, "\377", 1460, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 29, requires too many codewords (maximum 1063)", "" },
/* 90*/ { BARCODE_AZTEC, -1, -1, 30, -1, { 0, 0, "" }, "\377", 1566, ZINT_WARN_NONCOMPLIANT, 125, 125, "Warning 708: Number of ECC codewords 3 less than 57 (5% of data codewords 1141)", "" },
/* 91*/ { BARCODE_AZTEC, -1, -1, 30, -1, { 0, 0, "" }, "\377", 1567, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 30, requires too many codewords (maximum 1141)", "" },
/* 92*/ { BARCODE_AZTEC, -1, -1, 31, -1, { 0, 0, "" }, "\377", 1676, ZINT_WARN_NONCOMPLIANT, 131, 131, "Warning 708: Number of ECC codewords 3 less than 61 (5% of data codewords 1221)", "" },
/* 93*/ { BARCODE_AZTEC, -1, -1, 31, -1, { 0, 0, "" }, "\377", 1677, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 31, requires too many codewords (maximum 1221)", "" },
/* 94*/ { BARCODE_AZTEC, -1, -1, 32, -1, { 0, 0, "" }, "\377", 1789, ZINT_WARN_NONCOMPLIANT, 135, 135, "Warning 708: Number of ECC codewords 3 less than 65 (5% of data codewords 1303)", "" },
/* 95*/ { BARCODE_AZTEC, -1, -1, 32, -1, { 0, 0, "" }, "\377", 1790, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 32, requires too many codewords (maximum 1303)", "" },
/* 96*/ { BARCODE_AZTEC, -1, -1, 33, -1, { 0, 0, "" }, "\377", 1907, ZINT_WARN_NONCOMPLIANT, 139, 139, "Warning 708: Number of ECC codewords 3 less than 69 (5% of data codewords 1389)", "" },
/* 97*/ { BARCODE_AZTEC, -1, -1, 33, -1, { 0, 0, "" }, "\377", 1908, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 33, requires too many codewords (maximum 1389)", "" },
/* 98*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "1", 4429, ZINT_WARN_NONCOMPLIANT, 143, 143, "Warning 708: Number of ECC codewords 3 less than 73 (5% of data codewords 1477)", "" },
/* 99*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "1", 4430, ZINT_ERROR_TOO_LONG, 0, 0, "Error 505: Input too long for Version 34, requires 1478 codewords (maximum 1477)", "" },
/*100*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "\377", 2028, ZINT_WARN_NONCOMPLIANT, 143, 143, "Warning 708: Number of ECC codewords 3 less than 73 (5% of data codewords 1477)", "" },
/*101*/ { BARCODE_AZTEC, -1, -1, 34, -1, { 0, 0, "" }, "\377", 2029, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 34, requires too many codewords (maximum 1477)", "" },
/*102*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "1", 4699, ZINT_WARN_NONCOMPLIANT, 147, 147, "Warning 708: Number of ECC codewords 3 less than 78 (5% of data codewords 1567)", "" },
/*103*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "1", 4700, ZINT_ERROR_TOO_LONG, 0, 0, "Error 505: Input too long for Version 35, requires 1568 codewords (maximum 1567)", "" },
/*104*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "A", 3590, 0, 147, 147, "", "74 ECC codewords (1496 data codewords)" },
/*105*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "A", 3591, ZINT_WARN_NONCOMPLIANT, 147, 147, "Warning 708: Number of ECC codewords 73 less than 74 (5% of data codewords 1497)", "" },
/*106*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "A", 3760, ZINT_WARN_NONCOMPLIANT, 147, 147, "Warning 708: Number of ECC codewords 3 less than 78 (5% of data codewords 1567)", "" },
/*107*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "A", 3761, ZINT_ERROR_TOO_LONG, 0, 0, "Error 505: Input too long for Version 35, requires 1568 codewords (maximum 1567)", "" },
/*108*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "\377", 2149, ZINT_WARN_NONCOMPLIANT, 147, 147, "Warning 708: Number of ECC codewords 3 less than 78 (5% of data codewords 1567)", "" },
/*109*/ { BARCODE_AZTEC, -1, -1, 35, -1, { 0, 0, "" }, "\377", 2150, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 35, requires too many codewords (maximum 1567)", "" },
/*110*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "1", 4753, 0, 151, 151, "", "79 ECC codewords (1585 data codewords)" },
/*111*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "1", 4981, ZINT_WARN_NONCOMPLIANT, 151, 151, "Warning 708: Number of ECC codewords 3 less than 83 (5% of data codewords 1661)", "" },
/*112*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "1", 4982, ZINT_ERROR_TOO_LONG, 0, 0, "Error 502: Input too long, requires too many codewords (maximum 1661)", "" },
/*113*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "\377", 2279, ZINT_WARN_NONCOMPLIANT, 151, 151, "Warning 708: Number of ECC codewords 3 less than 83 (5% of data codewords 1661)", "" },
/*114*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 0, 0, "" }, "\377", 2280, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 36, requires too many codewords (maximum 1661)", "" },
/*115*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 0, 0, "" }, "\377", 2276, ZINT_WARN_NONCOMPLIANT, 151, 151, "Warning 708: Number of ECC codewords 3 less than 83 (5% of data codewords 1661)", "" },
/*116*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 0, 0, "" }, "\377", 2277, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 36, requires too many codewords (maximum 1661)", "" },
/*117*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 2, 3, "" }, "\377", 2276, ZINT_WARN_NONCOMPLIANT, 151, 151, "Warning 708: Number of ECC codewords 3 less than 83 (5% of data codewords 1661)", "" },
/*118*/ { BARCODE_AZTEC, -1, -1, 36, -1, { 2, 3, "" }, "\377", 2277, ZINT_ERROR_TOO_LONG, 0, 0, "Error 704: Input too long for Version 36, requires too many codewords (maximum 1661)", "" },
/*119*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 2, 3, "" }, "\377", 2273, ZINT_WARN_NONCOMPLIANT, 151, 151, "Warning 708: Number of ECC codewords 3 less than 83 (5% of data codewords 1661)", "" },
/*120*/ { BARCODE_AZTEC, 899, -1, 36, -1, { 2, 3, "" }, "\377", 2274, ZINT_ERROR_TOO_LONG, 0, 0, "Error 505: Input too long for Version 36, requires 1662 codewords (maximum 1661)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -194,7 +204,16 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, %d, %d, %d, %s, { %d, %d, \"\" }, \"%s\", %d, %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilBarcodeName(data[i].symbology), data[i].eci, data[i].option_1, data[i].option_2,
testUtilOutputOptionsName(data[i].output_options), data[i].structapp.index, data[i].structapp.count,
testUtilEscape(data[i].pattern, (int) strlen(data[i].pattern), escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
@ -210,8 +229,7 @@ static void test_large(const testCtx *const p_ctx) {
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped);
}
} else {
assert_zero(strcmp(symbol->errtxt, data[i].ret_errtxt), "i:%d errtxt %s != %s\n", i, symbol->errtxt, data[i].ret_errtxt);
}
}
ZBarcode_Delete(symbol);
@ -238,32 +256,37 @@ static void test_options(const testCtx *const p_ctx) {
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "" },
/* 1*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "" },
/* 2*/ { BARCODE_AZTEC, -1, -1, 4, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "" },
/* 3*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "1234567890", ZINT_WARN_INVALID_OPTION, 15, 15, "Warning 503: Invalid error correction level - using default instead" },
/* 4*/ { BARCODE_AZTEC, -1, -1, -1, 1, { 0, 0, "" }, "12345678901234567890", ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Data too long for specified Aztec Code symbol size" },
/* 3*/ { BARCODE_AZTEC, -1, -1, 5, -1, { 0, 0, "" }, "1234567890", ZINT_WARN_INVALID_OPTION, 15, 15, "Warning 503: Error correction level '5' out of range (1 to 4), ignoring" },
/* 4*/ { BARCODE_AZTEC, -1, -1, -1, 1, { 0, 0, "" }, "12345678901234567890", ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Input too long for Version 1, requires 15 codewords (maximum 14)" },
/* 5*/ { BARCODE_AZTEC, -1, -1, -1, 36, { 0, 0, "" }, "1234567890", 0, 151, 151, "" },
/* 6*/ { BARCODE_AZTEC, -1, -1, -1, 37, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Invalid Aztec Code size" },
/* 7*/ { BARCODE_AZTEC, GS1_MODE, READER_INIT, -1, -1, { 0, 0, "" }, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 501: Cannot encode in GS1 and Reader Initialisation mode at the same time" },
/* 8*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[91]A", 0, 15, 15, "" },
/* 9*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)A", 0, 15, 15, "" },
/* 10*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, { 0, 0, "" }, "A", 0, 109, 109, "" }, /* 22 layers */
/* 11*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, { 0, 0, "" }, "A", ZINT_ERROR_TOO_LONG, -1, -1, "Error 506: Data too long for reader initialisation symbol" }, /* 23 layers */
/* 12*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, { 0, 0, "" }, "A", 0, 15, 15, "" }, /* Compact 1 layer */
/* 13*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 2, { 0, 0, "" }, "A", 0, 19, 19, "" }, /* Compact 2 layers gets set to full 1 layer if READER_INIT set */
/* 14*/ { BARCODE_AZRUNE, -1, -1, -1, -1, { 0, 0, "" }, "0001", ZINT_ERROR_TOO_LONG, -1, -1, "Error 507: Input too large (3 character maximum)" },
/* 15*/ { BARCODE_AZRUNE, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 508: Invalid character in data (digits only)" },
/* 16*/ { BARCODE_AZRUNE, -1, -1, -1, -1, { 0, 0, "" }, "256", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 509: Input out of range (0 to 255)" },
/* 17*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 2, "" }, "1234567890", 0, 15, 15, "" },
/* 18*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 2, {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2'} }, "1234567890", 0, 23, 23, "" },
/* 19*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 1, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 701: Structured Append count out of range (2-26)" },
/* 20*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 0, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index out of range (1-2)" },
/* 21*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 3, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index out of range (1-2)" },
/* 22*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 2, "A B" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 703: Structured Append ID cannot contain spaces" },
/* 6*/ { BARCODE_AZTEC, -1, -1, -1, 37, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Version '37' out of range (1 to 36)" },
/* 7*/ { BARCODE_AZTEC, -1, -1, -1, -2, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Version '-2' out of range (1 to 36)" },
/* 8*/ { BARCODE_AZTEC, GS1_MODE, READER_INIT, -1, -1, { 0, 0, "" }, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 501: Cannot encode in GS1 and Reader Initialisation mode at the same time" },
/* 9*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[91]A", 0, 15, 15, "" },
/* 10*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)A", 0, 15, 15, "" },
/* 11*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, { 0, 0, "" }, "A", 0, 109, 109, "" }, /* 22 layers */
/* 12*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 709: Version '27' out of range for Reader Initialisation symbols (maximum 26)" }, /* 23 layers */
/* 13*/ { BARCODE_AZTEC, -1, READER_INIT, 4, -1, { 0, 0, "" }, "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377", ZINT_ERROR_TOO_LONG, -1, -1, "Error 506: Input too long for Reader Initialisation, requires 23 layers (maximum 22)" }, /* 23 layers */
/* 14*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, { 0, 0, "" }, "A", 0, 15, 15, "" }, /* Compact 1 layer */
/* 15*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 3, { 0, 0, "" }, "A", 0, 19, 19, "" }, /* Compact 3 layers gets set to full 1 layer if READER_INIT set */
/* 16*/ { BARCODE_AZTEC, -1, -1, 1, -1, { 0, 0, "" }, "A", 0, 15, 15, "" }, /* Compact 1 layer */
/* 17*/ { BARCODE_AZTEC, -1, READER_INIT, 1, -1, { 0, 0, "" }, "A", 0, 15, 15, "" }, /* Still compact 1 layer if READER_INIT set */
/* 18*/ { BARCODE_AZRUNE, -1, -1, -1, -1, { 0, 0, "" }, "0001", ZINT_ERROR_TOO_LONG, -1, -1, "Error 507: Input length 4 too long (maximum 3)" },
/* 19*/ { BARCODE_AZRUNE, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 508: Invalid character at position 1 in input (digits only)" },
/* 20*/ { BARCODE_AZRUNE, -1, -1, -1, -1, { 0, 0, "" }, "256", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 509: Input value out of range (0 to 255)" },
/* 21*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 2, "" }, "1234567890", 0, 15, 15, "" },
/* 22*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 2, {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2'} }, "1234567890", 0, 23, 23, "" },
/* 23*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 1, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 701: Structured Append count '1' out of range (2 to 26)" },
/* 24*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 0, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index '0' out of range (1 to count 2)" },
/* 25*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 3, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index '3' out of range (1 to count 2)" },
/* 26*/ { BARCODE_AZTEC, -1, -1, -1, -1, { 1, 2, "A B" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 703: Structured Append ID cannot contain spaces" },
/* 27*/ { BARCODE_HIBC_AZTEC, -1, -1, -1, -1, { 0, 0, "" }, "1234567890;", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 11 in input (alphanumerics, space and \"-.$/+%\" only)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -316,7 +339,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, UNICODE_MODE, -1, -1, -1, 1, "123456789012", -1, 0, 15, 15, 1, "ISO/IEC 24778:2008 Figure 1 (left)",
"000111000011100"
"110111001110010"
@ -2577,7 +2600,7 @@ static void test_encode(const testCtx *const p_ctx) {
"00111111100"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -2668,7 +2691,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, 1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 15, 15, 1, "ISO/IEC 24778:2008 16.5 example",
"001111000011111"
"110111100100011"
@ -2843,7 +2866,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"10001000000000111000011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
@ -2948,9 +2971,10 @@ static void test_fuzz(const testCtx *const p_ctx) {
char *data;
int length;
int ret;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, DATA_MODE, -1, -1,
"\133\060\060\060\135\060\125\125\125\125\140\060\125\125\125\125\060\060\060\271\060\060\125\103\164\125\125\125\377\377\125\125"
"\125\125\125\125\125\133\060\076\060\135\261\177\261\261\261\236\261\261\261\040\261\261\261\261\261\261\261\020\261\261\261\261"
@ -3023,7 +3047,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\261\261\261\261\261\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\135\135\135\135\135\135"
"\135\335\135\060\060\010\010\010\010\010\060",
2251, ZINT_ERROR_TOO_LONG
2251, ZINT_ERROR_TOO_LONG, "Error 707: Input too long for ECC level 2, requires too many codewords (maximum 1279)"
}, /* Original OSS-Fuzz triggering data for malloc leak */
/* 1*/ { BARCODE_AZTEC, DATA_MODE, -1, -1,
"\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060"
@ -3114,7 +3138,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\060\060\060\363\060\060\060\060\060\060\060\060\060\060\060\060\362\060\060\060\060\060\000\060\060\377\060\060\060\175\175\175"
"\175\060\060\060\175\175\175\175\060\060\005\060\005\060\005\060\060\060\060\000\000\060\060\060\060\060\060\377\060\060\060\060"
"\377\060\377\377\060\060\057\060\060\057\060\060\060\000\000\060\060",
2801, ZINT_ERROR_TOO_LONG
2801, ZINT_ERROR_TOO_LONG, "Error 502: Input too long, requires too many codewords (maximum 1661)"
}, /* Original OSS-Fuzz triggering data for binary_string buffer overrun */
/* 2*/ { BARCODE_AZTEC, -1, 1, -1,
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
@ -3150,7 +3174,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123",
4483, 0
4483, 0, ""
}, /* 4483 = (1664 (Max codewords) - 169 (ECC codewords) - 5/12 (D/L) - 3/12 (padding)) * 3 (3 4-bit digits per 12-bit wordcode) = 4483 */
/* 3*/ { BARCODE_AZTEC, -1, 1, -1,
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
@ -3186,7 +3210,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123",
4484, ZINT_ERROR_TOO_LONG
4484, ZINT_ERROR_TOO_LONG, "Error 707: Input too long for ECC level 1, requires too many codewords (maximum 1495)"
},
/* 4*/ { BARCODE_AZTEC, -1, 1, -1,
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -3216,8 +3240,8 @@ static void test_fuzz(const testCtx *const p_ctx) {
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY",
3587, 0
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ",
3588, 0, ""
},
/* 5*/ { BARCODE_AZTEC, -1, 1, -1,
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -3247,8 +3271,8 @@ static void test_fuzz(const testCtx *const p_ctx) {
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ",
3588, ZINT_ERROR_TOO_LONG
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA",
3589, ZINT_ERROR_TOO_LONG, "Error 707: Input too long for ECC level 1, requires too many codewords (maximum 1495)"
},
/* 6*/ { BARCODE_AZTEC, -1, 1, -1,
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
@ -3307,7 +3331,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240",
2237, 0
2237, 0, ""
},
/* 7*/ { BARCODE_AZTEC, -1, 1, -1,
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
@ -3366,7 +3390,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240"
"\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240\240",
2238, ZINT_ERROR_TOO_LONG
2238, ZINT_ERROR_TOO_LONG, "Error 707: Input too long for ECC level 1, requires too many codewords (maximum 1495)"
},
/* 8*/ { BARCODE_AZTEC, DATA_MODE, -1, 1,
"\105\105\000\000\000\000\000\000\000\000\077\012\377\377\377\072\376\376\350\350\350\350\350\250\350\350\350\350\354\350\350\350\350\350\001\000\000\000\000\000"
@ -3424,7 +3448,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\377\377\377\000\177\377\377\377"
"\046\000\000\000\000\000\000\027\027\027\027\027\027\027\027\027\027\027\027\000\027\027\027\027\000\004\000\000\000\000\000\135\000\044\103\000\000\377\377\377"
"\377\377\103\377\364\377\364",
2167, ZINT_ERROR_TOO_LONG
2167, ZINT_ERROR_TOO_LONG, "Error 704: Input too long for Version 1, requires too many codewords (maximum 14)"
}, /* #300 (#2) Andre Maute */
/* 9*/ { BARCODE_AZTEC, DATA_MODE, 1, -1,
"111\377\377\377\377\377\377\377\377"
@ -3480,7 +3504,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"111",
2054, 0
2054, 0, ""
}, /* 2048 byte block surrounded by digits */
/* 10*/ { BARCODE_AZTEC, DATA_MODE, -1, 1,
"\105\105\000\000\000\000\000\000\000\000\077\012\377\377\377\072\376\376\350\350\350\350\350\250\350\350\350\350\354\350\350\350\350\350\001\000\000\000\000\000"
@ -3537,7 +3561,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\377\377\377\377\377\377\377\000\177\377\377\377\046\000\000\000\000\000\000\027\027\027"
"\027\027\027\027\027\027\027\027\027\000\027\027\027\027\000\004\000\000\000\000\000\135\000\044\103\000\000\377\377\377\377\377\103\377\364\377\364",
2157, ZINT_ERROR_TOO_LONG
2157, ZINT_ERROR_TOO_LONG, "Error 704: Input too long for Version 1, requires too many codewords (maximum 14)"
}, /* #300 (#3) Andre Maute */
/* 11*/ { BARCODE_AZTEC, DATA_MODE, 2, -1,
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
@ -3565,7 +3589,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
996, 0
996, 0, ""
}, /* Padding 11 example causing issue with ZXing-C++ */
/* 12*/ { BARCODE_AZTEC, DATA_MODE, -1, -1,
"\133\060\060\060\135\060\125\125\125\125\140\060\125\125\125\125\060\060\060\271\060\060\125\103\164\125\125\125\377\377\125\125\125\125\125\125\125\133\060\076"
@ -3679,10 +3703,10 @@ static void test_fuzz(const testCtx *const p_ctx) {
"\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
"\377\377\377\377\377\261\261\261\261\261\060\060\060\060\060\060\060\060\060\060\060\060\060\060\060\135\135\135\135\135\135\135\335\135\060\060\010\010\010\010"
"\010\060",
4402, ZINT_ERROR_TOO_LONG
4402, ZINT_ERROR_TOO_LONG, "Error 502: Input too long, requires too many codewords (maximum 1661)"
}, /* fuzz_data (1st) */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -3705,6 +3729,8 @@ static void test_fuzz(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
@ -3747,7 +3773,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, -1, -1, -1,
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
@ -3787,7 +3813,7 @@ static void test_perf(const testCtx *const p_ctx) {
"255",
0, 11, 11, "3 chars, AZRUNE" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2022-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -47,12 +47,12 @@ static void test_input(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "123456", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input wrong length (should be between 7 and 18 characters)", "" },
/* 1*/ { UNICODE_MODE, -1, -1, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input wrong length (should be between 7 and 18 characters)", "" },
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "123456", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 792: Input length 6 too short (minimum 7)", "" },
/* 1*/ { UNICODE_MODE, -1, -1, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 790: Input length 19 too long (maximum 18)", "" },
/* 2*/ { UNICODE_MODE, -1, -1, "1234567", -1, 0, 1, 102, "1U234567", "" },
/* 3*/ { UNICODE_MODE, -1, -1, "1234567 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character in data (alphanumerics only, excluding the letter \"O\")", "" },
/* 4*/ { UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNOPQR", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character in data (alphanumerics only, excluding the letter \"O\")", "" },
/* 3*/ { UNICODE_MODE, -1, -1, "1234567 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 8 in input (alphanumerics only, excluding \"O\")", "" },
/* 4*/ { UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNOPQR", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 791: Invalid character at position 15 in input (alphanumerics only, excluding \"O\")", "" },
/* 5*/ { UNICODE_MODE, -1, -1, "ABCDEFGHIJKLMNPQRS", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" },
/* 6*/ { UNICODE_MODE, -1, -1, "STUVWXYZ1234567890", -1, 0, 1, 234, "SCTUVWXYZ1234567890", "" },
/* 7*/ { UNICODE_MODE, -1, -1, "abcdefghijklmnpqrs", -1, 0, 1, 234, "AQBCDEFGHIJKLMNPQRS", "" },
@ -71,16 +71,16 @@ static void test_input(const testCtx *const p_ctx) {
/* 20*/ { UNICODE_MODE, -1, -1, "2J1STN4ZE8AHVLG90R", -1, 0, 1, 234, "2PJ1STN4ZE8AHVLG90R", "" },
/* 21*/ { UNICODE_MODE, -1, -1, "JJJJJJJJJJJJJJJJJJ", -1, 0, 1, 234, "J9JJJJJJJJJJJJJJJJJ", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char bwipp_buf[8192];
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -135,7 +135,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, "AQ45670", 0, 1, 102, 1, "SEMI T1-95 Figure 2, same",
"100101000100100100010101000100010101000101010000010101001010000101001001000101001000100101010100000101"
},
@ -143,9 +143,9 @@ static void test_encode(const testCtx *const p_ctx) {
"100101000100100100100010100101001001000101000100010101000010100101010010000101010001000101010000100101010000010101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char bwipp_buf[8192];
@ -153,7 +153,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -45,7 +45,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 1, 1, "1", 0, 0 },
/* 1*/ { 2, 1, "11", 0, 0 },
/* 2*/ { 2, 2, "10", 1, 0 },
@ -57,7 +57,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
/* 8*/ { 5, 1, "10101", 0, 0 },
/* 9*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0, 0 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol *symbol;
@ -140,13 +140,13 @@ static void test_print(const testCtx *const p_ctx) {
char *data;
char *expected_file;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", "123", "pdf417_fg_bg.bmp" },
/* 1*/ { BARCODE_ULTRA, -1, -1, 5, -1, -1, -1, "147AD0", "FC9630", "123", "ultracode_fg_bg.bmp" },
/* 2*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, "147AD0", "FC9630", "123", "ultracode_fg_bg_hvwsp1_box1.bmp" },
/* 3*/ { BARCODE_PDF417COMP, -1, -1, 2, 2, -1, -1, "", "", "123", "pdf417comp_hvwsp2.bmp" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
@ -266,12 +266,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "601: Could not open BMP output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "bmp_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = bmp_pixel_plot(&symbol, data);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "bmp_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "bmp_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,7 +42,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, "1", -1, "01" },
/* 1*/ { 3, "1", -1, "01" },
/* 2*/ { 3, "12", -1, "12" },
@ -65,11 +65,11 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 19*/ { 8, "12", -1, "0000012" },
/* 20*/ { 8, "1", -1, "0000001" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_hrt");
testStartSymbol("test_hrt", &symbol);
for (i = 0; i < data_size; i++) {
@ -100,67 +100,70 @@ static void test_input(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { -1, "0", 0, 1, 19 }, /* < 3 ignored */
/* 1*/ { 0, "0", 0, 1, 19, },
/* 2*/ { 1, "0", 0, 1, 19, },
/* 3*/ { 2, "0", 0, 1, 19, },
/* 4*/ { 9, "0", 0, 1, 19, }, /* > 8 ignored */
/* 5*/ { -1, "00", 0, 1, 19 },
/* 6*/ { 3, "00", 0, 1, 19 },
/* 7*/ { -1, "26", 0, 1, 19, },
/* 8*/ { 3, "26", 0, 1, 19, },
/* 9*/ { 3, "27", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 10*/ { 3, "000", 0, 1, 19, },
/* 11*/ { 3, "001", 0, 1, 19, },
/* 12*/ { 3, "026", 0, 1, 19, },
/* 13*/ { -1, "27", 0, 1, 23 }, /* Channel 4 */
/* 14*/ { -1, "026", 0, 1, 23, }, /* Defaults to channel 4 due to length */
/* 15*/ { 3, "0026", 0, 1, 19, },
/* 16*/ { 3, "1234", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 17*/ { 4, "000", 0, 1, 23 },
/* 18*/ { -1, "000", 0, 1, 23 }, /* Defaults to channel 4 due to length */
/* 19*/ { 4, "026", 0, 1, 23 },
/* 20*/ { 4, "0000026", 0, 1, 23 },
/* 21*/ { 4, "0000", 0, 1, 23 },
/* 22*/ { 4, "292", 0, 1, 23 },
/* 23*/ { 4, "293", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 24*/ { -1, "293", 0, 1, 27 }, /* Channel 5 */
/* 25*/ { 5, "0000", 0, 1, 27 },
/* 26*/ { -1, "0000", 0, 1, 27 }, /* Defaults to channel 5 due to length */
/* 27*/ { -1, "3493", 0, 1, 27 },
/* 28*/ { 5, "3493", 0, 1, 27 },
/* 29*/ { 5, "3494", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 30*/ { -1, "3494", 0, 1, 31 }, /* Channel 6 */
/* 31*/ { 6, "00000", 0, 1, 31 },
/* 32*/ { -1, "00000", 0, 1, 31 }, /* Defaults to channel 5 due to length */
/* 33*/ { -1, "44072", 0, 1, 31 },
/* 34*/ { 6, "44072", 0, 1, 31 },
/* 35*/ { 6, "44073", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 36*/ { -1, "44073", 0, 1, 35 }, /* Channel 7 */
/* 37*/ { 7, "000000", 0, 1, 35 },
/* 38*/ { -1, "000000", 0, 1, 35 }, /* Defaults to channel 7 due to length */
/* 39*/ { 7, "576688", 0, 1, 35 },
/* 40*/ { 7, "576689", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 41*/ { 7, "0576688", 0, 1, 35 },
/* 42*/ { -1, "1234567", 0, 1, 39 },
/* 43*/ { -1, "576689", 0, 1, 39 }, /* Channel 8 */
/* 44*/ { 8, "0000000", 0, 1, 39, },
/* 45*/ { -1, "0000000", 0, 1, 39, }, /* Defaults to channel 8 due to length */
/* 46*/ { 8, "1234567", 0, 1, 39, },
/* 47*/ { 8, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 48*/ { 8, "01234567", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 49*/ { 8, "00000000", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 50*/ { 9, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 51*/ { -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
static const struct item data[] = {
/* 0*/ { -1, "0", 0, 1, 19, "" }, /* < 3 ignored */
/* 1*/ { 0, "0", 0, 1, 19, "" },
/* 2*/ { 1, "0", 0, 1, 19, "" },
/* 3*/ { 2, "0", 0, 1, 19, "" },
/* 4*/ { 9, "0", 0, 1, 19, "" }, /* > 8 ignored */
/* 5*/ { -1, "00", 0, 1, 19, "" },
/* 6*/ { 3, "00", 0, 1, 19, "" },
/* 7*/ { -1, "26", 0, 1, 19, "" },
/* 8*/ { 3, "26", 0, 1, 19, "" },
/* 9*/ { 3, "27", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"27\" out of range (0 to 26 for 3 channels)" },
/* 10*/ { 3, "027", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"27\" out of range (0 to 26 for 3 channels)" },
/* 11*/ { 3, "000", 0, 1, 19, "" },
/* 12*/ { 3, "001", 0, 1, 19, "" },
/* 13*/ { 3, "026", 0, 1, 19, "" },
/* 14*/ { -1, "27", 0, 1, 23, "" }, /* Channel 4 */
/* 15*/ { -1, "026", 0, 1, 23, "" }, /* Defaults to channel 4 due to length */
/* 16*/ { 3, "0026", 0, 1, 19, "" },
/* 17*/ { 3, "1234", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"1234\" out of range (0 to 26 for 3 channels)" },
/* 18*/ { 4, "000", 0, 1, 23, "" },
/* 19*/ { -1, "000", 0, 1, 23, "" }, /* Defaults to channel 4 due to length */
/* 20*/ { 4, "026", 0, 1, 23, "" },
/* 21*/ { 4, "0000026", 0, 1, 23, "" },
/* 22*/ { 4, "0000", 0, 1, 23, "" },
/* 23*/ { 4, "292", 0, 1, 23, "" },
/* 24*/ { 4, "293", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"293\" out of range (0 to 292 for 4 channels)" },
/* 25*/ { 4, "000293", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"293\" out of range (0 to 292 for 4 channels)" },
/* 26*/ { -1, "293", 0, 1, 27, "" }, /* Channel 5 */
/* 27*/ { 5, "0000", 0, 1, 27, "" },
/* 28*/ { -1, "0000", 0, 1, 27, "" }, /* Defaults to channel 5 due to length */
/* 29*/ { -1, "3493", 0, 1, 27, "" },
/* 30*/ { 5, "3493", 0, 1, 27, "" },
/* 31*/ { 5, "3494", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"3494\" out of range (0 to 3493 for 5 channels)" },
/* 32*/ { -1, "3494", 0, 1, 31, "" }, /* Channel 6 */
/* 33*/ { 6, "00000", 0, 1, 31, "" },
/* 34*/ { -1, "00000", 0, 1, 31, "" }, /* Defaults to channel 5 due to length */
/* 35*/ { -1, "44072", 0, 1, 31, "" },
/* 36*/ { 6, "44072", 0, 1, 31, "" },
/* 37*/ { 6, "44073", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"44073\" out of range (0 to 44072 for 6 channels)" },
/* 38*/ { -1, "44073", 0, 1, 35, "" }, /* Channel 7 */
/* 39*/ { 7, "000000", 0, 1, 35, "" },
/* 40*/ { -1, "000000", 0, 1, 35, "" }, /* Defaults to channel 7 due to length */
/* 41*/ { 7, "576688", 0, 1, 35, "" },
/* 42*/ { 7, "576689", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 335: Input value \"576689\" out of range (0 to 576688 for 7 channels)" },
/* 43*/ { 7, "0576688", 0, 1, 35, "" },
/* 44*/ { -1, "1234567", 0, 1, 39, "" },
/* 45*/ { -1, "576689", 0, 1, 39, "" }, /* Channel 8 */
/* 46*/ { 8, "0000000", 0, 1, 39, "" },
/* 47*/ { -1, "0000000", 0, 1, 39, "" }, /* Defaults to channel 8 due to length */
/* 48*/ { 8, "1234567", 0, 1, 39, "" },
/* 49*/ { 8, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 318: Input value \"7742863\" out of range (0 to 7742862)" },
/* 50*/ { 8, "01234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 333: Input length 8 too long (maximum 7)" },
/* 51*/ { 8, "00000000", ZINT_ERROR_TOO_LONG, -1, -1, "Error 333: Input length 8 too long (maximum 7)" },
/* 52*/ { 9, "7742863", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 318: Input value \"7742863\" out of range (0 to 7742862)" },
/* 53*/ { -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 334: Invalid character at position 1 in input (digits only)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -173,6 +176,8 @@ static void test_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
@ -200,7 +205,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, "1234", 0, 1, 27, "ANSI/AIM BC12-1998 Figure 1",
"101010101001010010011110011"
},
@ -412,15 +417,15 @@ static void test_encode(const testCtx *const p_ctx) {
"101010101000001110010101101100101110011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char bwipp_buf[8192];
char bwipp_msg[1024];
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {
@ -473,8 +478,8 @@ static void test_generate(const testCtx *const p_ctx) {
struct item {
char *data;
};
struct item data[] = { { "576688" }, { "7742862" } };
int data_size = ARRAY_SIZE(data);
static const struct item data[] = { { "576688" }, { "7742862" } };
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,48 +42,51 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { -1, -1, "A", 2666, 0, 44, 728 },
/* 1*/ { -1, -1, "A", 2725, 0, 44, 739 },
/* 2*/ { -1, -1, "A", 2726, 0, 44, 739 }, /* 4.2.1 c.3 says max 2725 but actually 44 * 62 - 2 == 2726 as mentioned later in 4.8.1 */
/* 3*/ { -1, -1, "A", 2727, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { -1, -1, "A", ZINT_MAX_DATA_LEN, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 5*/ { -1, -1, "12", 2726 * 2, 0, 44, 739 },
/* 6*/ { -1, -1, "12", 2726 * 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 7*/ { -1, -1, "\351", 2726 / 2, 0, 44, 739 },
/* 8*/ { -1, -1, "\351", 2726 / 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { 1, -1, "A", 99, 0, 1, 1124 }, /* CODE128 99 max */
/* 10*/ { 1, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { 2, -1, "A", 122, 0, 2, 739 },
/* 12*/ { 2, 10, "A", 122, 0, 2, 739 }, /* Cols 10 -> 67 */
/* 13*/ { 2, 67, "A", 122, 0, 2, 739 },
/* 14*/ { 2, -1, "A", 123, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 15*/ { 2, -1, "A", 63 * 2, ZINT_ERROR_TOO_LONG, -1, -1 }, /* Triggers initial testColumns > 62 */
/* 16*/ { 2, -1, "A", 2726 * 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 17*/ { 2, 9, "A", 2726 * 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { 3, -1, "A", 184, 0, 3, 739 },
/* 19*/ { 3, -1, "A", 185, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { 10, -1, "A", 618, 0, 10, 739 },
/* 21*/ { 10, -1, "A", 619, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 22*/ { 20, -1, "A", 1238, 0, 20, 739 },
/* 23*/ { 20, -1, "A", 1239, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 24*/ { 30, -1, "A", 1858, 0, 30, 739 },
/* 25*/ { 30, -1, "A", 1859, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 26*/ { 40, -1, "A", 2478, 0, 40, 739 },
/* 27*/ { 40, -1, "A", 2479, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 28*/ { 43, -1, "A", 2664, 0, 43, 739 },
/* 29*/ { 43, -1, "A", 2665, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 30*/ { 44, -1, "A", 2726, 0, 44, 739 },
/* 31*/ { 44, -1, "A", 2727, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 32*/ { 44, 60, "A", 2726, 0, 44, 739 }, /* Cols 60 -> 67 */
/* 33*/ { 44, 67, "A", 2726, 0, 44, 739 },
static const struct item data[] = {
/* 0*/ { -1, -1, "A", 2666, 0, 44, 728, "" },
/* 1*/ { -1, -1, "A", 2725, 0, 44, 739, "" },
/* 2*/ { -1, -1, "A", 2726, 0, 44, 739, "" }, /* 4.2.1 c.3 says max 2725 but actually 44 * 62 - 2 == 2726 as mentioned later in 4.8.1 */
/* 3*/ { -1, -1, "A", 2727, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 4*/ { -1, -1, "A", ZINT_MAX_DATA_LEN, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 5*/ { -1, -1, "12", 2726 * 2, 0, 44, 739, "" },
/* 6*/ { -1, -1, "12", 2726 * 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 7*/ { -1, -1, "\351", 2726 / 2, 0, 44, 739, "" },
/* 8*/ { -1, -1, "\351", 2726 / 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 9*/ { -1, -1, "\001", 2726, 0, 44, 739, "" },
/* 10*/ { -1, -1, "\001", 2727, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 11*/ { 1, -1, "A", 99, 0, 1, 1124, "" }, /* CODE128 99 max */
/* 12*/ { 1, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" },
/* 13*/ { 2, -1, "A", 122, 0, 2, 739, "" },
/* 14*/ { 2, 10, "A", 122, 0, 2, 739, "" }, /* Cols 10 -> 67 */
/* 15*/ { 2, 67, "A", 122, 0, 2, 739, "" },
/* 16*/ { 2, -1, "A", 123, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 17*/ { 2, -1, "A", 63 * 2, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" }, /* Triggers initial testColumns > 62 */
/* 18*/ { 2, -1, "A", 2726 * 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 19*/ { 2, 9, "A", 2726 * 2 + 1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 20*/ { 3, -1, "A", 184, 0, 3, 739, "" },
/* 21*/ { 3, -1, "A", 185, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 22*/ { 10, -1, "A", 618, 0, 10, 739, "" },
/* 23*/ { 10, -1, "A", 619, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 24*/ { 20, -1, "A", 1238, 0, 20, 739, "" },
/* 25*/ { 20, -1, "A", 1239, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 26*/ { 30, -1, "A", 1858, 0, 30, 739, "" },
/* 27*/ { 30, -1, "A", 1859, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 28*/ { 40, -1, "A", 2478, 0, 40, 739, "" },
/* 29*/ { 40, -1, "A", 2479, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 30*/ { 43, -1, "A", 2664, 0, 43, 739, "" },
/* 31*/ { 43, -1, "A", 2665, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 32*/ { 44, -1, "A", 2726, 0, 44, 739, "" },
/* 33*/ { 44, -1, "A", 2727, ZINT_ERROR_TOO_LONG, -1, -1, "Error 413: Input too long, requires too many symbol characters (maximum 2726)" },
/* 34*/ { 44, 60, "A", 2726, 0, 44, 739, "" }, /* Cols 60 -> 67 */
/* 35*/ { 44, 67, "A", 2726, 0, 44, 739, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -105,6 +108,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -128,36 +133,37 @@ static void test_options(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { UNICODE_MODE, 1, -1, "é", 0, 1, 57, "CODE128" },
/* 1*/ { UNICODE_MODE, -1, -1, "A", 0, 2, 101, "Defaults" },
/* 2*/ { UNICODE_MODE, 0, -1, "A", 0, 2, 101, "0 rows same as -1" },
/* 3*/ { UNICODE_MODE, 2, -1, "A", 0, 2, 101, "Rows 2, columns default" },
/* 4*/ { UNICODE_MODE, 3, -1, "A", 0, 3, 101, "Rows 3" },
/* 5*/ { UNICODE_MODE, 43, -1, "A", 0, 43, 101, "Rows 43" },
/* 6*/ { UNICODE_MODE, 44, -1, "A", 0, 44, 101, "Max rows" },
/* 7*/ { UNICODE_MODE, 45, -1, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "" },
/* 8*/ { UNICODE_MODE, -1, -1, "abcdefg", 0, 3, 101, "" },
/* 9*/ { UNICODE_MODE, 2, -1, "abcdefg", 0, 2, 112, "Rows given so columns expanded" },
/* 10*/ { UNICODE_MODE, 3, -1, "abcdefg", 0, 3, 101, "" },
/* 11*/ { UNICODE_MODE, -1, 8, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Min columns 9 (4 data)" },
/* 12*/ { UNICODE_MODE, -1, 9, "A", 0, 2, 101, "Min columns 9 (4 data)" },
/* 13*/ { UNICODE_MODE, -1, 10, "A", 0, 2, 112, "Columns 10" },
/* 14*/ { UNICODE_MODE, -1, 66, "A", 0, 2, 728, "Columns 66" },
/* 15*/ { UNICODE_MODE, -1, 67, "A", 0, 2, 739, "Max columns 67 (62 data)" },
/* 16*/ { UNICODE_MODE, -1, 68, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "" },
/* 17*/ { UNICODE_MODE, 2, 9, "A", 0, 2, 101, "Rows and columns defaults given" },
/* 18*/ { UNICODE_MODE, 2, 10, "A", 0, 2, 112, "Rows and columns given" },
/* 19*/ { UNICODE_MODE, 3, 11, "A", 0, 3, 123, "" },
/* 20*/ { UNICODE_MODE, 43, 66, "A", 0, 43, 728, "" },
/* 21*/ { UNICODE_MODE, 44, 67, "A", 0, 44, 739, "Max rows, max columns" },
/* 22*/ { GS1_MODE, -1, -1, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "GS1 not supported" },
/* 23*/ { GS1_MODE, 1, -1, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Check for CODE128" },
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 1, -1, "é", 0, 1, 57, "", "CODE128" },
/* 1*/ { UNICODE_MODE, -1, -1, "A", 0, 2, 101, "", "Defaults" },
/* 2*/ { UNICODE_MODE, 0, -1, "A", 0, 2, 101, "", "0 rows same as -1" },
/* 3*/ { UNICODE_MODE, 2, -1, "A", 0, 2, 101, "", "Rows 2, columns default" },
/* 4*/ { UNICODE_MODE, 3, -1, "A", 0, 3, 101, "", "Rows 3" },
/* 5*/ { UNICODE_MODE, 43, -1, "A", 0, 43, 101, "", "Rows 43" },
/* 6*/ { UNICODE_MODE, 44, -1, "A", 0, 44, 101, "", "Max rows" },
/* 7*/ { UNICODE_MODE, 45, -1, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 410: Number of rows '45' out of range (0 to 44)", "" },
/* 8*/ { UNICODE_MODE, -1, -1, "abcdefg", 0, 3, 101, "", "" },
/* 9*/ { UNICODE_MODE, 2, -1, "abcdefg", 0, 2, 112, "", "Rows given so columns expanded" },
/* 10*/ { UNICODE_MODE, 3, -1, "abcdefg", 0, 3, 101, "", "" },
/* 11*/ { UNICODE_MODE, -1, 8, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 411: Number of columns '8' out of range (9 to 67)", "Min columns 9 (4 data)" },
/* 12*/ { UNICODE_MODE, -1, 9, "A", 0, 2, 101, "", "Min columns 9 (4 data)" },
/* 13*/ { UNICODE_MODE, -1, 10, "A", 0, 2, 112, "", "Columns 10" },
/* 14*/ { UNICODE_MODE, -1, 66, "A", 0, 2, 728, "", "Columns 66" },
/* 15*/ { UNICODE_MODE, -1, 67, "A", 0, 2, 739, "", "Max columns 67 (62 data)" },
/* 16*/ { UNICODE_MODE, -1, 68, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 411: Number of columns '68' out of range (9 to 67)", "" },
/* 17*/ { UNICODE_MODE, 2, 9, "A", 0, 2, 101, "", "Rows and columns defaults given" },
/* 18*/ { UNICODE_MODE, 2, 10, "A", 0, 2, 112, "", "Rows and columns given" },
/* 19*/ { UNICODE_MODE, 3, 11, "A", 0, 3, 123, "", "" },
/* 20*/ { UNICODE_MODE, 43, 66, "A", 0, 43, 728, "", "" },
/* 21*/ { UNICODE_MODE, 44, 67, "A", 0, 44, 739, "", "Max rows, max columns" },
/* 22*/ { GS1_MODE, -1, -1, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 220: Selected symbology does not support GS1 mode", "" },
/* 23*/ { GS1_MODE, 1, -1, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 220: Selected symbology does not support GS1 mode", "Check for CODE128" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -174,6 +180,8 @@ static void test_options(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
@ -200,12 +208,12 @@ static void test_reader_init(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, READER_INIT, "1234", 0, 2, 101, "67 64 40 60 63 0C 22 2B 6A 67 64 0B 63 64 3A 1C 29 6A", "CodeB FNC3 CodeC 12 34 / CodeB Pads" },
/* 1*/ { BARCODE_CODABLOCKF, UNICODE_MODE, READER_INIT, "\001\002", 0, 2, 101, "67 62 40 60 41 42 63 32 6A 67 64 0B 63 64 45 42 0F 6A", "FNC3 SOH STX / CodeB Pads" },
/* 2*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, READER_INIT, "123456", 0, 3, 101, "67 64 41 60 0B 11 12 22 6A 67 63 2B 22 38 64 2A 1B 6A 67 64 0C 63 64 2B 2F 52 6A", "CodeB FNC3 + 1 2 / CodeC 34 56 CodeB J" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -278,7 +286,7 @@ static void test_input(const testCtx *const p_ctx) {
ñ U+00F1 (\361, 241), UTF-8 C3B1, CodeB-only extended ASCII
ÿ U+00FF (\377, 255), UTF-8 C3BF, CodeB-only extended ASCII
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "A", -1, 0, 2, 101, 1, "67 64 40 21 63 64 63 42 6A 67 64 0B 63 64 2B 40 4F 6A", "Fillings 5" },
/* 1*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAA", -1, 0, 2, 101, 1, "67 64 40 21 21 21 63 55 6A 67 64 0B 63 64 0E 57 48 6A", "Fillings 3" },
/* 2*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "AAAA", -1, 0, 2, 101, 1, "67 64 40 21 21 21 21 65 6A 67 64 0B 63 64 1A 0E 03 6A", "Fillings 2" },
@ -325,8 +333,9 @@ static void test_input(const testCtx *const p_ctx) {
/* 43*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé12345123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2" "B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé6789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890àààààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\012123456à\012à\012à\0123Ä4Ä5Ä6AÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécéÄÄÄÄÄÄ2ÄÄÄÄÄÄÄÄ4ÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécéÄÄÄAÄÄÄÄÄÄaÄÄÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé", -1, 0, 44, 739, 0, "(2948) 67 63 2A 0C 22 38 4E 5A 0C 22 65 15 21 22 23 24 25 26 27 28 29 4A 63 0C 22 38 64", "BWIPP gs command too long" },
/* 44*/ { BARCODE_CODABLOCKF, UNICODE_MODE, -1, -1, "ÿ12345678\012à12345678abcdef\012\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890ààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄÄÄÄÄ2ÄÄÄÄÄÄ4ÄÄÄÄÄÄaÄÄÄÄé1é2é34é56Ä78é9éAéBéCéééééaébécé123456789012345ABCDEFGHI\012123456ÿ12345678\012à12345678abcdef\012123456\012\0127890àABCDEFà\012\012ààGHIJKàLMNOPQabc\012defà1234567ghijk\012\012à901234\0122567890àààààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2B3C4a5b6c7d8e9\0120\0121\0122\0123Ä4Ä5Ä6A7a8A9a0\012Ä12345678ÄÄ2Ä4ÄaÄé1é2é34é56Ä78é9éAéBéCééaébécé123456789012345ABCDEF\012123456ÿ123456\012à12345678abcdef\012\0121234\012\0127890àABCDà\012\012ààGHIJKàLMabc\012defà1234567ghijk\012\012à901234\012\012\012\012567890ààABCDEFGààà\012\012\012HIJK\012\012\012\012à\012à\012à\01212345à\012à\012à67890ààÄ9012ÄÄ56789Ä12Ä3\0124\0125\0126A\012a\012A\012A\012a\012a\012BCD1A2", -1, 0, 33, 387, 0, "(1155) 67 64 5F 64 5F 63 0C 22 38 4E 65 4A 64 64 40 63 0C 22 38 4E 64 41 42 43 44 45 46", "BWIPP different encodation" },
/* 45*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, "A99912345/$$52001510X3", -1, 0, 6, 101, 1, "(54) 67 64 44 0B 21 19 19 3A 6A 67 63 2B 5B 17 2D 64 24 6A 67 64 0C 0F 04 04 15 16 6A 67", "" },
/* 46*/ { BARCODE_HIBC_BLOCKF, UNICODE_MODE, -1, -1, "A99912345/$$520:1510X3", -1, ZINT_ERROR_INVALID_DATA, -1, -1, 1, "Error 203: Invalid character at position 16 in input (alphanumerics, space and \"-.$/+%\" only)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -414,7 +423,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABLOCKF, 1, -1, "AIM", 0, 1, 68, 1, "Same as CODE128 (not supported by BWIPP or ZXing-C++)",
"11010010000101000110001100010001010111011000101110110001100011101011"
},
@ -502,7 +511,7 @@ static void test_encode(const testCtx *const p_ctx) {
"11010000100101111011101001101110010110001000101110111101101000111011000110110100011010001100011101011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -588,7 +597,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int bwipp_cmp;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, "\034\034I", 3, 0, 1, "" },
/* 1*/ { 6, -2147483647 - 1 /*Suppress MSVC warning C4146*/,
"\134\000\377\153\143\163\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061\061"
@ -600,7 +609,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
238, 0, 0, "BWIPP different (better) encodation"
}, /* #300 (#9) Andre Maute */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,39 +42,40 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "13", 140, 0, 1, 1151 }, /* 8 (Start) + 140*8 + 2*8 (Checks) + 7 (Stop) == 1151 */
/* 1*/ { BARCODE_CODE11, -1, "13", 141, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_CODE39, -1, "1", 86, 0, 1, 1143 }, /* 13 (Start) + 86*13 + 12 (Stop) == 1143 */
/* 3*/ { BARCODE_CODE39, -1, "1", 87, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_EXCODE39, -1, "1", 86, 0, 1, 1143 },
/* 5*/ { BARCODE_EXCODE39, -1, "1", 87, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_EXCODE39, -1, "a", 43, 0, 1, 1143 }, /* Takes 2 encoding chars per char */
/* 7*/ { BARCODE_EXCODE39, -1, "a", 44, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_EXCODE39, -1, "a", 86, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { BARCODE_LOGMARS, -1, "1", 30, 0, 1, 511 }, /* 16 (Start) + 30*16 + 15 (Stop) == 511 */
/* 10*/ { BARCODE_LOGMARS, -1, "1", 31, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { BARCODE_CODE93, -1, "1", 123, 0, 1, 1144 }, /* 9 (Start) + 123*9 + 2*9 (Checks) + 10 (Stop) == 1144 */
/* 12*/ { BARCODE_CODE93, -1, "1", 124, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 13*/ { BARCODE_CODE93, -1, "a", 61, 0, 1, 1135 }, /* Takes 2 encoding chars per char */
/* 14*/ { BARCODE_CODE93, -1, "a", 62, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 15*/ { BARCODE_CODE93, -1, "a", 124, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { BARCODE_CODE93, -1, "a1", 82, 0, 1, 1144 }, /* Takes 1.5 encoding chars (1.5*82 == 123) */
/* 17*/ { BARCODE_CODE93, -1, "a1", 83, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { BARCODE_PZN, -1, "1", 7, 0, 1, 142 }, /* Takes 8 with correct check digit */
/* 19*/ { BARCODE_PZN, -1, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { BARCODE_PZN, 1, "1", 6, 0, 1, 129 }, /* PZN7 takes 7 with correct check digit */
/* 21*/ { BARCODE_PZN, 1, "1", 8, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 22*/ { BARCODE_VIN, -1, "1", 17, 0, 1, 246 },
/* 23*/ { BARCODE_VIN, -1, "1", 18, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 24*/ { BARCODE_VIN, -1, "1", 16, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 25*/ { BARCODE_VIN, 1, "1", 17, 0, 1, 259 },
/* 26*/ { BARCODE_HIBC_39, -1, "1", 68, 0, 1, 1151 }, /* 70 - 2 ('+' and check digit) */
/* 27*/ { BARCODE_HIBC_39, -1, "1", 69, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "13", 140, 0, 1, 1151, "" }, /* 8 (Start) + 140*8 + 2*8 (Checks) + 7 (Stop) == 1151 */
/* 1*/ { BARCODE_CODE11, -1, "13", 141, ZINT_ERROR_TOO_LONG, -1, -1, "Error 320: Input length 141 too long (maximum 140)" },
/* 2*/ { BARCODE_CODE39, -1, "1", 86, 0, 1, 1143, "" }, /* 13 (Start) + 86*13 + 12 (Stop) == 1143 */
/* 3*/ { BARCODE_CODE39, -1, "1", 87, ZINT_ERROR_TOO_LONG, -1, -1, "Error 323: Input length 87 too long (maximum 86)" },
/* 4*/ { BARCODE_EXCODE39, -1, "1", 86, 0, 1, 1143, "" },
/* 5*/ { BARCODE_EXCODE39, -1, "1", 87, ZINT_ERROR_TOO_LONG, -1, -1, "Error 328: Input length 87 too long (maximum 86)" },
/* 6*/ { BARCODE_EXCODE39, -1, "a", 43, 0, 1, 1143, "" }, /* Takes 2 encoding chars per char */
/* 7*/ { BARCODE_EXCODE39, -1, "a", 44, ZINT_ERROR_TOO_LONG, -1, -1, "Error 317: Input too long, requires 88 symbol characters (maximum 86)" },
/* 8*/ { BARCODE_EXCODE39, -1, "a", 86, ZINT_ERROR_TOO_LONG, -1, -1, "Error 317: Input too long, requires 172 symbol characters (maximum 86)" },
/* 9*/ { BARCODE_LOGMARS, -1, "1", 30, 0, 1, 511, "" }, /* 16 (Start) + 30*16 + 15 (Stop) == 511 */
/* 10*/ { BARCODE_LOGMARS, -1, "1", 31, ZINT_ERROR_TOO_LONG, -1, -1, "Error 322: Input length 31 too long (maximum 30)" },
/* 11*/ { BARCODE_CODE93, -1, "1", 123, 0, 1, 1144, "" }, /* 9 (Start) + 123*9 + 2*9 (Checks) + 10 (Stop) == 1144 */
/* 12*/ { BARCODE_CODE93, -1, "1", 124, ZINT_ERROR_TOO_LONG, -1, -1, "Error 330: Input length 124 too long (maximum 123)" },
/* 13*/ { BARCODE_CODE93, -1, "a", 61, 0, 1, 1135, "" }, /* Takes 2 encoding chars per char */
/* 14*/ { BARCODE_CODE93, -1, "a", 62, ZINT_ERROR_TOO_LONG, -1, -1, "Error 332: Input too long, requires 124 symbol characters (maximum 123)" },
/* 15*/ { BARCODE_CODE93, -1, "a", 124, ZINT_ERROR_TOO_LONG, -1, -1, "Error 330: Input length 124 too long (maximum 123)" },
/* 16*/ { BARCODE_CODE93, -1, "a1", 82, 0, 1, 1144, "" }, /* Takes 1.5 encoding chars (1.5*82 == 123) */
/* 17*/ { BARCODE_CODE93, -1, "a1", 83, ZINT_ERROR_TOO_LONG, -1, -1, "Error 332: Input too long, requires 125 symbol characters (maximum 123)" },
/* 18*/ { BARCODE_PZN, -1, "1", 7, 0, 1, 142, "" }, /* Takes 8 with correct check digit */
/* 19*/ { BARCODE_PZN, -1, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 325: Input length 9 too long (maximum 8)" },
/* 20*/ { BARCODE_PZN, 1, "1", 6, 0, 1, 129, "" }, /* PZN7 takes 7 with correct check digit */
/* 21*/ { BARCODE_PZN, 1, "1", 8, ZINT_ERROR_TOO_LONG, -1, -1, "Error 325: Input length 8 too long (maximum 7)" },
/* 22*/ { BARCODE_VIN, -1, "1", 17, 0, 1, 246, "" },
/* 23*/ { BARCODE_VIN, -1, "1", 18, ZINT_ERROR_TOO_LONG, -1, -1, "Error 336: Input length 18 wrong (17 only)" },
/* 24*/ { BARCODE_VIN, -1, "1", 16, ZINT_ERROR_TOO_LONG, -1, -1, "Error 336: Input length 16 wrong (17 only)" },
/* 25*/ { BARCODE_VIN, 1, "1", 17, 0, 1, 259, "" },
/* 26*/ { BARCODE_HIBC_39, -1, "1", 68, 0, 1, 1151, "" }, /* 70 - 2 ('+' and check digit) */
/* 27*/ { BARCODE_HIBC_39, -1, "1", 69, ZINT_ERROR_TOO_LONG, -1, -1, "Error 319: Input length 69 too long (maximum 68)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -96,6 +97,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -120,7 +123,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "123-45", -1, "123-4552" }, /* 2 checksums */
/* 1*/ { BARCODE_CODE11, 1, "123-45", -1, "123-455" }, /* 1 check digit */
/* 2*/ { BARCODE_CODE11, 2, "123-45", -1, "123-45" }, /* No checksums */
@ -164,7 +167,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 40*/ { BARCODE_HIBC_39, -1, "abc1234", -1, "*+ABC1234+*" }, /* Converts to upper */
/* 41*/ { BARCODE_HIBC_39, -1, "123456789", -1, "*+1234567890*" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -195,84 +198,87 @@ static void test_input(const testCtx *const p_ctx) {
struct item {
int symbology;
int input_mode;
int option_2;
char *data;
int length;
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "-", -1, 0, 1, 37 },
/* 1*/ { BARCODE_CODE11, -1, "0123456789-", -1, 0, 1, 115 },
/* 2*/ { BARCODE_CODE11, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 3*/ { BARCODE_CODE11, -1, "12+", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_CODE11, -1, "1.2", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 5*/ { BARCODE_CODE11, -1, "12!", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 6*/ { BARCODE_CODE11, -1, " ", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 7*/ { BARCODE_CODE11, 3, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 8*/ { BARCODE_CODE39, -1, "a", -1, 0, 1, 38 }, /* Converts to upper */
/* 9*/ { BARCODE_CODE39, -1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", -1, 0, 1, 584 },
/* 10*/ { BARCODE_CODE39, -1, "AB!", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 11*/ { BARCODE_CODE39, -1, "A\"B", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 12*/ { BARCODE_CODE39, -1, "#AB", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 13*/ { BARCODE_CODE39, -1, "&", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 14*/ { BARCODE_CODE39, -1, "'", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 15*/ { BARCODE_CODE39, -1, "(", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 16*/ { BARCODE_CODE39, -1, ")", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 17*/ { BARCODE_CODE39, -1, "*", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 18*/ { BARCODE_CODE39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 19*/ { BARCODE_CODE39, -1, ":", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 20*/ { BARCODE_CODE39, -1, "@", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 21*/ { BARCODE_CODE39, -1, "[", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 22*/ { BARCODE_CODE39, -1, "`", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 23*/ { BARCODE_CODE39, -1, "{", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 24*/ { BARCODE_CODE39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 25*/ { BARCODE_CODE39, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 26*/ { BARCODE_CODE39, 0, "1", -1, 0, 1, 38 },
/* 27*/ { BARCODE_CODE39, 1, "1", -1, 0, 1, 51 }, /* Check digit */
/* 28*/ { BARCODE_CODE39, 2, "1", -1, 0, 1, 51 }, /* Hidden check digit */
/* 29*/ { BARCODE_CODE39, 3, "1", -1, 0, 1, 38 }, /* option_2 > 2 ignored */
/* 30*/ { BARCODE_EXCODE39, -1, "A", -1, 0, 1, 38 },
/* 31*/ { BARCODE_EXCODE39, 3, "A", -1, 0, 1, 38 }, /* option_2 > 2 ignored */
/* 32*/ { BARCODE_EXCODE39, -1, "a", -1, 0, 1, 51 },
/* 33*/ { BARCODE_EXCODE39, -1, ",", -1, 0, 1, 51 },
/* 34*/ { BARCODE_EXCODE39, -1, "\000", 1, 0, 1, 51 },
/* 35*/ { BARCODE_EXCODE39, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 36*/ { BARCODE_EXCODE39, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 37*/ { BARCODE_LOGMARS, -1, "A", -1, 0, 1, 47 },
/* 38*/ { BARCODE_LOGMARS, -1, "a", -1, 0, 1, 47 },
/* 39*/ { BARCODE_LOGMARS, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 40*/ { BARCODE_LOGMARS, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 41*/ { BARCODE_LOGMARS, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1, },
/* 42*/ { BARCODE_LOGMARS, 3, "A", -1, 0, 1, 47 }, /* option_2 > 2 ignored */
/* 43*/ { BARCODE_CODE93, -1, "A", -1, 0, 1, 46 },
/* 44*/ { BARCODE_CODE93, -1, "a", -1, 0, 1, 55 },
/* 45*/ { BARCODE_CODE93, -1, ",", -1, 0, 1, 55 },
/* 46*/ { BARCODE_CODE93, -1, "\000", 1, 0, 1, 55 },
/* 47*/ { BARCODE_CODE93, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 48*/ { BARCODE_CODE93, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 49*/ { BARCODE_PZN, -1, "1", -1, 0, 1, 142 },
/* 50*/ { BARCODE_PZN, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 51*/ { BARCODE_PZN, -1, "1000006", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Check digit == 10 so can't be used */
/* 52*/ { BARCODE_PZN, -1, "00000011", -1, ZINT_ERROR_INVALID_CHECK, -1, -1 },
/* 53*/ { BARCODE_PZN, 1, "100009", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Check digit == 10 so can't be used */
/* 54*/ { BARCODE_PZN, 1, "0000011", -1, ZINT_ERROR_INVALID_CHECK, -1, -1 },
/* 55*/ { BARCODE_VIN, -1, "5GZCZ43D13S812715", -1, 0, 1, 246 },
/* 56*/ { BARCODE_VIN, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_CHECK, -1, -1 }, /* North American with invalid check character */
/* 57*/ { BARCODE_VIN, -1, "WP0ZZZ99ZTS392124", -1, 0, 1, 246 }, /* Not North American so no check */
/* 58*/ { BARCODE_VIN, -1, "WP0ZZZ99ZTS392I24", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, /* I not allowed */
/* 59*/ { BARCODE_VIN, -1, "WPOZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, /* O not allowed */
/* 60*/ { BARCODE_VIN, -1, "WPQZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Q not allowed */
/* 61*/ { BARCODE_HIBC_39, -1, "a", -1, 0, 1, 79 }, /* Converts to upper */
/* 62*/ { BARCODE_HIBC_39, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 63*/ { BARCODE_HIBC_39, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 64*/ { BARCODE_HIBC_39, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 65*/ { BARCODE_HIBC_39, 1, "a", -1, 0, 1, 79 }, /* option_2 ignored */
/* 66*/ { BARCODE_HIBC_39, 2, "a", -1, 0, 1, 79 }, /* option_2 ignored */
static const struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, -1, "-", -1, 0, 1, 37, "" },
/* 1*/ { BARCODE_CODE11, -1, -1, "0123456789-", -1, 0, 1, 115, "" },
/* 2*/ { BARCODE_CODE11, -1, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 321: Invalid character at position 1 in input (digits and \"-\" only)" },
/* 3*/ { BARCODE_CODE11, -1, -1, "12+", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 321: Invalid character at position 3 in input (digits and \"-\" only)" },
/* 4*/ { BARCODE_CODE11, -1, -1, "1.2", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 321: Invalid character at position 2 in input (digits and \"-\" only)" },
/* 5*/ { BARCODE_CODE11, -1, -1, "12!", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 321: Invalid character at position 3 in input (digits and \"-\" only)" },
/* 6*/ { BARCODE_CODE11, -1, -1, " ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 321: Invalid character at position 1 in input (digits and \"-\" only)" },
/* 7*/ { BARCODE_CODE11, ESCAPE_MODE, -1, "\\d048 ", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 321: Invalid character at position 2 in input (digits and \"-\" only)" }, /* Note position doesn't account for escape sequences */
/* 8*/ { BARCODE_CODE11, -1, 3, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 339: Invalid check digit version '3' (1 or 2 only)" },
/* 9*/ { BARCODE_CODE39, -1, -1, "a", -1, 0, 1, 38, "" }, /* Converts to upper */
/* 10*/ { BARCODE_CODE39, -1, -1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", -1, 0, 1, 584, "" },
/* 11*/ { BARCODE_CODE39, -1, -1, "AB!", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 3 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 12*/ { BARCODE_CODE39, -1, -1, "A\"B", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 2 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 13*/ { BARCODE_CODE39, -1, -1, "#AB", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 14*/ { BARCODE_CODE39, -1, -1, "&", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 15*/ { BARCODE_CODE39, -1, -1, "'", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 16*/ { BARCODE_CODE39, -1, -1, "(", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 17*/ { BARCODE_CODE39, -1, -1, ")", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 18*/ { BARCODE_CODE39, -1, -1, "*", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 19*/ { BARCODE_CODE39, -1, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 20*/ { BARCODE_CODE39, -1, -1, ":", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 21*/ { BARCODE_CODE39, -1, -1, "@", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 22*/ { BARCODE_CODE39, -1, -1, "[", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 23*/ { BARCODE_CODE39, -1, -1, "`", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 24*/ { BARCODE_CODE39, -1, -1, "{", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 25*/ { BARCODE_CODE39, -1, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 26*/ { BARCODE_CODE39, -1, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 27*/ { BARCODE_CODE39, -1, 0, "1", -1, 0, 1, 38, "" },
/* 28*/ { BARCODE_CODE39, -1, 1, "1", -1, 0, 1, 51, "" }, /* Check digit */
/* 29*/ { BARCODE_CODE39, -1, 2, "1", -1, 0, 1, 51, "" }, /* Hidden check digit */
/* 30*/ { BARCODE_CODE39, -1, 3, "1", -1, 0, 1, 38, "" }, /* option_2 > 2 ignored */
/* 31*/ { BARCODE_EXCODE39, -1, -1, "A", -1, 0, 1, 38, "" },
/* 32*/ { BARCODE_EXCODE39, -1, 3, "A", -1, 0, 1, 38, "" }, /* option_2 > 2 ignored */
/* 33*/ { BARCODE_EXCODE39, -1, -1, "a", -1, 0, 1, 51, "" },
/* 34*/ { BARCODE_EXCODE39, -1, -1, ",", -1, 0, 1, 51, "" },
/* 35*/ { BARCODE_EXCODE39, -1, -1, "\000", 1, 0, 1, 51, "" },
/* 36*/ { BARCODE_EXCODE39, -1, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 329: Invalid character at position 1 in input, extended ASCII not allowed" },
/* 37*/ { BARCODE_EXCODE39, -1, -1, "ABCDé", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 329: Invalid character at position 5 in input, extended ASCII not allowed" },
/* 38*/ { BARCODE_LOGMARS, -1, -1, "A", -1, 0, 1, 47, "" },
/* 39*/ { BARCODE_LOGMARS, -1, -1, "a", -1, 0, 1, 47, "" },
/* 40*/ { BARCODE_LOGMARS, -1, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 41*/ { BARCODE_LOGMARS, -1, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 42*/ { BARCODE_LOGMARS, -1, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 324: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 43*/ { BARCODE_LOGMARS, -1, 3, "A", -1, 0, 1, 47, "" }, /* option_2 > 2 ignored */
/* 44*/ { BARCODE_CODE93, -1, -1, "A", -1, 0, 1, 46, "" },
/* 45*/ { BARCODE_CODE93, -1, -1, "a", -1, 0, 1, 55, "" },
/* 46*/ { BARCODE_CODE93, -1, -1, ",", -1, 0, 1, 55, "" },
/* 47*/ { BARCODE_CODE93, -1, -1, "\000", 1, 0, 1, 55, "" },
/* 48*/ { BARCODE_CODE93, -1, -1, "12\3004", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 331: Invalid character at position 3 in input, extended ASCII not allowed" },
/* 49*/ { BARCODE_CODE93, -1, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 331: Invalid character at position 1 in input, extended ASCII not allowed" },
/* 50*/ { BARCODE_PZN, -1, -1, "1", -1, 0, 1, 142, "" },
/* 51*/ { BARCODE_PZN, -1, -1, "A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 326: Invalid character at position 1 in input (digits only)" },
/* 52*/ { BARCODE_PZN, -1, -1, "1000006", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 327: Invalid PZN, check digit is '10'" }, /* Check digit == 10 so can't be used */
/* 53*/ { BARCODE_PZN, -1, -1, "00000011", -1, ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 890: Invalid check digit '1', expecting '7'" },
/* 54*/ { BARCODE_PZN, -1, 1, "100009", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 327: Invalid PZN, check digit is '10'" }, /* Check digit == 10 so can't be used */
/* 55*/ { BARCODE_PZN, -1, 1, "0000011", -1, ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 890: Invalid check digit '1', expecting '7'" },
/* 56*/ { BARCODE_VIN, -1, -1, "5GZCZ43D13S812715", -1, 0, 1, 246, "" },
/* 57*/ { BARCODE_VIN, -1, -1, "5GZCZ43D23S812715", -1, ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 338: Invalid check digit '2' (position 9), expecting '1'" }, /* North American with invalid check character */
/* 58*/ { BARCODE_VIN, -1, -1, "WP0ZZZ99ZTS392124", -1, 0, 1, 246, "" }, /* Not North American so no check */
/* 59*/ { BARCODE_VIN, -1, -1, "WP0ZZZ99ZTS392I24", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 337: Invalid character at position 15 in input (alphanumerics only, excluding \"IOQ\")" }, /* I not allowed */
/* 60*/ { BARCODE_VIN, -1, -1, "WPOZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 337: Invalid character at position 3 in input (alphanumerics only, excluding \"IOQ\")" }, /* O not allowed */
/* 61*/ { BARCODE_VIN, -1, -1, "WPQZZZ99ZTS392124", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 337: Invalid character at position 3 in input (alphanumerics only, excluding \"IOQ\")" }, /* Q not allowed */
/* 62*/ { BARCODE_HIBC_39, -1, -1, "a", -1, 0, 1, 79, "" }, /* Converts to upper */
/* 63*/ { BARCODE_HIBC_39, -1, -1, ",", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 64*/ { BARCODE_HIBC_39, -1, -1, "\000", 1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 65*/ { BARCODE_HIBC_39, -1, -1, "\300", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)" },
/* 66*/ { BARCODE_HIBC_39, -1, 1, "a", -1, 0, 1, 79, "" }, /* option_2 ignored */
/* 67*/ { BARCODE_HIBC_39, -1, 2, "a", -1, 0, 1, 79, "" }, /* option_2 ignored */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -285,10 +291,12 @@ static void test_input(const testCtx *const p_ctx) {
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -316,7 +324,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE11, -1, "123-45", -1, 0, 1, 78, "2 check digits (52); verified manually against TEC-IT",
"101100101101011010010110110010101011010101101101101101011011010100101101011001"
},
@ -447,7 +455,7 @@ static void test_encode(const testCtx *const p_ctx) {
"1000101110111010100010100010001010001000100010101000100010001010111010001110101010111000101011101010001110111010101000111011101011101000101011101110100011101010111010001010111010100011101110101000101110101110111011100010101010101000111011101010111000101110100010111011101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -536,7 +544,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE39, -1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+", 0, 1, 1130, "CODE39 85" },
/* 1*/ { BARCODE_CODE39, -1, "123456ABCD", 0, 1, 155, "CODE39 10" },
/* 2*/ { BARCODE_CODE93, -1,
@ -546,7 +554,7 @@ static void test_perf(const testCtx *const p_ctx) {
/* 4*/ { BARCODE_CODE11, -1, "1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-1234567890-", 0, 1, 966, "CODE11 121" },
/* 5*/ { BARCODE_CODE11, -1, "1234567890-", 0, 1, 116, "CODE11 5" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -43,154 +43,158 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* Reference AIM USS Code One Table 2 */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { -1, -1, { 0, 0, "" }, "1", 3550, 0, 148, 134 }, /* Auto Version H */
/* 1*/ { -1, -1, { 0, 0, "" }, "1", 3551, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { 3, -1, { 0, 0, "" }, "1", 3535, 0, 148, 134 }, /* With ECI */
/* 3*/ { 3, -1, { 0, 0, "" }, "1", 3536, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { -1, -1, { 1, 2, "" }, "1", 3546, 0, 148, 134 }, /* With Structured Append (Group mode, count < 2) */
/* 5*/ { -1, -1, { 1, 2, "" }, "1", 3547, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { -1, -1, { 1, 16, "" }, "1", 3541, 0, 148, 134 }, /* With Structured Append (Extended Group mode, count >= 16) */
/* 7*/ { -1, -1, { 1, 16, "" }, "1", 3542, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { 3, -1, { 1, 2, "" }, "1", 3532, 0, 148, 134 }, /* With ECI and Structured Append (Group mode) 1st symbol */
/* 9*/ { 3, -1, { 1, 2, "" }, "1", 3533, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { 3, -1, { 2, 2, "" }, "1", 3537, 0, 148, 134 }, /* With ECI and Structured Append (Group mode) subsequent symbol */
/* 11*/ { 3, -1, { 2, 2, "" }, "1", 3538, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { 3, -1, { 1, 16, "" }, "1", 3530, 0, 148, 134 }, /* With ECI and Structured Append (Extended Group mode) 1st symbol */
/* 13*/ { 3, -1, { 1, 16, "" }, "1", 3531, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { 3, -1, { 2, 16, "" }, "1", 3535, 0, 148, 134 }, /* With ECI and Structured Append (Extended Group mode) subsequent symbol */
/* 15*/ { 3, -1, { 2, 16, "" }, "1", 3536, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { -1, -1, { 0, 0, "" }, "A", 2218, 0, 148, 134 },
/* 17*/ { -1, -1, { 0, 0, "" }, "A", 2219, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { -1, -1, { 0, 0, "" }, "\001", 1480, 0, 148, 134 }, /* Full ASCII */
/* 19*/ { -1, -1, { 0, 0, "" }, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { -1, -1, { 0, 0, "" }, "\200", 1478, 0, 148, 134 }, /* BYTE */
/* 21*/ { -1, -1, { 0, 0, "" }, "\200", 1479, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 22*/ { -1, 1, { 0, 0, "" }, "1", 22, 0, 16, 18 }, /* Version A */
/* 23*/ { -1, 1, { 0, 0, "" }, "1", 23, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 24*/ { -1, 1, { 0, 0, "" }, "A", 13, 0, 16, 18 },
/* 25*/ { -1, 1, { 0, 0, "" }, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 26*/ { 3, 1, { 0, 0, "" }, "A", 4, 0, 16, 18 }, /* With ECI */
/* 27*/ { 3, 1, { 0, 0, "" }, "A", 5, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 28*/ { -1, 1, { 1, 2, "" }, "A", 10, 0, 16, 18 }, /* With Structured Append */
/* 29*/ { -1, 1, { 1, 2, "" }, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 30*/ { 3, 1, { 1, 2, "" }, "A", 2, 0, 16, 18 }, /* With ECI and Structured Append 1st symbol */
/* 31*/ { 3, 1, { 1, 2, "" }, "A", 3, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 32*/ { 3, 1, { 2, 2, "" }, "A", 4, 0, 16, 18 }, /* With ECI and Structured Append subsequent symbol */
/* 33*/ { 3, 1, { 2, 2, "" }, "A", 5, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 34*/ { -1, 1, { 0, 0, "" }, "\001", 10, 0, 16, 18 },
/* 35*/ { -1, 1, { 0, 0, "" }, "\001", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 36*/ { -1, 1, { 0, 0, "" }, "\200", 8, 0, 16, 18 },
/* 37*/ { -1, 1, { 0, 0, "" }, "\200", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 38*/ { -1, 2, { 0, 0, "" }, "1", 44, 0, 22, 22 }, /* Version B */
/* 39*/ { -1, 2, { 0, 0, "" }, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 40*/ { -1, 2, { 0, 0, "" }, "A", 27, 0, 22, 22 },
/* 41*/ { -1, 2, { 0, 0, "" }, "A", 28, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 42*/ { -1, 2, { 0, 0, "" }, "A", 26, 0, 22, 22 },
/* 43*/ { -1, 2, { 0, 0, "" }, "\001", 19, 0, 22, 22 },
/* 44*/ { -1, 2, { 0, 0, "" }, "\001", 20, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 45*/ { -1, 2, { 0, 0, "" }, "\200", 17, 0, 22, 22 },
/* 46*/ { -1, 2, { 0, 0, "" }, "\200", 18, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 47*/ { -1, 3, { 0, 0, "" }, "1", 104, 0, 28, 32 }, /* Version C */
/* 48*/ { -1, 3, { 0, 0, "" }, "1", 105, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 49*/ { -1, 3, { 0, 0, "" }, "A", 64, 0, 28, 32 },
/* 50*/ { -1, 3, { 0, 0, "" }, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 51*/ { -1, 3, { 0, 0, "" }, "\001", 44, 0, 28, 32 },
/* 52*/ { -1, 3, { 0, 0, "" }, "\001", 45, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 53*/ { -1, 3, { 0, 0, "" }, "\200", 42, 0, 28, 32 },
/* 54*/ { -1, 3, { 0, 0, "" }, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 55*/ { -1, 4, { 0, 0, "" }, "1", 217, 0, 40, 42 }, /* Version D */
/* 56*/ { -1, 4, { 0, 0, "" }, "1", 218, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 57*/ { -1, 4, { 0, 0, "" }, "A", 135, 0, 40, 42 },
/* 58*/ { -1, 4, { 0, 0, "" }, "A", 136, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 59*/ { -1, 4, { 0, 0, "" }, "\001", 91, 0, 40, 42 },
/* 60*/ { -1, 4, { 0, 0, "" }, "\001", 92, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 61*/ { -1, 4, { 0, 0, "" }, "\200", 89, 0, 40, 42 },
/* 62*/ { -1, 4, { 0, 0, "" }, "\200", 90, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 63*/ { -1, 5, { 0, 0, "" }, "1", 435, 0, 52, 54 }, /* Version E (note 435 multiple of 3) */
/* 64*/ { -1, 5, { 0, 0, "" }, "1", 436, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 65*/ { -1, 5, { 0, 0, "" }, "1", 434, ZINT_ERROR_TOO_LONG, -1, -1 }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */
/* 66*/ { -1, 5, { 0, 0, "" }, "1", 433, 0, 52, 54 },
/* 67*/ { -1, 5, { 0, 0, "" }, "A", 271, 0, 52, 54 },
/* 68*/ { -1, 5, { 0, 0, "" }, "A", 272, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 69*/ { -1, 5, { 0, 0, "" }, "\001", 182, 0, 52, 54 },
/* 70*/ { -1, 5, { 0, 0, "" }, "\001", 183, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 71*/ { -1, 5, { 0, 0, "" }, "\200", 180, 0, 52, 54 },
/* 72*/ { -1, 5, { 0, 0, "" }, "\200", 181, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 73*/ { -1, 6, { 0, 0, "" }, "1", 886, 0, 70, 76 }, /* Version F */
/* 74*/ { -1, 6, { 0, 0, "" }, "1", 887, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 75*/ { -1, 6, { 0, 0, "" }, "A", 553, 0, 70, 76 },
/* 76*/ { -1, 6, { 0, 0, "" }, "A", 554, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 77*/ { -1, 6, { 0, 0, "" }, "\001", 370, 0, 70, 76 },
/* 78*/ { -1, 6, { 0, 0, "" }, "\001", 371, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 79*/ { -1, 6, { 0, 0, "" }, "\200", 368, 0, 70, 76 },
/* 80*/ { -1, 6, { 0, 0, "" }, "\200", 369, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 81*/ { -1, 7, { 0, 0, "" }, "1", 1755, 0, 104, 98 }, /* Version G (note 1755 multiple of 3) */
/* 82*/ { -1, 7, { 0, 0, "" }, "1", 1756, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 83*/ { -1, 7, { 0, 0, "" }, "1", 1754, ZINT_ERROR_TOO_LONG, -1, -1 }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */
/* 84*/ { -1, 7, { 0, 0, "" }, "1", 1753, 0, 104, 98 },
/* 85*/ { -1, 7, { 0, 0, "" }, "A", 1096, 0, 104, 98 },
/* 86*/ { -1, 7, { 0, 0, "" }, "A", 1097, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 87*/ { -1, 7, { 0, 0, "" }, "\001", 732, 0, 104, 98 },
/* 88*/ { -1, 7, { 0, 0, "" }, "\001", 733, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 89*/ { -1, 7, { 0, 0, "" }, "\200", 730, 0, 104, 98 },
/* 90*/ { -1, 7, { 0, 0, "" }, "\200", 731, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 91*/ { -1, 8, { 0, 0, "" }, "1", 3550, 0, 148, 134 }, /* Version H */
/* 92*/ { -1, 8, { 0, 0, "" }, "1", 3551, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 93*/ { -1, 8, { 0, 0, "" }, "A", 2218, 0, 148, 134 },
/* 94*/ { -1, 8, { 0, 0, "" }, "A", 2219, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 95*/ { -1, 8, { 0, 0, "" }, "\001", 1480, 0, 148, 134 },
/* 96*/ { -1, 8, { 0, 0, "" }, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 97*/ { -1, 8, { 0, 0, "" }, "\200", 1478, 0, 148, 134 },
/* 98*/ { -1, 8, { 0, 0, "" }, "\200", 1479, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 99*/ { -1, 9, { 0, 0, "" }, "1", 6, 0, 8, 11 }, /* Version S-10 */
/*100*/ { -1, 9, { 0, 0, "" }, "1", 7, 0, 8, 21 }, /* -> S-20 */
/*101*/ { -1, 9, { 0, 0, "" }, "1", 12, 0, 8, 21 }, /* Version S-20 */
/*102*/ { -1, 9, { 0, 0, "" }, "1", 13, 0, 8, 31 }, /* -> S-30 */
/*103*/ { -1, 9, { 0, 0, "" }, "1", 18, 0, 8, 31 }, /* Version S-30 */
/*104*/ { -1, 9, { 0, 0, "" }, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/*105*/ { -1, 9, { 0, 0, "" }, "1", 17, 0, 8, 31 },
/*106*/ { -1, 10, { 0, 0, "" }, "1", 22, 0, 16, 17 }, /* Version T-16 */
/*107*/ { -1, 10, { 0, 0, "" }, "1", 23, 0, 16, 33 }, /* -> T-32 */
/*108*/ { -1, 10, { 0, 0, "" }, "A", 13, 0, 16, 17 },
/*109*/ { -1, 10, { 0, 0, "" }, "A", 14, 0, 16, 33 }, /* -> T-32 */
/*110*/ { -1, 10, { 0, 0, "" }, "\001", 10, 0, 16, 17 },
/*111*/ { -1, 10, { 0, 0, "" }, "\001", 11, 0, 16, 33 }, /* -> T-32 */
/*112*/ { -1, 10, { 0, 0, "" }, "\200", 8, 0, 16, 17 },
/*113*/ { -1, 10, { 0, 0, "" }, "\200", 9, 0, 16, 33 }, /* -> T-32 */
/*114*/ { -1, 10, { 0, 0, "" }, "1", 56, 0, 16, 33 }, /* Version T-32 */
/*115*/ { -1, 10, { 0, 0, "" }, "1", 57, 0, 16, 49 }, /* -> T-48 */
/*116*/ { -1, 10, { 0, 0, "" }, "A", 34, 0, 16, 33 },
/*117*/ { -1, 10, { 0, 0, "" }, "A", 35, 0, 16, 49 }, /* -> T-48 */
/*118*/ { -1, 10, { 0, 0, "" }, "\001", 24, 0, 16, 33 },
/*119*/ { -1, 10, { 0, 0, "" }, "\001", 25, 0, 16, 49 }, /* -> T-48 */
/*120*/ { -1, 10, { 0, 0, "" }, "\200", 22, 0, 16, 33 },
/*121*/ { -1, 10, { 0, 0, "" }, "\200", 23, 0, 16, 49 }, /* -> T-48 */
/*122*/ { -1, 10, { 0, 0, "" }, "1", 90, 0, 16, 49 }, /* Version T-48 (note 90 multiple of 3) */
/*123*/ { -1, 10, { 0, 0, "" }, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 },
/*124*/ { -1, 10, { 0, 0, "" }, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1 }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */
/*125*/ { -1, 10, { 0, 0, "" }, "1", 88, 0, 16, 49 },
/*126*/ { -1, 10, { 0, 0, "" }, "A", 55, 0, 16, 49 },
/*127*/ { -1, 10, { 0, 0, "" }, "A", 56, ZINT_ERROR_TOO_LONG, -1, -1 },
/*128*/ { -1, 10, { 0, 0, "" }, "A", 90, ZINT_ERROR_TOO_LONG, -1, -1 },
/*129*/ { -1, 10, { 0, 0, "" }, "\001", 38, 0, 16, 49 },
/*130*/ { -1, 10, { 0, 0, "" }, "\001", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
/*131*/ { -1, 10, { 0, 0, "" }, "\001", 90, ZINT_ERROR_TOO_LONG, -1, -1 },
/*132*/ { -1, 10, { 0, 0, "" }, "\\", 38, 0, 16, 49 },
/*133*/ { -1, 10, { 0, 0, "" }, "\\", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
/*134*/ { -1, 10, { 0, 0, "" }, "\200", 36, 0, 16, 49 },
/*135*/ { -1, 10, { 0, 0, "" }, "\200", 37, ZINT_ERROR_TOO_LONG, -1, -1 },
/*136*/ { -1, 10, { 0, 0, "" }, "AAA\200", 31, 0, 16, 49 }, /* ASCII + BYTE (ASCII UpSh - worse than BYTE) */
/*137*/ { -1, 10, { 0, 0, "" }, "AAA\200", 32, ZINT_ERROR_TOO_LONG, -1, -1 },
/*138*/ { 3, 10, { 0, 0, "" }, "A", 46, 0, 16, 49 }, /* Version T-48 with ECI (9 less as PAD escape char + "\123456") */
/*139*/ { 3, 10, { 0, 0, "" }, "A", 47, ZINT_ERROR_TOO_LONG, -1, -1 },
/*140*/ { 3, 10, { 0, 0, "" }, "\001", 32, 0, 16, 49 },
/*141*/ { 3, 10, { 0, 0, "" }, "\001", 33, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { -1, -1, { 0, 0, "" }, "1", 3550, 0, 148, 134, "" }, /* Auto Version H */
/* 1*/ { -1, -1, { 0, 0, "" }, "1", 3551, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 2*/ { 3, -1, { 0, 0, "" }, "1", 3535, 0, 148, 134, "" }, /* With ECI */
/* 3*/ { 3, -1, { 0, 0, "" }, "1", 3536, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 4*/ { -1, -1, { 1, 2, "" }, "1", 3546, 0, 148, 134, "" }, /* With Structured Append (Group mode, count < 2) */
/* 5*/ { -1, -1, { 1, 2, "" }, "1", 3547, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 6*/ { -1, -1, { 1, 16, "" }, "1", 3541, 0, 148, 134, "" }, /* With Structured Append (Extended Group mode, count >= 16) */
/* 7*/ { -1, -1, { 1, 16, "" }, "1", 3542, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 8*/ { 3, -1, { 1, 2, "" }, "1", 3532, 0, 148, 134, "" }, /* With ECI and Structured Append (Group mode) 1st symbol */
/* 9*/ { 3, -1, { 1, 2, "" }, "1", 3533, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 10*/ { 3, -1, { 2, 2, "" }, "1", 3537, 0, 148, 134, "" }, /* With ECI and Structured Append (Group mode) subsequent symbol */
/* 11*/ { 3, -1, { 2, 2, "" }, "1", 3538, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 12*/ { 3, -1, { 1, 16, "" }, "1", 3530, 0, 148, 134, "" }, /* With ECI and Structured Append (Extended Group mode) 1st symbol */
/* 13*/ { 3, -1, { 1, 16, "" }, "1", 3531, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 14*/ { 3, -1, { 2, 16, "" }, "1", 3535, 0, 148, 134, "" }, /* With ECI and Structured Append (Extended Group mode) subsequent symbol */
/* 15*/ { 3, -1, { 2, 16, "" }, "1", 3536, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 16*/ { -1, -1, { 0, 0, "" }, "A", 2218, 0, 148, 134, "" },
/* 17*/ { -1, -1, { 0, 0, "" }, "A", 2219, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 18*/ { -1, -1, { 0, 0, "" }, "\001", 1480, 0, 148, 134, "" }, /* Full ASCII */
/* 19*/ { -1, -1, { 0, 0, "" }, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 20*/ { -1, -1, { 0, 0, "" }, "\200", 1478, 0, 148, 134, "" }, /* BYTE */
/* 21*/ { -1, -1, { 0, 0, "" }, "\200", 1479, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 22*/ { -1, 1, { 0, 0, "" }, "1", 22, 0, 16, 18, "" }, /* Version A */
/* 23*/ { -1, 1, { 0, 0, "" }, "1", 23, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 11 codewords (maximum 10)" },
/* 24*/ { -1, 1, { 0, 0, "" }, "A", 13, 0, 16, 18, "" },
/* 25*/ { -1, 1, { 0, 0, "" }, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 12 codewords (maximum 10)" },
/* 26*/ { -1, 1, { 0, 0, "" }, "A", 2218, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 1480 codewords (maximum 10)" },
/* 27*/ { 3, 1, { 0, 0, "" }, "A", 4, 0, 16, 18, "" }, /* With ECI */
/* 28*/ { 3, 1, { 0, 0, "" }, "A", 5, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 11 codewords (maximum 10)" },
/* 29*/ { -1, 1, { 1, 2, "" }, "A", 10, 0, 16, 18, "" }, /* With Structured Append */
/* 30*/ { -1, 1, { 1, 2, "" }, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 12 codewords (maximum 10)" },
/* 31*/ { 3, 1, { 1, 2, "" }, "A", 2, 0, 16, 18, "" }, /* With ECI and Structured Append 1st symbol */
/* 32*/ { 3, 1, { 1, 2, "" }, "A", 3, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 11 codewords (maximum 10)" },
/* 33*/ { 3, 1, { 2, 2, "" }, "A", 4, 0, 16, 18, "" }, /* With ECI and Structured Append subsequent symbol */
/* 34*/ { 3, 1, { 2, 2, "" }, "A", 5, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 11 codewords (maximum 10)" },
/* 35*/ { -1, 1, { 0, 0, "" }, "\001", 10, 0, 16, 18, "" },
/* 36*/ { -1, 1, { 0, 0, "" }, "\001", 11, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 11 codewords (maximum 10)" },
/* 37*/ { -1, 1, { 0, 0, "" }, "\200", 8, 0, 16, 18, "" },
/* 38*/ { -1, 1, { 0, 0, "" }, "\200", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 11 codewords (maximum 10)" },
/* 39*/ { -1, 2, { 0, 0, "" }, "1", 44, 0, 22, 22, "" }, /* Version B */
/* 40*/ { -1, 2, { 0, 0, "" }, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version B, requires 20 codewords (maximum 19)" },
/* 41*/ { -1, 2, { 0, 0, "" }, "A", 27, 0, 22, 22, "" },
/* 42*/ { -1, 2, { 0, 0, "" }, "A", 28, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version B, requires 21 codewords (maximum 19)" },
/* 43*/ { -1, 2, { 0, 0, "" }, "A", 26, 0, 22, 22, "" },
/* 44*/ { -1, 2, { 0, 0, "" }, "\001", 19, 0, 22, 22, "" },
/* 45*/ { -1, 2, { 0, 0, "" }, "\001", 20, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version B, requires 20 codewords (maximum 19)" },
/* 46*/ { -1, 2, { 0, 0, "" }, "\200", 17, 0, 22, 22, "" },
/* 47*/ { -1, 2, { 0, 0, "" }, "\200", 18, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version B, requires 20 codewords (maximum 19)" },
/* 48*/ { -1, 3, { 0, 0, "" }, "1", 104, 0, 28, 32, "" }, /* Version C */
/* 49*/ { -1, 3, { 0, 0, "" }, "1", 105, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version C, requires 45 codewords (maximum 44)" },
/* 50*/ { -1, 3, { 0, 0, "" }, "A", 64, 0, 28, 32, "" },
/* 51*/ { -1, 3, { 0, 0, "" }, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version C, requires 46 codewords (maximum 44)" },
/* 52*/ { -1, 3, { 0, 0, "" }, "\001", 44, 0, 28, 32, "" },
/* 53*/ { -1, 3, { 0, 0, "" }, "\001", 45, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version C, requires 45 codewords (maximum 44)" },
/* 54*/ { -1, 3, { 0, 0, "" }, "\200", 42, 0, 28, 32, "" },
/* 55*/ { -1, 3, { 0, 0, "" }, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version C, requires 45 codewords (maximum 44)" },
/* 56*/ { -1, 4, { 0, 0, "" }, "1", 217, 0, 40, 42, "" }, /* Version D */
/* 57*/ { -1, 4, { 0, 0, "" }, "1", 218, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version D, requires 93 codewords (maximum 91)" },
/* 58*/ { -1, 4, { 0, 0, "" }, "A", 135, 0, 40, 42, "" },
/* 59*/ { -1, 4, { 0, 0, "" }, "A", 136, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version D, requires 93 codewords (maximum 91)" },
/* 60*/ { -1, 4, { 0, 0, "" }, "\001", 91, 0, 40, 42, "" },
/* 61*/ { -1, 4, { 0, 0, "" }, "\001", 92, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version D, requires 92 codewords (maximum 91)" },
/* 62*/ { -1, 4, { 0, 0, "" }, "\200", 89, 0, 40, 42, "" },
/* 63*/ { -1, 4, { 0, 0, "" }, "\200", 90, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version D, requires 92 codewords (maximum 91)" },
/* 64*/ { -1, 5, { 0, 0, "" }, "1", 435, 0, 52, 54, "" }, /* Version E (note 435 multiple of 3) */
/* 65*/ { -1, 5, { 0, 0, "" }, "1", 436, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version E, requires 183 codewords (maximum 182)" },
/* 66*/ { -1, 5, { 0, 0, "" }, "1", 434, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version E, requires 183 codewords (maximum 182)" }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */
/* 67*/ { -1, 5, { 0, 0, "" }, "1", 433, 0, 52, 54, "" },
/* 68*/ { -1, 5, { 0, 0, "" }, "A", 271, 0, 52, 54, "" },
/* 69*/ { -1, 5, { 0, 0, "" }, "A", 272, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version E, requires 184 codewords (maximum 182)" },
/* 70*/ { -1, 5, { 0, 0, "" }, "\001", 182, 0, 52, 54, "" },
/* 71*/ { -1, 5, { 0, 0, "" }, "\001", 183, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version E, requires 183 codewords (maximum 182)" },
/* 72*/ { -1, 5, { 0, 0, "" }, "\200", 180, 0, 52, 54, "" },
/* 73*/ { -1, 5, { 0, 0, "" }, "\200", 181, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version E, requires 183 codewords (maximum 182)" },
/* 74*/ { -1, 6, { 0, 0, "" }, "1", 886, 0, 70, 76, "" }, /* Version F */
/* 75*/ { -1, 6, { 0, 0, "" }, "1", 887, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version F, requires 371 codewords (maximum 370)" },
/* 76*/ { -1, 6, { 0, 0, "" }, "A", 553, 0, 70, 76, "" },
/* 77*/ { -1, 6, { 0, 0, "" }, "A", 554, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version F, requires 372 codewords (maximum 370)" },
/* 78*/ { -1, 6, { 0, 0, "" }, "\001", 370, 0, 70, 76, "" },
/* 79*/ { -1, 6, { 0, 0, "" }, "\001", 371, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version F, requires 371 codewords (maximum 370)" },
/* 80*/ { -1, 6, { 0, 0, "" }, "\200", 368, 0, 70, 76, "" },
/* 81*/ { -1, 6, { 0, 0, "" }, "\200", 369, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version F, requires 372 codewords (maximum 370)" },
/* 82*/ { -1, 7, { 0, 0, "" }, "1", 1755, 0, 104, 98, "" }, /* Version G (note 1755 multiple of 3) */
/* 83*/ { -1, 7, { 0, 0, "" }, "1", 1756, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 733 codewords (maximum 732)" },
/* 84*/ { -1, 7, { 0, 0, "" }, "1", 1754, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 733 codewords (maximum 732)" }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */
/* 85*/ { -1, 7, { 0, 0, "" }, "1", 1753, 0, 104, 98, "" },
/* 86*/ { -1, 7, { 0, 0, "" }, "A", 1096, 0, 104, 98, "" },
/* 87*/ { -1, 7, { 0, 0, "" }, "A", 1097, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 734 codewords (maximum 732)" },
/* 88*/ { -1, 7, { 0, 0, "" }, "\001", 732, 0, 104, 98, "" },
/* 89*/ { -1, 7, { 0, 0, "" }, "\001", 733, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 733 codewords (maximum 732)" },
/* 90*/ { -1, 7, { 0, 0, "" }, "\200", 730, 0, 104, 98, "" },
/* 91*/ { -1, 7, { 0, 0, "" }, "\200", 731, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 734 codewords (maximum 732)" },
/* 92*/ { -1, 7, { 0, 0, "" }, "\200", 732, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 735 codewords (maximum 732)" },
/* 93*/ { -1, 7, { 0, 0, "" }, "\200", 1478, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version G, requires 1480 codewords (maximum 732)" },
/* 94*/ { -1, 8, { 0, 0, "" }, "1", 3550, 0, 148, 134, "" }, /* Version H */
/* 95*/ { -1, 8, { 0, 0, "" }, "1", 3551, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 96*/ { -1, 8, { 0, 0, "" }, "A", 2218, 0, 148, 134, "" },
/* 97*/ { -1, 8, { 0, 0, "" }, "A", 2219, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/* 98*/ { -1, 8, { 0, 0, "" }, "\001", 1480, 0, 148, 134, "" },
/* 99*/ { -1, 8, { 0, 0, "" }, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/*100*/ { -1, 8, { 0, 0, "" }, "\200", 1478, 0, 148, 134, "" },
/*101*/ { -1, 8, { 0, 0, "" }, "\200", 1479, ZINT_ERROR_TOO_LONG, -1, -1, "Error 517: Input too long, requires too many codewords (maximum 1480)" },
/*102*/ { -1, 9, { 0, 0, "" }, "1", 6, 0, 8, 11, "" }, /* Version S-10 */
/*103*/ { -1, 9, { 0, 0, "" }, "1", 7, 0, 8, 21, "" }, /* -> S-20 */
/*104*/ { -1, 9, { 0, 0, "" }, "1", 12, 0, 8, 21, "" }, /* Version S-20 */
/*105*/ { -1, 9, { 0, 0, "" }, "1", 13, 0, 8, 31, "" }, /* -> S-30 */
/*106*/ { -1, 9, { 0, 0, "" }, "1", 18, 0, 8, 31, "" }, /* Version S-30 */
/*107*/ { -1, 9, { 0, 0, "" }, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1, "Error 514: Input length 19 too long for Version S (maximum 18)" },
/*108*/ { -1, 9, { 0, 0, "" }, "1", 17, 0, 8, 31, "" },
/*109*/ { -1, 10, { 0, 0, "" }, "1", 22, 0, 16, 17, "" }, /* Version T-16 */
/*110*/ { -1, 10, { 0, 0, "" }, "1", 23, 0, 16, 33, "" }, /* -> T-32 */
/*111*/ { -1, 10, { 0, 0, "" }, "A", 13, 0, 16, 17, "" },
/*112*/ { -1, 10, { 0, 0, "" }, "A", 14, 0, 16, 33, "" }, /* -> T-32 */
/*113*/ { -1, 10, { 0, 0, "" }, "\001", 10, 0, 16, 17, "" },
/*114*/ { -1, 10, { 0, 0, "" }, "\001", 11, 0, 16, 33, "" }, /* -> T-32 */
/*115*/ { -1, 10, { 0, 0, "" }, "\200", 8, 0, 16, 17, "" },
/*116*/ { -1, 10, { 0, 0, "" }, "\200", 9, 0, 16, 33, "" }, /* -> T-32 */
/*117*/ { -1, 10, { 0, 0, "" }, "1", 56, 0, 16, 33, "" }, /* Version T-32 */
/*118*/ { -1, 10, { 0, 0, "" }, "1", 57, 0, 16, 49, "" }, /* -> T-48 */
/*119*/ { -1, 10, { 0, 0, "" }, "A", 34, 0, 16, 33, "" },
/*120*/ { -1, 10, { 0, 0, "" }, "A", 35, 0, 16, 49, "" }, /* -> T-48 */
/*121*/ { -1, 10, { 0, 0, "" }, "\001", 24, 0, 16, 33, "" },
/*122*/ { -1, 10, { 0, 0, "" }, "\001", 25, 0, 16, 49, "" }, /* -> T-48 */
/*123*/ { -1, 10, { 0, 0, "" }, "\200", 22, 0, 16, 33, "" },
/*124*/ { -1, 10, { 0, 0, "" }, "\200", 23, 0, 16, 49, "" }, /* -> T-48 */
/*125*/ { -1, 10, { 0, 0, "" }, "1", 90, 0, 16, 49, "" }, /* Version T-48 (note 90 multiple of 3) */
/*126*/ { -1, 10, { 0, 0, "" }, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input length 91 too long for Version T (maximum 90)" },
/*127*/ { -1, 10, { 0, 0, "" }, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 39 codewords (maximum 38)" }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */
/*128*/ { -1, 10, { 0, 0, "" }, "1", 88, 0, 16, 49, "" },
/*129*/ { -1, 10, { 0, 0, "" }, "A", 55, 0, 16, 49, "" },
/*130*/ { -1, 10, { 0, 0, "" }, "A", 56, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 40 codewords (maximum 38)" },
/*131*/ { -1, 10, { 0, 0, "" }, "A", 90, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 61 codewords (maximum 38)" },
/*132*/ { -1, 10, { 0, 0, "" }, "\001", 38, 0, 16, 49, "" },
/*133*/ { -1, 10, { 0, 0, "" }, "\001", 39, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 39 codewords (maximum 38)" },
/*134*/ { -1, 10, { 0, 0, "" }, "\001", 90, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 90 codewords (maximum 38)" },
/*135*/ { -1, 10, { 0, 0, "" }, "\\", 38, 0, 16, 49, "" },
/*136*/ { -1, 10, { 0, 0, "" }, "\\", 39, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 39 codewords (maximum 38)" },
/*137*/ { -1, 10, { 0, 0, "" }, "\200", 36, 0, 16, 49, "" },
/*138*/ { -1, 10, { 0, 0, "" }, "\200", 37, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 39 codewords (maximum 38)" },
/*139*/ { -1, 10, { 0, 0, "" }, "AAA\200", 31, 0, 16, 49, "" }, /* ASCII + BYTE (ASCII UpSh - worse than BYTE) */
/*140*/ { -1, 10, { 0, 0, "" }, "AAA\200", 32, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 40 codewords (maximum 38)" },
/*141*/ { 3, 10, { 0, 0, "" }, "A", 46, 0, 16, 49, "" }, /* Version T-48 with ECI (9 less as PAD escape char + "\123456") */
/*142*/ { 3, 10, { 0, 0, "" }, "A", 47, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 40 codewords (maximum 38)" },
/*143*/ { 3, 10, { 0, 0, "" }, "\001", 32, 0, 16, 49, "" },
/*144*/ { 3, 10, { 0, 0, "" }, "\001", 33, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 39 codewords (maximum 38)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -215,6 +219,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -243,46 +249,47 @@ static void test_input(const testCtx *const p_ctx) {
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, -1, { 0, 0, "" }, "123456789012ABCDEFGHI", -1, 0, 22, 22, "", },
/* 1*/ { -1, -1, -1, { 0, 0, "" }, "123456789012ABCDEFGHIJ", -1, 0, 22, 22, "", },
/* 2*/ { -1, -1, -1, { 0, 0, "" }, "1", -1, 0, 16, 18, "", },
/* 3*/ { -1, -1, 0, { 0, 0, "" }, "1", -1, 0, 16, 18, "", },
/* 4*/ { -1, -1, 1, { 0, 0, "" }, "1", -1, 0, 16, 18, "", },
/* 5*/ { -1, -1, 1, { 0, 0, "" }, "ABCDEFGHIJKLMN", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for selected symbol size", },
/* 5*/ { -1, -1, 1, { 0, 0, "" }, "ABCDEFGHIJKLMN", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for Version A, requires 12 codewords (maximum 10)", },
/* 6*/ { GS1_MODE, -1, 1, { 0, 0, "" }, "[01]12345678901231", -1, 0, 16, 18, "", },
/* 7*/ { GS1_MODE | GS1PARENS_MODE, -1, 1, { 0, 0, "" }, "(01)12345678901231", -1, 0, 16, 18, "", },
/* 8*/ { -1, 3, 1, { 0, 0, "" }, "1", -1, 0, 16, 18, "", },
/* 9*/ { UNICODE_MODE, 3, 1, { 0, 0, "" }, "é", -1, 0, 16, 18, "", },
/* 10*/ { GS1_MODE, 3, 1, { 0, 0, "" }, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 18, "Warning 512: ECI ignored for GS1 mode", },
/* 11*/ { -1, -1, 9, { 0, 0, "" }, "123456789012345678", -1, 0, 8, 31, "", },
/* 12*/ { -1, -1, 9, { 0, 0, "" }, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 515: Invalid input data (Version S encodes numeric input only)", },
/* 13*/ { -1, -1, 9, { 0, 0, "" }, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 514: Input data too long for Version S", },
/* 12*/ { -1, -1, 9, { 0, 0, "" }, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 515: Invalid character at position 18 in input (Version S encodes digits only)", },
/* 13*/ { -1, -1, 9, { 0, 0, "" }, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 514: Input length 19 too long for Version S (maximum 18)", },
/* 14*/ { GS1_MODE, -1, 9, { 0, 0, "" }, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 8, 31, "Warning 511: GS1 mode ignored for Version S", },
/* 15*/ { -1, 3, 9, { 0, 0, "" }, "1", -1, ZINT_WARN_INVALID_OPTION, 8, 11, "Warning 511: ECI ignored for Version S", },
/* 16*/ { GS1_MODE, 3, 9, { 0, 0, "" }, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 8, 31, "Warning 511: ECI and GS1 mode ignored for Version S", },
/* 17*/ { -1, -1, 10, { 0, 0, "" }, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, 0, 16, 49, "", },
/* 18*/ { -1, -1, 10, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", },
/* 18*/ { -1, -1, 10, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input length 91 too long for Version T (maximum 90)", },
/* 19*/ { -1, -1, 10, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 0, 16, 49, "", },
/* 20*/ { -1, -1, 10, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", },
/* 20*/ { -1, -1, 10, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 55 codewords (maximum 38)", },
/* 21*/ { -1, -1, 10, { 0, 0, "" }, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 38, 0, 16, 49, "", },
/* 22*/ { -1, 3, 10, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456", -1, 0, 16, 49, "", },
/* 23*/ { -1, 3, 10, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", },
/* 24*/ { -1, 3, 10, { 0, 0, "" }, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", },
/* 23*/ { -1, 3, 10, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input too long for Version T, requires 39 codewords (maximum 38)", },
/* 24*/ { -1, 3, 10, { 0, 0, "" }, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input length 91 too long for Version T (maximum 90)", },
/* 25*/ { GS1_MODE, -1, 10, { 0, 0, "" }, "[01]12345678901231", -1, 0, 16, 17, "", },
/* 26*/ { GS1_MODE, 3, 10, { 0, 0, "" }, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 17, "Warning 512: ECI ignored for GS1 mode", },
/* 27*/ { -1, -1, 11, { 0, 0, "" }, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 513: Invalid symbol size", },
/* 28*/ { GS1_MODE, -1, -1, { 1, 2, "" }, "[01]12345678901231", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 710: Cannot have Structured Append and GS1 mode at the same time", },
/* 29*/ { -1, -1, -1, { 1, 1, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 711: Structured Append count out of range (2-128)", },
/* 30*/ { -1, -1, -1, { 1, 1, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 711: Structured Append count out of range (2-128)", },
/* 31*/ { -1, -1, -1, { 1, 129, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 711: Structured Append count out of range (2-128)", },
/* 32*/ { -1, -1, -1, { 0, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 712: Structured Append index out of range (1-2)", },
/* 33*/ { -1, -1, -1, { 3, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 712: Structured Append index out of range (1-2)", },
/* 34*/ { -1, -1, -1, { 1, 2, "1" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 713: Structured Append ID not available for Code One", },
/* 35*/ { -1, -1, 9, { 1, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not available for Version S", },
/* 36*/ { -1, -1, 9, { 3, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not available for Version S", }, /* Trumps other checking */
/* 27*/ { -1, -1, 11, { 0, 0, "" }, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 513: Version '11' out of range (1 to 10)", },
/* 28*/ { -1, -1, -2, { 0, 0, "" }, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 513: Version '-2' out of range (1 to 10)", },
/* 29*/ { GS1_MODE, -1, -1, { 1, 2, "" }, "[01]12345678901231", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 710: Cannot have Structured Append and GS1 mode at the same time", },
/* 30*/ { -1, -1, -1, { 1, 1, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 711: Structured Append count '1' out of range (2 to 128)", },
/* 31*/ { -1, -1, -1, { 1, -1, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 711: Structured Append count '-1' out of range (2 to 128)", },
/* 32*/ { -1, -1, -1, { 1, 129, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 711: Structured Append count '129' out of range (2 to 128)", },
/* 33*/ { -1, -1, -1, { 0, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 712: Structured Append index '0' out of range (1 to count 2)", },
/* 34*/ { -1, -1, -1, { 3, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 712: Structured Append index '3' out of range (1 to count 2)", },
/* 35*/ { -1, -1, -1, { 1, 2, "1" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 713: Structured Append ID not available for Code One", },
/* 36*/ { -1, -1, 9, { 1, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not available for Version S", },
/* 37*/ { -1, -1, 9, { 3, 2, "" }, "123456789012ABCDEFGHI", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 714: Structured Append not available for Version S", }, /* Trumps other checking */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -334,7 +341,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *expected;
};
/* Figure examples AIM USS Code One (USSCO) Revision March 3, 2000 */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, -1, { 0, 0, "" }, "1234567890123456789012", -1, 0, 16, 18, 1, "USSCO Figure 1 (Version A, no padding), same",
"111111111111001100"
"000110000110010101"
@ -2879,7 +2886,7 @@ static void test_encode(const testCtx *const p_ctx) {
"110100001010111101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -2969,7 +2976,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *expected;
};
/* Figure examples AIM USS Code One (USSCO) Revision March 3, 2000 */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 16, 18, 1, "Standard example",
"100011010111100011"
"000110110110110111"
@ -3268,7 +3275,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
""
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
@ -3363,7 +3370,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, "3333P33B\035333V3333333333333\0363", -1, 0, 1, "" }, /* #181 Nico Gunkel, OSS-Fuzz */
/* 1*/ { -1, "{{-06\024755712162106130000000829203983\377", -1, 0, 1, "" }, /* #232 Jan Schrewe, CI-Fuzz, out-of-bounds in is_last_single_ascii() sp + 1 */
/* 2*/ { -1, "\000\000\000\367\000\000\000\000\000\103\040\000\000\244\137\140\140\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\165\060\060\060\060\061\060\060\114\114\060\010\102\102\102\102\102\102\102\102\057\102\100\102\057\233\100\102", 60, 0, 1, "" }, /* #300 (#4) Andre Maute (`c1_c40text_cnt()` not accounting for extended ASCII shifts) */
@ -3371,7 +3378,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
/* 4*/ { 10, "\015\015\353\362\015\015\015\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\110\015\015\015\015\015\015\015\015\015\015\015\015\015\015\015\362\362\000", 39, 0, 1, "" }, /* #300 (#8 shortened) Andre Maute */
/* 5*/ { 10, "\153\153\153\153\153\060\001\000\000\134\153\153\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\153\153\153\153\153\153\043\000\000\307\000\147\000\000\000\043\113\153\162\162\215\220", 90, ZINT_ERROR_TOO_LONG, 1, "" }, /* #300 (#12) Andre Maute (too small buffer for Version T) */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;

View file

@ -43,41 +43,42 @@ static void test_large(const testCtx *const p_ctx) {
int length;
int ret;
int expected_width;
char *expected_errtxt;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, "A", 99, 0, 1124 },
/* 1*/ { BARCODE_CODE128, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1 },
/* 2*/ { BARCODE_CODE128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1 },
/* 3*/ { BARCODE_CODE128, READER_INIT, "A", 99, 0, 1135 },
/* 4*/ { BARCODE_CODE128, READER_INIT, "A", 100, ZINT_ERROR_TOO_LONG, -1 },
/* 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, "\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 },
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, "A", 99, 0, 1124, "" },
/* 1*/ { BARCODE_CODE128, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" },
/* 2*/ { BARCODE_CODE128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" },
/* 3*/ { BARCODE_CODE128, READER_INIT, "A", 99, 0, 1135, "" },
/* 4*/ { BARCODE_CODE128, READER_INIT, "A", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" },
/* 5*/ { BARCODE_CODE128, READER_INIT, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" },
/* 6*/ { BARCODE_CODE128, -1, "\351A", 66, 0, 1124, "" },
/* 7*/ { BARCODE_CODE128, -1, "\351A", 67, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 101 symbol characters (maximum 99)" }, /* 67 chars (+ 34 shifts) */
/* 8*/ { BARCODE_CODE128, -1, "\351", 97, 0, 1124, "" }, /* Less 2 FNC4s for latch */
/* 9*/ { BARCODE_CODE128, -1, "\351", 98, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" },
/* 10*/ { BARCODE_CODE128, -1, "0", 198, 0, 1124, "" },
/* 11*/ { BARCODE_CODE128, -1, "0", 199, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 101 symbol characters (maximum 99)" },
/* 12*/ { BARCODE_CODE128, -1, "0", 257, ZINT_ERROR_TOO_LONG, -1, "Error 340: Input length 257 too long (maximum 256)" },
/* 13*/ { BARCODE_CODE128AB, -1, "A", 99, 0, 1124, "" },
/* 14*/ { BARCODE_CODE128AB, -1, "A", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" },
/* 15*/ { BARCODE_CODE128AB, -1, "0", 99, 0, 1124, "" },
/* 16*/ { BARCODE_CODE128AB, -1, "0", 100, ZINT_ERROR_TOO_LONG, -1, "Error 341: Input too long, requires 100 symbol characters (maximum 99)" },
/* 17*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_WARN_HRT_TRUNCATED, 1135, "Warning 844: Human Readable Text truncated" }, /* 196 nos + 3 FNC1s */
/* 18*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 101 symbol characters (maximum 99)" }, /* 196 nos + CodeA + single no. + 3 FNC1s */
/* 19*/ { BARCODE_GS1_128, -1, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, ZINT_ERROR_TOO_LONG, -1, "Error 344: Input too long, requires 100 symbol characters (maximum 99)" }, /* 198 nos + 3 FNC1s */
/* 20*/ { BARCODE_GS1_128, -1, "A", 257, ZINT_ERROR_TOO_LONG, -1, "Error 342: Input length 257 too long (maximum 256)" },
/* 21*/ { BARCODE_EAN14, -1, "1234567890123", -1, 0, 134, "" },
/* 22*/ { BARCODE_EAN14, -1, "12345678901234", -1, ZINT_ERROR_TOO_LONG, -1, "Error 347: Input length 14 too long (maximum 13)" },
/* 23*/ { BARCODE_NVE18, -1, "12345678901234567", -1, 0, 156, "" },
/* 24*/ { BARCODE_NVE18, -1, "123456789012345678", -1, ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)" },
/* 25*/ { BARCODE_HIBC_128, -1, "1", 110, 0, 684, "" },
/* 26*/ { BARCODE_HIBC_128, -1, "1", 111, ZINT_ERROR_TOO_LONG, -1, "Error 202: Input length 111 too long for HIBC LIC (maximum 110)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -103,6 +104,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
@ -130,7 +133,7 @@ static void test_hrt(const testCtx *const p_ctx) {
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "1234567890", -1, "1234567890" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, "\000ABC\000DEF\000", 9, " ABC DEF " },
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, "12345\00067890", 11, "12345 67890" },
@ -175,7 +178,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 41*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", -1, "EE 876 543 216 CA" }, /* UPU S10 Annex A */
/* BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 hrt tested in test_gs1.c */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -217,7 +220,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "A", 0, 1, 57, "(5) 104 96 33 60 106", "StartA FNC3 A" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, READER_INIT, "12", 0, 1, 68, "(6) 104 96 99 12 22 106", "StartB FNC3 CodeC 12" },
/* 2*/ { BARCODE_CODE128AB, UNICODE_MODE, READER_INIT, "\0371234", 0, 1, 101, "(9) 103 96 95 17 18 19 20 6 106", "StartA FNC3 US 1 2 3 4" },
@ -226,7 +229,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
/* 5*/ { BARCODE_NVE18, GS1_MODE, READER_INIT, "12", 0, 1, 156, "(14) 105 102 0 0 0 0 0 0 0 0 1 23 58 106", "StartC FNC1 00 (8) 01 23 (Reader Initialise not supported by GS1 barcodes (use CODE128))" },
/* 6*/ { BARCODE_HIBC_128, UNICODE_MODE, READER_INIT, "A", 0, 1, 79, "(7) 104 96 11 33 24 5 106", "StartA FNC3 + A 8 (check) (Not sensible, use CODE128)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -290,8 +293,8 @@ static void test_input(const testCtx *const p_ctx) {
ß U+00DF (\337, 223), UTF-8 C39F, CodeA and CodeB extended ASCII
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
struct item data[] = {
/* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 204: Invalid character in input data (ISO/IEC 8859-1 only)", "PAD not in ISO 8859-1" },
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 204: Invalid character in input (ISO/IEC 8859-1 only)", "PAD not in ISO 8859-1" },
/* 1*/ { DATA_MODE, "\200", -1, 0, 57, 1, "(5) 103 101 64 23 106", "PAD ok using binary" },
/* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, 1, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" },
/* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP no manual mode" },
@ -343,59 +346,72 @@ static void test_input(const testCtx *const p_ctx) {
/* 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 <LF>; 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 <LF> CodeC 12 34 CodeA A 1 2 <LF>; 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 * <CR> <LF> 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 <LF> ShA <LF>; 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" },
/* 52*/ { UNICODE_MODE, "aéééb", -1, 0, 123, 1, "(11) 104 65 100 73 100 73 100 73 66 5 106", "StartB a FNC4 é (4) b" },
/* 53*/ { UNICODE_MODE, "aééééb", -1, 0, 134, 0, "(12) 104 65 100 100 73 73 73 73 100 66 64 106", "StartB a Latch é (4) Shift b; BWIPP different encodation" },
/* 54*/ { UNICODE_MODE, "aéééééb", -1, 0, 145, 1, "(13) 104 65 100 100 73 73 73 73 73 100 66 93 106", "StartB a Latch é (5) Shift b" },
/* 55*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 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" },
/* 56*/ { UNICODE_MODE, "aééééébcd", -1, 0, 178, 1, "(16) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 66 106", "StartB a Latch é (5) Unlatch b c d" },
/* 57*/ { UNICODE_MODE, "aééééébcde", -1, 0, 189, 1, "(17) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 2 106", "StartB a Latch é (5) Unlatch b c d e" },
/* 58*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 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" },
/* 59*/ { 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" },
/* 60*/ { 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)" },
/* 61*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, 1, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" },
/* 62*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 211, 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)" },
/* 63*/ { 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" },
/* 64*/ { 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" },
/* 65*/ { 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" },
/* 66*/ { 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" },
/* 67*/ { 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 \\202; BWIPP different encodation" },
/* 68*/ { DATA_MODE, "@g(\202\202\202\202\202555\202\202\202\202\202\202\202\202", -1, 0, 310, 0, "(28) 104 32 71 8 101 101 101 66 66 66 66 66 101 21 101 21 101 21 66 66 66 66 66 66 66 66 5", "Above less one 5; BWIPP different encodation" },
/* 69*/ { UNICODE_MODE, "±±±±1234AA", -1, 0, 189, 0, "(17) 104 100 100 17 17 17 17 99 12 34 100 100 33 100 33 89 106", "BWIPP PR #275 (extended ASCII treated as digits)" },
/* 70*/ { UNICODE_MODE, "ÁÁèÁÁFç7Z", -1, 0, 189, 0, "(17) 104 100 100 33 33 72 33 33 100 38 71 100 100 23 58 95 106", "Okapi code128/extended-mode-shift.png; BWIPP different encodation" },
/* 71*/ { UNICODE_MODE, "m\nm\nm", -1, 0, 112, 1, "(10) 104 77 98 74 77 98 74 77 11 106", "Okapi code128/code-set-b-a-b-a-b.png" },
/* 72*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" },
/* 73*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" },
/* 74*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP different encodation, ShA instead of CodeA" },
/* 75*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\012àa\\^A\0121\012\\^BàAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP different encodation, FNC4 before CodeB" },
/* 76*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP different encodation, CodeA instead of ShA, same width" },
/* 77*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ1234\012à\\^Aa\0121\012\\^C7890\\^BàAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 101 74 101 98 64 98 65 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP no manual mode" },
/* 78*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 89 100 95 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation, CodeA instead of ShA, same width" },
/* 79*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 89 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation, CodeA instead of ShA, same width" },
/* 80*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 100 95 99 12 34 101 74 100 100 64 65 101 74 17 74 99 78 90 100 100 64 33", "BWIPP different encodation, CodeA instead of ShA, same width" },
/* 81*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 662, 0, "(60) 104 100 95 99 12 34 56 78 101 74 100 100 64 99 12 34 56 78 100 65 66 67 68 69 70 101", "BWIPP different encodation, CodeA instead of ShA, same width" },
/* 82*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 200, 0, "(18) 104 0 100 100 1 1 1 1 100 0 1 1 1 1 100 0 91 106", "StartB <SP> Latch <A0> (4) FNC4 <SP> <A0> (4) FNC4 <SP>, adapted from BWIPP PR #272; BWIPP pending PR #275" },
/* 83*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 222, 0, "(20) 104 0 100 100 1 1 1 1 100 0 100 0 1 1 1 1 100 0 63 106", "2 middle spaces; BWIPP pending PR #275" },
/* 84*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 244, 0, "(22) 104 0 100 100 1 1 1 1 100 0 100 0 100 0 1 1 1 1 100 0 29 106", "3 middle spaces; BWIPP pending PR #275" },
/* 85*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 266, 0, "(24) 104 0 100 100 1 1 1 1 100 0 100 0 100 0 100 0 1 1 1 1 100 0 92 106", "4 middle spaces (no unlatch); BWIPP pending PR #275" },
/* 86*/ { UNICODE_MODE, " ¡¡¡¡ ¡¡¡¡ ", -1, 0, 277, 0, "(25) 104 0 100 100 1 1 1 1 100 100 0 0 0 0 0 100 100 1 1 1 1 100 0 81 106", "5 middle spaces (unlatch); BWIPP pending PR #275" },
/* 87*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 12\\^1 ", -1, 0, 90, 0, "(8) 104 0 17 18 102 0 85 106", "BWIPP PR #272" },
/* 88*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, " 1234\\^1567", -1, 0, 123, 0, "(11) 104 0 99 12 34 102 56 100 23 41 106", "BWIPP PR #272" },
/* 89*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^14567", -1, 0, 101, 0, "(9) 104 17 99 23 102 45 67 84 106", "BWIPP PR #272" },
/* 90*/ { DATA_MODE | ESCAPE_MODE | EXTRA_ESCAPE_MODE, "\\d031\\d031_\\d127\\d159\\d031\\d159\\d159\\d159\\d15912345``\\d255\\d000\\d127\\d255\\d224\\d224\\d159`", -1, 0, 442, 0, "(40) 103 95 95 63 98 95 101 95 95 101 101 95 95 95 95 99 12 34 100 100 100 21 64 64 100 95", "Code set limit chars; BWIPP different encodation" },
/* 91*/ { DATA_MODE, "\200\200\200\200\200A0000A\200", -1, 0, 211, 0, "(19) 103 101 101 64 64 64 64 64 101 33 99 0 0 101 101 33 64 4 106", "BWIPP different encodation" },
/* 92*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^167\\^18", -1, 0, 145, 1, "(13) 105 12 102 34 100 21 102 22 23 102 24 49 106", "" },
/* 93*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP no manual mode" },
/* 94*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 100 33 34 35 99 12 101 74 36 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA <LF>; BWIPP no manual mode" },
/* 95*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF" },
/* 96*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 1, "(13) 103 33 74 99 12 34 101 33 17 18 74 99 106", "StartA A <LF> CodeC 12 34 CodeA A 1 2 <LF>; Okapi c128/improved-lookahead-mode-a.png" },
/* 97*/ { UNICODE_MODE, "21*\015\012M0", -1, 0, 112, 0, "(10) 105 21 101 10 77 74 45 16 79 106", "StartC 21 CodeA * <CR> <LF> M 0; Okapi c128/improved-lookahead-rule-1c.png; BWIPP different encodation, same width" },
/* 98*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^112345\\^11234\\^112345", -1, 0, 178, 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)" },
/* 99*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^1SN123456789012", -1, 0, 145, 1, "(13) 104 102 51 46 99 12 34 56 78 90 12 65 106", "StartB FNC1 S N CodeC 12 34 56 78 90 12" },
/*100*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1SN123456789012", -1, 0, 200, 0, "(18) 104 102 51 46 17 18 19 20 21 22 23 24 25 16 17 18 56 106", "StartB FNC1 S N 1 2 3 4 5 6 7 8 9 0 1 2; BWIPP no manual mode" },
/*101*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^1BC\\^1DEF\\^1", -1, 0, 134, 1, "(12) 104 33 102 34 35 102 36 37 38 102 9 106", "StartB A FNC1 B C FNC1 D E F FNC1" },
/*102*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP no manual mode" },
/*103*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 1, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3" },
/*104*/ { 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" },
/*105*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^123", -1, 0, 79, 0, "(7) 104 17 99 102 23 99 106", "StartB 1 CodeC FNC1 23; BWIPP different encodation (same codeword count)" },
/*106*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" },
/*107*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134\\^1", -1, 0, 79, 1, "(7) 105 12 102 34 102 7 106", "StartC 12 FNC1 34 FNC1" },
/*108*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^145\\^1", -1, 0, 101, 1, "(9) 104 17 99 23 102 45 102 88 106", "StartB 1 CodeC 23 FNC1 45 FNC1" },
/*109*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^1", -1, 0, 101, 1, "(9) 105 12 102 34 100 21 102 98 106", "StartC 12 FNC1 34 CodeB 5 FNC1" },
/*110*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156\\^1", -1, 0, 90, 1, "(8) 105 12 34 102 56 102 92 106", "StartC 12 34 FNC1 56 FNC1" },
/*111*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156789\\^101\\^11\\^1", -1, 0, 178, 1, "(16) 105 12 34 102 56 78 100 25 102 16 17 102 17 102 100 106", "StartC 12 34 FNC1 56 78 CodeB 9 FNC1 0 1 FNC1 1 FNC1" },
/*112*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^Aaa\\^B\012\012", -1, 0, 134, 0, "(12) 103 98 65 98 65 100 98 74 98 74 27 106", "StartA ShB a ShB a CodeB ShA <LF> ShA <LF>; BWIPP no manual mode" },
/*113*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\\^B\202\202", -1, 0, 156, 0, "(14) 103 101 101 98 66 98 66 100 98 66 98 66 72 106", "StartA FNC4 FNC4 ShB 226(E2) ShB 226(E2) CodeB ShA 130(82) ShA 130(82); BWIPP no manual mode" },
/*114*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\342\342\342\342\\^Baaaaa", -1, 0, 255, 0, "(23) 103 101 101 98 66 98 66 98 66 98 66 98 66 100 100 100 65 65 65 65 65 46 106", "BWIPP no manual mode" },
/*115*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\342\012\342\342\342\\^B\202\342\012\012", -1, 0, 277, 0, "(25) 103 101 98 66 74 101 101 98 66 98 66 98 66 100 98 66 66 100 98 74 100 98 74 69 106", "BWIPP no manual mode" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -477,38 +493,38 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01; BWIPP different encodation (same 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)" },
static const struct item data[] = {
/* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01; BWIPP different encodation (same width)" },
/* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, 0, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01; BWIPP different encodation (same width)" },
/* 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, 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)" },
/* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, 0, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01; BWIPP different encodation (same width)" },
/* 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" },
/* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 167, 0, "(15) 105 102 90 100 17 102 25 99 1 102 90 100 17 88 106", "StartC FNC1(GS1) 90 CodeB 1 FNC1(29) 9 CodeC 01 FNC1(29) 90 CodeB 1; BWIPP different encodation (same width)" },
/* 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)" },
/* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 102 25 99 1 45 106", "StartC FNC1 90 12 FNC1 90 12 CodeB 3 FNC1 9 CodeC 01; BWIPP different encodation (same width)" },
/* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, 0, "(15) 105 102 90 12 102 90 12 100 19 99 102 90 12 100 106", "StartC FNC1 90 12 FNC1 90 12 CodeB 3 CodeC FNC1 90 12; BWIPP different encodation (same width)" },
/* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 178, 0, "(16) 105 102 90 12 100 19 102 25 99 1 102 90 100 17 66 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 90 CodeB 1; BWIPP different encodation (same width)" },
/* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 167, 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, 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)" },
/* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, 0, "(12) 105 102 90 100 17 33 102 25 99 1 36 106", "StartC FNC1 90 CodeB 1 A FNC1 9 CodeC 01; BWIPP different encodation (same width)" },
/* 21*/ { GS1_MODE, "[90]12A[90]123", 0, 145, 1, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
/* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 222, 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)" },
/* 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 width)" },
/* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, 0, "(16) 105 102 90 12 34 100 21 33 99 12 34 100 21 33 8 106", "StartC FNC1 90 12 34 CodeB 5 A CodeC 12 34 CodeB 5 A; BWIPP different encodation (same width)" },
/* 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" },
/* 25*/ { GS1_MODE, "[01]12345678901231[90]123456789012345678901234567890[91]1", ZINT_WARN_NONCOMPLIANT, 354, 1, "Warning 843: Input too long, requires 52 characters (maximum 48)", "Over length" },
/* 26*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]1234", ZINT_WARN_HRT_TRUNCATED, 1135, 1, "Warning 844: Human Readable Text truncated", "Max input" },
/* 27*/ { GS1_MODE, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]567890[20]34[20]78", ZINT_WARN_HRT_TRUNCATED, 1135, 1, "Warning 844: Human Readable Text truncated", "HRT truncation warning trumps non-compliant (3100) warning" },
/* 28*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, 1, "Error 344: Input too long (99 symbol character maximum)", "" },
/* 28*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, 1, "Error 344: Input too long, requires 101 symbol characters (maximum 99)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -598,17 +614,17 @@ static void test_hibc_input(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", "" },
static const struct item data[] = {
/* 0*/ { ",", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 203: Invalid character at position 1 in input (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)", "" },
/* 5*/ { "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%", ZINT_ERROR_TOO_LONG, -1, 0, "Error 341: Input too long, requires 100 symbol characters (maximum 99)", "" },
/* 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);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -678,6 +694,62 @@ static void test_hibc_input(const testCtx *const p_ctx) {
testFinish();
}
static void test_nve18_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
char *data;
int ret;
int expected_width;
char *expected;
char *comment;
};
static const struct item data[] = {
/* 0*/ { -1, "123456789012345678", ZINT_ERROR_TOO_LONG, -1, "Error 345: Input length 18 too long (maximum 17)", "" },
/* 1*/ { -1, "1234A568901234567", ZINT_ERROR_INVALID_DATA, -1, "Error 346: Invalid character at position 5 in input (digits only)", "" },
/* 2*/ { ESCAPE_MODE, "\\d049\\d050\\d051\\d052A568901234567", ZINT_ERROR_INVALID_DATA, -1, "Error 346: Invalid character at position 5 in input (digits only)", "Position does not account for escape sequences" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
char escaped[1024];
testStartSymbol("test_nve18_input", &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */
length = testUtilSetSymbol(symbol, BARCODE_NVE18, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (p_ctx->generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
} else {
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if (ret < ZINT_ERROR) {
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_ean14_input(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@ -688,11 +760,11 @@ static void test_ean14_input(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 347: Input too long (13 character maximum)", "" },
/* 1*/ { "A", ZINT_ERROR_INVALID_DATA, -1, "Error 348: Invalid character in data (digits only)", "" },
static const struct item data[] = {
/* 0*/ { "12345678901234", ZINT_ERROR_TOO_LONG, -1, "Error 347: Input length 14 too long (maximum 13)", "" },
/* 1*/ { "123456789012A", ZINT_ERROR_INVALID_DATA, -1, "Error 348: Invalid character at position 13 in input (digits only)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -744,16 +816,16 @@ static void test_dpd_input(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input wrong length (27 or 28 characters required)", "" },
/* 1*/ { 1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input wrong length (27 characters required)", "" },
static const struct item data[] = {
/* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input length 26 wrong (27 or 28 only)", "" },
/* 1*/ { 1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input length 26 wrong (27 only)", "" },
/* 2*/ { -1, -1, "123456789012345678901234567", 0, 211, 50, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "27 chars ok now, ident tag prefixed" },
/* 3*/ { -1, -1, "%123456789012345678901234567", 0, 211, 50, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "" },
/* 4*/ { 1, -1, "123456789012345678901234567", 0, 200, 25, "(18) 105 12 34 56 78 90 12 34 56 78 90 12 34 56 100 23 102 106", "27 chars also ok (and necessary) for relabel" },
/* 5*/ { -1, -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input wrong length (27 or 28 characters required)", "" },
/* 6*/ { 1, -1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input wrong length (27 characters required)", "" },
/* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 299: Invalid character in data (alphanumerics only after first character)", "Alphanumerics only in body" },
/* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 300: Invalid character in data (alphanumerics only)", "Alphanumerics only in body" },
/* 5*/ { -1, -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input length 29 wrong (27 or 28 only)", "" },
/* 6*/ { 1, -1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input length 28 wrong (27 only)", "" },
/* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 299: Invalid character at position 27 in input (alphanumerics only after first)", "Alphanumerics only in body" },
/* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 300: Invalid character at position 27 in input (alphanumerics only)", "Alphanumerics only" },
/* 9*/ { -1, -1, ",234567890123456789012345678", 0, 211, 50, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" },
/* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char <US> as DPD ident tag" },
/* 11*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" },
@ -777,7 +849,7 @@ static void test_dpd_input(const testCtx *const p_ctx) {
/* 29*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
/* 30*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -828,9 +900,9 @@ static void test_upu_s10_input(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { "AB123456789ABC", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input must be 12 or 13 characters long", "" },
/* 1*/ { "AB1234567AB", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input must be 12 or 13 characters long", "" },
static const struct item data[] = {
/* 0*/ { "AB123456789ABC", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 14 wrong (12 or 13 only)", "" },
/* 1*/ { "AB1234567AB", ZINT_ERROR_TOO_LONG, 0, "Error 834: Input length 11 wrong (12 or 13 only)", "" },
/* 2*/ { "1B123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" },
/* 3*/ { "1B12345678AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" },
/* 4*/ { "A2123456789AB", ZINT_ERROR_INVALID_DATA, 0, "Error 835: Invalid character in Service Indictor (first 2 characters) (alphabetic only)", "" },
@ -850,7 +922,7 @@ static void test_upu_s10_input(const testCtx *const p_ctx) {
/* 18*/ { "AB123100000IE", 0, 156, "", "Check digit 10 -> 0" },
/* 19*/ { "AB000000005IE", 0, 156, "", "Check digit 11 -> 5" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -908,7 +980,7 @@ static void test_encode(const testCtx *const p_ctx) {
/* BARCODE_GS1_128 examples verified manually against GS1 General Specifications 21.0.1 (GGS) */
/* BARCODE_DPD examples Specification DPD and primetime Parcel Despatch (DPDAPPD) Version 4.0.2, also
DPD Parcel Label Specification (DPDPLS) Version 2.4.1 (19.01.2021) */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, "AIM", 0, 1, 68, 1, "ISO/IEC 15417:2007 Figure 1",
"11010010000101000110001100010001010111011000101110110001100011101011"
},
@ -933,10 +1005,10 @@ static void test_encode(const testCtx *const p_ctx) {
/* 7*/ { BARCODE_GS1_128, GS1_MODE, -1, "[415]5412345678908[3911]710125", 0, 1, 189, 1, "GGS Figure 2.6.6-1 top",
"110100111001111010111011000100010111010001101100010001011101101110101110110001000010110011011011110100011001001101000100011000100100100110100001100110110011100101100100001001101100011101011"
},
/* 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",
/* 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 width; BWIPP as standard",
"110100111001111010111010110011100110011011001001000110011100101100101001111001100100111010111101110101000110001000101100010001000110100111001101011101111011101101110111101000101100011101011"
},
/* 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",
/* 9*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153005812345678901", 0, 1, 211, 0, "GGS Figure 2.6.9-1 **NOT SAME**, different encodation, same width; BWIPP as standard",
"1101001110011110101110111001011001101000100011000101110110001001001100110110011011101110110110011001110110001010110011100100010110001110001011011000010100110111101101011110111010011100110101110110001100011101011"
},
/* 10*/ { BARCODE_GS1_128, GS1_MODE, -1, "[253]950110153006567890543210987", 0, 1, 211, 1, "GGS Figure 2.6.9-2",
@ -960,7 +1032,7 @@ static void test_encode(const testCtx *const p_ctx) {
/* 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"
},
/* 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",
/* 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 width",
"110100100001111010111011001001110101110111101001001100011000101000111001001101101110010011110101110110001010001100101110011000101110110001001001100110110011011101110101111011101000101100010011101100101110111101100100010011001101100110001101101100011101011"
},
/* 18*/ { BARCODE_GS1_128, GS1_MODE, -1, "[00]395011015300000011", 0, 1, 156, 1, "GGS Figure 6.6.5-2 bottom",
@ -1032,7 +1104,7 @@ static void test_encode(const testCtx *const p_ctx) {
/* 40*/ { BARCODE_NVE18, GS1_MODE, -1, "40700000071967072", 0, 1, 156, 1, "",
"110100111001111010111011011001100110001010001011000010011011001100110110011001001100010011001011100100001011001001100010011001001110110111011101100011101011"
},
/* 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",
/* 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 width",
"1101001000011000100100101110111101011110010011101100100101111011101110100110010001100010111010011001101000100011100101100110001010001001110110010110111000110011100101101000100010001001100110100010001100011101011"
},
/* 42*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, "A123BJC5D6E71", 0, 1, 200, 1, "ANSI/HIBC 2.6 - 2016 Figure 1, same",
@ -1065,11 +1137,11 @@ static void test_encode(const testCtx *const p_ctx) {
/* 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"
},
/* 52*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", 0, 1, 156, 0, "BWIPP different encodation, same codeword count",
/* 52*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, "EE876543216CA", 0, 1, 156, 0, "BWIPP different encodation, same width",
"110100100001000110100010001101000101110111101111001010010010110000101100011101101110010010111101110110011101001000100011010100011000100010011001100011101011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -1162,12 +1234,12 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, "123456ABCD123456ABCD123456ABCD123456ABCD123456ABCD123456ABCD", 0, 1, 618, "CODE128 60" },
/* 1*/ { BARCODE_CODE128, "123456ABCD", 0, 1, 123, "CODE128 10" },
/* 2*/ { BARCODE_GS1_128, "[01]09501101530003", 0, 1, 134, "GS1_128 (01)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
@ -1258,6 +1330,7 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input },
{ "test_gs1_128_input", test_gs1_128_input },
{ "test_hibc_input", test_hibc_input },
{ "test_nve18_input", test_nve18_input },
{ "test_ean14_input", test_ean14_input },
{ "test_dpd_input", test_dpd_input },
{ "test_upu_s10_input", test_upu_s10_input },

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -40,21 +40,23 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "A", 77, 0, 16, 70 }, /* BS EN 12323:2005 4.1 (l) */
/* 1*/ { "A", 78, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "0", 154, 0, 16, 70 }, /* BS EN 12323:2005 4.1 (l) */
/* 3*/ { "0", 155, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { "0", 153, ZINT_ERROR_TOO_LONG, -1, -1 }, /* Fails due to odd length */
/* 5*/ { "0", 161, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { "\001", 77, 0, 16, 70 },
/* 7*/ { "\001", 78, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { "\377", 38, 0, 16, 70 }, /* FNC4 + char for each so half 77 as not using double latch */
/* 9*/ { "\377", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { "A", 77, 0, 16, 70, "" }, /* BS EN 12323:2005 4.1 (l) */
/* 1*/ { "A", 78, ZINT_ERROR_TOO_LONG, -1, -1, "Error 421: Input too long, requires 79 symbol characters (maximum 78)" },
/* 2*/ { "A", 257, ZINT_ERROR_TOO_LONG, -1, -1, "Error 420: Input length 257 too long (maximum 256)" },
/* 3*/ { "0", 154, 0, 16, 70, "" }, /* BS EN 12323:2005 4.1 (l) */
/* 4*/ { "0", 155, ZINT_ERROR_TOO_LONG, -1, -1, "Error 421: Input too long, requires 80 symbol characters (maximum 78)" },
/* 5*/ { "0", 153, ZINT_ERROR_TOO_LONG, -1, -1, "Error 421: Input too long, requires 79 symbol characters (maximum 78)" }, /* Fails due to odd length */
/* 6*/ { "0", 161, ZINT_ERROR_TOO_LONG, -1, -1, "Error 421: Input too long, requires 79 symbol characters (maximum 78)" },
/* 7*/ { "\001", 77, 0, 16, 70, "" },
/* 8*/ { "\001", 78, ZINT_ERROR_TOO_LONG, -1, -1, "Error 421: Input too long, requires 79 symbol characters (maximum 78)" },
/* 9*/ { "\377", 38, 0, 16, 70, "" }, /* FNC4 + char for each so half 77 as not using double latch */
/* 10*/ { "\377", 39, ZINT_ERROR_TOO_LONG, -1, -1, "Error 421: Input too long, requires 79 symbol characters (maximum 78)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -76,6 +78,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -101,13 +105,13 @@ static void test_reader_init(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, READER_INIT, "A", 0, 2, 70, "(10) 1 96 33 103 103 103 103 103 68 35", "ModeB FNC3 A Pad (5)" },
/* 1*/ { UNICODE_MODE, READER_INIT, "12", 0, 2, 70, "(10) 5 96 12 103 103 103 103 103 99 41", "ModeC1SB FNC3 12 Pad (5)" },
/* 2*/ { UNICODE_MODE, READER_INIT, "A1234", 0, 2, 70, "(10) 6 96 33 12 34 103 103 103 65 53", "ModeC2SB FNC3 A 12 34 Pad (3)" },
/* 3*/ { GS1_MODE, READER_INIT, "[90]1", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 422: Cannot use both GS1 mode and Reader Initialisation", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -135,10 +139,10 @@ static void test_reader_init(const testCtx *const p_ctx) {
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, symbol->errtxt, data[i].comment);
} else {
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
@ -172,7 +176,7 @@ static void test_input(const testCtx *const p_ctx) {
ß U+00DF (\337, 223), UTF-8 C39F, CodeA and CodeB extended ASCII
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "\037", -1, 0, 2, 70, 1, "(10) 0 95 103 103 103 103 103 103 22 42", "ModeA US Pad (6)" },
/* 1*/ { UNICODE_MODE, -1, "A", -1, 0, 2, 70, 1, "(10) 1 33 103 103 103 103 103 103 52 82", "ModeB A Pad (6)" },
/* 2*/ { UNICODE_MODE, -1, "12", -1, 0, 2, 70, 1, "(10) 2 12 103 103 103 103 103 103 98 27", "ModeC 12 Pad (6)" },
@ -202,8 +206,8 @@ static void test_input(const testCtx *const p_ctx) {
/* 26*/ { UNICODE_MODE, 4, "123456789012345678901234", -1, 0, 4, 70, 1, "(20) 16 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 66 96", "Min 4 rows" },
/* 27*/ { UNICODE_MODE, 5, "123456789012345678901234", -1, 0, 5, 70, 1, "(25) 23 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 103 103 103 103 103 68 61", "Min 5 rows" },
/* 28*/ { UNICODE_MODE, 16, "123456789012345678901234", -1, 0, 16, 70, 1, "(80) 100 12 34 56 78 90 12 34 56 78 90 12 34 103 103 103 103 103 103 103 103 103 103 103", "Min 16 rows" },
/* 29*/ { UNICODE_MODE, 1, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, "Error 424: Minimum number of rows out of range (2 to 16)", "" },
/* 30*/ { UNICODE_MODE, 17, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, "Error 424: Minimum number of rows out of range (2 to 16)", "" },
/* 29*/ { UNICODE_MODE, 1, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, "Error 424: Minimum number of rows '1' out of range (2 to 16)", "" },
/* 30*/ { UNICODE_MODE, 17, "123456789012345678901234", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, 1, "Error 424: Minimum number of rows '17' out of range (2 to 16)", "" },
/* 31*/ { UNICODE_MODE, -1, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 6, 70, 0, "(30) 29 100 33 100 33 100 33 100 33 100 33 100 33 99 99 99 99 99 99 99 99 100 100 33 103", "BWIPP different encodation, uses double FNC4 latch" },
/* 32*/ { UNICODE_MODE, -1, "ÿ\012àa\0121\012àAà", -1, 0, 4, 70, 0, "(20) 15 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 47 35", "BWIPP different encodation, uses CodeA instead of 1SA" },
/* 33*/ { UNICODE_MODE, -1, "ÿ\012àa\0121\012àAà\012à", -1, 0, 5, 70, 0, "(25) 22 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 98 74 100 64 103 89 18", "BWIPP different encodation, uses CodeA instead of 1SA" },
@ -218,7 +222,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 42*/ { UNICODE_MODE, -1, "ÿ123456\012à123456abcd\0121\01223456\012\0127890àAàBCDEà\012\012à", -1, 0, 11, 70, 0, "(55) 69 100 95 12 34 56 101 74 101 98 64 99 12 34 56 100 65 66 67 68 98 74 17 98 74 18 99", "BWIPP different encodation, uses Sh3C + other differences" },
/* 43*/ { UNICODE_MODE, -1, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 12, 70, 0, "(60) 76 100 95 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74 17", "BWIPP different encodation, uses Sh2C + other differences" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -251,7 +255,7 @@ static void test_input(const testCtx *const p_ctx) {
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment);
} else {
assert_zero(strcmp((char *) symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data);
@ -304,7 +308,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "ab0123456789", 0, 2, 70, "BS EN 12323:2005 Figure 3",
"1110010101100110111011010011110110111100100110010011000100100010001101"
"1100110101000100111011110100110010010000100110100011010010001110011001"
@ -347,7 +351,7 @@ static void test_encode(const testCtx *const p_ctx) {
"1110100100101111011001011110110010111101100101110001001110010010111101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;

View file

@ -40,21 +40,22 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "A", 49, 0, 8, 70 }, /* ANSI/AIM BC6-2000 Table 1 */
/* 1*/ { "A", 50, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "0", 81, 0, 8, 70 }, /* ANSI/AIM BC6-2000 Table 1 */
/* 3*/ { "0", 82, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { "A", 49, 0, 8, 70, "" }, /* ANSI/AIM BC6-2000 Table 1 */
/* 1*/ { "A", 50, ZINT_ERROR_TOO_LONG, -1, -1, "Error 432: Input too long, requires 50 codewords (maximum 49)" },
/* 2*/ { "0", 81, 0, 8, 70, "" }, /* ANSI/AIM BC6-2000 Table 1 */
/* 3*/ { "0", 82, ZINT_ERROR_TOO_LONG, -1, -1, "Error 430: Input length 82 too long (maximum 81)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char data_buf[4096];
testStart("test_large");
testStartSymbol("test_large", &symbol);
for (i = 0; i < data_size; i++) {
@ -70,6 +71,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -100,8 +103,8 @@ static void test_input(const testCtx *const p_ctx) {
NUL U+0000, S1 SP (39)
US U+001F (\037, 31), S1 5
*/
struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "é", -1, ZINT_ERROR_INVALID_DATA, 0, 0, "Error 431: Invalid character in input data, extended ASCII not allowed", "ASCII only" },
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "é", -1, ZINT_ERROR_INVALID_DATA, 0, 0, "Error 431: Invalid character at position 1 in input, extended ASCII not allowed", "ASCII only" },
/* 1*/ { UNICODE_MODE, -1, "EXAMPLE 2", -1, 0, 2, 70, "(16) 14 33 10 22 25 21 14 41 38 2 35 14 18 13 0 22", "2.3.7 Symbol Example" },
/* 2*/ { UNICODE_MODE, -1, "12345", -1, 0, 2, 70, "(16) 5 17 9 48 48 48 48 27 48 48 13 23 0 13 2 0", "2.3 Example 1: Numeric Encodation (Start 2, Numeric)" },
/* 3*/ { UNICODE_MODE, -1, "123456", -1, 0, 2, 70, "(16) 5 17 9 6 48 48 48 34 48 48 36 9 23 41 2 11", "2.3 Example 1: Numeric Encodation" },
@ -127,11 +130,11 @@ static void test_input(const testCtx *const p_ctx) {
/* 23*/ { UNICODE_MODE, 7, "1234567890123456789012345678901234567890", -1, 0, 7, 70, "(56) 5 17 9 29 22 18 5 7 17 9 29 22 18 5 17 19 9 29 22 18 5 17 9 11 29 22 18 48 48 48 48 16", "" },
/* 24*/ { UNICODE_MODE, 8, "1234567890123456789012345678901234567890", -1, 0, 8, 70, "(64) 5 17 9 29 22 18 5 7 17 9 29 22 18 5 17 19 9 29 22 18 5 17 9 11 29 22 18 48 48 48 48 16", "" },
/* 25*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW", -1, 0, 8, 70, "(64) 10 11 12 13 14 15 16 42 17 18 19 20 21 22 23 42 24 25 26 27 28 29 30 42 31 32 33 34 35", "" },
/* 26*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX", -1, ZINT_ERROR_TOO_LONG, 0, 0, "Error 432: Input too long (49 symbol character maximum)", "" },
/* 26*/ { UNICODE_MODE, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX", -1, ZINT_ERROR_TOO_LONG, 0, 0, "Error 432: Input too long, requires 50 codewords (maximum 49)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[8192];
@ -139,7 +142,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -199,7 +202,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, "MULTIPLE ROWS IN CODE 49", 0, 5, 70, "ANSI/AIM BC6-2000 Figure 1",
"1011111011001011101011100110000110111101011011111010111101000100001111"
"1010100001000010001001111000101110100110001111010010001011100011001111"
@ -227,9 +230,9 @@ static void test_encode(const testCtx *const p_ctx) {
"1011110110100100001010000100010000111010010011111011001000111011001111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char bwipp_buf[8192];
@ -237,7 +240,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -59,7 +59,7 @@ static void test_to_int(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, 0 },
/* 1*/ { "1234", -1, 1234 },
/* 2*/ { "-1234", -1, -1 },
@ -67,7 +67,7 @@ static void test_to_int(const testCtx *const p_ctx) {
/* 4*/ { " ", -1, -1 },
/* 5*/ { "999999999", -1, 999999999 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
testStart("test_to_int");
@ -93,13 +93,13 @@ static void test_to_upper(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, "" },
/* 1*/ { "abcefghijklmnopqrstuvwxyz", -1, "ABCEFGHIJKLMNOPQRSTUVWXYZ" },
/* 2*/ { ".a[b`cA~B\177C;\200", -1, ".A[B`CA~B\177C;\200" },
/* 3*/ { "é", -1, "é" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length;
unsigned char buf[512];
@ -132,12 +132,12 @@ static void test_chr_cnt(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, 'a', 0 },
/* 1*/ { "BDAaED", -1, 'a', 1 },
/* 1*/ { "aBDAaaaEaDa", -1, 'a', 6 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
testStart("test_chr_cnt");
@ -155,7 +155,7 @@ static void test_chr_cnt(const testCtx *const p_ctx) {
testFinish();
}
static void test_is_sane(const testCtx *const p_ctx) {
static void test_not_sane(const testCtx *const p_ctx) {
struct item {
unsigned int flg;
@ -166,97 +166,97 @@ static void test_is_sane(const testCtx *const p_ctx) {
char *orig_test;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { IS_SPC_F, " ", -1, 1, " " },
/* 1*/ { IS_SPC_F, "\000", 1, 0, " " },
/* 2*/ { IS_HSH_F, "#", -1, 1, "#" },
/* 3*/ { IS_HSH_F, " ", -1, 0, "#" },
/* 4*/ { IS_AST_F, "*", -1, 1, "*" },
/* 5*/ { IS_AST_F, " ", -1, 0, "*" },
/* 6*/ { IS_PLS_F, "+", -1, 1, "+" },
/* 7*/ { IS_PLS_F, " ", -1, 0, "+" },
/* 8*/ { IS_MNS_F, "-", -1, 1, "-" },
/* 9*/ { IS_MNS_F, " ", -1, 0, "-" },
/* 10*/ { IS_NUM_F, "0123456789", -1, 1, "0123456789" }, /* NEON */
/* 11*/ { IS_NUM_F, "0123456789 ", -1, 0, "0123456789" },
/* 12*/ { IS_NUM_F, "012345678A9", -1, 0, "0123456789" },
/* 13*/ { IS_UPO_F, "GHIJKLMNOPQRSTUVWYZ", -1, 1, "GHIJKLMNOPQRSTUVWYZ" },
/* 14*/ { IS_UPO_F, "FGHIJKLMNOPQRSTUVWYZ", -1, 0, "GHIJKLMNOPQRSTUVWYZ" },
/* 15*/ { IS_LWO_F, "ghijklmnopqrstuvwyz", -1, 1, "ghijklmnopqrstuvwyz" },
/* 16*/ { IS_LWO_F, "fghijklmnopqrstuvwyz", -1, 0, "ghijklmnopqrstuvwyz" },
/* 17*/ { IS_UHX_F, "ABCDEF", -1, 1, "ABCDEF" },
/* 18*/ { IS_UHX_F, "ABCDEf", -1, 0, "ABCDEF" },
/* 19*/ { IS_LHX_F, "abcdef", -1, 1, "abcdef" },
/* 20*/ { IS_LHX_F, "abcdeF", -1, 0, "abcdef" },
/* 21*/ { IS_UPR_F, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 22*/ { IS_UPR_F, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ", -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 23*/ { IS_UPR_F, "X", -1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 24*/ { IS_UPR_F, "x", -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 25*/ { IS_LWR_F, "abcdefghijklmnopqrstuvwxyz", -1, 1, "abcdefghijklmnopqrstuvwxyz" },
/* 26*/ { IS_LWR_F, "abcdefghijklmnopqrstuvwxyz ", -1, 0, "abcdefghijklmnopqrstuvwxyz" },
/* 27*/ { IS_LWR_F, "x", -1, 1, "abcdefghijklmnopqrstuvwxyz" },
/* 28*/ { IS_LWR_F, "X", -1, 0, "abcdefghijklmnopqrstuvwxyz" },
/* 29*/ { IS_UX__F, "X", -1, 1, "X" },
/* 30*/ { IS_UX__F, "x", -1, 0, "X" },
/* 31*/ { IS_LX__F, "x", -1, 1, "x" },
/* 32*/ { IS_LX__F, "X", -1, 0, "x" },
/* 33*/ { IS_C82_F, "!\"%&'(),./:;<=>?_", -1, 1, "!\"%&'(),./:;<=>?_" }, /* CSET82 punctuation less "*+-" */
/* 34*/ { IS_C82_F, "!\"%&'(),./:;<=>?_ ", -1, 0, "!\"%&'(),./:;<=>?_" },
/* 35*/ { IS_C82_F, "-", -1, 0, "!\"%&'(),./:;<=>?_" },
/* 36*/ { IS_C82_F, "$", -1, 0, "!\"%&'(),./:;<=>?_" },
/* 37*/ { IS_SIL_F, ".$/%", -1, 1, ".$/%" }, /* SILVER punctuation less " +-" */
/* 38*/ { IS_SIL_F, ".$/% " , -1, 0, ".$/%" },
/* 39*/ { IS_SIL_F, "-", -1, 0, ".$/%" },
/* 40*/ { IS_CLI_F, "$:/.", -1, 1, "$:/." }, /* CALCIUM INNER punctuation less "+-" */
/* 41*/ { IS_CLI_F, "$:/. ", -1, 0, "$:/." },
/* 42*/ { IS_CLI_F, "+", -1, 0, "$:/." },
/* 43*/ { IS_ARS_F, "ABCDEFGHJKLMNPRSTUVWXYZ", -1, 1, "ABCDEFGHJKLMNPRSTUVWXYZ" }, /* ARSENIC uppercase */
/* 44*/ { IS_ARS_F, "ABCDEFGHJKLMNPRSTUVWXYZ ", -1, 0, "ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 45*/ { IS_ARS_F, "I", -1, 0, "ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 46*/ { IS_ARS_F, "O", -1, 0, "ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 47*/ { IS_NUM_F | IS_UHX_F, "0123456789ABCDEF", -1, 1, "0123456789ABCDEF" }, /* SSET */
/* 48*/ { IS_NUM_F | IS_UHX_F, "0123456789ABCDEf", -1, 0, "0123456789ABCDEF" },
/* 49*/ { IS_NUM_F | IS_PLS_F, "0123456789+", -1, 1, "0123456789+" }, /* SODIUM_PLS */
/* 50*/ { IS_NUM_F | IS_PLS_F, "0123456789+-", -1, 0, "0123456789+" },
/* 51*/ { IS_NUM_F | IS_UX__F, "0123456789X", -1, 1, "0123456789X" }, /* ISBNX_SANE */
/* 52*/ { IS_NUM_F | IS_UX__F, "0123456789x", -1, 0, "0123456789X" },
/* 53*/ { IS_NUM_F | IS_UX__F | IS_LX__F | IS_PLS_F, "0123456789Xx+", -1, 1, "0123456789Xx+" }, /* ISBNX_ADDON_SANE */
/* 54*/ { IS_NUM_F | IS_UX__F | IS_LX__F | IS_PLS_F, "0123456789Xx+Y", -1, 0, "0123456789Xx+" },
/* 55*/ { IS_NUM_F | IS_MNS_F, "0123456789-", -1, 1, "0123456789-" }, /* SODIUM_MNS */
/* 56*/ { IS_NUM_F | IS_MNS_F, "0123456789-+", -1, 0, "0123456789-" },
/* 57*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz", -1, 1, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" }, /* CSET82 */
/* 58*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, " ", -1, 0, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 59*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "#", -1, 0, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 60*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "$", -1, 0, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 61*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "@", -1, 0, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 62*/ { IS_LWR_F | IS_C82_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SPC_F, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ ", -1, 1, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ " }, /* IS_ISOIEC_F */
/* 63*/ { IS_LWR_F | IS_C82_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SPC_F, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ #", -1, 0, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ " },
/* 64*/ { IS_LWR_F | IS_C82_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SPC_F, "$", -1, 0, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ " },
/* 65*/ { IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "-. $/+%", -1, 1, "" },
/* 66*/ { IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "-. $/!+%", -1, 0, "" },
/* 67*/ { IS_NUM_F | IS_UPR_F | IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", -1, 1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%" }, /* SILVER */
/* 68*/ { IS_NUM_F | IS_UPR_F | IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%a", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%" },
/* 69*/ { IS_NUM_F | IS_ARS_F, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ", -1, 1, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ" }, /* ARSENIC */
/* 70*/ { IS_NUM_F | IS_ARS_F, "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ", -1, 0, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 71*/ { IS_NUM_F | IS_ARS_F, "0123456789ABCDEFGHJKLMNPRSTUVWXYz", -1, 0, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 72*/ { IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #", -1, 1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #" }, /* GDSET */
/* 73*/ { IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #!", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #" },
/* 74*/ { IS_NUM_F | IS_MNS_F | IS_CLI_F | IS_PLS_F, "0123456789-$:/.+", -1, 1, "0123456789-$:/.+" }, /* CALCIUM_INNER */
/* 75*/ { IS_NUM_F | IS_MNS_F | IS_CLI_F | IS_PLS_F, "0123456789-$:/.+ ", -1, 0, "0123456789-$:/.+" },
/* 76*/ { IS_NUM_F | IS_MNS_F | IS_CLI_F | IS_PLS_F, "0123456789-$:/.+!", -1, 0, "0123456789-$:/.+" },
/* 77*/ { IS_NUM_F | IS_UPR_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, /* KRSET */
/* 78*/ { IS_NUM_F | IS_UPR_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYz", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 79*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ", -1, 1, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " }, /* RUBIDIUM */
/* 80*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F, "0123456789aBCDEFGHIJKLMNOPQRSTUVWXYZ ", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " },
/* 81*/ { IS_NUM_F | IS_MNS_F | IS_UPR_F, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 1, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, /* SHKASUTSET */
/* 82*/ { IS_NUM_F | IS_MNS_F | IS_UPR_F, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYz", -1, 0, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 83*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SIL_F | IS_CLI_F, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 1, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, /* QR_ALPHA */
/* 84*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SIL_F | IS_CLI_F, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYz", -1, 0, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
static const struct item data[] = {
/* 0*/ { IS_SPC_F, " ", -1, 0, " " },
/* 1*/ { IS_SPC_F, "\000", 0, 0, " " },
/* 2*/ { IS_HSH_F, "#", -1, 0, "#" },
/* 3*/ { IS_HSH_F, " ", -1, 1, "#" },
/* 4*/ { IS_AST_F, "*", -1, 0, "*" },
/* 5*/ { IS_AST_F, " ", -1, 1, "*" },
/* 6*/ { IS_PLS_F, "+", -1, 0, "+" },
/* 7*/ { IS_PLS_F, " ", -1, 1, "+" },
/* 8*/ { IS_MNS_F, "-", -1, 0, "-" },
/* 9*/ { IS_MNS_F, " ", -1, 1, "-" },
/* 10*/ { IS_NUM_F, "0123456789", -1, 0, "0123456789" }, /* NEON */
/* 11*/ { IS_NUM_F, "0123456789 ", -1, 11, "0123456789" },
/* 12*/ { IS_NUM_F, "012345678A9", -1, 10, "0123456789" },
/* 13*/ { IS_UPO_F, "GHIJKLMNOPQRSTUVWYZ", -1, 0, "GHIJKLMNOPQRSTUVWYZ" },
/* 14*/ { IS_UPO_F, "FGHIJKLMNOPQRSTUVWYZ", -1, 1, "GHIJKLMNOPQRSTUVWYZ" },
/* 15*/ { IS_LWO_F, "ghijklmnopqrstuvwyz", -1, 0, "ghijklmnopqrstuvwyz" },
/* 16*/ { IS_LWO_F, "fghijklmnopqrstuvwyz", -1, 1, "ghijklmnopqrstuvwyz" },
/* 17*/ { IS_UHX_F, "ABCDEF", -1, 0, "ABCDEF" },
/* 18*/ { IS_UHX_F, "ABCDEf", -1, 6, "ABCDEF" },
/* 19*/ { IS_LHX_F, "abcdef", -1, 0, "abcdef" },
/* 20*/ { IS_LHX_F, "abcdeF", -1, 6, "abcdef" },
/* 21*/ { IS_UPR_F, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 22*/ { IS_UPR_F, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ", -1, 27, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 23*/ { IS_UPR_F, "X", -1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 24*/ { IS_UPR_F, "x", -1, 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 25*/ { IS_LWR_F, "abcdefghijklmnopqrstuvwxyz", -1, 0, "abcdefghijklmnopqrstuvwxyz" },
/* 26*/ { IS_LWR_F, "abcdefghijklmnopqrstuvwxyz ", -1, 27, "abcdefghijklmnopqrstuvwxyz" },
/* 27*/ { IS_LWR_F, "x", -1, 0, "abcdefghijklmnopqrstuvwxyz" },
/* 28*/ { IS_LWR_F, "X", -1, 1, "abcdefghijklmnopqrstuvwxyz" },
/* 29*/ { IS_UX__F, "X", -1, 0, "X" },
/* 30*/ { IS_UX__F, "x", -1, 1, "X" },
/* 31*/ { IS_LX__F, "x", -1, 0, "x" },
/* 32*/ { IS_LX__F, "X", -1, 1, "x" },
/* 33*/ { IS_C82_F, "!\"%&'(),./:;<=>?_", -1, 0, "!\"%&'(),./:;<=>?_" }, /* CSET82 punctuation less "*+-" */
/* 34*/ { IS_C82_F, "!\"%&'(),./:;<=>?_ ", -1, 18, "!\"%&'(),./:;<=>?_" },
/* 35*/ { IS_C82_F, "-", -1, 1, "!\"%&'(),./:;<=>?_" },
/* 36*/ { IS_C82_F, "$", -1, 1, "!\"%&'(),./:;<=>?_" },
/* 37*/ { IS_SIL_F, ".$/%", -1, 0, ".$/%" }, /* SILVER punctuation less " +-" */
/* 38*/ { IS_SIL_F, ".$/% " , -1, 5, ".$/%" },
/* 39*/ { IS_SIL_F, "-", -1, 1, ".$/%" },
/* 40*/ { IS_CLI_F, "$:/.", -1, 0, "$:/." }, /* CALCIUM INNER punctuation less "+-" */
/* 41*/ { IS_CLI_F, "$:/. ", -1, 5, "$:/." },
/* 42*/ { IS_CLI_F, "+", -1, 1, "$:/." },
/* 43*/ { IS_ARS_F, "ABCDEFGHJKLMNPRSTUVWXYZ", -1, 0, "ABCDEFGHJKLMNPRSTUVWXYZ" }, /* ARSENIC uppercase */
/* 44*/ { IS_ARS_F, "ABCDEFGHJKLMNPRSTUVWXYZ ", -1, 24, "ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 45*/ { IS_ARS_F, "I", -1, 1, "ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 46*/ { IS_ARS_F, "O", -1, 1, "ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 47*/ { IS_NUM_F | IS_UHX_F, "0123456789ABCDEF", -1, 0, "0123456789ABCDEF" }, /* SSET */
/* 48*/ { IS_NUM_F | IS_UHX_F, "0123456789ABCDEf", -1, 16, "0123456789ABCDEF" },
/* 49*/ { IS_NUM_F | IS_PLS_F, "0123456789+", -1, 0, "0123456789+" }, /* SODIUM_PLS */
/* 50*/ { IS_NUM_F | IS_PLS_F, "0123456789+-", -1, 12, "0123456789+" },
/* 51*/ { IS_NUM_F | IS_UX__F, "0123456789X", -1, 0, "0123456789X" }, /* ISBNX_SANE */
/* 52*/ { IS_NUM_F | IS_UX__F, "0123456789x", -1, 11, "0123456789X" },
/* 53*/ { IS_NUM_F | IS_UX__F | IS_LX__F | IS_PLS_F, "0123456789Xx+", -1, 0, "0123456789Xx+" }, /* ISBNX_ADDON_SANE */
/* 54*/ { IS_NUM_F | IS_UX__F | IS_LX__F | IS_PLS_F, "0123456789Xx+Y", -1, 14, "0123456789Xx+" },
/* 55*/ { IS_NUM_F | IS_MNS_F, "0123456789-", -1, 0, "0123456789-" }, /* SODIUM_MNS */
/* 56*/ { IS_NUM_F | IS_MNS_F, "0123456789-+", -1, 12, "0123456789-" },
/* 57*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz", -1, 0, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" }, /* CSET82 */
/* 58*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, " ", -1, 1, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 59*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "#", -1, 1, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 60*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "$", -1, 1, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 61*/ { IS_C82_F | IS_AST_F | IS_MNS_F | IS_PLS_F | IS_NUM_F | IS_UPR_F | IS_LWR_F, "@", -1, 1, "!\"%&'()*+,-./0123456789:;<=>?ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" },
/* 62*/ { IS_LWR_F | IS_C82_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SPC_F, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ ", -1, 0, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ " }, /* IS_ISOIEC_F */
/* 63*/ { IS_LWR_F | IS_C82_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SPC_F, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ #", -1, 48, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ " },
/* 64*/ { IS_LWR_F | IS_C82_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SPC_F, "$", -1, 1, "abcdefghijklmnopqrstuvwxyz!\"%&'()*+,-./:;<=>?_ " },
/* 65*/ { IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "-. $/+%", -1, 0, "" },
/* 66*/ { IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "-. $/!+%", -1, 6, "" },
/* 67*/ { IS_NUM_F | IS_UPR_F | IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%" }, /* SILVER */
/* 68*/ { IS_NUM_F | IS_UPR_F | IS_MNS_F | IS_SIL_F | IS_SPC_F | IS_PLS_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%a", -1, 44, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%" },
/* 69*/ { IS_NUM_F | IS_ARS_F, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ", -1, 0, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ" }, /* ARSENIC */
/* 70*/ { IS_NUM_F | IS_ARS_F, "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ", -1, 25, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 71*/ { IS_NUM_F | IS_ARS_F, "0123456789ABCDEFGHJKLMNPRSTUVWXYz", -1, 33, "0123456789ABCDEFGHJKLMNPRSTUVWXYZ" },
/* 72*/ { IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #" }, /* GDSET */
/* 73*/ { IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #!", -1, 65, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #" },
/* 74*/ { IS_NUM_F | IS_MNS_F | IS_CLI_F | IS_PLS_F, "0123456789-$:/.+", -1, 0, "0123456789-$:/.+" }, /* CALCIUM_INNER */
/* 75*/ { IS_NUM_F | IS_MNS_F | IS_CLI_F | IS_PLS_F, "0123456789-$:/.+ ", -1, 17, "0123456789-$:/.+" },
/* 76*/ { IS_NUM_F | IS_MNS_F | IS_CLI_F | IS_PLS_F, "0123456789-$:/.+!", -1, 17, "0123456789-$:/.+" },
/* 77*/ { IS_NUM_F | IS_UPR_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, /* KRSET */
/* 78*/ { IS_NUM_F | IS_UPR_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYz", -1, 36, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 79*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ", -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " }, /* RUBIDIUM */
/* 80*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F, "0123456789aBCDEFGHIJKLMNOPQRSTUVWXYZ ", -1, 11, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ " },
/* 81*/ { IS_NUM_F | IS_MNS_F | IS_UPR_F, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, /* SHKASUTSET */
/* 82*/ { IS_NUM_F | IS_MNS_F | IS_UPR_F, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYz", -1, 37, "1234567890-ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
/* 83*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SIL_F | IS_CLI_F, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYZ" }, /* QR_ALPHA */
/* 84*/ { IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_AST_F | IS_PLS_F | IS_MNS_F | IS_SIL_F | IS_CLI_F, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYz", -1, 45, "1234567890 $%*+-./:ABCDEFGHIJKLMNOPQRSTUVWXYZ" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, length, ret;
testStart("test_is_sane");
testStart("test_not_sane");
for (i = 0; i < data_size; i++) {
@ -264,22 +264,22 @@ static void test_is_sane(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret = is_sane(data[i].flg, (const unsigned char *) data[i].data, length);
ret = not_sane(data[i].flg, (const unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
if (data[i].orig_test[0]) {
int orig_ret = is_sane_orig(data[i].orig_test, (const unsigned char *) data[i].data, length);
if (orig_ret == 0) {
assert_nonzero(ret, "i:%d orig_ret %d, ret %d == 0\n", i, orig_ret, ret);
} else {
assert_zero(ret, "i:%d orig_ret %d, ret %d != 0\n", i, orig_ret, ret);
} else {
assert_nonzero(ret, "i:%d orig_ret %d, ret %d == 0\n", i, orig_ret, ret);
}
}
ret = 1;
ret = 0;
for (j = 0; j < length; j++) {
if (!is_chr(data[i].flg, data[i].data[j])) {
ret = 0;
ret = j + 1;
break;
}
}
@ -289,7 +289,7 @@ static void test_is_sane(const testCtx *const p_ctx) {
testFinish();
}
static void test_is_sane_lookup(const testCtx *const p_ctx) {
static void test_not_sane_lookup(const testCtx *const p_ctx) {
struct item {
char *test_string;
@ -301,16 +301,16 @@ static void test_is_sane_lookup(const testCtx *const p_ctx) {
int posns[32];
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "1234567", -1, "7654321357", -1, 1, { 6, 5, 4, 3, 2, 1, 0, 2, 4, 6 } },
/* 1*/ { "1234567", -1, "76543213578", -1, 0, {0} },
static const struct item data[] = {
/* 0*/ { "1234567", -1, "7654321357", -1, 0, { 6, 5, 4, 3, 2, 1, 0, 2, 4, 6 } },
/* 1*/ { "1234567", -1, "76543213578", -1, 11, {0} },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
int test_length;
int posns[32];
testStart("test_is_sane_lookup");
testStart("test_not_sane_lookup");
for (i = 0; i < data_size; i++) {
@ -319,10 +319,10 @@ static void test_is_sane_lookup(const testCtx *const p_ctx) {
test_length = data[i].test_length == -1 ? (int) strlen(data[i].test_string) : data[i].test_length;
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret = is_sane_lookup(data[i].test_string, test_length, (const unsigned char *) data[i].data, length, posns);
ret = not_sane_lookup(data[i].test_string, test_length, (const unsigned char *) data[i].data, length, posns);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
if (ret) {
if (ret == 0) {
int j;
for (j = 0; j < length; j++) {
assert_equal(posns[j], data[i].posns[j], "i:%d posns[%d] %d != expected posns[%d] %d\n", i, j, posns[j], j, data[i].posns[j]);
@ -333,6 +333,206 @@ static void test_is_sane_lookup(const testCtx *const p_ctx) {
testFinish();
}
static void test_errtxt(const testCtx *const p_ctx) {
struct item {
int debug_test;
int error_number;
int err_id;
char *msg;
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 0, ZINT_ERROR_TOO_LONG, -1, "", "" },
/* 1*/ { 0, ZINT_ERROR_TOO_LONG, 123, "", "123: " },
/* 2*/ { 0, ZINT_ERROR_TOO_LONG, 0, "Data too long", "000: Data too long" },
/* 3*/ { 0, ZINT_ERROR_TOO_LONG, 9, "Data too long", "009: Data too long" },
/* 4*/ { 0, ZINT_ERROR_TOO_LONG, 99, "Data too long", "099: Data too long" },
/* 5*/ { 0, ZINT_ERROR_TOO_LONG, 100, "Data too long", "100: Data too long" },
/* 6*/ { 0, ZINT_ERROR_TOO_LONG, 999, "Data too long", "999: Data too long" },
/* 7*/ { 0, ZINT_ERROR_TOO_LONG, 1000, "Data too long", "1000: Data too long" },
/* 8*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "Data too long", "9999: Data too long" },
/* 9*/ { 0, ZINT_ERROR_TOO_LONG, 10000, "Data too long", "9999: Data too long" },
/* 10*/ { 0, ZINT_ERROR_TOO_LONG, 99999, "Data too long", "9999: Data too long" },
/* 11*/ { 1, ZINT_ERROR_TOO_LONG, 10000, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234", "9999: 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
testStart("test_errtxt");
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
memset(symbol, 0, sizeof(*symbol));
if (data[i].debug_test) symbol->debug |= ZINT_DEBUG_TEST;
ret = errtxt(data[i].error_number, symbol, data[i].err_id, data[i].msg);
assert_equal(ret, data[i].error_number, "i:%d ret %d != %d\n", i, ret, data[i].error_number);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
testFinish();
}
static void test_errtxtf(const testCtx *const p_ctx) {
struct item {
int debug_test;
int error_number;
int err_id;
char *fmt;
int num_args;
int i_arg;
const char *s_arg;
double f_arg;
int ret;
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%0$d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 1*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%1d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 2*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%10$d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 3*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%10d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 4*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%00d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 5*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%000d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 6*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%001d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 7*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%0111d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid numbered format specifer" },
/* 8*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%x", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: unknown format specifier ('%c','%d','%f','%g','%s' only)" },
/* 9*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%1$10d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: unknown format specifier ('%c','%d','%f','%g','%s' only)" },
/* 10*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%.0s", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid length precision" },
/* 11*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%.ss", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid length precision" },
/* 12*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%.10d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: invalid length precision" },
/* 13*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%1$d %d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: mixed numbered and unnumbered format specifiers" },
/* 14*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%d %d %d %d %s %d %d %d %d %d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: too many format specifiers (9 maximum)" },
/* 15*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%1$d %2$d %3$d %4$d %5$s %6$d %7$d %8$d %9$d %9$d", 0, 0, NULL, 0, ZINT_ERROR_ENCODING_PROBLEM, "000: Internal error: too many format specifiers (9 maximum)" },
/* 16*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%d %d %d %d %s %d %d %d %d", 9, 4, "5max", -1, -1, "123: 2100000001 2100000002 3333 4 5max 2100000006 2100000007 2100000008 2100000009" },
/* 17*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%1$d %2$d %3$d %4$d %5$s %6$d %7$d %8$d %9$d", 9, 4, "5max", -1, -1, "123: 2100000001 2100000002 3333 4 5max 2100000006 2100000007 2100000008 2100000009" },
/* 18*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%9$d %8$d %7$d %6$d %5$s %4$d %3$d %2$d %1$d", 9, 4, "5max", -1, -1, "123: 2100000009 2100000008 2100000007 2100000006 5max 4 3333 2100000002 2100000001" },
/* 19*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%9$d %8$d %7$d %6$d %5$.3s %4$d %3$d %2$d %1$d", 9, 4, "5max", -1, -1, "123: 2100000009 2100000008 2100000007 2100000006 5ma 4 3333 2100000002 2100000001" },
/* 20*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%1$d %2$d %3$d %5$.*4$s %6$d %7$d %8$d %9$d", 9, 4, "45max", -1, -1, "123: 2100000001 2100000002 3333 45ma 2100000006 2100000007 2100000008 2100000009" },
/* 21*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%%%d %d %d %d %s %d %d %d %d", 9, 4, "5max", -1, -1, "123: %2100000001 2100000002 3333 4 5max 2100000006 2100000007 2100000008 2100000009" },
/* 22*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%%%d%%%% %%d %d%%%%%09d %d%% %%%s %d %d %%%% %d%d%%", 9, 4, "5max", -1, -1, "123: %2100000001%% %d 2100000002%%000003333 4% %5max 2100000006 2100000007 %% 21000000082100000009%" },
/* 23*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%%%d%%%% %%d %d%%%%%09d %d%% %%%s %d %d %%%% %d %d%%", 9, 4, "5max", -1, -1, "123: %2100000001%% %d 2100000002%%000003333 4% %5max 2100000006 2100000007 %% 2100000008 2100000009" }, /* Truncated */
/* 24*/ { 1, ZINT_ERROR_TOO_LONG, 123, "%%%d%%%% %%d %d%%%%%09d %d%% %%%s %d %d %%%% %d %d ", 9, 4, "5max", -1, -1, "123: %2100000001%% %d 2100000002%%000003333 4% %5max 2100000006 2100000007 %% 2100000008 2100000009" }, /* Truncated */
/* 25*/ { 0, ZINT_ERROR_TOO_LONG, 123, "%d %011d %05d %05d %s %d %d %d %014d", 9, 4, "5max", -1, -1, "123: 2100000001 02100000002 03333 00004 5max 2100000006 2100000007 2100000008 00002100000009" },
/* 26*/ { 0, ZINT_ERROR_TOO_LONG, 123, "", 0, 0, NULL, 0, -1, "123: " },
/* 27*/ { 0, ZINT_ERROR_TOO_LONG, -1, "Gosh '%c' wow", 1, 1, NULL, -1, -1, "Gosh '\001' wow" },
/* 28*/ { 0, ZINT_ERROR_TOO_LONG, 0, "Gosh '%c' wow", 1, 1, NULL, -1, -1, "000: Gosh '\001' wow" },
/* 29*/ { 0, ZINT_ERROR_TOO_LONG, 99, "Gosh %d wow", 1, 1, NULL, -1, -1, "099: Gosh 1 wow" },
/* 30*/ { 0, ZINT_ERROR_TOO_LONG, 99, "Gosh %02d wow", 1, 1, NULL, -1, -1, "099: Gosh 01 wow" },
/* 31*/ { 0, ZINT_ERROR_TOO_LONG, 99, "Gosh %03d wow", 1, 99, NULL, -1, -1, "099: Gosh 099 wow" },
/* 32*/ { 0, ZINT_ERROR_TOO_LONG, 99, "Gosh %012d wow", 1, 99, NULL, -1, -1, "099: Gosh 000000000099 wow" },
/* 33*/ { 0, ZINT_ERROR_TOO_LONG, -1, "%099d", 1, 99, NULL, -1, -1, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099" },
/* 34*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "Gosh %d%% wow", 1, 100, NULL, -1, -1, "9999: Gosh 100% wow" },
/* 35*/ { 0, ZINT_ERROR_TOO_LONG, 10000, "Gosh %d%% wow", 1, 100, NULL, -1, -1, "9999: Gosh 100% wow" },
/* 36*/ { 0, ZINT_ERROR_TOO_LONG, 99999, "Gosh %d%% wow", 1, 100, NULL, -1, -1, "9999: Gosh 100% wow" },
/* 37*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "%%%d%% wow", 1, 100, NULL, -1, -1, "9999: %100% wow" },
/* 38*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "Gosh %1$d wow", 1, 1, NULL, -1, -1, "9999: Gosh 1 wow" },
/* 39*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "Gosh %1$d wow %1$d", 1, 1, NULL, -1, -1, "9999: Gosh 1 wow 1" },
/* 40*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "Gosh %1$09d wow", 1, 10, NULL, -1, -1, "9999: Gosh 000000010 wow" },
/* 41*/ { 0, ZINT_ERROR_TOO_LONG, 9999, "Gosh %1$03d wow %1$04d", 1, 10, NULL, -1, -1, "9999: Gosh 0010 wow 0010" }, /* TODO: incompat: last min field trumps but each should be respected */
/* 42*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%f' wow", 1, -1, NULL, 3.1, -1, "123: Gosh '3.100000' wow" },
/* 43*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %g wow", 1, -1, NULL, 3.1, -1, "123: Gosh 3.1 wow" },
/* 44*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%s' wow", 1, -1, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 45*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.1s' wow", 1, -1, "12345678901234567890", -1, -1, "123: Gosh '1' wow" },
/* 46*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.9s' wow", 1, -1, "12345678901234567890", -1, -1, "123: Gosh '123456789' wow" },
/* 47*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.10s' wow", 1, -1, "12345678901234567890", -1, -1, "123: Gosh '1234567890' wow" },
/* 48*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.19s' wow", 1, -1, "12345678901234567890", -1, -1, "123: Gosh '1234567890123456789' wow" },
/* 49*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%1$.1s' wow", 1, -1, "12345678901234567890", -1, -1, "123: Gosh '1' wow" },
/* 50*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%1$.20s' wow", 1, -1, "12345678901234567890", -1, -1, "123: Gosh '12345678901234567890' wow" },
/* 51*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.2s' wow", 1, -1, "gee", -1, -1, "123: Gosh 'ge' wow" },
/* 52*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.3s' wow", 1, -1, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 53*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.4s' wow", 1, -1, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 54*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.9s' wow", 1, -1, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 55*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.*s' wow", 2, 0, "gee", -1, -1, "123: Gosh '' wow" },
/* 56*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.*s' wow", 2, 1, "gee", -1, -1, "123: Gosh 'g' wow" },
/* 57*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.*s' wow", 2, 2, "gee", -1, -1, "123: Gosh 'ge' wow" },
/* 58*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.*s' wow", 2, 3, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 59*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.*s' wow", 2, 4, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 60*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%.*s' wow", 2, 999, "gee", -1, -1, "123: Gosh 'gee' wow" },
/* 61*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%2$.*1$s' wow", 2, 2, "gee", -1, -1, "123: Gosh 'ge' wow" },
/* 62*/ { 1, ZINT_ERROR_TOO_LONG, 123, "Gosh %s wow", 1, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456", -1, -1, "123: Gosh 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456 wo" },
/* 63*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh '%c' %g wow", 2, 'A', NULL, -12.1f, -1, "123: Gosh 'A' -12.1 wow" },
/* 64*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %d %s wow", 2, 123456789, "cor", -1, -1, "123: Gosh 123456789 cor wow" },
/* 65*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %1$d %2$s wow", 2, 123456789, "cor", -1, -1, "123: Gosh 123456789 cor wow" },
/* 66*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %1$d %2$.1s wow", 2, 123456789, "cor", -1, -1, "123: Gosh 123456789 c wow" },
/* 67*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$s %1$d wow", 2, 123456789, "cor", -1, -1, "123: Gosh cor 123456789 wow" },
/* 68*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$g %1$d wow", 2, 1, NULL, 2, -1, "123: Gosh 2 1 wow" },
/* 69*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$s %1$d wow second %2$s", 2, 123456789, "cor", -1, -1, "123: Gosh cor 123456789 wow second cor" },
/* 70*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$.2s %1$d wow second %2$s", 2, 123456789, "cor", -1, -1, "123: Gosh co 123456789 wow second co" }, /* TODO: incompat: last length trumps but each should be respected */
/* 71*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$.2s %1$d wow second %2$.1s", 2, 123456789, "cor", -1, -1, "123: Gosh c 123456789 wow second c" }, /* TODO: incompat: last length trumps */
/* 72*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$.1s %1$d wow second %2$.2s", 2, 123456789, "cor", -1, -1, "123: Gosh co 123456789 wow second co" }, /* TODO: incompat: last length trumps */
/* 73*/ { 1, ZINT_ERROR_TOO_LONG, -1, "%1$s %1$s", 1, -1, "12345678901234567890123456789012345678901234567890", -1, -1, "12345678901234567890123456789012345678901234567890 123456789012345678901234567890123456789012345678" },
/* 74*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %d %s %g wow", 3, 1, "cor", 3, -1, "123: Gosh 1 cor 3 wow" },
/* 75*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %1$d %2$s %3$g wow", 3, 1, "cor", 3, -1, "123: Gosh 1 cor 3 wow" },
/* 76*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %3$g %2$s %1$d wow", 3, 1, "cor", 3, -1, "123: Gosh 3 cor 1 wow" },
/* 77*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %3$g %1$d %2$s wow", 3, 1, "cor", 3, -1, "123: Gosh 3 1 cor wow" },
/* 78*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %3$g %1$d %2$s wow %2$s %1$d", 3, 1, "cor", 3, -1, "123: Gosh 3 1 cor wow cor 1" },
/* 79*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$.*1$s %3$g wow", 3, 1, "cor", 3, -1, "123: Gosh c 3 wow" },
/* 80*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %2$.*1$s %3$g wow %2$s blimey", 3, 1, "cor", 3, -1, "123: Gosh c 3 wow c blimey" },
/* 81*/ { 0, ZINT_ERROR_TOO_LONG, 123, "Gosh %3$g %2$.*1$s wow", 3, 1, "cor", 3, -1, "123: Gosh 3 c wow" },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
testStart("test_errtxtf");
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
memset(symbol, 0, sizeof(*symbol));
if (data[i].debug_test) symbol->debug |= ZINT_DEBUG_TEST;
if (data[i].num_args == 0) {
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, NULL /*suppress -Wformat-security*/);
} else if (data[i].num_args == 1) {
if (data[i].i_arg != -1) {
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].i_arg);
} else if (data[i].s_arg != NULL) {
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].s_arg);
} else {
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].f_arg);
}
} else if (data[i].num_args == 2) {
if (data[i].i_arg != -1) {
if (data[i].s_arg != NULL) {
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].i_arg, data[i].s_arg);
} else {
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].i_arg, data[i].f_arg);
}
} else {
assert_nonnull(data[i].s_arg, "i:%d num_args:%d data[i].s_arg NULL", i, data[i].num_args);
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].s_arg, data[i].f_arg);
}
} else if (data[i].num_args == 3) {
assert_nonnull(data[i].s_arg, "i:%d num_args:%d data[i].s_arg NULL", i, data[i].num_args);
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, data[i].i_arg, data[i].s_arg, data[i].f_arg);
} else if (data[i].num_args == 9) { /* Special case max, assuming 4th arg "%d", 5th arg "%s" */
assert_nonnull(data[i].s_arg, "i:%d num_args:%d data[i].s_arg NULL", i, data[i].num_args);
ret = errtxtf(data[i].error_number, symbol, data[i].err_id, data[i].fmt, 2100000001, 2100000002, 3333, data[i].i_arg, data[i].s_arg, 2100000006, 2100000007, 2100000008, 2100000009);
} else {
assert_nonnull(NULL, "i:%d num_args:%d > 3 && != 9\n", i, data[i].num_args);
}
if (data[i].ret == -1) {
assert_equal(ret, data[i].error_number, "i:%d ret %d != %d (%s)\n", i, ret, data[i].error_number, symbol->errtxt);
} else {
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
}
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
testFinish();
}
static void test_cnt_digits(const testCtx *const p_ctx) {
struct item {
@ -343,7 +543,7 @@ static void test_cnt_digits(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, 0, -1, 0 },
/* 1*/ { "asdf1", -1, 0, -1, 0 },
/* 2*/ { "asdf1asdf", -1, 4, -1, 1 },
@ -351,7 +551,7 @@ static void test_cnt_digits(const testCtx *const p_ctx) {
/* 4*/ { "a12345asdf", -1, 1, 4, 4},
/* 5*/ { "a1234", -1, 1, 5, 4},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
testStart("test_cnt_digits");
@ -378,7 +578,7 @@ static void test_is_valid_utf8(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, 1, "" },
/* 1*/ { "abcdefghijklmnopqrstuvwxyz", -1, 1, "" },
/* 2*/ { "éa", -1, 1, "" },
@ -390,7 +590,7 @@ static void test_is_valid_utf8(const testCtx *const p_ctx) {
/* 7*/ { "\300\201", -1, 0, "Overlong 0xC081" },
/* 8*/ { "\355\240\200", -1, 0, "Surrogate 0xEDA080" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
testStart("test_is_valid_utf8");
@ -421,22 +621,23 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, 1, 0, 0, {0}, "" },
/* 1*/ { "\000a\302\200\340\240\200", 7, 1, 0, 4, { 0, 'a', 0x80, 0x800 }, "NUL a C280 E0A080" },
/* 2*/ { "\357\277\277", -1, 1, 0, 1, { 0xFFFF }, "EFBFBF" },
/* 3*/ { "\360\220\200\200", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Four-byte F0908080" },
/* 4*/ { "a\200b", -1, 1, ZINT_ERROR_INVALID_DATA, -1, {0}, "Orphan continuation 0x80" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
unsigned int vals[20];
struct zint_symbol symbol = {0};
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
testStart("test_utf8_to_unicode");
symbol.debug = debug;
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int ret_length;
@ -446,7 +647,7 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret_length = length;
ret = utf8_to_unicode(&symbol, (unsigned char *) data[i].data, vals, &ret_length, data[i].disallow_4byte);
ret = utf8_to_unicode(symbol, (unsigned char *) data[i].data, vals, &ret_length, data[i].disallow_4byte);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
if (ret == 0) {
int j;
@ -477,7 +678,7 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
é U+00E9 (\351, 233), UTF-8 C3A9
*/
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", -1, 0, "", "" },
/* 1*/ { "abc", -1, 0, "abc", "" },
/* 2*/ { "\000A\001B\002\036\037C ~\177", 11, 0, " A B C ~ ", "" },
@ -501,14 +702,15 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
/* 20*/ { "\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351\351", -1, 1, "ééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé", "101 \351 (truncated)" },
/* 21*/ { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "200 A (truncated)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol symbol = {0};
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
testStart("test_hrt_cpy_iso8859_1");
symbol.debug = debug;
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int j;
@ -517,15 +719,15 @@ static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
ret = hrt_cpy_iso8859_1(&symbol, (unsigned char *) data[i].data, length);
ret = hrt_cpy_iso8859_1(symbol, (unsigned char *) data[i].data, length);
if (p_ctx->index != -1 && (debug & ZINT_DEBUG_TEST_PRINT)) {
for (j = 0; j < ret; j++) {
fprintf(stderr, "symbol.text[%d] %2X\n", j, symbol.text[j]);
fprintf(stderr, "symbol->text[%d] %2X\n", j, symbol->text[j]);
}
}
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_nonzero(testUtilIsValidUTF8(symbol.text, (int) ustrlen(symbol.text)), "i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol.text);
assert_zero(strcmp((char *) symbol.text, data[i].expected), "i:%d symbol.text (%s) != expected (%s)\n", i, symbol.text, data[i].expected);
assert_nonzero(testUtilIsValidUTF8(symbol->text, (int) ustrlen(symbol->text)), "i:%d testUtilIsValidUTF8(%s) != 1\n", i, symbol->text);
assert_zero(strcmp((char *) symbol->text, data[i].expected), "i:%d symbol->text (%s) != expected (%s)\n", i, symbol->text, data[i].expected);
}
testFinish();
@ -550,7 +752,7 @@ static void test_set_height(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 0, { 0 }, 0, 0, 0, 0, 0, 0, 0.5, "", "" },
/* 1*/ { 2, { 1, 1 }, 2, 0, 0, 0, 0, 0, 2, "", "zero_count == 0, fixed height only" },
/* 2*/ { 2, { 1, 1 }, 2, 0, 0, 1, 1, ZINT_WARN_NONCOMPLIANT, 2, "", "zero_count == 0, height < max height" },
@ -562,31 +764,32 @@ static void test_set_height(const testCtx *const p_ctx) {
/* 8*/ { 2, { 2, 0 }, 20, 0, 20, 0, 0, 0, 20, "", "zero_count != 0, height 20" },
/* 9*/ { 2, { 2, 0 }, 0, 2, 0, 0, 0, 0, 4, "", "zero_count != 0, min_row_height 2" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol symbol;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
testStart("set_height");
symbol.debug = debug;
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int j;
if (testContinue(p_ctx, i)) continue;
memset(&symbol, 0, sizeof(symbol));
symbol.rows = data[i].rows;
memset(symbol, 0, sizeof(*symbol));
symbol->rows = data[i].rows;
for (j = 0; j < ARRAY_SIZE(data[i].row_height); j++) {
symbol.row_height[j] = data[i].row_height[j];
symbol->row_height[j] = data[i].row_height[j];
}
symbol.height = data[i].height;
symbol->height = data[i].height;
ret = set_height(&symbol, data[i].min_row_height, data[i].default_height, data[i].max_height, data[i].no_errtxt);
ret = set_height(symbol, data[i].min_row_height, data[i].default_height, data[i].max_height, data[i].no_errtxt);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_equal(symbol.height, data[i].expected_height, "i:%d symbol.height %g != %g\n", i, symbol.height, data[i].expected_height);
assert_zero(strcmp(symbol.errtxt, data[i].expected_errtxt), "i:%d errtxt %s != %s\n", i, symbol.errtxt, data[i].expected_errtxt);
assert_equal(symbol->height, data[i].expected_height, "i:%d symbol->height %g != %g\n", i, symbol->height, data[i].expected_height);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt);
}
testFinish();
@ -603,26 +806,27 @@ static void test_debug_test_codeword_dump_int(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { { 2147483647, -2147483646, 2147483647, 0, 2147483647, 2147483647, 2147483647, 2147483647, 123456 }, 10, "(10) 2147483647 -2147483646 2147483647 0 2147483647 2147483647 2147483647 2147483647 123456" },
/* 1*/ { { 2147483647, -2147483646, 2147483647, 0, 2147483647, 2147483647, 2147483647, 2147483647, 1234567 }, 10, "(10) 2147483647 -2147483646 2147483647 0 2147483647 2147483647 2147483647 2147483647" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i;
struct zint_symbol symbol = {0};
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
testStart("test_debug_test_codeword_dump_int");
symbol.debug = debug;
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
debug_test_codeword_dump_int(&symbol, data[i].codewords, data[i].length);
assert_nonzero(strlen(symbol.errtxt) < 92, "i:%d strlen(%s) >= 92 (%d)\n", i, symbol.errtxt, (int) strlen(symbol.errtxt));
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (%d, %d)\n", i, symbol.errtxt, data[i].expected, (int) strlen(symbol.errtxt), (int) strlen(data[i].expected));
debug_test_codeword_dump_int(symbol, data[i].codewords, data[i].length);
assert_nonzero(strlen(symbol->errtxt) < 92, "i:%d strlen(%s) >= 92 (%d)\n", i, symbol->errtxt, (int) strlen(symbol->errtxt));
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (%d, %d)\n", i, symbol->errtxt, data[i].expected, (int) strlen(symbol->errtxt), (int) strlen(data[i].expected));
}
testFinish();
@ -634,8 +838,10 @@ int main(int argc, char *argv[]) {
{ "test_chr_cnt", test_chr_cnt },
{ "test_to_int", test_to_int },
{ "test_to_upper", test_to_upper },
{ "test_is_sane", test_is_sane },
{ "test_is_sane_lookup", test_is_sane_lookup },
{ "test_not_sane", test_not_sane },
{ "test_not_sane_lookup", test_not_sane_lookup },
{ "test_errtxt", test_errtxt },
{ "test_errtxtf", test_errtxtf },
{ "test_cnt_digits", test_cnt_digits },
{ "test_is_valid_utf8", test_is_valid_utf8 },
{ "test_utf8_to_unicode", test_utf8_to_unicode },

View file

@ -44,7 +44,7 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
int expected_width;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, "1", "[21]A12345678", 0, 8, 72 }, /* EAN-8 */
/* 1*/ { BARCODE_EANX_CC, "12", "[21]A12345678", 0, 8, 72 },
/* 2*/ { BARCODE_EANX_CC, "123", "[21]A12345678", 0, 8, 72 },
@ -73,7 +73,7 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
/*25*/ { BARCODE_EANX_CC, "1234567890128+12", "[21]A12345678", 0, 7, 125 }, /* EAN-13 + CHK + EAN-2 */
/*26*/ { BARCODE_EANX_CC, "1234567890128+12345", "[21]A12345678", 0, 7, 152 }, /* EAN-13 + CHK + EAN-5 */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -95,10 +95,8 @@ static void test_eanx_leading_zeroes(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
}
ZBarcode_Delete(symbol);
}
@ -153,7 +151,7 @@ static void test_examples(const testCtx *const p_ctx) {
char *expected;
};
/* Verified manually against GS1 General Specifications 21.0.1 (GGS) and ISO/IEC 24723:2010, with noted exceptions, and verified via bwipp_dump.ps against BWIPP */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMNSTK_CC, -1, 1, "0401234567890", "[17]050101[10]ABC123", 0, 11, 56, 1, "GSS Figure 5.1-5. GS1 DataBar Stacked Omnidirectional barcode with a Composite Component",
"01101100110101110001001100001000000110100111011110101001"
"01101101110110001100010100001100001000010110011100101001"
@ -1424,7 +1422,14 @@ static void test_examples(const testCtx *const p_ctx) {
"00000000010110001100001010001001000010010100110001101110100111000111010010011110101100100001001010011000110111010011100011101001001111010110010000100101001100011011101001110001110100100111101011010000100010010000100100111000101000000000000"
"00000001101001110011110101110110111101101011001110010001011000111000101101100001010011011110110101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010100101111011101101111011011000111010110000000000"
},
/* 70*/ { BARCODE_EANX_CC, -1, 1, "123456789012+12", "[91]123456789012345678901", 0, 8, 125, 1, "Example of EAN-13 with 2-digit addon, CC-A 4 cols, 4 rows",
/* 70*/ { BARCODE_GS1_128_CC, -1, 3, "[01]12345678901231[90]123", "[20]12", 0, 5, 205, 1, "Example with 8 cols, left/right padding of linear (BWIPP)",
"1111111101010100011101010111000000111010110011110001110111110111010010000010000100010111010011011110001001100111101110010000110111001100111000101101111001000101110111000011101010001110000111111101000101001"
"1111111101010100011110101000010000111010111011000001111110111001010011111001000100110111000000100110101100100111000001011111010001101110110101110001000001111010100001000011111010101100000111111101000101001"
"1111111101010100011101010001111110100010100011110001111101011100001011000011001011110100101001111000001011111011010000011101111110010100110111100010001101011001001110000010101000011110000111111101000101001"
"0000000001011000110000101000100110010011010011000110111010011100011101001001111010110010000100101001100011001001110010010000100101001100011010000100010011010001100010100001001000100010011100010100000000000"
"0000000110100111001111010111011001101100101100111001000101100011100010110110000101001101111011010110011100110110001101101111011010110011100101111011101100101110011101011110110111011101100011101011000000000"
},
/* 71*/ { BARCODE_EANX_CC, -1, 1, "123456789012+12", "[91]123456789012345678901", 0, 8, 125, 1, "Example of EAN-13 with 2-digit addon, CC-A 4 cols, 4 rows",
"11010010001111001101001110010111011100010000100100011010111011100100000110000010011011101110110010100000000000000000000000000"
"11010110001110101100100000011001111010111110100100001011001011110110000110010011100000101100110010100000000000000000000000000"
"11010111001110101111101000011111100110111010101100001011111010111100110100110100111000001101110010100000000000000000000000000"
@ -1434,7 +1439,7 @@ static void test_examples(const testCtx *const p_ctx) {
"00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000"
"00010100100110111101001110101100010000101001000101010100100011101001110010110011011011001001000101000000010110011001010010011"
},
/* 71*/ { BARCODE_EANX_CC, -1, 1, "123456789012+54321", "[91]1234567890", 0, 7, 152, 1, "Example of EAN-13 with 5-digit addon, CC-B 4 cols, 3 rows",
/* 72*/ { BARCODE_EANX_CC, -1, 1, "123456789012+54321", "[91]1234567890", 0, 7, 152, 1, "Example of EAN-13 with 5-digit addon, CC-B 4 cols, 3 rows",
"11011011101111001101001110010111011100010000100111010010111011100100000110000010011011101101100010100000000000000000000000000000000000000000000000000000"
"11011011001111110101001110011111000100100110100110010011010001110001000100101111110011101100100010100000000000000000000000000000000000000000000000000000"
"11011010001010000010111100011100111100101110100110011011001111101001000100111110110100001110100010100000000000000000000000000000000000000000000000000000"
@ -1443,7 +1448,7 @@ static void test_examples(const testCtx *const p_ctx) {
"00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000"
"00010100100110111101001110101100010000101001000101010100100011101001110010110011011011001001000101000000010110111001010100011010100001010010011010011001"
},
/* 72*/ { BARCODE_UPCA_CC, -1, 1, "12345678901+12", "[91]123456789", 0, 7, 127, 1, "Example of UPC-A with 2-digit addon, CC-A 4 cols, 3 rows",
/* 73*/ { BARCODE_UPCA_CC, -1, 1, "12345678901+12", "[91]123456789", 0, 7, 127, 1, "Example of UPC-A with 2-digit addon, CC-A 4 cols, 3 rows",
"1101101110111100110100111001011101110001000010011101001011101110010000011000001001101110110110001010000000000000000000000000000"
"1101101100111001110011110101100001000111001010011001001110101100100000010010111111001110110010001010000000000000000000000000000"
"1101101000100001111001000101011110100000010010011001101000111000010110011011100010001110111010001010000000000000000000000000000"
@ -1452,7 +1457,7 @@ static void test_examples(const testCtx *const p_ctx) {
"0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000"
"0001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000000010110011001010010011"
},
/* 73*/ { BARCODE_UPCA_CC, -1, 2, "12345678901+12121", "[91]1234567890123", 0, 8, 154, 1, "Example of UPC-A with 5-digit addon, CC-B 4 cols, 4 rows",
/* 74*/ { BARCODE_UPCA_CC, -1, 2, "12345678901+12121", "[91]1234567890123", 0, 8, 154, 1, "Example of UPC-A with 5-digit addon, CC-B 4 cols, 4 rows",
"1101001110100011111010011101101111110101110010011101101101000011110110011001011100001000110100100010000000000000000000000000000000000000000000000000000000"
"1101001100101100100111000001011111011000001010011101001101111110011010011101001111100100110101100010000000000000000000000000000000000000000000000000000000"
"1101000100111001101000011001100100000101100010011001001001111011110100011100011101000100110101110010000000000000000000000000000000000000000000000000000000"
@ -1462,7 +1467,7 @@ static void test_examples(const testCtx *const p_ctx) {
"0001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000"
"0001010011001001001101111010100011011000101011110101010001001001000111010011100101100110110110010100000000010110011001010010011010110011010011011010011001"
},
/* 74*/ { BARCODE_UPCE_CC, -1, 1, "0654321+89", "[91]1", 0, 9, 81, 1, "Example of UPC-E with 2-digit addon, CC-A 2 cols, 5 rows",
/* 75*/ { BARCODE_UPCE_CC, -1, 1, "0654321+89", "[91]1", 0, 9, 81, 1, "Example of UPC-E with 2-digit addon, CC-A 2 cols, 5 rows",
"110110011011110111010111110101000100011110001111010100100000000000000000000000000"
"110110111011101100001000110111001010111000001110010100100000000000000000000000000"
"110110110011000101111101110111101000010010001110110100100000000000000000000000000"
@ -1473,7 +1478,7 @@ static void test_examples(const testCtx *const p_ctx) {
"000100000000000000000000000000000000000000000000000001000000000000000000000000000"
"000101000010101100010011101011110100110110011001010101000000010110110111010010111"
},
/* 75*/ { BARCODE_UPCE_CC, -1, 2, "1876543+56789", "[91]12345", 0, 12, 108, 1, "Example of UPC-E with 5-digit addon, CC-B 2 cols, 8 rows",
/* 76*/ { BARCODE_UPCE_CC, -1, 2, "1876543+56789", "[91]12345", 0, 12, 108, 1, "Example of UPC-E with 5-digit addon, CC-B 2 cols, 8 rows",
"110010001011101111101110100100000100001000101100100010100000000000000000000000000000000000000000000000000000"
"111010001011010000111101100110010111000010001110100010100000000000000000000000000000000000000000000000000000"
"111011001011101100100111110100011110010000101110110010100000000000000000000000000000000000000000000000000000"
@ -1487,7 +1492,7 @@ static void test_examples(const testCtx *const p_ctx) {
"000100000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000"
"000101011011100100010000101011000101000110100001010101000000010110110001010101111010010001010110111010010111"
},
/* 76*/ { BARCODE_EANX_CC, -1, 1, "9876543+65", "[91]1234567", 0, 8, 98, 1, "Example of EAN-8 with 2-digit addon, CC-A 3 cols, 4 rows",
/* 77*/ { BARCODE_EANX_CC, -1, 1, "9876543+65", "[91]1234567", 0, 8, 98, 1, "Example of EAN-8 with 2-digit addon, CC-A 3 cols, 4 rows",
"10010001111100110101001100011100010111001100110001011101000001110100110100000000000000000000000000"
"11011111100110100101011100011011110010110000111100010011110101110101110100000000000000000000000000"
"10000101100000110101011000010101111101111100111010010000111001110101100100000000000000000000000000"
@ -1497,7 +1502,7 @@ static void test_examples(const testCtx *const p_ctx) {
"00001000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000"
"00001010001011011011101110110101111010101001110101110010000101110010101000000010110101111010111001"
},
/* 77*/ { BARCODE_EANX_CC, -1, 2, "9876543+74083", "[91]123456789012345678", 0, 12, 135, 1, "Example of EAN-8 with 5-digit addon, CC-B 3 cols, 8 rows",
/* 78*/ { BARCODE_EANX_CC, -1, 2, "9876543+74083", "[91]123456789012345678", 0, 12, 135, 1, "Example of EAN-8 with 5-digit addon, CC-B 3 cols, 8 rows",
"110011101011101111101110100100001011010000010000100010111110110100111101100111010100000000000000000000000000000000000000000000000000000"
"111011101011001011100001000100001001011100101100100000111000110111010001110111010100000000000000000000000000000000000000000000000000000"
"111001101011011111100110100100001101010100010111100000110010011011111101110011010100000000000000000000000000000000000000000000000000000"
@ -1511,7 +1516,7 @@ static void test_examples(const testCtx *const p_ctx) {
"000000000000001000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000"
"000000000000001010001011011011101110110101111010101001110101110010000101110010101000000010110111011010011101010001101010110111010100001"
},
/* 78*/ { BARCODE_EANX_CC, -1, 1, "1234567890128+65", "[91]1234567", 0, 7, 125, 1, "Example of EAN-13 + CHK with 2-digit addon, CC-A 3 cols, 4 rows",
/* 79*/ { BARCODE_EANX_CC, -1, 1, "1234567890128+65", "[91]1234567", 0, 7, 125, 1, "Example of EAN-13 + CHK with 2-digit addon, CC-A 3 cols, 4 rows",
"11011011101111001101001110010111011100010000100111010010111011100100000110000110010100001101100010100000000000000000000000000"
"11011011001001100101111110011111011001000010100110010011111101110010100110101110001000001100100010100000000000000000000000000"
"11011010001101011111100100011011101000011100100110011010001001001111000101000011011111001110100010100000000000000000000000000"
@ -1521,7 +1526,7 @@ static void test_examples(const testCtx *const p_ctx) {
"00010100100110111101001110101100010000101001000101010100100011101001110010110011011011001001000101000000010110101111010111001"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -1603,7 +1608,7 @@ static void test_odd_numbered_numeric(const testCtx *const p_ctx) {
char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP, and manually against tec-it.com */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCE_CC, 1, "1234567", "[91]1234567890123", 0, 9, 55, "Test odd-numbered numeric, 1st fit, 9-bit remainder, 7-bit final, 2-bit alphanumeric latch, no padding",
"1101100110111011101011110001001111100110010011110101001"
"1101101110110001100001000101100010000100110011100101001"
@ -1697,7 +1702,7 @@ static void test_odd_numbered_numeric(const testCtx *const p_ctx) {
"0001010010011011110101000110111001000010100100010101010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -1768,7 +1773,7 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
char *expected;
};
/* 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[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128_CC, -1, "[91]1", "[21]A1B2C3D4E5F6G7H8", 0, 6, 100, 1, "CC-A alignment, bottom shift 10",
"1101001000110100001000001101101011110111110010010001101010000010010000011101110100010000111011001010"
"1101011000110101111001100001111010001101100010010000101111000011001101011100101100001000110011001010"
@ -1826,7 +1831,7 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
"1101001110011110101110111101101101011001110010001011000111000101101100001010011011110110101111011101001110011010111011110100110100001100011101011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -1897,7 +1902,7 @@ static void test_ean128_cc_width(const testCtx *const p_ctx) {
char *comment;
};
/* Verified manually with BWIPP (except very large tests) */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "[91]1", "[02]13012345678909", 0, 11, 103, "" },
/* 1*/ { "[91]12", "[02]13012345678909", 0, 20, 86, "" },
/* 2*/ { "[91]123", "[02]13012345678909", 0, 11, 108, "" },
@ -1912,7 +1917,7 @@ static void test_ean128_cc_width(const testCtx *const p_ctx) {
/*11*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345" "675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]1234567890", 0, 32, 579, "With composite 2372 digits == max" },
/*12*/ { "[00]123456789012345675", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345" "675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678901", ZINT_ERROR_TOO_LONG, 0, 0, "With composite 2373 digits > max" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -1965,7 +1970,7 @@ static void test_encodation_0(const testCtx *const p_ctx) {
char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP and manually against tec-it.com (with noted exception) */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCE_CC, 1, "1234567", "[91]1", 0, 9, 55, "Single numeric",
"1101100110111101110101111101010001000111100011110101001"
"1101101110111011000010001101110010101110000011100101001"
@ -2374,7 +2379,7 @@ static void test_encodation_0(const testCtx *const p_ctx) {
"0001010010011011110101000110111001000010100100010101010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -2444,7 +2449,7 @@ static void test_encodation_10(const testCtx *const p_ctx) {
char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP, and manually, with noted exceptions, against tec-it.com */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCE_CC, 1, "1234567", "[11]201001[10]AB1234", 0, 9, 55, "Mode '10' date + even-numbered numeric lot, 1st fit, alphanumeric latch and padding",
"1101100110101110000100011001001000100111100011110101001"
"1101101110110010100011000001100110010000001011100101001"
@ -2512,7 +2517,7 @@ static void test_encodation_10(const testCtx *const p_ctx) {
"0001010010011011110101000110111001000010100100010101010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -2582,7 +2587,7 @@ static void test_encodation_11(const testCtx *const p_ctx) {
char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP, and manually against tec-it.com (with noted exception) */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCE_CC, 1, "1234567", "[90]A", 0, 9, 55, "Mode '11', letter prefix only",
"1101100110100111100000101001110110010011111011110101001"
"1101101110110001000101100001100011010010000011100101001"
@ -2715,8 +2720,8 @@ static void test_encodation_11(const testCtx *const p_ctx) {
"0001000000000000000000000000000000000000000000000000010"
"0001010010011011110101000110111001000010100100010101010"
},
/*12*/ { BARCODE_UPCE_CC, 1, "1234567", "[90]1AB#D", ZINT_ERROR_INVALID_DATA, 0, 0, "Mode '11', invalid char [90]", "" },
/*13*/ { BARCODE_UPCE_CC, 2, "1234567", "[90]1AB#D", ZINT_ERROR_INVALID_DATA, 0, 0, "Mode '11', invalid char [90]", "" },
/*12*/ { BARCODE_UPCE_CC, 1, "1234567", "[90]1AB#D", ZINT_ERROR_INVALID_DATA, 0, 0, "Mode '11', invalid char [90]", "Error 441: Invalid character in input (2D component)" },
/*13*/ { BARCODE_UPCE_CC, 2, "1234567", "[90]1AB#D", ZINT_ERROR_INVALID_DATA, 0, 0, "Mode '11', invalid char [90]", "Error 441: Invalid character in input (2D component)" },
/*14*/ { BARCODE_UPCE_CC, 1, "1234567", "[90]A12345[21]AB", 0, 10, 55, "Mode '11', numeric [90], with [21]",
"1100100010111000111011011001001100011000010011100101101"
"1110100010101000001111001001111100110100010011000101101"
@ -2928,7 +2933,7 @@ static void test_encodation_11(const testCtx *const p_ctx) {
"0001010010011011110101000110111001000010100100010101010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -2999,7 +3004,7 @@ static void test_addongap(const testCtx *const p_ctx) {
char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, 1, -1, "1234567+12", 0, 8, 98, "EAN-8 default 7 gap",
"10010001111100110101001100011110001011001100110110011110000101110100110100000000000000000000000000"
"10000011100101100101011100010111100010001000100000100101111001110101110100000000000000000000000000"
@ -3079,7 +3084,7 @@ static void test_addongap(const testCtx *const p_ctx) {
"00010100100110111101010001101110010000101001000101010100000000000010110011001010010011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -3153,7 +3158,7 @@ static void test_gs1parens(const testCtx *const p_ctx) {
int expected_width;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, "1234567", "[21]A12345678", 0, 8, 72 }, /* EAN-8 */
/* 1*/ { BARCODE_EANX_CC, GS1PARENS_MODE, "1234567", "(21)A12345678", 0, 8, 72 }, /* EAN-8 */
/* 2*/ { BARCODE_EANX_CC, -1, "123456789012", "[21]A12345678", 0, 7, 99 }, /* EAN-13 */
@ -3177,7 +3182,7 @@ static void test_gs1parens(const testCtx *const p_ctx) {
/* 20*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[3103]001234", "[21]A12345678", 0, 9, 102 },
/* 21*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(01)12345678901231(3103)001234", "(21)A12345678", 0, 9, 102 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -3199,10 +3204,8 @@ static void test_gs1parens(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
}
ZBarcode_Delete(symbol);
}
@ -3223,7 +3226,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, "1234567", "[20]12", 0, "12345670" }, /* EAN-8 */
/* 1*/ { BARCODE_EANX_CC, -1, "123456789012", "[20]12", 0, "1234567890128" }, /* EAN-13 */
/* 2*/ { BARCODE_EANX_CC, -1, "1234567890128", "[20]12", 0, "1234567890128" },
@ -3260,7 +3263,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 33*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[20]12", 0, "" }, /* No HRT for stacked symbologies */
/* 34*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[20]12", 0, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -3309,109 +3312,109 @@ static void test_input(const testCtx *const p_ctx) {
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[20]12", 0, 8, 72, "" }, /* EAN-8 */
/* 1*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" }, /* EAN-8 */
/* 2*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" }, /* Linear component still checked */
/* 3*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" },
/* 1*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" only) (linear component)" }, /* EAN-8 */
/* 2*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 7 in input (digits and \"+\" only) (linear component)" }, /* Linear component still checked */
/* 3*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" },
/* 4*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[20]1A", 0, 8, 72, "" },
/* 5*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 5*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 8, 72, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 6*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[02]12345678901234", 0, 8, 72, "" },
/* 7*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "12345671", "[20]12", 0, 7, 99, "" }, /* EAN-13 for EANX_CC as length 8 only EAN-8 for EANX_CHK */
/* 8*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012", "[20]12", 0, 7, 99, "" }, /* EAN-13 */
/* 9*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[20]12", 0, 7, 99, "" }, /* EAN-13 */
/* 10*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' in linear component" },
/* 11*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' in linear component" }, /* Linear component still checked */
/* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 448: Input too long (13 character maximum) in linear component" },
/* 13*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 448: Input too long (13 character maximum) in linear component" },
/* 14*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" },
/* 15*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" },
/* 16*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 10*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)" },
/* 11*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 275: Invalid check digit '3', expecting '8' (linear component)" }, /* Linear component still checked */
/* 12*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)" },
/* 13*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901234", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 294: Input length 14 too long (maximum 13) (linear component)" },
/* 14*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" only) (linear component)" },
/* 15*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 13 in input (digits and \"+\" only) (linear component)" },
/* 16*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 17*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890128", "[20]1A", 0, 7, 99, "" },
/* 18*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 18*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 19*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890128", "[02]12345678901234", 0, 7, 99, "" },
/* 20*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567", 0, 48, 99, "" }, /* Max CC-B for EAN-13 */
/* 21*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, -1, "Error 444: Input too long for selected 2D component" },
/* 21*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "1234567890128", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]1234567890123456789012345678901234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, -1, "Error 444: Input too long (2D component)" },
/* 22*/ { BARCODE_EANX_CC, -1, 3, -1, -1, "1234567890128", "[20]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 447: Invalid mode (CC-C only valid with GS1-128 linear component)" },
/* 23*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012345678901", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 449: Input wrong length in linear component" },
/* 23*/ { BARCODE_EANX_CC, -1, -1, -1, -1, "123456789012345678901", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 449: Input length 21 wrong (linear component)" },
/* 24*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 5, 100, "" },
/* 25*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 5, 100, "" },
/* 26*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' in linear component" },
/* 27*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' in linear component" }, /* Linear component still checked */
/* 28*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum) in linear component" },
/* 29*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum) in linear component" },
/* 30*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only) in linear component" },
/* 31*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only) in linear component" },
/* 32*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 26*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)" },
/* 27*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)" }, /* Linear component still checked */
/* 28*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)" },
/* 29*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)" },
/* 30*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)" },
/* 31*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)" },
/* 32*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 33*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 5, 100, "" },
/* 34*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 34*/ { BARCODE_DBAR_OMN_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 100, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 35*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 5, 100, "" },
/* 36*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 6, 79, "" },
/* 37*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 6, 79, "" },
/* 38*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' in linear component" },
/* 39*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' in linear component" }, /* Linear component still checked */
/* 40*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input too long (14 character maximum) in linear component" },
/* 41*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input too long (14 character maximum) in linear component" },
/* 42*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character in data (digits only) in linear component" },
/* 43*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character in data (digits only) in linear component" },
/* 44*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 38*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' (linear component)" },
/* 39*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '2', expecting '1' (linear component)" }, /* Linear component still checked */
/* 40*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14) (linear component)" },
/* 41*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012345", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14) (linear component)" },
/* 42*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 1 in input (digits only) (linear component)" },
/* 43*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "A1234567890123", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 1 in input (digits only) (linear component)" },
/* 44*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 45*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 6, 79, "" },
/* 46*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 46*/ { BARCODE_DBAR_LTD_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 6, 79, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 47*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 6, 79, "" },
/* 48*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "12345678901", "[20]12", 0, 7, 99, "" },
/* 49*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[20]12", 0, 7, 99, "" },
/* 50*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' in linear component" },
/* 51*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' in linear component" }, /* Linear component still checked */
/* 52*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input wrong length (12 character maximum) in linear component" },
/* 53*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input wrong length (12 character maximum) in linear component" },
/* 54*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" },
/* 55*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" },
/* 56*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 50*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' (linear component)" },
/* 51*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 270: Invalid check digit '3', expecting '2' (linear component)" }, /* Linear component still checked */
/* 52*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input length 13 wrong (11 or 12 only) (linear component)" },
/* 53*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 289: Input length 13 wrong (11 or 12 only) (linear component)" },
/* 54*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 12 in input (digits and \"+\" only) (linear component)" },
/* 55*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 12 in input (digits and \"+\" only) (linear component)" },
/* 56*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[20]1A", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 57*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012", "[20]1A", 0, 7, 99, "" },
/* 58*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 58*/ { BARCODE_UPCA_CC, -1, -1, -1, -1, "123456789012", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 7, 99, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 59*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012", "[02]12345678901234", 0, 7, 99, "" },
/* 60*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "123456", "[20]12", 0, 9, 55, "" },
/* 61*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[20]12", 0, 9, 55, "" },
/* 62*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "12345670", "[20]12", 0, 9, 55, "" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */
/* 63*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' in linear component" },
/* 64*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' in linear component" }, /* Linear component still checked */
/* 65*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input wrong length (8 character maximum) in linear component" },
/* 66*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input wrong length (8 character maximum) in linear component" },
/* 67*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" },
/* 68*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component" },
/* 69*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 63*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' (linear component)" },
/* 64*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 274: Invalid check digit '1', expecting '0' (linear component)" }, /* Linear component still checked */
/* 65*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input length 9 wrong (6, 7 or 8 only) (linear component)" },
/* 66*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456712", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 291: Input length 9 wrong (6, 7 or 8 only) (linear component)" },
/* 67*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 8 in input (digits and \"+\" only) (linear component)" },
/* 68*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 284: Invalid character at position 8 in input (digits and \"+\" only) (linear component)" },
/* 69*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 70*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[20]1A", 0, 9, 55, "" },
/* 71*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 71*/ { BARCODE_UPCE_CC, -1, -1, -1, -1, "1234567", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 55, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 72*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567", "[02]12345678901234", 0, 9, 55, "" },
/* 73*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 9, 56, "" },
/* 74*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 9, 56, "" },
/* 75*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' in linear component" },
/* 76*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' in linear component" }, /* Linear component still checked */
/* 77*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum) in linear component" },
/* 78*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum) in linear component" },
/* 79*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only) in linear component" },
/* 80*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only) in linear component" },
/* 81*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 75*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)" },
/* 76*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)" }, /* Linear component still checked */
/* 77*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)" },
/* 78*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012323", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)" },
/* 79*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)" },
/* 80*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)" },
/* 81*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 82*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 9, 56, "" },
/* 83*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 83*/ { BARCODE_DBAR_STK_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 9, 56, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 84*/ { BARCODE_DBAR_STK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 9, 56, "" },
/* 85*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "1234567890123", "[20]12", 0, 11, 56, "" },
/* 86*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[20]12", 0, 11, 56, "" },
/* 87*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' in linear component" },
/* 88*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' in linear component" }, /* Linear component still checked */
/* 89*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum) in linear component" },
/* 90*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum) in linear component" },
/* 91*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only) in linear component" },
/* 92*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only) in linear component" },
/* 93*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (20) position 2: Non-numeric character 'A' in 2D component" }, /* AI (20) should be 2 nos. */
/* 87*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)" },
/* 88*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '2', expecting '1' (linear component)" }, /* Linear component still checked */
/* 89*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)" },
/* 90*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "123456789012312", "[20]12", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14) (linear component)" },
/* 91*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)" },
/* 92*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "1234567890123A", "[20]12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 14 in input (digits only) (linear component)" },
/* 93*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" }, /* AI (20) should be 2 nos. */
/* 94*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[20]1A", 0, 11, 56, "" },
/* 95*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' in 2D component" },
/* 95*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, -1, -1, "12345678901231", "[02]12345678901234", ZINT_WARN_NONCOMPLIANT, 11, 56, "Warning 261: AI (02) position 14: Bad checksum '4', expected '1' (2D component)" },
/* 96*/ { BARCODE_DBAR_OMNSTK_CC, GS1NOCHECK_MODE, -1, -1, -1, "12345678901231", "[02]12345678901234", 0, 11, 56, "" },
/* 97*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "", "[20]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 445: No primary (linear) message" },
/* 98*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 31, 273, "" }, /* Tries CC-A then CC-B then CC-C - ensure errtxt empty */
/* 99*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123", ZINT_WARN_NONCOMPLIANT, 29, 702, "Warning 843: GS1-128 input too long (48 character maximum) in linear component" }, /* Overlarge linear and CC-C input */
/*100*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1,"[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_TOO_LONG, -1, -1, "Error 442: Input too long for selected 2D component" }, /* Overlarge linear and oversized CC-C input */
/*101*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" "JKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLM", ZINT_ERROR_TOO_LONG, -1, -1, "Error 446: 2D component input data too long" }, /* Reduced length 2291 */
/* 99*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[95]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[97]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[98]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[99]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[91]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[92]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[93]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890[94]123456789012345678901234567890123456789012345678901234567890123", ZINT_WARN_NONCOMPLIANT, 29, 702, "Warning 843: Input too long, requires 115 characters (maximum 48) (linear component)" }, /* Overlarge linear and CC-C input */
/*100*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_TOO_LONG, -1, -1, "Error 442: Input too long (2D component)" }, /* Overlarge linear and oversized CC-C input */
/*101*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[97]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[98]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[99]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[94]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[95]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[96]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[91]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[92]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" "JKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL[93]ABCDEFGHIJKLM", ZINT_ERROR_TOO_LONG, -1, -1, "Error 446: 2D component input too long, requires 2991 characters (maximum 2990)" }, /* Reduced length 2291 */
/*102*/ { BARCODE_GS1_128_CC, -1, -1, -1, -1, "[01]12345678901231", "[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012" "345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[00]123456789012345675[11]121212[20]12", 0, 32, 579, "" }, /* Reduced length 2372 digits (no FNC1s) with not recommended ECC 4 > 2361 digit limit given in ISO/IEC 24723:2010 4.1 (d)(2)(iii) */
/*103*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" },
/*104*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, 1, -1, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" },
@ -3422,7 +3425,7 @@ static void test_input(const testCtx *const p_ctx) {
/*109*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 3, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" },
/*110*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, -1, 4, "[91]1234567890123456789012345678901234", "[20]12", 0, 13, 102, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -3474,20 +3477,20 @@ static void test_fuzz(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, -1, "+123456789012345678", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 448: Input too long (5 character maximum for add-on) in linear component", "" },
/* 1*/ { BARCODE_UPCA_CC, -1, -1, "+123456789012345678", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 294: Input too long (5 character maximum for add-on) in linear component", "" },
/* 2*/ { BARCODE_UPCE_CC, -1, -1, "+123456789012345678", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 294: Input too long (5 character maximum for add-on) in linear component", "" },
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, -1, "+123456789012345678", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 297: Input add-on length 18 too long (maximum 5) (linear component)", "" },
/* 1*/ { BARCODE_UPCA_CC, -1, -1, "+123456789012345678", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 297: Input add-on length 18 too long (maximum 5) (linear component)", "" },
/* 2*/ { BARCODE_UPCE_CC, -1, -1, "+123456789012345678", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 297: Input add-on length 18 too long (maximum 5) (linear component)", "" },
/* 3*/ { BARCODE_EANX_CC, -1, -1, "+12345", -1, "[21]A12345678", 0 , 0, "", "BWIPP checks for proper EAN data" },
/* 4*/ { BARCODE_EANX_CC, -1, -1, "+123456", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 448: Input too long (5 character maximum for add-on) in linear component", "" },
/* 5*/ { BARCODE_EANX_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "kks", -1, "()111%", ZINT_ERROR_INVALID_DATA, 1, "Error 284: Invalid character in data (digits and \"+\" only) in linear component", "" }, /* #300 (#5), Andre Maute (`dbar_date()` not checking length + other non-checks) */
/* 6*/ { BARCODE_UPCA_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\225\215\153\153\153\153\153\153\263\153\153\153\153\153\153\153\153\153\153\163", -1, "()90", ZINT_ERROR_TOO_LONG, 1, "Error 283: Input too long (19 character maximum) in linear component", "" }, /* #300 (#6), Andre Maute (`dbar_date()` not checking length + other non-checks) */
/* 7*/ { BARCODE_UPCA_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\225\215\153\153\153\153\153\153\263\153\153\377\002\000\000\153\153\153\153\163\000\000\000\153\153\153\153\153\153\153\060\047\047\043\047\057\153\153\153\153\153\000\000\000\000\153\153\153\161\153\153\153\153\153\153\153\153\153\153\153\153\153\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\001\100\000\000\000\000\000\000\000\167\167\167\167\167\167\167\167\167\167\167\167\167\167", 127, "()904OOOOO)CK0336680OOOOOOOOOOOOOO29[0kkkk%%%%(", ZINT_ERROR_INVALID_DATA, 1, "Error 253: Malformed AI in input data (brackets don't match) in 2D component", "" }, /* #300 (#11), Andre Maute (`gs1_verify()` not checking length on resolve AI data loop) */
/* 8*/ { BARCODE_EANX_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\225\215\153\153\153\153\153\153\263\153\153\377\002\000\000\153\153\153\153\163\000\000\000\153\153\153\153\153\153\153\060\047\047\043\047\057\153\153\153\153\153\000\000\000\000\153\153\153\161\153\153\153\153\153\153\153\153\153\153\153\153\153\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\001\100\000\000\000\000\000\000\000\167\167\167\167\167\167\167\167\167\167\167\167\167\167", 127, "()904OOOOO)CK0336680OOOOOOOOOOOOOO29[0kkkk%%%%(", ZINT_ERROR_INVALID_DATA, 1, "Error 253: Malformed AI in input data (brackets don't match) in 2D component", "" }, /* #300 (#11 with EANX_CC) */
/* 4*/ { BARCODE_EANX_CC, -1, -1, "+123456", -1, "[21]A12345678", ZINT_ERROR_TOO_LONG, 1, "Error 297: Input add-on length 6 too long (maximum 5) (linear component)", "" },
/* 5*/ { BARCODE_EANX_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "kks", -1, "()111%", ZINT_ERROR_INVALID_DATA, 1, "Error 284: Invalid character at position 1 in input (digits and \"+\" only) (linear component)", "" }, /* #300 (#5), Andre Maute (`dbar_date()` not checking length + other non-checks) */
/* 6*/ { BARCODE_UPCA_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\225\215\153\153\153\153\153\153\263\153\153\153\153\153\153\153\153\153\153\163", -1, "()90", ZINT_ERROR_TOO_LONG, 1, "Error 283: Input length 46 too long (maximum 19) (linear component)", "" }, /* #300 (#6), Andre Maute (`dbar_date()` not checking length + other non-checks) */
/* 7*/ { BARCODE_UPCA_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\225\215\153\153\153\153\153\153\263\153\153\377\002\000\000\153\153\153\153\163\000\000\000\153\153\153\153\153\153\153\060\047\047\043\047\057\153\153\153\153\153\000\000\000\000\153\153\153\161\153\153\153\153\153\153\153\153\153\153\153\153\153\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\001\100\000\000\000\000\000\000\000\167\167\167\167\167\167\167\167\167\167\167\167\167\167", 127, "()904OOOOO)CK0336680OOOOOOOOOOOOOO29[0kkkk%%%%(", ZINT_ERROR_INVALID_DATA, 1, "Error 253: Malformed AI in input (brackets don't match) (2D component)", "" }, /* #300 (#11), Andre Maute (`gs1_verify()` not checking length on resolve AI data loop) */
/* 8*/ { BARCODE_EANX_CC, GS1PARENS_MODE | GS1NOCHECK_MODE, -1, "\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\153\225\215\153\153\153\153\153\153\263\153\153\377\002\000\000\153\153\153\153\163\000\000\000\153\153\153\153\153\153\153\060\047\047\043\047\057\153\153\153\153\153\000\000\000\000\153\153\153\161\153\153\153\153\153\153\153\153\153\153\153\153\153\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\167\001\100\000\000\000\000\000\000\000\167\167\167\167\167\167\167\167\167\167\167\167\167\167", 127, "()904OOOOO)CK0336680OOOOOOOOOOOOOO29[0kkkk%%%%(", ZINT_ERROR_INVALID_DATA, 1, "Error 253: Malformed AI in input (brackets don't match) (2D component)", "" }, /* #300 (#11 with EANX_CC) */
/* 9*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, 3, "[]28", -1, "[]RRR___________________KKKRRR0000", 0, 1, "", "" }, /* #300 (#13), Andre Maute (`calc_padding_ccc()` dividing by zero when linear width == 68) */
/*10*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, 3, "[]2", -1, "[]RRR___________________KKKRRR0000", 0, 1, "", "" }, /* #300 (#13 shortened to min linear input (but same linear width 68)) */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
@ -3558,7 +3561,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, 1, "123456789012",
"[91]123456789012345678901234567890123456789012345678901234",
0, 11, 99, "58 chars CC-A" },
@ -3577,7 +3580,7 @@ static void test_perf(const testCtx *const p_ctx) {
"[96]123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
0, 32, 205, "564 chars CC-C" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;

View file

@ -44,317 +44,321 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
char *expected_errtxt2;
char *comment;
};
/* ISO/IEC 16022:2006 Table 7 and ISO/IEC 21471:2020 (DMRE) Table 7 */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "1", 3116, 0, 144, 144 },
/* 1*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "1", 3117, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "1", 10922, ZINT_ERROR_TOO_LONG, -1, -1 }, /* Minimal encoding can handle max (10921 + 1) * 6 = 65532 < 65536 (2*16) due to sizeof(previous) */
/* 3*/ { BARCODE_DATAMATRIX, -1, { 1, 2, "001001"}, "1", 3108, 0, 144, 144 }, /* Structured Append 4 codewords overhead == 8 digits */
/* 4*/ { BARCODE_DATAMATRIX, -1, { 1, 2, "001001"}, "1", 3109, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 5*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "A", 2335, 0, 144, 144 },
/* 6*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "A", 2336, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 7*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\200", 1556, 0, 144, 144 }, /* Spec says 1555 but 1556 correct as only single byte count of 0 required */
/* 8*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\200", 1557, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\001", 1558, 0, 144, 144 },
/* 10*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\001", 1559, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { BARCODE_HIBC_DM, -1, { 0, 0, "" }, "1", 110, 0, 32, 32 },
/* 12*/ { BARCODE_HIBC_DM, -1, { 0, 0, "" }, "1", 111, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 13*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "1", 6, 0, 10, 10 },
/* 14*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "1", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 15*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "A", 3, 0, 10, 10 },
/* 16*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "A", 4, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 17*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "\200", 1, 0, 10, 10 },
/* 18*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "\200", 2, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 19*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "1", 10, 0, 12, 12 },
/* 20*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "1", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 21*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "A", 6, 0, 12, 12 },
/* 22*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "A", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 23*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "\200", 3, 0, 12, 12 },
/* 24*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "\200", 4, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 25*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "1", 16, 0, 14, 14 },
/* 26*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "1", 17, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 27*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "A", 10, 0, 14, 14 },
/* 28*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 29*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "\200", 6, 0, 14, 14 },
/* 30*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "\200", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 31*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "1", 24, 0, 16, 16 },
/* 32*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "1", 25, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 33*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "A", 16, 0, 16, 16 },
/* 34*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "A", 17, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 35*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "\200", 10, 0, 16, 16 },
/* 36*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "\200", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 37*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "1", 36, 0, 18, 18 },
/* 38*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "1", 37, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 39*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "A", 25, 0, 18, 18 },
/* 40*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "A", 26, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 41*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "\200", 16, 0, 18, 18 },
/* 42*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "\200", 17, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 43*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "1", 44, 0, 20, 20 },
/* 44*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 45*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "A", 31, 0, 20, 20 },
/* 46*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "A", 32, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 47*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "\200", 20, 0, 20, 20 },
/* 48*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "\200", 21, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 49*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "1", 60, 0, 22, 22 },
/* 50*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "1", 61, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 51*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "A", 43, 0, 22, 22 },
/* 52*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "A", 44, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 53*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "\200", 28, 0, 22, 22 },
/* 54*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "\200", 29, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 55*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "1", 72, 0, 24, 24 },
/* 56*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "1", 73, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 57*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "A", 52, 0, 24, 24 },
/* 58*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "A", 53, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 59*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "\200", 34, 0, 24, 24 },
/* 60*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "\200", 35, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 61*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "1", 88, 0, 26, 26 },
/* 62*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 63*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "A", 64, 0, 26, 26 },
/* 64*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 65*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "\200", 42, 0, 26, 26 },
/* 66*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 67*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "1", 124, 0, 32, 32 },
/* 68*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "1", 125, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 69*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "A", 91, 0, 32, 32 },
/* 70*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "A", 92, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 71*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "\200", 60, 0, 32, 32 },
/* 72*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "\200", 61, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 73*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "1", 172, 0, 36, 36 },
/* 74*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "1", 173, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 75*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "A", 127, 0, 36, 36 },
/* 76*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "A", 128, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 77*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "\200", 84, 0, 36, 36 },
/* 78*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "\200", 85, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 79*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "1", 228, 0, 40, 40 },
/* 80*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "1", 229, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 81*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "A", 169, 0, 40, 40 },
/* 82*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "A", 170, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 83*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "\200", 112, 0, 40, 40 },
/* 84*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "\200", 113, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 85*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "1", 288, 0, 44, 44 },
/* 86*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "1", 289, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 87*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "A", 214, 0, 44, 44 },
/* 88*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "A", 215, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 89*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "\200", 142, 0, 44, 44 },
/* 90*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "\200", 143, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 91*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "1", 348, 0, 48, 48 },
/* 92*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "1", 349, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 93*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "A", 259, 0, 48, 48 },
/* 94*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "A", 260, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 95*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "\200", 172, 0, 48, 48 },
/* 96*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "\200", 173, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 97*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "1", 408, 0, 52, 52 },
/* 98*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "1", 409, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 99*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "A", 304, 0, 52, 52 },
/*100*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "A", 305, ZINT_ERROR_TOO_LONG, -1, -1 },
/*101*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "\200", 202, 0, 52, 52 },
/*102*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "\200", 203, ZINT_ERROR_TOO_LONG, -1, -1 },
/*103*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "1", 560, 0, 64, 64 },
/*104*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "1", 561, ZINT_ERROR_TOO_LONG, -1, -1 },
/*105*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "A", 418, 0, 64, 64 },
/*106*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "A", 419, ZINT_ERROR_TOO_LONG, -1, -1 },
/*107*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "\200", 278, 0, 64, 64 }, /* Spec says 277 but 278 correct as only single byte count of 0 required */
/*108*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "\200", 279, ZINT_ERROR_TOO_LONG, -1, -1 },
/*109*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "1", 736, 0, 72, 72 },
/*110*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "1", 737, ZINT_ERROR_TOO_LONG, -1, -1 },
/*111*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "A", 550, 0, 72, 72 },
/*112*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "A", 551, ZINT_ERROR_TOO_LONG, -1, -1 },
/*113*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "\200", 366, 0, 72, 72 }, /* Spec says 365 but 366 correct as only single byte count of 0 required */
/*114*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "\200", 367, ZINT_ERROR_TOO_LONG, -1, -1 },
/*115*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "1", 912, 0, 80, 80 },
/*116*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "1", 913, ZINT_ERROR_TOO_LONG, -1, -1 },
/*117*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "A", 682, 0, 80, 80 },
/*118*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "A", 683, ZINT_ERROR_TOO_LONG, -1, -1 },
/*119*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "\200", 454, 0, 80, 80 }, /* Spec says 453 but 454 correct as only single byte count of 0 required */
/*120*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "\200", 455, ZINT_ERROR_TOO_LONG, -1, -1 },
/*121*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "1", 1152, 0, 88, 88 },
/*122*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "1", 1153, ZINT_ERROR_TOO_LONG, -1, -1 },
/*123*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "A", 862, 0, 88, 88 },
/*124*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "A", 863, ZINT_ERROR_TOO_LONG, -1, -1 },
/*125*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "\200", 574, 0, 88, 88 }, /* Spec says 573 but 574 correct as only single byte count of 0 required */
/*126*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "\200", 575, ZINT_ERROR_TOO_LONG, -1, -1 },
/*127*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "1", 1392, 0, 96, 96 },
/*128*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "1", 1393, ZINT_ERROR_TOO_LONG, -1, -1 },
/*129*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "A", 1042, 0, 96, 96 },
/*130*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "A", 1043, ZINT_ERROR_TOO_LONG, -1, -1 },
/*131*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "\200", 694, 0, 96, 96 }, /* Spec says 693 but 694 correct as only single byte count of 0 required */
/*132*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "\200", 695, ZINT_ERROR_TOO_LONG, -1, -1 },
/*133*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "1", 1632, 0, 104, 104 },
/*134*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "1", 1633, ZINT_ERROR_TOO_LONG, -1, -1 },
/*135*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "A", 1222, 0, 104, 104 },
/*136*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "A", 1223, ZINT_ERROR_TOO_LONG, -1, -1 },
/*137*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "\200", 814, 0, 104, 104 }, /* Spec says 813 but 814 correct as only single byte count of 0 required */
/*138*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "\200", 815, ZINT_ERROR_TOO_LONG, -1, -1 },
/*139*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "1", 2100, 0, 120, 120 },
/*140*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "1", 2101, ZINT_ERROR_TOO_LONG, -1, -1 },
/*141*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "A", 1573, 0, 120, 120 },
/*142*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "A", 1574, ZINT_ERROR_TOO_LONG, -1, -1 },
/*143*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "\200", 1048, 0, 120, 120 }, /* Spec says 1047 but 1048 correct as only single byte count of 0 required */
/*144*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "\200", 1049, ZINT_ERROR_TOO_LONG, -1, -1 },
/*145*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "1", 2608, 0, 132, 132 },
/*146*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "1", 2609, ZINT_ERROR_TOO_LONG, -1, -1 },
/*147*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "A", 1954, 0, 132, 132 },
/*148*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "A", 1955, ZINT_ERROR_TOO_LONG, -1, -1 },
/*149*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "\200", 1302, 0, 132, 132 }, /* Spec says 1301 but 1302 correct as only single byte count of 0 required */
/*150*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "\200", 1303, ZINT_ERROR_TOO_LONG, -1, -1 },
/*151*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "1", 3116, 0, 144, 144 },
/*152*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "1", 3117, ZINT_ERROR_TOO_LONG, -1, -1 },
/*153*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "A", 2335, 0, 144, 144 },
/*154*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "A", 2336, ZINT_ERROR_TOO_LONG, -1, -1 },
/*155*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "\200", 1556, 0, 144, 144 }, /* Spec says 1555 but 1556 correct as only single byte count of 0 required */
/*156*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "\200", 1557, ZINT_ERROR_TOO_LONG, -1, -1 },
/*157*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "1", 10, 0, 8, 18 },
/*158*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "1", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/*159*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "A", 6, 0, 8, 18 },
/*160*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "A", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/*161*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "\200", 3, 0, 8, 18 },
/*162*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "\200", 4, ZINT_ERROR_TOO_LONG, -1, -1 },
/*163*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "1", 20, 0, 8, 32 },
/*164*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "1", 21, ZINT_ERROR_TOO_LONG, -1, -1 },
/*165*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "A", 13, 0, 8, 32 },
/*166*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/*167*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "\200", 8, 0, 8, 32 },
/*168*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "\200", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
/*169*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "1", 32, 0, 12, 26 },
/*170*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "1", 33, ZINT_ERROR_TOO_LONG, -1, -1 },
/*171*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "A", 22, 0, 12, 26 },
/*172*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "A", 23, ZINT_ERROR_TOO_LONG, -1, -1 },
/*173*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "\200", 14, 0, 12, 26 },
/*174*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "\200", 15, ZINT_ERROR_TOO_LONG, -1, -1 },
/*175*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "1", 44, 0, 12, 36 },
/*176*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1 },
/*177*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "A", 31, 0, 12, 36 },
/*178*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "A", 32, ZINT_ERROR_TOO_LONG, -1, -1 },
/*179*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "\200", 20, 0, 12, 36 },
/*180*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "\200", 21, ZINT_ERROR_TOO_LONG, -1, -1 },
/*181*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "1", 64, 0, 16, 36 },
/*182*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "1", 65, ZINT_ERROR_TOO_LONG, -1, -1 },
/*183*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "A", 46, 0, 16, 36 },
/*184*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "A", 47, ZINT_ERROR_TOO_LONG, -1, -1 },
/*185*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "\200", 30, 0, 16, 36 },
/*186*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "\200", 31, ZINT_ERROR_TOO_LONG, -1, -1 },
/*187*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "1", 98, 0, 16, 48 },
/*188*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "1", 99, ZINT_ERROR_TOO_LONG, -1, -1 },
/*189*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "A", 72, 0, 16, 48 },
/*190*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "A", 73, ZINT_ERROR_TOO_LONG, -1, -1 },
/*191*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "\200", 47, 0, 16, 48 },
/*192*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "\200", 48, ZINT_ERROR_TOO_LONG, -1, -1 },
/*193*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "1", 36, 0, 8, 48 },
/*194*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "1", 37, ZINT_ERROR_TOO_LONG, -1, -1 },
/*195*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "A", 25, 0, 8, 48 },
/*196*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "A", 26, ZINT_ERROR_TOO_LONG, -1, -1 },
/*197*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "\200", 16, 0, 8, 48 },
/*198*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "\200", 17, ZINT_ERROR_TOO_LONG, -1, -1 },
/*199*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "1", 48, 0, 8, 64 },
/*200*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "1", 49, ZINT_ERROR_TOO_LONG, -1, -1 },
/*201*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "A", 34, 0, 8, 64 },
/*202*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "A", 35, ZINT_ERROR_TOO_LONG, -1, -1 },
/*203*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "\200", 22, 0, 8, 64 },
/*204*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "\200", 23, ZINT_ERROR_TOO_LONG, -1, -1 },
/*205*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "1", 64, 0, 8, 80 },
/*206*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "1", 65, ZINT_ERROR_TOO_LONG, -1, -1 },
/*207*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "A", 46, 0, 8, 80 },
/*208*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "A", 47, ZINT_ERROR_TOO_LONG, -1, -1 },
/*209*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "\200", 30, 0, 8, 80 },
/*210*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "\200", 31, ZINT_ERROR_TOO_LONG, -1, -1 },
/*211*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "1", 76, 0, 8, 96 },
/*212*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "1", 77, ZINT_ERROR_TOO_LONG, -1, -1 },
/*213*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "A", 55, 0, 8, 96 },
/*214*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "A", 56, ZINT_ERROR_TOO_LONG, -1, -1 },
/*215*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "\200", 36, 0, 8, 96 },
/*216*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "\200", 37, ZINT_ERROR_TOO_LONG, -1, -1 },
/*217*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "1", 98, 0, 8, 120 },
/*218*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "1", 99, ZINT_ERROR_TOO_LONG, -1, -1 },
/*219*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "A", 72, 0, 8, 120 },
/*220*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "A", 73, ZINT_ERROR_TOO_LONG, -1, -1 },
/*221*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "\200", 47, 0, 8, 120 },
/*222*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "\200", 48, ZINT_ERROR_TOO_LONG, -1, -1 },
/*223*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "1", 126, 0, 8, 144 },
/*224*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "1", 127, ZINT_ERROR_TOO_LONG, -1, -1 },
/*225*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "A", 93, 0, 8, 144 },
/*226*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "A", 94, ZINT_ERROR_TOO_LONG, -1, -1 },
/*227*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "\200", 61, 0, 8, 144 },
/*228*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "\200", 62, ZINT_ERROR_TOO_LONG, -1, -1 },
/*229*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "1", 86, 0, 12, 64 },
/*230*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "1", 87, ZINT_ERROR_TOO_LONG, -1, -1 },
/*231*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "A", 63, 0, 12, 64 },
/*232*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "A", 64, ZINT_ERROR_TOO_LONG, -1, -1 },
/*233*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "\200", 41, 0, 12, 64 },
/*234*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "\200", 42, ZINT_ERROR_TOO_LONG, -1, -1 },
/*235*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "1", 128, 0, 12, 88 },
/*236*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "1", 129, ZINT_ERROR_TOO_LONG, -1, -1 },
/*237*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "A", 94, 0, 12, 88 },
/*238*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "A", 95, ZINT_ERROR_TOO_LONG, -1, -1 },
/*239*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "\200", 62, 0, 12, 88 },
/*240*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "\200", 63, ZINT_ERROR_TOO_LONG, -1, -1 },
/*241*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "1", 124, 0, 16, 64 },
/*242*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "1", 125, ZINT_ERROR_TOO_LONG, -1, -1 },
/*243*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "A", 91, 0, 16, 64 },
/*244*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "A", 92, ZINT_ERROR_TOO_LONG, -1, -1 },
/*245*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "\200", 60, 0, 16, 64 },
/*246*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "\200", 61, ZINT_ERROR_TOO_LONG, -1, -1 },
/*247*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "1", 88, 0, 20, 36 },
/*248*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1 },
/*249*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "A", 64, 0, 20, 36 },
/*250*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1 },
/*251*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "\200", 42, 0, 20, 36 },
/*252*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1 },
/*253*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "1", 112, 0, 20, 44 },
/*254*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "1", 113, ZINT_ERROR_TOO_LONG, -1, -1 },
/*255*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "A", 82, 0, 20, 44 },
/*256*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "A", 83, ZINT_ERROR_TOO_LONG, -1, -1 },
/*257*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "\200", 54, 0, 20, 44 },
/*258*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "\200", 55, ZINT_ERROR_TOO_LONG, -1, -1 },
/*259*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "1", 168, 0, 20, 64 }, /* Spec says 186 but typo */
/*260*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "1", 169, ZINT_ERROR_TOO_LONG, -1, -1 },
/*261*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "A", 124, 0, 20, 64 },
/*262*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "A", 125, ZINT_ERROR_TOO_LONG, -1, -1 },
/*263*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "\200", 82, 0, 20, 64 },
/*264*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "\200", 83, ZINT_ERROR_TOO_LONG, -1, -1 },
/*265*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "1", 144, 0, 22, 48 },
/*266*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "1", 145, ZINT_ERROR_TOO_LONG, -1, -1 },
/*267*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "A", 106, 0, 22, 48 },
/*268*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "A", 107, ZINT_ERROR_TOO_LONG, -1, -1 },
/*269*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "\200", 70, 0, 22, 48 },
/*270*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "\200", 71, ZINT_ERROR_TOO_LONG, -1, -1 },
/*271*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "1", 160, 0, 24, 48 },
/*272*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "1", 161, ZINT_ERROR_TOO_LONG, -1, -1 },
/*273*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "A", 118, 0, 24, 48 },
/*274*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "A", 119, ZINT_ERROR_TOO_LONG, -1, -1 },
/*275*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "\200", 78, 0, 24, 48 },
/*276*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "\200", 79, ZINT_ERROR_TOO_LONG, -1, -1 },
/*277*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "1", 216, 0, 24, 64 },
/*278*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "1", 217, ZINT_ERROR_TOO_LONG, -1, -1 },
/*279*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "A", 160, 0, 24, 64 },
/*280*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "A", 161, ZINT_ERROR_TOO_LONG, -1, -1 },
/*281*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "\200", 106, 0, 24, 64 },
/*282*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "\200", 107, ZINT_ERROR_TOO_LONG, -1, -1 },
/*283*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "1", 140, 0, 26, 40 },
/*284*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "1", 141, ZINT_ERROR_TOO_LONG, -1, -1 },
/*285*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "A", 103, 0, 26, 40 },
/*286*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "A", 104, ZINT_ERROR_TOO_LONG, -1, -1 },
/*287*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "\200", 68, 0, 26, 40 },
/*288*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "\200", 69, ZINT_ERROR_TOO_LONG, -1, -1 },
/*289*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "1", 180, 0, 26, 48 },
/*290*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "1", 181, ZINT_ERROR_TOO_LONG, -1, -1 },
/*291*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "A", 133, 0, 26, 48 },
/*292*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "A", 134, ZINT_ERROR_TOO_LONG, -1, -1 },
/*293*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "\200", 88, 0, 26, 48 },
/*294*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "\200", 89, ZINT_ERROR_TOO_LONG, -1, -1 },
/*295*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "1", 236, 0, 26, 64 },
/*296*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "1", 237, ZINT_ERROR_TOO_LONG, -1, -1 },
/*297*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "A", 175, 0, 26, 64 },
/*298*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "A", 176, ZINT_ERROR_TOO_LONG, -1, -1 },
/*299*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "\200", 116, 0, 26, 64 },
/*300*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "\200", 117, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "1", 3116, 0, 144, 144, "", "", "" },
/* 1*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "1", 3117, ZINT_ERROR_TOO_LONG, 0, 0, "Error 719: Input length 3117 too long (maximum 3116)", "", "" },
/* 2*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "1", 10922, ZINT_ERROR_TOO_LONG, 0, 0, "Error 719: Input length 10922 too long (maximum 3116)", "", "Minimal encoding can handle max (10921 + 1) * 6 = 65532 < 65536 (2*16) due to sizeof(previous)" },
/* 3*/ { BARCODE_DATAMATRIX, -1, { 1, 2, "001001" }, "1", 3108, 0, 144, 144, "", "", "Structured Append 4 codewords overhead == 8 digits" },
/* 4*/ { BARCODE_DATAMATRIX, -1, { 1, 2, "001001" }, "1", 3109, ZINT_ERROR_TOO_LONG, 0, 0, "Error 729: Input too long, requires too many codewords (maximum 1558)", "Error 520: Input too long, requires too many codewords (maximum 1558)", "" },
/* 5*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "A", 2335, 0, 144, 144, "", "", "" },
/* 6*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "A", 2336, ZINT_ERROR_TOO_LONG, 0, 0, "Error 729: Input too long, requires too many codewords (maximum 1558)", "Error 523: Input too long, requires 1560 codewords (maximum 1558)", "" },
/* 7*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\200", 1556, 0, 144, 144, "", "", "Spec says 1555 but 1556 correct as only single byte count of 0 required" },
/* 8*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\200", 1557, ZINT_ERROR_TOO_LONG, 0, 0, "Error 729: Input too long, requires too many codewords (maximum 1558)", "Error 520: Input too long, requires too many codewords (maximum 1558)", "" },
/* 9*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\001", 1558, 0, 144, 144, "", "", "" },
/* 10*/ { BARCODE_DATAMATRIX, -1, { 0, 0, "" }, "\001", 1559, ZINT_ERROR_TOO_LONG, 0, 0, "Error 729: Input too long, requires too many codewords (maximum 1558)", "Error 520: Input too long, requires too many codewords (maximum 1558)", "" },
/* 11*/ { BARCODE_HIBC_DM, -1, { 0, 0, "" }, "1", 110, 0, 32, 32, "", "", "" },
/* 12*/ { BARCODE_HIBC_DM, -1, { 0, 0, "" }, "1", 111, ZINT_ERROR_TOO_LONG, 0, 0, "Error 202: Input length 111 too long for HIBC LIC (maximum 110)", "", "" },
/* 13*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "1", 6, 0, 10, 10, "", "", "" },
/* 14*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "1", 7, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 1, requires 4 codewords (maximum 3)", "", "" },
/* 15*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "A", 3, 0, 10, 10, "", "", "" },
/* 16*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "A", 4, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 1, requires 4 codewords (maximum 3)", "", "" },
/* 17*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "\200", 1, 0, 10, 10, "", "", "" },
/* 18*/ { BARCODE_DATAMATRIX, 1, { 0, 0, "" }, "\200", 2, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 1, requires 4 codewords (maximum 3)", "", "" },
/* 19*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "1", 10, 0, 12, 12, "", "", "" },
/* 20*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "1", 11, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 2, requires 6 codewords (maximum 5)", "", "" },
/* 21*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "A", 6, 0, 12, 12, "", "", "" },
/* 22*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "A", 7, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 2, requires 6 codewords (maximum 5)", "", "" },
/* 23*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "\200", 3, 0, 12, 12, "", "", "" },
/* 24*/ { BARCODE_DATAMATRIX, 2, { 0, 0, "" }, "\200", 4, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 2, requires 6 codewords (maximum 5)", "", "" },
/* 25*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "1", 16, 0, 14, 14, "", "", "" },
/* 26*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "1", 17, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 3, requires 9 codewords (maximum 8)", "", "" },
/* 27*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "A", 10, 0, 14, 14, "", "", "" },
/* 28*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "A", 11, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 3, requires 9 codewords (maximum 8)", "Error 522: Input too long for Version 3, requires 10 codewords (maximum 8)", "" },
/* 29*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "\200", 6, 0, 14, 14, "", "", "" },
/* 30*/ { BARCODE_DATAMATRIX, 3, { 0, 0, "" }, "\200", 7, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 3, requires 9 codewords (maximum 8)", "", "" },
/* 31*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "1", 24, 0, 16, 16, "", "", "" },
/* 32*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "1", 25, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 4, requires 13 codewords (maximum 12)", "", "" },
/* 33*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "A", 16, 0, 16, 16, "", "", "" },
/* 34*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "A", 17, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 4, requires 13 codewords (maximum 12)", "Error 522: Input too long for Version 4, requires 14 codewords (maximum 12)", "" },
/* 35*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "\200", 10, 0, 16, 16, "", "", "" },
/* 36*/ { BARCODE_DATAMATRIX, 4, { 0, 0, "" }, "\200", 11, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 4, requires 13 codewords (maximum 12)", "", "" },
/* 37*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "1", 36, 0, 18, 18, "", "", "" },
/* 38*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "1", 37, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 5, requires 19 codewords (maximum 18)", "", "" },
/* 39*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "A", 25, 0, 18, 18, "", "", "" },
/* 40*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "A", 26, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 5, requires 19 codewords (maximum 18)", "Error 522: Input too long for Version 5, requires 20 codewords (maximum 18)", "" },
/* 41*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "\200", 16, 0, 18, 18, "", "", "" },
/* 42*/ { BARCODE_DATAMATRIX, 5, { 0, 0, "" }, "\200", 17, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 5, requires 19 codewords (maximum 18)", "", "" },
/* 43*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "1", 44, 0, 20, 20, "", "", "" },
/* 44*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "1", 45, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 6, requires 23 codewords (maximum 22)", "", "" },
/* 45*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "A", 31, 0, 20, 20, "", "", "" },
/* 46*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "A", 32, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 6, requires 23 codewords (maximum 22)", "Error 522: Input too long for Version 6, requires 24 codewords (maximum 22)", "" },
/* 47*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "\200", 20, 0, 20, 20, "", "", "" },
/* 48*/ { BARCODE_DATAMATRIX, 6, { 0, 0, "" }, "\200", 21, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 6, requires 23 codewords (maximum 22)", "", "" },
/* 49*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "1", 60, 0, 22, 22, "", "", "" },
/* 50*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "1", 61, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 7, requires 31 codewords (maximum 30)", "", "" },
/* 51*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "A", 43, 0, 22, 22, "", "", "" },
/* 52*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "A", 44, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 7, requires 31 codewords (maximum 30)", "Error 522: Input too long for Version 7, requires 32 codewords (maximum 30)", "" },
/* 53*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "\200", 28, 0, 22, 22, "", "", "" },
/* 54*/ { BARCODE_DATAMATRIX, 7, { 0, 0, "" }, "\200", 29, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 7, requires 31 codewords (maximum 30)", "", "" },
/* 55*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "1", 72, 0, 24, 24, "", "", "" },
/* 56*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "1", 73, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 8, requires 37 codewords (maximum 36)", "", "" },
/* 57*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "A", 52, 0, 24, 24, "", "", "" },
/* 58*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "A", 53, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 8, requires 37 codewords (maximum 36)", "Error 522: Input too long for Version 8, requires 38 codewords (maximum 36)", "" },
/* 59*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "\200", 34, 0, 24, 24, "", "", "" },
/* 60*/ { BARCODE_DATAMATRIX, 8, { 0, 0, "" }, "\200", 35, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 8, requires 37 codewords (maximum 36)", "", "" },
/* 61*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "1", 88, 0, 26, 26, "", "", "" },
/* 62*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "1", 89, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 9, requires 45 codewords (maximum 44)", "", "" },
/* 63*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "A", 64, 0, 26, 26, "", "", "" },
/* 64*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "A", 65, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 9, requires 45 codewords (maximum 44)", "Error 522: Input too long for Version 9, requires 46 codewords (maximum 44)", "" },
/* 65*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "\200", 42, 0, 26, 26, "", "", "" },
/* 66*/ { BARCODE_DATAMATRIX, 9, { 0, 0, "" }, "\200", 43, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 9, requires 45 codewords (maximum 44)", "", "" },
/* 67*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "1", 124, 0, 32, 32, "", "", "" },
/* 68*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "1", 125, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 10, requires 63 codewords (maximum 62)", "", "" },
/* 69*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "A", 91, 0, 32, 32, "", "", "" },
/* 70*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "A", 92, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 10, requires 63 codewords (maximum 62)", "Error 522: Input too long for Version 10, requires 64 codewords (maximum 62)", "" },
/* 71*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "\200", 60, 0, 32, 32, "", "", "" },
/* 72*/ { BARCODE_DATAMATRIX, 10, { 0, 0, "" }, "\200", 61, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 10, requires 63 codewords (maximum 62)", "", "" },
/* 73*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "1", 172, 0, 36, 36, "", "", "" },
/* 74*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "1", 173, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 11, requires 87 codewords (maximum 86)", "", "" },
/* 75*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "A", 127, 0, 36, 36, "", "", "" },
/* 76*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "A", 128, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 11, requires 87 codewords (maximum 86)", "Error 522: Input too long for Version 11, requires 88 codewords (maximum 86)", "" },
/* 77*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "\200", 84, 0, 36, 36, "", "", "" },
/* 78*/ { BARCODE_DATAMATRIX, 11, { 0, 0, "" }, "\200", 85, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 11, requires 87 codewords (maximum 86)", "", "" },
/* 79*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "1", 228, 0, 40, 40, "", "", "" },
/* 80*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "1", 229, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 12, requires 115 codewords (maximum 114)", "", "" },
/* 81*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "A", 169, 0, 40, 40, "", "", "" },
/* 82*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "A", 170, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 12, requires 115 codewords (maximum 114)", "Error 522: Input too long for Version 12, requires 116 codewords (maximum 114)", "" },
/* 83*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "\200", 112, 0, 40, 40, "", "", "" },
/* 84*/ { BARCODE_DATAMATRIX, 12, { 0, 0, "" }, "\200", 113, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 12, requires 115 codewords (maximum 114)", "", "" },
/* 85*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "1", 288, 0, 44, 44, "", "", "" },
/* 86*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "1", 289, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 13, requires 145 codewords (maximum 144)", "", "" },
/* 87*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "A", 214, 0, 44, 44, "", "", "" },
/* 88*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "A", 215, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 13, requires 145 codewords (maximum 144)", "Error 522: Input too long for Version 13, requires 146 codewords (maximum 144)", "" },
/* 89*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "\200", 142, 0, 44, 44, "", "", "" },
/* 90*/ { BARCODE_DATAMATRIX, 13, { 0, 0, "" }, "\200", 143, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 13, requires 145 codewords (maximum 144)", "", "" },
/* 91*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "1", 348, 0, 48, 48, "", "", "" },
/* 92*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "1", 349, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 14, requires 175 codewords (maximum 174)", "", "" },
/* 93*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "A", 259, 0, 48, 48, "", "", "" },
/* 94*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "A", 260, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 14, requires 175 codewords (maximum 174)", "Error 522: Input too long for Version 14, requires 176 codewords (maximum 174)", "" },
/* 95*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "\200", 172, 0, 48, 48, "", "", "" },
/* 96*/ { BARCODE_DATAMATRIX, 14, { 0, 0, "" }, "\200", 173, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 14, requires 175 codewords (maximum 174)", "", "" },
/* 97*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "1", 408, 0, 52, 52, "", "", "" },
/* 98*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "1", 409, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 15, requires 205 codewords (maximum 204)", "", "" },
/* 99*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "A", 304, 0, 52, 52, "", "", "" },
/*100*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "A", 305, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 15, requires 205 codewords (maximum 204)", "Error 522: Input too long for Version 15, requires 206 codewords (maximum 204)", "" },
/*101*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "\200", 202, 0, 52, 52, "", "", "" },
/*102*/ { BARCODE_DATAMATRIX, 15, { 0, 0, "" }, "\200", 203, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 15, requires 205 codewords (maximum 204)", "", "" },
/*103*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "1", 560, 0, 64, 64, "", "", "" },
/*104*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "1", 561, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 16, requires 281 codewords (maximum 280)", "", "" },
/*105*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "A", 418, 0, 64, 64, "", "", "" },
/*106*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "A", 419, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 16, requires 281 codewords (maximum 280)", "Error 522: Input too long for Version 16, requires 282 codewords (maximum 280)", "" },
/*107*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "\200", 278, 0, 64, 64, "", "", "Spec says 277 but 278 correct as only single byte count of 0 required" },
/*108*/ { BARCODE_DATAMATRIX, 16, { 0, 0, "" }, "\200", 279, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 16, requires 281 codewords (maximum 280)", "", "" },
/*109*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "1", 736, 0, 72, 72, "", "", "" },
/*110*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "1", 737, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 17, requires 369 codewords (maximum 368)", "", "" },
/*111*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "A", 550, 0, 72, 72, "", "", "" },
/*112*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "A", 551, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 17, requires 369 codewords (maximum 368)", "Error 522: Input too long for Version 17, requires 370 codewords (maximum 368)", "" },
/*113*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "\200", 366, 0, 72, 72, "", "", "Spec says 365 but 366 correct as only single byte count of 0 required" },
/*114*/ { BARCODE_DATAMATRIX, 17, { 0, 0, "" }, "\200", 367, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 17, requires 369 codewords (maximum 368)", "", "" },
/*115*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "1", 912, 0, 80, 80, "", "", "" },
/*116*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "1", 913, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 18, requires 457 codewords (maximum 456)", "", "" },
/*117*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "A", 682, 0, 80, 80, "", "", "" },
/*118*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "A", 683, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 18, requires 457 codewords (maximum 456)", "Error 522: Input too long for Version 18, requires 458 codewords (maximum 456)", "" },
/*119*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "\200", 454, 0, 80, 80, "", "", "Spec says 453 but 454 correct as only single byte count of 0 required" },
/*120*/ { BARCODE_DATAMATRIX, 18, { 0, 0, "" }, "\200", 455, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 18, requires 457 codewords (maximum 456)", "", "" },
/*121*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "1", 1152, 0, 88, 88, "", "", "" },
/*122*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "1", 1153, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 19, requires 577 codewords (maximum 576)", "", "" },
/*123*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "A", 862, 0, 88, 88, "", "", "" },
/*124*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "A", 863, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 19, requires 577 codewords (maximum 576)", "Error 522: Input too long for Version 19, requires 578 codewords (maximum 576)", "" },
/*125*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "\200", 574, 0, 88, 88, "", "", "Spec says 573 but 574 correct as only single byte count of 0 required" },
/*126*/ { BARCODE_DATAMATRIX, 19, { 0, 0, "" }, "\200", 575, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 19, requires 577 codewords (maximum 576)", "", "" },
/*127*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "1", 1392, 0, 96, 96, "", "", "" },
/*128*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "1", 1393, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 20, requires 697 codewords (maximum 696)", "", "" },
/*129*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "A", 1042, 0, 96, 96, "", "", "" },
/*130*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "A", 1043, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 20, requires 697 codewords (maximum 696)", "Error 522: Input too long for Version 20, requires 698 codewords (maximum 696)", "" },
/*131*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "\200", 694, 0, 96, 96, "", "", "Spec says 693 but 694 correct as only single byte count of 0 required" },
/*132*/ { BARCODE_DATAMATRIX, 20, { 0, 0, "" }, "\200", 695, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 20, requires 697 codewords (maximum 696)", "", "" },
/*133*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "1", 1632, 0, 104, 104, "", "", "" },
/*134*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "1", 1633, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 21, requires 817 codewords (maximum 816)", "", "" },
/*135*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "A", 1222, 0, 104, 104, "", "", "" },
/*136*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "A", 1223, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 21, requires 817 codewords (maximum 816)", "Error 522: Input too long for Version 21, requires 818 codewords (maximum 816)", "" },
/*137*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "\200", 814, 0, 104, 104, "", "", "Spec says 813 but 814 correct as only single byte count of 0 required" },
/*138*/ { BARCODE_DATAMATRIX, 21, { 0, 0, "" }, "\200", 815, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 21, requires 817 codewords (maximum 816)", "", "" },
/*139*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "1", 2100, 0, 120, 120, "", "", "" },
/*140*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "1", 2101, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 22, requires 1051 codewords (maximum 1050)", "", "" },
/*141*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "A", 1573, 0, 120, 120, "", "", "" },
/*142*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "A", 1574, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 22, requires 1051 codewords (maximum 1050)", "Error 522: Input too long for Version 22, requires 1052 codewords (maximum 1050)", "" },
/*143*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "\200", 1048, 0, 120, 120, "", "", "Spec says 1047 but 1048 correct as only single byte count of 0 required" },
/*144*/ { BARCODE_DATAMATRIX, 22, { 0, 0, "" }, "\200", 1049, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 22, requires 1051 codewords (maximum 1050)", "", "" },
/*145*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "1", 2608, 0, 132, 132, "", "", "" },
/*146*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "1", 2609, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 23, requires 1305 codewords (maximum 1304)", "", "" },
/*147*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "A", 1954, 0, 132, 132, "", "", "" },
/*148*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "A", 1955, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 23, requires 1305 codewords (maximum 1304)", "Error 522: Input too long for Version 23, requires 1306 codewords (maximum 1304)", "" },
/*149*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "\200", 1302, 0, 132, 132, "", "", "Spec says 1301 but 1302 correct as only single byte count of 0 required" },
/*150*/ { BARCODE_DATAMATRIX, 23, { 0, 0, "" }, "\200", 1303, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 23, requires 1305 codewords (maximum 1304)", "", "" },
/*151*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "1", 3116, 0, 144, 144, "", "", "" },
/*152*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "1", 3117, ZINT_ERROR_TOO_LONG, 0, 0, "Error 719: Input length 3117 too long (maximum 3116)", "", "" },
/*153*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "A", 2335, 0, 144, 144, "", "", "" },
/*154*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "A", 2336, ZINT_ERROR_TOO_LONG, 0, 0, "Error 729: Input too long, requires too many codewords (maximum 1558)", "Error 522: Input too long for Version 24, requires 1560 codewords (maximum 1558)", "" },
/*155*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "\200", 1556, 0, 144, 144, "", "", "Spec says 1555 but 1556 correct as only single byte count of 0 required" },
/*156*/ { BARCODE_DATAMATRIX, 24, { 0, 0, "" }, "\200", 1557, ZINT_ERROR_TOO_LONG, 0, 0, "Error 729: Input too long, requires too many codewords (maximum 1558)", "Error 520: Input too long, requires too many codewords (maximum 1558)", "" },
/*157*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "1", 10, 0, 8, 18, "", "", "" },
/*158*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "1", 11, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 25, requires 6 codewords (maximum 5)", "", "" },
/*159*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "A", 6, 0, 8, 18, "", "", "" },
/*160*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "A", 7, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 25, requires 6 codewords (maximum 5)", "", "" },
/*161*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "\200", 3, 0, 8, 18, "", "", "" },
/*162*/ { BARCODE_DATAMATRIX, 25, { 0, 0, "" }, "\200", 4, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 25, requires 6 codewords (maximum 5)", "", "" },
/*163*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "1", 20, 0, 8, 32, "", "", "" },
/*164*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "1", 21, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 26, requires 11 codewords (maximum 10)", "", "" },
/*165*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "A", 13, 0, 8, 32, "", "", "" },
/*166*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "A", 14, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 26, requires 11 codewords (maximum 10)", "Error 522: Input too long for Version 26, requires 12 codewords (maximum 10)", "" },
/*167*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "\200", 8, 0, 8, 32, "", "", "" },
/*168*/ { BARCODE_DATAMATRIX, 26, { 0, 0, "" }, "\200", 9, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 26, requires 11 codewords (maximum 10)", "", "" },
/*169*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "1", 32, 0, 12, 26, "", "", "" },
/*170*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "1", 33, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 27, requires 17 codewords (maximum 16)", "", "" },
/*171*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "A", 22, 0, 12, 26, "", "", "" },
/*172*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "A", 23, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 27, requires 17 codewords (maximum 16)", "Error 522: Input too long for Version 27, requires 18 codewords (maximum 16)", "" },
/*173*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "\200", 14, 0, 12, 26, "", "", "" },
/*174*/ { BARCODE_DATAMATRIX, 27, { 0, 0, "" }, "\200", 15, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 27, requires 17 codewords (maximum 16)", "", "" },
/*175*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "1", 44, 0, 12, 36, "", "", "" },
/*176*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "1", 45, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 28, requires 23 codewords (maximum 22)", "", "" },
/*177*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "A", 31, 0, 12, 36, "", "", "" },
/*178*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "A", 32, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 28, requires 23 codewords (maximum 22)", "Error 522: Input too long for Version 28, requires 24 codewords (maximum 22)", "" },
/*179*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "\200", 20, 0, 12, 36, "", "", "" },
/*180*/ { BARCODE_DATAMATRIX, 28, { 0, 0, "" }, "\200", 21, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 28, requires 23 codewords (maximum 22)", "", "" },
/*181*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "1", 64, 0, 16, 36, "", "", "" },
/*182*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "1", 65, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 29, requires 33 codewords (maximum 32)", "", "" },
/*183*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "A", 46, 0, 16, 36, "", "", "" },
/*184*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "A", 47, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 29, requires 33 codewords (maximum 32)", "Error 522: Input too long for Version 29, requires 34 codewords (maximum 32)", "" },
/*185*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "\200", 30, 0, 16, 36, "", "", "" },
/*186*/ { BARCODE_DATAMATRIX, 29, { 0, 0, "" }, "\200", 31, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 29, requires 33 codewords (maximum 32)", "", "" },
/*187*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "1", 98, 0, 16, 48, "", "", "" },
/*188*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "1", 99, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 30, requires 50 codewords (maximum 49)", "", "" },
/*189*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "A", 72, 0, 16, 48, "", "", "" },
/*190*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "A", 73, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 30, requires 50 codewords (maximum 49)", "", "" },
/*191*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "\200", 47, 0, 16, 48, "", "", "" },
/*192*/ { BARCODE_DATAMATRIX, 30, { 0, 0, "" }, "\200", 48, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 30, requires 50 codewords (maximum 49)", "", "" },
/*193*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "1", 36, 0, 8, 48, "", "", "" },
/*194*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "1", 37, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 31, requires 19 codewords (maximum 18)", "", "" },
/*195*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "A", 25, 0, 8, 48, "", "", "" },
/*196*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "A", 26, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 31, requires 19 codewords (maximum 18)", "Error 522: Input too long for Version 31, requires 20 codewords (maximum 18)", "" },
/*197*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "\200", 16, 0, 8, 48, "", "", "" },
/*198*/ { BARCODE_DATAMATRIX, 31, { 0, 0, "" }, "\200", 17, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 31, requires 19 codewords (maximum 18)", "", "" },
/*199*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "1", 48, 0, 8, 64, "", "", "" },
/*200*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "1", 49, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 32, requires 25 codewords (maximum 24)", "", "" },
/*201*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "A", 34, 0, 8, 64, "", "", "" },
/*202*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "A", 35, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 32, requires 25 codewords (maximum 24)", "Error 522: Input too long for Version 32, requires 26 codewords (maximum 24)", "" },
/*203*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "\200", 22, 0, 8, 64, "", "", "" },
/*204*/ { BARCODE_DATAMATRIX, 32, { 0, 0, "" }, "\200", 23, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 32, requires 25 codewords (maximum 24)", "", "" },
/*205*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "1", 64, 0, 8, 80, "", "", "" },
/*206*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "1", 65, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 33, requires 33 codewords (maximum 32)", "", "" },
/*207*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "A", 46, 0, 8, 80, "", "", "" },
/*208*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "A", 47, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 33, requires 33 codewords (maximum 32)", "Error 522: Input too long for Version 33, requires 34 codewords (maximum 32)", "" },
/*209*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "\200", 30, 0, 8, 80, "", "", "" },
/*210*/ { BARCODE_DATAMATRIX, 33, { 0, 0, "" }, "\200", 31, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 33, requires 33 codewords (maximum 32)", "", "" },
/*211*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "1", 76, 0, 8, 96, "", "", "" },
/*212*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "1", 77, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 34, requires 39 codewords (maximum 38)", "", "" },
/*213*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "A", 55, 0, 8, 96, "", "", "" },
/*214*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "A", 56, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 34, requires 39 codewords (maximum 38)", "Error 522: Input too long for Version 34, requires 40 codewords (maximum 38)", "" },
/*215*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "\200", 36, 0, 8, 96, "", "", "" },
/*216*/ { BARCODE_DATAMATRIX, 34, { 0, 0, "" }, "\200", 37, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 34, requires 39 codewords (maximum 38)", "", "" },
/*217*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "1", 98, 0, 8, 120, "", "", "" },
/*218*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "1", 99, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 35, requires 50 codewords (maximum 49)", "", "" },
/*219*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "A", 72, 0, 8, 120, "", "", "" },
/*220*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "A", 73, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 35, requires 50 codewords (maximum 49)", "", "" },
/*221*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "\200", 47, 0, 8, 120, "", "", "" },
/*222*/ { BARCODE_DATAMATRIX, 35, { 0, 0, "" }, "\200", 48, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 35, requires 50 codewords (maximum 49)", "", "" },
/*223*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "1", 126, 0, 8, 144, "", "", "" },
/*224*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "1", 127, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 36, requires 64 codewords (maximum 63)", "", "" },
/*225*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "A", 93, 0, 8, 144, "", "", "" },
/*226*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "A", 94, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 36, requires 64 codewords (maximum 63)", "", "" },
/*227*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "\200", 61, 0, 8, 144, "", "", "" },
/*228*/ { BARCODE_DATAMATRIX, 36, { 0, 0, "" }, "\200", 62, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 36, requires 64 codewords (maximum 63)", "", "" },
/*229*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "1", 86, 0, 12, 64, "", "", "" },
/*230*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "1", 87, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 37, requires 44 codewords (maximum 43)", "", "" },
/*231*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "A", 63, 0, 12, 64, "", "", "" },
/*232*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "A", 64, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 37, requires 44 codewords (maximum 43)", "", "" },
/*233*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "\200", 41, 0, 12, 64, "", "", "" },
/*234*/ { BARCODE_DATAMATRIX, 37, { 0, 0, "" }, "\200", 42, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 37, requires 44 codewords (maximum 43)", "", "" },
/*235*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "1", 128, 0, 12, 88, "", "", "" },
/*236*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "1", 129, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 38, requires 65 codewords (maximum 64)", "", "" },
/*237*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "A", 94, 0, 12, 88, "", "", "" },
/*238*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "A", 95, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 38, requires 65 codewords (maximum 64)", "Error 522: Input too long for Version 38, requires 66 codewords (maximum 64)", "" },
/*239*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "\200", 62, 0, 12, 88, "", "", "" },
/*240*/ { BARCODE_DATAMATRIX, 38, { 0, 0, "" }, "\200", 63, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 38, requires 65 codewords (maximum 64)", "", "" },
/*241*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "1", 124, 0, 16, 64, "", "", "" },
/*242*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "1", 125, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 39, requires 63 codewords (maximum 62)", "", "" },
/*243*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "A", 91, 0, 16, 64, "", "", "" },
/*244*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "A", 92, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 39, requires 63 codewords (maximum 62)", "Error 522: Input too long for Version 39, requires 64 codewords (maximum 62)", "" },
/*245*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "\200", 60, 0, 16, 64, "", "", "" },
/*246*/ { BARCODE_DATAMATRIX, 39, { 0, 0, "" }, "\200", 61, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 39, requires 63 codewords (maximum 62)", "", "" },
/*247*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "1", 88, 0, 20, 36, "", "", "" },
/*248*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "1", 89, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 40, requires 45 codewords (maximum 44)", "", "" },
/*249*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "A", 64, 0, 20, 36, "", "", "" },
/*250*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "A", 65, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 40, requires 45 codewords (maximum 44)", "Error 522: Input too long for Version 40, requires 46 codewords (maximum 44)", "" },
/*251*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "\200", 42, 0, 20, 36, "", "", "" },
/*252*/ { BARCODE_DATAMATRIX, 40, { 0, 0, "" }, "\200", 43, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 40, requires 45 codewords (maximum 44)", "", "" },
/*253*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "1", 112, 0, 20, 44, "", "", "" },
/*254*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "1", 113, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 41, requires 57 codewords (maximum 56)", "", "" },
/*255*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "A", 82, 0, 20, 44, "", "", "" },
/*256*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "A", 83, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 41, requires 57 codewords (maximum 56)", "Error 522: Input too long for Version 41, requires 58 codewords (maximum 56)", "" },
/*257*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "\200", 54, 0, 20, 44, "", "", "" },
/*258*/ { BARCODE_DATAMATRIX, 41, { 0, 0, "" }, "\200", 55, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 41, requires 57 codewords (maximum 56)", "", "" },
/*259*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "1", 168, 0, 20, 64, "", "", "Spec says 186 but typo" },
/*260*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "1", 169, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 42, requires 85 codewords (maximum 84)", "", "" },
/*261*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "A", 124, 0, 20, 64, "", "", "" },
/*262*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "A", 125, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 42, requires 85 codewords (maximum 84)", "Error 522: Input too long for Version 42, requires 86 codewords (maximum 84)", "" },
/*263*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "\200", 82, 0, 20, 64, "", "", "" },
/*264*/ { BARCODE_DATAMATRIX, 42, { 0, 0, "" }, "\200", 83, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 42, requires 85 codewords (maximum 84)", "", "" },
/*265*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "1", 144, 0, 22, 48, "", "", "" },
/*266*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "1", 145, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 43, requires 73 codewords (maximum 72)", "", "" },
/*267*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "A", 106, 0, 22, 48, "", "", "" },
/*268*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "A", 107, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 43, requires 73 codewords (maximum 72)", "Error 522: Input too long for Version 43, requires 74 codewords (maximum 72)", "" },
/*269*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "\200", 70, 0, 22, 48, "", "", "" },
/*270*/ { BARCODE_DATAMATRIX, 43, { 0, 0, "" }, "\200", 71, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 43, requires 73 codewords (maximum 72)", "", "" },
/*271*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "1", 160, 0, 24, 48, "", "", "" },
/*272*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "1", 161, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 44, requires 81 codewords (maximum 80)", "", "" },
/*273*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "A", 118, 0, 24, 48, "", "", "" },
/*274*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "A", 119, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 44, requires 81 codewords (maximum 80)", "Error 522: Input too long for Version 44, requires 82 codewords (maximum 80)", "" },
/*275*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "\200", 78, 0, 24, 48, "", "", "" },
/*276*/ { BARCODE_DATAMATRIX, 44, { 0, 0, "" }, "\200", 79, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 44, requires 81 codewords (maximum 80)", "", "" },
/*277*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "1", 216, 0, 24, 64, "", "", "" },
/*278*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "1", 217, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 45, requires 109 codewords (maximum 108)", "", "" },
/*279*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "A", 160, 0, 24, 64, "", "", "" },
/*280*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "A", 161, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 45, requires 109 codewords (maximum 108)", "Error 522: Input too long for Version 45, requires 110 codewords (maximum 108)", "" },
/*281*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "\200", 106, 0, 24, 64, "", "", "" },
/*282*/ { BARCODE_DATAMATRIX, 45, { 0, 0, "" }, "\200", 107, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 45, requires 109 codewords (maximum 108)", "", "" },
/*283*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "1", 140, 0, 26, 40, "", "", "" },
/*284*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "1", 141, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 46, requires 71 codewords (maximum 70)", "", "" },
/*285*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "A", 103, 0, 26, 40, "", "", "" },
/*286*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "A", 104, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 46, requires 71 codewords (maximum 70)", "Error 522: Input too long for Version 46, requires 72 codewords (maximum 70)", "" },
/*287*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "\200", 68, 0, 26, 40, "", "", "" },
/*288*/ { BARCODE_DATAMATRIX, 46, { 0, 0, "" }, "\200", 69, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 46, requires 71 codewords (maximum 70)", "", "" },
/*289*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "1", 180, 0, 26, 48, "", "", "" },
/*290*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "1", 181, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 47, requires 91 codewords (maximum 90)", "", "" },
/*291*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "A", 133, 0, 26, 48, "", "", "" },
/*292*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "A", 134, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 47, requires 91 codewords (maximum 90)", "Error 522: Input too long for Version 47, requires 92 codewords (maximum 90)", "" },
/*293*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "\200", 88, 0, 26, 48, "", "", "" },
/*294*/ { BARCODE_DATAMATRIX, 47, { 0, 0, "" }, "\200", 89, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 47, requires 91 codewords (maximum 90)", "", "" },
/*295*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "1", 236, 0, 26, 64, "", "", "" },
/*296*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "1", 237, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 48, requires 119 codewords (maximum 118)", "", "" },
/*297*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "A", 175, 0, 26, 64, "", "", "" },
/*298*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "A", 176, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 48, requires 119 codewords (maximum 118)", "Error 522: Input too long for Version 48, requires 120 codewords (maximum 118)", "" },
/*299*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "\200", 116, 0, 26, 64, "", "", "" },
/*300*/ { BARCODE_DATAMATRIX, 48, { 0, 0, "" }, "\200", 117, ZINT_ERROR_TOO_LONG, 0, 0, "Error 522: Input too long for Version 48, requires 119 codewords (maximum 118)", "", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[ZINT_MAX_DATA_LEN];
char escaped[64];
testStartSymbol("test_large", &symbol);
@ -374,7 +378,22 @@ static void test_large(const testCtx *const p_ctx) {
}
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
if (p_ctx->generate) {
char errtxt[sizeof(symbol->errtxt)];
strcpy(errtxt, symbol->errtxt);
printf(" /*%3d*/ { %s, %d, { %d, %d, \"%s\" }, \"%s\", %d, %s, %d, %d, \"%s\",",
i, testUtilBarcodeName(data[i].symbology), data[i].option_2,
data[i].structapp.index, data[i].structapp.count, data[i].structapp.id,
testUtilEscape(data[i].pattern, (int) strlen(data[i].pattern), escaped, sizeof(escaped)), data[i].length,
testUtilErrorName(ret), symbol->rows, symbol->width, errtxt);
symbol->input_mode |= FAST_MODE;
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
printf(" \"%s\", \"%s\" },\n", strcmp(errtxt, symbol->errtxt) != 0 ? symbol->errtxt : "", data[i].comment);
} else {
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -384,10 +403,18 @@ static void test_large(const testCtx *const p_ctx) {
symbol->input_mode |= FAST_MODE;
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
} else {
if (data[i].expected_errtxt2[0]) {
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt2), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt2);
} else {
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
}
}
}
ZBarcode_Delete(symbol);
@ -409,11 +436,11 @@ static void test_buffer(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 16383, UNICODE_MODE, READER_INIT, "1", 0, "" },
/* 1*/ { 3, UNICODE_MODE, 0, "000106j 05 Galeria A Nação0000000000", 0, "From Okapi, consecutive use of upper shift; #176" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -456,7 +483,7 @@ static void test_options(const testCtx *const p_ctx) {
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 0, 0, "" }, "1", 0, 10, 10, "" },
/* 1*/ { BARCODE_DATAMATRIX, -1, 2, -1, -1, -1, { 0, 0, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 524: Older Data Matrix standards are no longer supported" },
/* 2*/ { BARCODE_DATAMATRIX, -1, -1, 1, -1, -1, { 0, 0, "" }, "1", 0, 10, 10, "" },
@ -464,7 +491,7 @@ static void test_options(const testCtx *const p_ctx) {
/* 4*/ { BARCODE_DATAMATRIX, -1, -1, 48, -1, -1, { 0, 0, "" }, "1", 0, 26, 64, "" },
/* 5*/ { BARCODE_DATAMATRIX, -1, -1, 49, -1, -1, { 0, 0, "" }, "1", 0, 10, 10, "" }, /* Ignored */
/* 6*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 0, 0, "" }, "____", 0, 12, 12, "" }, /* 4 data */
/* 7*/ { BARCODE_DATAMATRIX, -1, -1, 1, -1, -1, { 0, 0, "" }, "____", ZINT_ERROR_TOO_LONG, -1, -1, "Error 522: Input too long for selected symbol size" },
/* 7*/ { BARCODE_DATAMATRIX, -1, -1, 1, -1, -1, { 0, 0, "" }, "____", ZINT_ERROR_TOO_LONG, -1, -1, "Error 522: Input too long for Version 1, requires 4 codewords (maximum 3)" },
/* 8*/ { BARCODE_DATAMATRIX, -1, -1, 25, -1, -1, { 0, 0, "" }, "____", 0, 8, 18, "" },
/* 9*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 0, 0, "" }, "__________", 0, 8, 32, "" }, /* 10 data */
/* 10*/ { BARCODE_DATAMATRIX, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "__________", 0, 8, 32, "" },
@ -541,23 +568,24 @@ static void test_options(const testCtx *const p_ctx) {
/* 81*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)12", 0, 10, 10, "" },
/* 82*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "" },
/* 83*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "" },
/* 84*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 1, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count out of range (2-16)" },
/* 85*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 17, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count out of range (2-16)" },
/* 86*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 0, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index out of range (1-16)" },
/* 87*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 17, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index out of range (1-16)" },
/* 84*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 1, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '1' out of range (2 to 16)" },
/* 85*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 17, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '17' out of range (2 to 16)" },
/* 86*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 0, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '0' out of range (1 to count 16)" },
/* 87*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 17, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '17' out of range (1 to count 16)" },
/* 88*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "1", 0, 12, 12, "" },
/* 89*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "A" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 723: Invalid Structured Append ID (digits only)" },
/* 90*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "0" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '000' and ID2 '000' out of range (001-254) (ID '000000')" },
/* 91*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '000' out of range (001-254) (ID '000001')" },
/* 92*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1000" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '000' out of range (001-254) (ID '001000')" },
/* 93*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "001255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '255' out of range (001-254) (ID '001255')" },
/* 94*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "255001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '255' out of range (001-254) (ID '255001')" },
/* 95*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "255255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '255' and ID2 '255' out of range (001-254) (ID '255255')" },
/* 96*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1234567" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 722: Structured Append ID too long (6 digit maximum)" },
/* 90*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "0" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '000' and ID2 '000' out of range (001 to 254) (ID \"000000\")" },
/* 91*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '000' out of range (001 to 254) (ID \"000001\")" },
/* 92*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1000" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '000' out of range (001 to 254) (ID \"001000\")" },
/* 93*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "001255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '255' out of range (001 to 254) (ID \"001255\")" },
/* 94*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "255001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '255' out of range (001 to 254) (ID \"255001\")" },
/* 95*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "255255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '255' and ID2 '255' out of range (001 to 254) (ID \"255255\")" },
/* 96*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 2, 3, "1234567" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 722: Structured Append ID length 7 too long (6 digit maximum)" },
/* 97*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, READER_INIT, { 2, 3, "1001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 727: Cannot have Structured Append and Reader Initialisation at the same time" },
/* 98*/ { BARCODE_DATAMATRIX, ESCAPE_MODE, -1, -1, -1, -1, { 2, 3, "1001" }, "[)>\\R05\\GA\\R\\E", 0, 12, 26, "" }, /* Macro05/06 ignored if have Structured Append TODO: error/warning */
/* 99*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234,67", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 5 in input (alphanumerics, space and \"-.$/+%\" only)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -615,11 +643,11 @@ static void test_reader_init(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, READER_INIT, "A", 0, 10, 10, "EA 42 81 19 A4 53 21 DF", "TODO: Check this" },
/* 1*/ { BARCODE_DATAMATRIX, GS1_MODE, READER_INIT, "[91]A", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 521: Cannot encode in GS1 mode and Reader Initialisation at the same time", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -687,7 +715,7 @@ static void test_input(const testCtx *const p_ctx) {
int expected_diff; /* Difference between default minimal encodation and ISO encodation (FAST_MODE) */
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, 1, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "#208", 0 },
/* 1*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, 1, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "#208", 0 },
/* 2*/ { UNICODE_MODE | FAST_MODE, 0, 5, -1, -1, "0466010592130100000k*AGUATY80", 0, 0, 18, 18, 1, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 93 B0 1C 3C 76 FB D4 AB 16 11", "", 0 },
@ -696,8 +724,8 @@ static void test_input(const testCtx *const p_ctx) {
/* 5*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY8", 0, 0, 18, 18, 0, "(32) 86 C4 83 87 DE 8F 83 82 82 31 6C 2B 42 E6 82 5F D4 3D 0A 34 D7 21 4E D2 8D C5 9C D7", "AAAAAAAAAAAAAAAAAAAAAACCCCCC; BWIPP different encodation", 0 },
/* 6*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, 1, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "", 0 },
/* 7*/ { UNICODE_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, 0, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C F0 A8 11 D5 05 46 5F D2 56 81 76 3C D6 92 14 9F E2", "AAAAAAAAAAAAAAAAAAAAEEEEEEEAAA; BWIPP same as FAST_MODE", 0 },
/* 8*/ { UNICODE_MODE | FAST_MODE, 0, 5, -1, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, 0, "Error 522: Input too long for selected symbol size", "", 0 },
/* 9*/ { UNICODE_MODE, 0, 5, -1, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, 0, "Error 522: Input too long for selected symbol size", "", 0 },
/* 8*/ { UNICODE_MODE | FAST_MODE, 0, 5, -1, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, 0, "Error 522: Input too long for Version 5, requires 19 codewords (maximum 18)", "", 0 },
/* 9*/ { UNICODE_MODE, 0, 5, -1, -1, "0466010592130100000k*AGUATY80U", ZINT_ERROR_TOO_LONG, -1, 0, 0, 0, "Error 522: Input too long for Version 5, requires 19 codewords (maximum 18)", "", 0 },
/* 10*/ { UNICODE_MODE | FAST_MODE, 0, 6, -1, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, 1, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C EE 08 85 D6 D2 EF 65 FE 56 81 76 4F AB 22 B8 6F 0A", "", 0 },
/* 11*/ { UNICODE_MODE, 0, 6, -1, -1, "0466010592130100000k*AGUATY80U", 0, 0, 20, 20, 0, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C F0 A8 11 D5 05 46 5F D2 56 81 76 3C D6 92 14 9F E2", "AAAAAAAAAAAAAAAAAAAAEEEEEEEAAA; BWIPP same as FAST_MODE", 0 },
/* 12*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, "0466010592130100000k*AGUATY80UA", 0, 0, 20, 20, 1, "(40) 86 C4 83 87 DE 8F 83 82 82 31 6C E6 07 B7 82 5F D4 3D 1E 5F FE 81 1E 1B B0 FE E7 54", "", 0 },
@ -934,7 +962,7 @@ static void test_input(const testCtx *const p_ctx) {
/*243*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, "A*B>C 1A*B>C\013 1*B>C 1A*B>C 1A*", 0, 0, 22, 22, 1, "(50) EE 57 B8 0F 04 21 72 5E 21 FE 0C EE 13 8A 5E 21 13 97 08 9B 64 7E FE 42 2B 81 68 FE", "process_p 0", 1 },
/*244*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, "A*B>C 1A*B>C 1*\013B>C 1A*B>C 1A*", 0, 0, 22, 22, 1, "(50) EE 57 B8 0F 04 21 72 5E 21 13 8A FE 0C EE 5E 21 13 97 08 9B 64 7E FE 42 2B 81 68 FE", "process_p 0", 1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -1085,7 +1113,7 @@ static void test_encode(const testCtx *const p_ctx) {
/* Verified manually against ISO/IEC 16022:2006, ISO/IEC 21471:2020, GS1 General Specifications 21.0.1 (GGS), ANSI/HIBC LIC 2.6-2016 (HIBC/LIC),
ANSI/HIBC PAS 1.3-2010 (HIBC/PAS) and AIM ITS/04-023:2022 (ECI Part 3: Register), with noted exceptions
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, FAST_MODE, -1, -1, -1, -1, "1234abcd", -1, 0, 14, 14, 1, "", 0,
"10101010101010"
"11001010001111"
@ -5503,7 +5531,7 @@ static void test_encode(const testCtx *const p_ctx) {
"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -5637,7 +5665,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 14, 14, 1, "ISO 16022:2006 11.6 example",
"10101010101010"
"10000100111111"
@ -5799,7 +5827,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"11111111111111111111111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
@ -5915,7 +5943,7 @@ static void test_minimalenc(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, "A", -1, 0, 0, "ASC" },
/* 1*/ { BARCODE_DATAMATRIX, -1, -1, -1, "AA", -1, 0, 0, "ASC" },
/* 2*/ { BARCODE_DATAMATRIX, -1, -1, -1, "AAA", -1, 0, 0, "ASC" },
@ -6934,7 +6962,7 @@ static void test_minimalenc(const testCtx *const p_ctx) {
/*1015*/ { BARCODE_DATAMATRIX, -1, -1, -1, "\200\200\200@A1^B2?C\200\200\200", -1, 0, 0, "" },
/*1016*/ { BARCODE_DATAMATRIX, -1, -1, -1, "@@@@@@@@@_", -1, 0, 1, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -7017,7 +7045,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, FAST_MODE, -1, -1,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM"
"NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK"
@ -7089,7 +7117,7 @@ static void test_perf(const testCtx *const p_ctx) {
/* 4*/ { BARCODE_DATAMATRIX, FAST_MODE, -1, -1, "https://example.com/01/09506000134369", 0, 22, 22, "37 chars, text/numeric" },
/* 5*/ { BARCODE_DATAMATRIX, -1, -1, -1, "https://example.com/01/09506000134369", 0, 22, 22, "37 chars, text/numeric" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -39,17 +39,18 @@ static void test_large(const testCtx *const p_ctx) {
char datum;
int length;
int ret;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { 200, '0', 2940, 0 }, /* 2940 largest Code Set C data that fits in 200x199 HxW */
/* 1*/ { 200, '0', 2941, ZINT_ERROR_INVALID_OPTION },
/* 2*/ { 200, '9', 200, 0 }, /* Changes a number of mask scores re pre-Rev. 4 version, but best score still the same (7) */
/* 3*/ { 201, '0', 2940, ZINT_ERROR_INVALID_OPTION },
/* 4*/ { 201, '0', 2974, ZINT_ERROR_INVALID_OPTION }, /* Height > 200 also */
/* 5*/ { 30, '\001', 71, 0 }, /* Codeword length 72, ECC length 39, for ND + 1 == 112 */
static const struct item data[] = {
/* 0*/ { 200, '0', 2940, 0, "" }, /* 2940 largest Code Set C data that fits in 200x199 HxW */
/* 1*/ { 200, '0', 2941, ZINT_ERROR_INVALID_OPTION, "Error 528: Symbol height '201' is too large" },
/* 2*/ { 200, '9', 200, 0, "" }, /* Changes a number of mask scores re pre-Rev. 4 version, but best score still the same (7) */
/* 3*/ { 201, '0', 2940, ZINT_ERROR_INVALID_OPTION, "Error 528: Symbol width '201' is too large" },
/* 4*/ { 201, '0', 2974, ZINT_ERROR_INVALID_OPTION, "Error 526: Symbol size '201x202' (WxH) is too large" }, /* Height > 200 also */
/* 5*/ { 30, '\001', 71, 0, "" }, /* Codeword length 72, ECC length 39, for ND + 1 == 112 */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -70,6 +71,7 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
ZBarcode_Delete(symbol);
}
@ -95,29 +97,29 @@ static void test_options(const testCtx *const p_ctx) {
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, -1, -1, -1, { 0, 0, "" }, "1", 0, 9, 14, "" },
/* 1*/ { -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890", 0, 12, 19, "" },
/* 2*/ { -1, -1, -1, 19, -1, { 0, 0, "" }, "1234567890", 0, 12, 19, "" },
/* 3*/ { -1, -1, -1, 12, -1, { 0, 0, "" }, "1234567890", 0, 19, 12, "" },
/* 4*/ { -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890", 0, 44, 5, "" },
/* 5*/ { -1, -1, -1, 4, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol width 4 is too small" }, /* Cols < 5 */
/* 6*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol height 3 is too small" }, /* Not enough data - height 3 too small */
/* 5*/ { -1, -1, -1, 4, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol width '4' is too small" }, /* Cols < 5 */
/* 6*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 529: Symbol height '3' is too small" }, /* Not enough data - height 3 too small */
/* 7*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890", 0, 5, 200, "" }, /* Cols 200 max */
/* 8*/ { -1, -1, -1, 200, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 7, 200, "" },
/* 9*/ { -1, -1, -1, 201, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 528: Symbol width 201 is too large" },
/* 9*/ { -1, -1, -1, 201, -1, { 0, 0, "" }, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 528: Symbol width '201' is too large" },
/* 10*/ { -1, -1, -1, -1, 10 << 8, { 0, 0, "" }, "1", 0, 9, 14, "" }, /* Mask > 8 + 1 ignored */
/* 11*/ { -1, -1, -1, 19, -1, { 0, 0, "" }, "ABCDE", 0, 12, 19, "" },
/* 12*/ { -1, -1, -1, 19, -1, { 35, 35, "" }, "ABCDE", 0, 16, 19, "" },
/* 13*/ { -1, -1, -1, 19, -1, { 1, 1, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count out of range (2-35)" },
/* 14*/ { -1, -1, -1, 19, -1, { 1, 36, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count out of range (2-35)" },
/* 15*/ { -1, -1, -1, 19, -1, { 3, 2, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 731: Structured Append index out of range (1-2)" },
/* 13*/ { -1, -1, -1, 19, -1, { 1, 1, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count '1' out of range (2 to 35)" },
/* 14*/ { -1, -1, -1, 19, -1, { 1, 36, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 730: Structured Append count '36' out of range (2 to 35)" },
/* 15*/ { -1, -1, -1, 19, -1, { 3, 2, "" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 731: Structured Append index '3' out of range (1 to count 2)" },
/* 16*/ { -1, -1, -1, 19, -1, { 1, 2, "1" }, "ABCDE", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 732: Structured Append ID not available for DotCode" },
/* 17*/ { GS1_MODE, 3, -1, -1, -1, { 0, 0, "" }, "[20]01", ZINT_WARN_NONCOMPLIANT, 11, 16, "Warning 733: Using ECI in GS1 mode not supported by GS1 standards" },
/* 18*/ { GS1_MODE, -1, -1, -1, -1, { 1, 2, "" }, "[20]01", ZINT_WARN_NONCOMPLIANT, 12, 19, "Warning 734: Using Structured Append in GS1 mode not supported by GS1 standards" },
/* 19*/ { GS1_MODE, 3, -1, -1, -1, { 1, 2, "" }, "[20]01", ZINT_WARN_NONCOMPLIANT, 14, 21, "Warning 733: Using ECI in GS1 mode not supported by GS1 standards" }, /* ECI trumps Structured Append */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -166,7 +168,7 @@ static void test_input(const testCtx *const p_ctx) {
int bwipp_cmp;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "A", -1, 0, "66 21 6A", 1, "" },
/* 1*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "A", -1, 0, "6C 03 66 21", 1, "" },
/* 2*/ { UNICODE_MODE, 40, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 00 00 66 21", 1, "" },
@ -174,7 +176,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 4*/ { UNICODE_MODE, 899, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 28 07 44 66 21", 1, "" },
/* 5*/ { UNICODE_MODE, 12769, 18, 8 << 8, { 0, 0, "" }, "A", -1, 0, "6C 28 70 49 66 21", 1, "" },
/* 6*/ { UNICODE_MODE, 811799, 18, -1, { 0, 0, "" }, "A", -1, 0, "6C 67 40 50 66 21", 1, "" },
/* 7*/ { UNICODE_MODE, 811800, -1, -1, { 0, 0, "" }, "A", -1, ZINT_ERROR_INVALID_OPTION, "Error 525: Invalid ECI", 1, "" },
/* 7*/ { UNICODE_MODE, 811800, -1, -1, { 0, 0, "" }, "A", -1, ZINT_ERROR_INVALID_OPTION, "Error 525: ECI code '811800' out of range (0 to 811799)", 1, "" },
/* 8*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\000", 1, 0, "65 40 6A", 1, "LatchA (0x65) NUL PAD" },
/* 9*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\010", -1, 0, "65 48 6A", 1, "LatchA (0x65) BS PAD" },
/* 10*/ { UNICODE_MODE, -1, 13, -1, { 0, 0, "" }, "\011", -1, 0, "65 49 6A", 1, "Lead special; LatchA (0x65) HT PAD" },
@ -210,7 +212,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 40*/ { UNICODE_MODE, -1, -1, -1, { 2, 3, "" }, "\001\002\003\004", -1, 0, "65 41 42 43 44 6A 12 13 6C", 1, "LatchA (0x65) <SOH> <STX> <ETX> <EOT> PAD 2 3 FNC2" },
/* 41*/ { DATA_MODE, -1, -1, -1, { 1, 34, "" }, "\200\201\202\203", -1, 0, "70 13 56 0A 59 2C 6D 11 39 6C", 1, "BinaryLatch (0x70) (...) TermA (0x6D) 1 Y FNC2" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -306,7 +308,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *expected;
};
/* ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019 */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { GS1_MODE, 64, -1, { 0, 0, "" }, "[01]00012345678905[17]201231[10]ABC123456", -1, 0, 9, 64, 1, 1, "ISS DotCode Rev 4.0 Figure 1 (left), same",
"1010000000101000101010000010000010001010100010101000101000001010"
"0100010001010001010001000001010100010100010001000100010101000001"
@ -1077,7 +1079,7 @@ static void test_encode(const testCtx *const p_ctx) {
"10100010000010101010000010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -1179,7 +1181,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *expected;
};
/* ISS DotCode, Rev 4.0, DRAFT 0.15, TSC Pre-PR #5, MAY 28, 2019 */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 18, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 13, 18, 1, 1, "ISS DotCode Rev 4.0 13.5 example **NOT SAME** different encodation",
"100000001010101010"
"000100000100010101"
@ -1457,7 +1459,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"01000101000001010100000100010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
@ -1567,7 +1569,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { DATA_MODE, "(\207'", -1, 0 }, /* 0x28,0x87,0x27 Note: should but doesn't trigger sanitize error if no length check, for some reason; UPDATE: use up-to-date gcc (9)! */
/* 1*/ { DATA_MODE,
"\133\061\106\133\061\106\070\161\116\133\116\116\067\040\116\016\000\116\125\111\125\125\316\125\125\116\116\116\116\117\116\125"
@ -1591,7 +1593,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
/* 5*/ { DATA_MODE, "\237\032", -1, 0 }, /* As above L904 */
/* 6*/ { DATA_MODE, "\237", -1, 0 }, /* As above L1090 */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -1692,7 +1694,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DOTCODE, -1, -1, -1,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM"
"NOPQRSTUVWXYZ;<>@[]_`~!||()?{}'123456789012345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJK"
@ -1702,7 +1704,7 @@ static void test_perf(const testCtx *const p_ctx) {
"fghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO",
0, 124, 185, "960 chars, text/numeric" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -53,7 +53,7 @@ static void test_print(const testCtx *const p_ctx) {
char *expected_file;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0.0f, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.emf", "" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0.0f, 100.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_100dpi.emf", "" },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0.0f, 150.0f / 25.4f, "", "", 0, "Égjpqy", "code128_egrave_bold_150dpi.emf", "" },
@ -95,7 +95,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 38*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 0.0f, 300.0f, "", "FFFFFF00", 90, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", "maxicode_rotate_90_nobg_300dpi.emf", "" },
/* 39*/ { BARCODE_UPU_S10, -1, -1, CMYK_COLOUR, -1, -1, -1, -1, 0.0f, 0, "71,0,40,44", "FFFFFF00", 0, "QA47312482PS", "upu_s10_cmyk_nobg.emf", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -229,12 +229,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "640: Could not open EMF output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "emf_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = emf_plot(&symbol, 0);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "emf_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "emf_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -45,7 +45,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, 1, 1, "1", 0, 0 },
/* 1*/ { BARCODE_CODE128, 2, 1, "11", 0, 0 },
/* 2*/ { BARCODE_CODE128, 3, 1, "101", 0, 0 },
@ -58,7 +58,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
/* 9*/ { BARCODE_ULTRA, 19, 32, "WWCWBWMWRWYWGWKCCWCMCRCYCGCKBWBCBBMBRBYBGBKMWMCMBMMRMYMGMKRWRCRBRMRRYRGRKYWYCYBYMYRYYGYKGWGCGBGMGRGYGGKKWK", 1, 0 }, /* Two LZW blocks, last size 1 */
/* 10*/ { BARCODE_ULTRA, 1, 1, "D", 0, 0 }, /* This used to fail, now just maps unknown codes to 0 (1st colour index) */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol *symbol = NULL;
@ -143,7 +143,7 @@ static void test_print(const testCtx *const p_ctx) {
char *expected_file;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "12", "dotcode_1.0.gif", "" },
/* 1*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 0.1, { 0, 0, "" }, "", "", "12", "dotcode_1.0_ds0.1.gif", "" },
/* 2*/ { BARCODE_DOTCODE, -1, -1, -1, -1, -1, -1, 0, 0, 1.1, { 0, 0, "" }, "", "", "12", "dotcode_1.0_ds1.1.gif", "" },
@ -182,7 +182,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 35*/ { BARCODE_ULTRA, -1, -1, 1, -1, -1, 2, 0, 0, 0, { 0, 0, "" }, "", "", "12", "ultra_rev2.gif", "Revision 2" },
/* 36*/ { BARCODE_DPD, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, 0, 0, 0, { 0, 0, "" }, "", "", "008182709980000020028101276", "dpd_compliant.gif", "Now with bind top 3X default" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -314,12 +314,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "611: Could not open GIF output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "gif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = gif_pixel_plot(&symbol, data);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "gif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "gif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,36 +42,58 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { -1, -1, "1", 2751, 0, 162, 162 },
/* 1*/ { -1, -1, "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { -1, -1, "1", 2755, ZINT_ERROR_TOO_LONG, -1, -1 }, /* Triggers buffer > 9191 */
/* 3*/ { -1, -1, "A", 1836, 0, 162, 162 },
/* 4*/ { -1, -1, "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 5*/ { -1, -1, "A1", 1529, 0, 162, 162 },
/* 6*/ { -1, -1, "A1", 1530, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 7*/ { -1, -1, "\200", 1143, 0, 162, 162 },
/* 8*/ { -1, -1, "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { -1, ZINT_FULL_MULTIBYTE, "\241", 1410, 0, 162, 162 },
/* 10*/ { -1, ZINT_FULL_MULTIBYTE, "\241", 1412, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { 1, -1, "1", 18, 0, 18, 18 },
/* 12*/ { 1, -1, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 13*/ { 1, -1, "A", 13, 0, 18, 18 },
/* 14*/ { 1, -1, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 15*/ { 1, -1, "\200", 7, 0, 18, 18 },
/* 16*/ { 1, -1, "\200", 8, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 17*/ { 1, ZINT_FULL_MULTIBYTE, "\241", 8, 0, 18, 18 },
/* 18*/ { 1, ZINT_FULL_MULTIBYTE, "\241", 10, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 19*/ { 11, -1, "1", 1995, 0, 138, 138 },
/* 20*/ { 11, -1, "1", 1996, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { -1, -1, "1", 2751, 0, 162, 162, "" },
/* 1*/ { -1, -1, "1", 2752, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" },
/* 2*/ { -1, -1, "1", 2755, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" }, /* Triggers buffer > 9191 */
/* 3*/ { -1, -1, "A", 1836, 0, 162, 162, "" },
/* 4*/ { -1, -1, "A", 1837, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" },
/* 5*/ { -1, -1, "A1", 1529, 0, 162, 162, "" },
/* 6*/ { -1, -1, "A1", 1530, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" },
/* 7*/ { -1, -1, "\200", 1143, 0, 162, 162, "" },
/* 8*/ { -1, -1, "\200", 1144, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" },
/* 9*/ { -1, ZINT_FULL_MULTIBYTE, "\241", 1410, 0, 162, 162, "" },
/* 10*/ { -1, ZINT_FULL_MULTIBYTE, "\241", 1412, ZINT_ERROR_TOO_LONG, -1, -1, "Error 531: Input too long, requires too many codewords (maximum 1313)" },
/* 11*/ { 1, -1, "1", 18, 0, 18, 18, "" },
/* 12*/ { 1, -1, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 13 codewords (maximum 11)" },
/* 13*/ { 1, -1, "A", 13, 0, 18, 18, "" },
/* 14*/ { 1, -1, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" },
/* 15*/ { 1, -1, "\200", 7, 0, 18, 18, "" },
/* 16*/ { 1, -1, "\200", 8, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" },
/* 17*/ { 1, ZINT_FULL_MULTIBYTE, "\241", 8, 0, 18, 18, "" },
/* 18*/ { 1, ZINT_FULL_MULTIBYTE, "\241", 10, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 12 codewords (maximum 11)" },
/* 19*/ { 2, ZINT_FULL_MULTIBYTE, "\241", 40, 0, 30, 30, "" },
/* 20*/ { 2, ZINT_FULL_MULTIBYTE, "\241", 41, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 2, requires 42 codewords (maximum 40)" },
/* 21*/ { 3, -1, "A", 108, 0, 42, 42, "" },
/* 22*/ { 3, -1, "A", 109, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 3, requires 80 codewords (maximum 79)" },
/* 23*/ { 4, -1, "A", 202, 0, 54, 54, "" },
/* 24*/ { 4, -1, "A", 203, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 4, requires 147 codewords (maximum 146)" },
/* 25*/ { 5, -1, "1", 453, 0, 66, 66, "" },
/* 26*/ { 5, -1, "1", 454, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 5, requires 220 codewords (maximum 218)" },
/* 27*/ { 6, -1, "1", 633, 0, 78, 78, "" },
/* 28*/ { 6, -1, "1", 634, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 6, requires 306 codewords (maximum 305)" },
/* 29*/ { 7, -1, "\200", 352, 0, 90, 90, "" },
/* 30*/ { 7, -1, "\200", 353, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 7, requires 406 codewords (maximum 405)" },
/* 31*/ { 8, -1, "A", 727, 0, 102, 102, "" },
/* 32*/ { 8, -1, "A", 728, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 8, requires 522 codewords (maximum 521)" },
/* 33*/ { 9, -1, "A", 908, 0, 114, 114, "" },
/* 34*/ { 9, -1, "A", 909, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 9, requires 651 codewords (maximum 650)" },
/* 35*/ { 10, -1, "1", 1662, 0, 126, 126, "" },
/* 36*/ { 10, -1, "1", 1663, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 10, requires 796 codewords (maximum 794)" },
/* 37*/ { 11, -1, "1", 1995, 0, 138, 138, "" },
/* 38*/ { 11, -1, "1", 1996, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 11, requires 954 codewords (maximum 953)" },
/* 39*/ { 11, -1, "1", 2748, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 11, requires 1311 codewords (maximum 953)" },
/* 40*/ { 12, -1, "1", 2355, 0, 150, 150, "" },
/* 41*/ { 12, -1, "1", 2356, ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 12, requires 1126 codewords (maximum 1125)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[2755 + 1];
char data_buf[2800 + 1];
testStartSymbol("test_large", &symbol);
@ -89,6 +111,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -115,13 +139,13 @@ static void test_options(const testCtx *const p_ctx) {
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 0, 0, { 0, 0, "" }, "12345", 0, 0, 18, "" },
/* 1*/ { 0, 1, { 0, 0, "" }, "12345", 0, 0, 18, "" },
/* 2*/ { 0, 2, { 0, 0, "" }, "12345", 0, 0, 30, "" },
/* 3*/ { 0, 14, { 0, 0, "" }, "12345", 0, 0, 18, "" }, /* Version > max version 13 so ignored */
/* 4*/ { 0, 13, { 0, 0, "" }, "12345", 0, 0, 162, "" },
/* 5*/ { 0, 1, { 0, 0, "" }, "1234567890123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input data too long for selected symbol size" },
/* 5*/ { 0, 1, { 0, 0, "" }, "1234567890123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 534: Input too long for Version 1, requires 13 codewords (maximum 11)" },
/* 6*/ { 0, 2, { 0, 0, "" }, "1234567890123456789", 0, 0, 30, "" },
/* 7*/ { 0, 0, { 0, 0, "" }, "123456789012345678", 0, 0, 30, "" }, /* Version auto-set to 2 */
/* 8*/ { 0, 1, { 0, 0, "" }, "123456789012345678", 0, 0, 18, "" },
@ -131,16 +155,16 @@ static void test_options(const testCtx *const p_ctx) {
/* 12*/ { 1, 0, { 0, 0, "" }, "123456789012345678", 0, 0, 30, "" }, /* ECC < min ECC 2, ECC 2 used */
/* 13*/ { 4, 1, { 0, 0, "" }, "123456789012345678", 0, 0, 18, "" },
/* 14*/ { 0, 0, { 1, 2, "" }, "12345", 0, 0, 18, "" },
/* 15*/ { 0, 0, { 1, 1, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 536: Structured Append count out of range (2-16)" },
/* 16*/ { 0, 0, { 1, 17, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 536: Structured Append count out of range (2-16)" },
/* 17*/ { 0, 0, { 0, 2, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 537: Structured Append index out of range (1-2)" },
/* 18*/ { 0, 0, { 3, 2, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 537: Structured Append index out of range (1-2)" },
/* 15*/ { 0, 0, { 1, 1, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 536: Structured Append count '1' out of range (2 to 16)" },
/* 16*/ { 0, 0, { 1, 17, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 536: Structured Append count '17' out of range (2 to 16)" },
/* 17*/ { 0, 0, { 0, 2, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 537: Structured Append index '0' out of range (1 to count 2)" },
/* 18*/ { 0, 0, { 3, 2, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 537: Structured Append index '3' out of range (1 to count 2)" },
/* 19*/ { 0, 0, { 1, 2, "255" }, "12345", 0, 0, 18, "" },
/* 20*/ { 0, 0, { 1, 2, "1234" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 538: Structured Append ID too long (3 digit maximum)" },
/* 20*/ { 0, 0, { 1, 2, "1234" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 538: Structured Append ID length 4 too long (3 digit maximum)" },
/* 21*/ { 0, 0, { 1, 2, "A" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 539: Invalid Structured Append ID (digits only)" },
/* 22*/ { 0, 0, { 1, 2, "256" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 530: Structured Append ID '256' out of range (0-255)" },
/* 22*/ { 0, 0, { 1, 2, "256" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 530: Structured Append ID value '256' out of range (0 to 255)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -199,7 +223,7 @@ static void test_input(const testCtx *const p_ctx) {
U+3229 in GB 2312 0x226E
U+4E00 in GB 2312 0x523B
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "é", 0, 0, "08 54 6F 78 00", "H1 (GB 2312) Note: Grid Matrix default is GB 2312, not ISO 8859-1" },
/* 1*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "é", 0, 3, "60 01 58 00 74 40", "ECI-3 B1 (ISO 8859-1)" },
/* 2*/ { UNICODE_MODE, 29, -1, -1, { 0, 0, "" }, "é", 0, 29, "60 0E 44 2A 37 7C 00", "ECI-29 H1 (GB 2312)" },
@ -308,8 +332,8 @@ static void test_input(const testCtx *const p_ctx) {
/*105*/ { UNICODE_MODE, 900, -1, -1, { 0, 0, "" }, "é", 0, 900, "63 42 18 01 61 6A 20", "ECI-900 B2 (no conversion)" },
/*106*/ { UNICODE_MODE, 1024, -1, -1, { 0, 0, "" }, "é", 0, 1024, "64 08 00 30 03 43 54 40", "ECI-1024 B2 (no conversion)" },
/*107*/ { UNICODE_MODE, 32768, -1, -1, { 0, 0, "" }, "é", 0, 32768, "66 08 00 01 40 0E 0E 52 00", "ECI-32768 B2 (no conversion)" },
/*108*/ { UNICODE_MODE, 811800, -1, -1, { 0, 0, "" }, "é", ZINT_ERROR_INVALID_OPTION, 811800, "Error 533: Invalid ECI", "" },
/*109*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "β", ZINT_ERROR_INVALID_DATA, 3, "Error 535: Invalid character in input data for ECI 3", "" },
/*108*/ { UNICODE_MODE, 811800, -1, -1, { 0, 0, "" }, "é", ZINT_ERROR_INVALID_OPTION, 811800, "Error 533: ECI code '811800' out of range (0 to 811799)", "" },
/*109*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "β", ZINT_ERROR_INVALID_DATA, 3, "Error 535: Invalid character in input for ECI '3'", "" },
/*110*/ { UNICODE_MODE, 0, READER_INIT, -1, { 0, 0, "" }, "12", 0, 0, "51 11 71 7E 40", "" },
/*111*/ { UNICODE_MODE, 0, -1, -1, { 1, 16, "" }, "12", 0, 0, "48 03 60 24 3C 3F 50", "FNC2 ID0 Cnt15 Ind0 N2" },
/*112*/ { UNICODE_MODE, 0, READER_INIT, -1, { 1, 16, "" }, "12", 0, 0, "54 40 1E 02 23 63 7D 00", "FNC3 FNC2 ID0 Cnt15 Ind0 N2" },
@ -317,7 +341,7 @@ static void test_input(const testCtx *const p_ctx) {
/*114*/ { UNICODE_MODE, 0, READER_INIT, -1, { 2, 16, "" }, "12", 0, 0, "48 03 62 24 3C 3F 50", "FNC2 ID0 Cnt15 Ind1 N2 (FNC3 omitted)" },
/*115*/ { UNICODE_MODE, 0, -1, -1, { 3, 3, "255" }, "12", 0, 0, "4F 7C 44 24 3C 3F 50", "FNC2 ID256 Cnt2 Ind2 N2" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -377,7 +401,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "1234", UNICODE_MODE, -1, -1, 0, 18, 18, "",
"111111000000111111"
"101111001100101001"
@ -475,7 +499,7 @@ static void test_encode(const testCtx *const p_ctx) {
"111111000000111111000000111111000000111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -536,7 +560,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
not in GB 2312 (in ISO/IEC 8869-1)
Ж in GB 2312 (and ISO/IEC 8859-5)
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, ZINT_WARN_USES_ECI, 30, 30, "Standard example (adds ECI 3 for ¶)",
"111111000000111111000000111111"
"111111011110111111011110111111"
@ -810,7 +834,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"111111000000111111000000111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
@ -886,7 +910,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_GRIDMATRIX, UNICODE_MODE, -1, -1,
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738",
0, 66, 66, "97 chars, mixed modes" },
@ -903,7 +927,7 @@ static void test_perf(const testCtx *const p_ctx) {
"AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738 AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738",
0, 162, 162, "970 chars, mixed modes" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -43,33 +43,34 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { -1, -1, -1, "1", 7827, 0, 189, 189 },
/* 1*/ { -1, -1, -1, "1", 7828, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { -1, -1, -1, "A", 4350, 0, 189, 189 },
/* 3*/ { -1, -1, -1, "A", 4351, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { -1, -1, -1, "\200", 3261, 0, 189, 189 },
/* 5*/ { -1, -1, -1, "\200", 3262, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { -1, -1, ZINT_FULL_MULTIBYTE, "\241", 4348, 0, 189, 189 },
/* 7*/ { -1, -1, ZINT_FULL_MULTIBYTE, "\241", 4350, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { -1, 1, -1, "1", 45, 0, 23, 23 },
/* 9*/ { -1, 1, -1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { -1, 1, -1, "A", 26, 0, 23, 23 },
/* 11*/ { -1, 1, -1, "A", 27, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { -1, 1, -1, "\200", 18, 0, 23, 23 },
/* 13*/ { -1, 1, -1, "\200", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { -1, 1, ZINT_FULL_MULTIBYTE, "\241", 24, 0, 23, 23 },
/* 15*/ { -1, 1, ZINT_FULL_MULTIBYTE, "\241", 26, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { 2, 1, -1, "A", 21, 0, 23, 23 },
/* 17*/ { 2, 1, -1, "A", 22, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { 3, 1, -1, "A", 15, 0, 23, 23 },
/* 19*/ { 3, 1, -1, "A", 16, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { 4, 1, -1, "A", 10, 0, 23, 23 },
/* 21*/ { 4, 1, -1, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { -1, -1, -1, "1", 7827, 0, 189, 189, "" },
/* 1*/ { -1, -1, -1, "1", 7828, ZINT_ERROR_TOO_LONG, -1, -1, "Error 541: Input too long, requires 3265 codewords (maximum 3264)" },
/* 2*/ { -1, -1, -1, "A", 4350, 0, 189, 189, "" },
/* 3*/ { -1, -1, -1, "A", 4351, ZINT_ERROR_TOO_LONG, -1, -1, "Error 541: Input too long, requires 3265 codewords (maximum 3264)" },
/* 4*/ { -1, -1, -1, "\200", 3261, 0, 189, 189, "" },
/* 5*/ { -1, -1, -1, "\200", 3262, ZINT_ERROR_TOO_LONG, -1, -1, "Error 541: Input too long, requires 3265 codewords (maximum 3264)" },
/* 6*/ { -1, -1, ZINT_FULL_MULTIBYTE, "\241", 4348, 0, 189, 189, "" },
/* 7*/ { -1, -1, ZINT_FULL_MULTIBYTE, "\241", 4350, ZINT_ERROR_TOO_LONG, -1, -1, "Error 541: Input too long, requires 3265 codewords (maximum 3264)" },
/* 8*/ { -1, 1, -1, "1", 45, 0, 23, 23, "" },
/* 9*/ { -1, 1, -1, "1", 46, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, requires 22 codewords (maximum 21)" },
/* 10*/ { -1, 1, -1, "A", 26, 0, 23, 23, "" },
/* 11*/ { -1, 1, -1, "A", 27, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, requires 22 codewords (maximum 21)" },
/* 12*/ { -1, 1, -1, "\200", 18, 0, 23, 23, "" },
/* 13*/ { -1, 1, -1, "\200", 19, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, requires 22 codewords (maximum 21)" },
/* 14*/ { -1, 1, ZINT_FULL_MULTIBYTE, "\241", 24, 0, 23, 23, "" },
/* 15*/ { -1, 1, ZINT_FULL_MULTIBYTE, "\241", 26, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, requires 22 codewords (maximum 21)" },
/* 16*/ { 2, 1, -1, "A", 21, 0, 23, 23, "" },
/* 17*/ { 2, 1, -1, "A", 22, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, ECC 2, requires 18 codewords (maximum 17)" },
/* 18*/ { 3, 1, -1, "A", 15, 0, 23, 23, "" },
/* 19*/ { 3, 1, -1, "A", 16, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, ECC 3, requires 14 codewords (maximum 13)" },
/* 20*/ { 4, 1, -1, "A", 10, 0, 23, 23, "" },
/* 21*/ { 4, 1, -1, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1, "Error 542: Input too long for Version 1, ECC 4, requires 10 codewords (maximum 9)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -97,6 +98,7 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -133,7 +135,7 @@ static void test_options(const testCtx *const p_ctx) {
int expected_size;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, "12345", 0, 0, 23 }, /* Default version 1, ECC auto-set to 4 */
/* 1*/ { 1, -1, "12345", 0, 0, 23 },
/* 2*/ { -1, 2, "12345", 0, 0, 25 },
@ -147,7 +149,7 @@ static void test_options(const testCtx *const p_ctx) {
/* 10*/ { 5, -1, "12345678901234567", 0, 0, 23 }, /* ECC > max ECC 4 so ignored and auto-settings version 1, ECC 3 used */
/* 11*/ { -1, -1, "1234567890123456789012345678901234567890123456", 0, 0, 25 }, /* Version auto-set to 2, ECC auto-set to 2 */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -223,7 +225,7 @@ static void test_input(const testCtx *const p_ctx) {
U+4E02 GB 18030 2-byte Region 0x8140, UTF-8 E4B882
<EFBFBD> (REPLACEMENT CHARACTER) U+FFFD GB 18030 4-byte Region 0x81308130, UTF-8 EFBFBD (\357\277\275)
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, "é", -1, 0, 0, "30 00 F4 80 00 00 00 00 00", 1, "B1 (ISO 8859-1)" },
/* 1*/ { UNICODE_MODE, 3, -1, "é", -1, 0, 3, "80 33 00 0F 48 00 00 00 00", 1, "ECI-3 B1 (ISO 8859-1)" },
/* 2*/ { UNICODE_MODE, 29, -1, "é", -1, 0, 29, "81 D4 FC FF FF 00 00 00 00", 1, "ECI-29 H(1)1 (GB 2312)" },
@ -310,10 +312,10 @@ static void test_input(const testCtx *const p_ctx) {
/* 83*/ { DATA_MODE, 900, -1, "\303\251", -1, 0, 900, "88 38 43 00 16 1D 48 00 00", 1, "ECI-900 B2 (no conversion)" },
/* 84*/ { UNICODE_MODE, 16384, -1, "é", -1, 0, 16384, "8C 04 00 03 00 16 1D 48 00", 0, "ECI-16384 B2 (no conversion); ZXing-C++ test can't handle UNICODE_MODE binary" },
/* 85*/ { DATA_MODE, 16384, -1, "\303\251", -1, 0, 16384, "8C 04 00 03 00 16 1D 48 00", 1, "ECI-16384 B2 (no conversion)" },
/* 86*/ { UNICODE_MODE, 3, -1, "β", -1, ZINT_ERROR_INVALID_DATA, 3, "Error 545: Invalid character in input data for ECI 3", 1, "" },
/* 86*/ { UNICODE_MODE, 3, -1, "β", -1, ZINT_ERROR_INVALID_DATA, 3, "Error 545: Invalid character in input for ECI '3'", 1, "" },
/* 87*/ { GS1_MODE, -1, -1, "[10]01", -1, ZINT_ERROR_INVALID_OPTION, 0, "Error 220: Selected symbology does not support GS1 mode", 1, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -394,7 +396,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, -1, "1234", -1, 0, 23, 23, "Mode nnnn, mask 10",
"11111110101011001111111"
"10000000000000100000001"
@ -3162,7 +3164,7 @@ static void test_encode(const testCtx *const p_ctx) {
"11101010101010001111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -3241,7 +3243,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 23, 23, "Standard example",
"11111110101100101111111"
"10000000010110000000001"
@ -3446,7 +3448,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"11101010001010001111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
@ -3547,10 +3549,10 @@ static void test_fuzz(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_HANXIN, DATA_MODE, 35, -1, -1, ZINT_FULL_MULTIBYTE, "\215\215\215\215\215\350\215\215999\215\21500000\215\215\215\215\215\215\377O\000\000\036\000\000\000\000\357\376\026\377\377\377\377\241\241\232\232\232\232\232\232\235\032@\374:JGB \000\000@d\000\000\000\241\241\000\000\027\002\241\241\000\000\014\000\000\000\000\357\327\004\000\000\000\000\000\000\000\375\000\000\000\000\000\000\000\000\000\000\000\000\0000253]9R4R44,44,4404[255\350999\215\21599999\215\215\215\2150000\215\215\215\215\215\215\215\215\215]9444442<4444,4044%44vA\000\000\002\000'\000\000\215\377@\215\215\350\215\215\215\215\215\215\215\307\306\306n\215\215\000\000\001\000\000\203\000\000\000\000\000\000@\215\215\215[\2154315@]R0", 229, 0, 1, "" }, /* #300 (#16, adapted to HANXIN), Andre Maute */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -3594,7 +3596,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_HANXIN, UNICODE_MODE, -1, -1,
"汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。",
ZINT_WARN_NONCOMPLIANT, 43, 43, "98 chars, Region One and Text" },
@ -3628,7 +3630,7 @@ static void test_perf(const testCtx *const p_ctx) {
"汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。汉信码(Chinese-Sensible Code)是一种能够有效表示汉字、图像等信息的二维条码。",
ZINT_WARN_NONCOMPLIANT, 147, 147, "1470 chars, Region One and Text" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -68,7 +68,9 @@ static void test_csv(const testCtx *const p_ctx) {
int test_performance = debug & ZINT_DEBUG_TEST_PERFORMANCE; /* -d 256 */
int perf_iterations = test_performance ? TEST_CSV_PERF_ITERATIONS : 1;
testStart("test_csv");
struct zint_symbol *symbol = NULL;
testStartSymbol("test_csv", &symbol);
if (test_performance) {
printf("test_csv perf iterations: %d\n", perf_iterations);
@ -83,7 +85,6 @@ static void test_csv(const testCtx *const p_ctx) {
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
const char *b;
struct zint_symbol *symbol;
lc++;
@ -170,14 +171,14 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "53379777234994544928-51135759461", "" }, /* None */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_hrt");
testStartSymbol("test_hrt", &symbol);
for (i = 0; i < data_size; i++) {
@ -207,33 +208,34 @@ static void test_input(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { "53379777234994544928-51135759461", 0, 3, 129 },
/* 1*/ { "123456789012345678901234567890123", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 3*/ { "12345678901234567890", 0, 3, 129 }, /* Tracker only, no ZIP */
/* 4*/ { "15345678901234567890", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Tracker 2nd char > 4 */
/* 5*/ { "1234567890123456789", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* Tracker 20 chars */
/* 6*/ { "12345678901234567890-1234", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
/* 7*/ { "12345678901234567890-12345", 0, 3, 129 },
/* 8*/ { "12345678901234567890-123456", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
/* 9*/ { "12345678901234567890-12345678", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
/* 10*/ { "12345678901234567890-123456789", 0, 3, 129 },
/* 11*/ { "12345678901234567890-1234567890", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* ZIP wrong len */
/* 12*/ { "12345678901234567890-12345678901", 0, 3, 129 },
static const struct item data[] = {
/* 0*/ { "53379777234994544928-51135759461", 0, 3, 129, "" },
/* 1*/ { "123456789012345678901234567890123", ZINT_ERROR_TOO_LONG, -1, -1, "Error 450: Input length 33 too long (maximum 32)" },
/* 2*/ { "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 451: Invalid character at position 1 in input (digits and \"-\" only)" },
/* 3*/ { "12345678901234567890", 0, 3, 129, "" }, /* Tracker only, no ZIP */
/* 4*/ { "15345678901234567890", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 454: Barcode Identifier (second character) out of range (0 to 4)" }, /* Tracker 2nd char > 4 */
/* 5*/ { "1234567890123456789", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 452: Invalid length for tracking code (20 characters required)" }, /* Tracker 20 chars */
/* 6*/ { "12345678901234567890-1234", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 453: Invalid length for ZIP code (5, 9 or 11 characters required)" }, /* ZIP wrong len */
/* 7*/ { "12345678901234567890-12345", 0, 3, 129, "" },
/* 8*/ { "12345678901234567890-123456", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 453: Invalid length for ZIP code (5, 9 or 11 characters required)" }, /* ZIP wrong len */
/* 9*/ { "12345678901234567890-12345678", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 453: Invalid length for ZIP code (5, 9 or 11 characters required)" }, /* ZIP wrong len */
/* 10*/ { "12345678901234567890-123456789", 0, 3, 129, "" },
/* 11*/ { "12345678901234567890-1234567890", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 453: Invalid length for ZIP code (5, 9 or 11 characters required)" }, /* ZIP wrong len */
/* 12*/ { "12345678901234567890-12345678901", 0, 3, 129, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char cmp_buf[8192];
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -246,6 +248,7 @@ static void test_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -281,16 +284,16 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "01234567094987654321-01234567891", 0, 3, 129, "USPS-B-3200 Rev. H (2015) Figure 5",
"101000001010001000001000001010001010001000000000101010000000000000001010100010000000001010100000000000100010101010001000001010001"
"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"000010001010101000100010000000100000001010001010000000101000100000100010001000101010001010101010000000001010000000101000100000100"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char bwipp_buf[8192];
@ -298,7 +301,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {

View file

@ -42,8 +42,10 @@
# endif
# if defined(__clang__)
# pragma GCC diagnostic ignored "-Wformat-non-iso"
# elif defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))
# pragma GCC diagnostic ignored "-Wformat" /* Doesn't seem to be way to only avoid non-ISO warnings */
# elif defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
# pragma GCC diagnostic ignored "-Wno-pedantic-ms-format"
# elif defined(__GNUC__) && __GNUC__ >= 2
# pragma GCC diagnostic ignored "-Wformat"
# endif
#elif (defined(__WORDSIZE) && __WORDSIZE == 32) || (defined(ULONG_MAX) && ULONG_MAX <= 0xFFFFFFFF) \
|| defined(__APPLE__) || defined(__OpenBSD__)

View file

@ -60,11 +60,11 @@ static void test_checks(const testCtx *const p_ctx) {
int expected_symbology;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching", -1 },
/* 1*/ { BARCODE_CODE128, -1, "1234", -1, -1, 0, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
/* 2*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
/* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: Invalid ECI code 1000000", -1 },
/* 3*/ { BARCODE_QRCODE, -1, "1234", -1, -1, 999999 + 1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1000000' out of range (0 to 999999, excluding 1, 2, 14 and 19)", -1 },
/* 4*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 0.009, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 },
/* 5*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, 200.01, -1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 227: Scale out of range (0.01 to 200)", -1 },
/* 6*/ { BARCODE_CODE128, -1, "1234", -1, -1, -1, 0, 0, 0, 0, -1, 20.1, 0, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 221: Dot size out of range (0.01 to 20)", -1 },
@ -106,7 +106,7 @@ static void test_checks(const testCtx *const p_ctx) {
/* 42*/ { 15, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_EANX },
/* 43*/ { 17, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCA },
/* 44*/ { 17, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA },
/* 45*/ { 19, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_TOO_LONG, "Error 362: Input too short (3 character minimum)", BARCODE_CODABAR },
/* 45*/ { 19, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_TOO_LONG, "Error 362: Input length 1 too short (minimum 3)", BARCODE_CODABAR },
/* 46*/ { 19, -1, "A1B", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 207: Codabar 18 not supported", BARCODE_CODABAR },
/* 47*/ { 19, -1, "A1B", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 207: Codabar 18 not supported", -1 },
/* 48*/ { 26, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCA },
@ -119,7 +119,7 @@ static void test_checks(const testCtx *const p_ctx) {
/* 55*/ { 36, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCA },
/* 56*/ { 39, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_UPCE },
/* 57*/ { 39, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_UPCE },
/* 58*/ { 41, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 479: Input length is not standard (5, 9 or 11 characters)", BARCODE_POSTNET },
/* 58*/ { 41, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 479: Input length 1 is not standard (5, 9 or 11)", BARCODE_POSTNET },
/* 59*/ { 41, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET },
/* 60*/ { 41, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, 0, "", BARCODE_POSTNET },
/* 61*/ { 42, -1, "12345", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", BARCODE_POSTNET },
@ -195,7 +195,7 @@ static void test_checks(const testCtx *const p_ctx) {
/*131*/ { 147, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
/*132*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 },
/*133*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
/*134*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input data", -1 },
/*134*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*135*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 },
/*136*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) position 14: Bad checksum '4', expected '1'", -1 },
/*137*/ { BARCODE_QRCODE, -1, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
@ -208,12 +208,12 @@ static void test_checks(const testCtx *const p_ctx) {
/*144*/ { BARCODE_AZTEC, -1, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
/*145*/ { BARCODE_AZTEC, -1, "", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 },
/*146*/ { BARCODE_AZTEC, -1, "", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_USES_ECI, "Error 222: Encoded data includes ECI 13", -1 },
/*147*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Invalid error correction level - using default instead", -1 },
/*148*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Invalid error correction level - using default instead", -1 },
/*147*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 503: Error correction level '6' out of range (1 to 4), ignoring", -1 },
/*148*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 },
/*149*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_USES_ECI, "Warning 222: Encoded data includes ECI 13", -1 }, /* ECI warning trumps all other warnings */
/*150*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Invalid error correction level - using default instead", -1 }, /* But not errors */
/*150*/ { BARCODE_AZTEC, 6, "", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 503: Error correction level '6' out of range (1 to 4)", -1 }, /* But not errors */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -289,24 +289,24 @@ static void test_checks_segs(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 0, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 205: No input data" },
/* 1*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 257, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 771: Too many input segments (max 256)" },
/* 1*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 257, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 771: Too many input segments (maximum 256)" },
/* 2*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 772: Input segment 0 source NULL" },
/* 3*/ { BARCODE_CODE128, -1, { { TU(""), 0, 0 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 778: No input data" },
/* 4*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 0 }, { NULL, 0, 0 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 772: Input segment 1 source NULL" },
/* 5*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 0 }, { TU(""), 0, 0 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 773: Input segment 1 empty" },
/* 6*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 0 } }, 2, -1, 4, -1, ZINT_ERROR_INVALID_OPTION, "Error 774: Symbol ECI 4 must match segment zero ECI 3" },
/* 6*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 0 } }, 2, -1, 4, -1, ZINT_ERROR_INVALID_OPTION, "Error 774: Symbol ECI '4' must match segment zero ECI '3'" },
/* 7*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 775: Symbology does not support multiple segments" },
/* 8*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching" },
/* 9*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 1 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: Invalid ECI code 1" },
/* 9*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 1 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1' out of range (0 to 999999, excluding 1, 2, 14 and 19)" },
/* 10*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, GS1_MODE, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 776: GS1 mode not supported for multiple segments" },
/* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input data" },
/* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input" },
/* 12*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, -1, -1, -1, 0, "" },
/* 13*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 0 }, { TU("B"), 0, 4 } }, 2, -1, 3, -1, 0, "" },
/* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 243: Input data too long" },
/* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 243: Input too long" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol *symbol = NULL;
@ -350,16 +350,16 @@ static void test_input_data(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, "1234", -1, "", 0, "" },
/* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901231", -1, "", 0, "" },
/* 2*/ { BARCODE_GS1_128, -1, "", -1, "", ZINT_ERROR_INVALID_DATA, "Error 778: No input data" },
/* 3*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", -1, "[10]121212", 0, "" },
/* 4*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", -1, "", ZINT_ERROR_INVALID_DATA, "Error 779: No composite data in 2D component" },
/* 4*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", -1, "", ZINT_ERROR_INVALID_DATA, "Error 779: No composite data (2D component)" },
/* 5*/ { BARCODE_GS1_128_CC, -1, "", -1, "[10]121212", ZINT_ERROR_INVALID_OPTION, "Error 445: No primary (linear) message" },
/* 6*/ { BARCODE_DATAMATRIX, -1, "", -1, "", ZINT_ERROR_INVALID_DATA, "Error 778: No input data (segment 0 empty)" },
/* 6*/ { BARCODE_DATAMATRIX, -1, "", -1, "", ZINT_ERROR_INVALID_DATA, "Error 228: No input data (segment 0 empty)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -391,6 +391,36 @@ static void test_input_data(const testCtx *const p_ctx) {
ZBarcode_Delete(symbol);
}
if (p_ctx->index == -1 && p_ctx->exclude[0] == -1) {
char data_buf[ZINT_MAX_DATA_LEN + 10];
int expected_ret = ZINT_ERROR_TOO_LONG;
char *expected_errtxt[] = { "Error 797: Input too long", "Error 340: Input length 17399 too long (maximum 256)" };
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
/* Caught by `ZBarcode_Encode_Segs()` de-escape loop */
symbol->input_mode = ESCAPE_MODE;
testUtilStrCpyRepeat(data_buf, "A", ZINT_MAX_DATA_LEN);
data_buf[ZINT_MAX_DATA_LEN] = '\\';
data_buf[ZINT_MAX_DATA_LEN + 1] = 'n';
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, ZINT_MAX_DATA_LEN + 2);
assert_equal(ret, expected_ret, "ZBarcode_Encode(%d) ret %d != %d (%s)\n", symbol->symbology, ret, expected_ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, expected_errtxt[0]), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, expected_errtxt[0]);
/* Passes de-escape loop, caught by `code128()` */
symbol->errtxt[0] = '\0';
data_buf[ZINT_MAX_DATA_LEN - 2] = '\\';
data_buf[ZINT_MAX_DATA_LEN - 1] = 'n';
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, ZINT_MAX_DATA_LEN);
assert_equal(ret, expected_ret, "ZBarcode_Encode(%d) ret %d != %d (%s)\n", symbol->symbology, ret, expected_ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, expected_errtxt[1]), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, expected_errtxt[1]);
ZBarcode_Delete(symbol);
}
testFinish();
}
@ -485,16 +515,17 @@ static int test_prev_map_invalid_symbology(int *p_symbology) {
static void test_symbologies(const testCtx *const p_ctx) {
int i, ret;
struct zint_symbol symbol = {0};
struct zint_symbol s_symbol = {0};
struct zint_symbol *symbol = &s_symbol;
testStart("test_symbologies");
for (i = -1; i < 148; i++) {
if (testContinue(p_ctx, i)) continue;
symbol.symbology = i;
ret = ZBarcode_Encode(&symbol, TU(""), 0);
assert_notequal(ret, ZINT_ERROR_ENCODING_PROBLEM, "i:%d Encoding problem (%s)\n", i, symbol.errtxt);
symbol->symbology = i;
ret = ZBarcode_Encode(symbol, TU(""), 0);
assert_notequal(ret, ZINT_ERROR_ENCODING_PROBLEM, "i:%d Encoding problem (%s)\n", i, symbol->errtxt);
if (!ZBarcode_ValidID(i)) {
int prev_symbology = i;
@ -502,8 +533,8 @@ static void test_symbologies(const testCtx *const p_ctx) {
if (ret != ZINT_ERROR_INVALID_DATA) {
assert_equal(prev_ret, ret, "i:%d prev_ret (%d) != ret (%d)\n", i, prev_ret, ret);
}
assert_equal(prev_symbology, symbol.symbology, "i:%d prev_symbology (%d) != symbol.symbology (%d)\n",
i, prev_symbology, symbol.symbology);
assert_equal(prev_symbology, symbol->symbology, "i:%d prev_symbology (%d) != symbol->symbology (%d)\n",
i, prev_symbology, symbol->symbology);
} else {
/* No input data */
assert_equal(ret, ZINT_ERROR_INVALID_DATA, "i:%d ret (%d) != ZINT_ERROR_INVALID_DATA\n", i, ret);
@ -525,7 +556,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "1234", DATA_MODE, 0, DATA_MODE, "" },
/* 1*/ { "1234", DATA_MODE | ESCAPE_MODE, 0, DATA_MODE | ESCAPE_MODE, "" },
/* 2*/ { "1234", UNICODE_MODE, 0, UNICODE_MODE, "" },
@ -538,7 +569,7 @@ static void test_input_mode(const testCtx *const p_ctx) {
/* 9*/ { "1234", UNICODE_MODE | 0x10, 0, UNICODE_MODE | 0x10, "" },
/* 10*/ { "[01]12345678901231", GS1_MODE | 0x20, 0, GS1_MODE | 0x20, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -579,7 +610,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
int compare_previous;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 26, "01 05 08 09 0A 0B 0C 0D 0E 1C 1E 1F EB 02 5D 81 21 0D 92 2E 3D FD B6 9A 37 2A CD 61 FB 95", 0, "" },
/* 1*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 101, "(45) 67 62 43 40 44 47 48 29 6A 67 62 0B 49 4A 4B 4C 18 6A 67 62 0C 4D 5B 5D 5E 62 6A 67", 0, "" },
/* 2*/ { BARCODE_CODE16K, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 70, "(20) 14 64 68 71 72 73 74 75 76 77 91 93 94 101 65 60 103 103 45 61", 0, "" },
@ -591,21 +622,21 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 8*/ { BARCODE_ULTRA, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 20, "(15) 257 0 4 7 8 9 10 11 12 13 27 29 30 129 92", 0, "" },
/* 9*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\d129\\o201\\\\", "", 0, 18, "(32) 01 05 08 09 0A 0B 0C 0D 0E 1C 1E 1F E7 32 45 DB 70 5D E3 16 7B 2B 44 60 E1 55 F7 08", 0, "" },
/* 10*/ { BARCODE_HANXIN, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\d129\\o201\\\\", "", 0, 23, "2F 80 10 72 09 28 B3 0D 6F F3 00 30 E8 F4 0C 0C 0A E0 00 00 00", 0, "" },
/* 11*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input data", 0, "" },
/* 12*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\", "", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input data", 0, "" },
/* 13*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input data", 0, "" },
/* 14*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input data", 0, "" },
/* 15*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1g", "", ZINT_ERROR_INVALID_DATA, 0, "Error 233: Invalid character in escape sequence '\\x1g' in input data (hexadecimal only)", 0, "" },
/* 16*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input data", 0, "" },
/* 17*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input data", 0, "" },
/* 18*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input data", 0, "" },
/* 19*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12a", "", ZINT_ERROR_INVALID_DATA, 0, "Error 233: Invalid character in escape sequence '\\d12a' in input data (decimal only)", 0, "" },
/* 20*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d256", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\d256' in input data out of range (000-255)", 0, "" },
/* 21*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input data", 0, "" },
/* 22*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input data", 0, "" },
/* 23*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input data", 0, "" },
/* 24*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o128", "", ZINT_ERROR_INVALID_DATA, 0, "Error 233: Invalid character in escape sequence '\\o128' in input data (octal only)", 0, "" },
/* 25*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o400", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\o400' in input data out of range (000-377)", 0, "" },
/* 11*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input", 0, "" },
/* 12*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\", "", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input", 0, "" },
/* 13*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input", 0, "" },
/* 14*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input", 0, "" },
/* 15*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1g", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\x1g' in input (hexadecimal only)", 0, "" },
/* 16*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" },
/* 17*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" },
/* 18*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" },
/* 19*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12a", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\d12a' in input (decimal only)", 0, "" },
/* 20*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d256", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\d256' in input out of range (000 to 255)", 0, "" },
/* 21*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" },
/* 22*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" },
/* 23*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" },
/* 24*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o128", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\o128' in input (octal only)", 0, "" },
/* 25*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o400", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\o400' in input out of range (000 to 377)", 0, "" },
/* 26*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\xA01\\xFF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 0, "" },
/* 27*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1601\\d255", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" },
/* 28*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o2401\\o377", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" },
@ -621,15 +652,15 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 38*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\o303\\o277", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" },
/* 39*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u00fF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" },
/* 40*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U0000fF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" },
/* 41*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input data", 0, "" },
/* 42*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input data", 0, "" },
/* 43*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input data", 0, "" },
/* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input data", 0, "" },
/* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input data", 0, "" },
/* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 211: Invalid character for '\\u' escape sequence in input data (hexadecimal only)", 0, "" },
/* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ufffe' in input data out of range", 0, "Reversed BOM" },
/* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ud800' in input data out of range", 0, "Surrogate" },
/* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\udfff' in input data out of range", 0, "Surrogate" },
/* 41*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 42*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 43*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 211: Invalid character for '\\u' escape sequence in input (hexadecimal only)", 0, "" },
/* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" },
/* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" },
/* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" },
/* 50*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uffff", "", 0, 12, "E7 2C B0 16 AB A1 1F 85 EB 50 A1 4C", 0, "" },
/* 51*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\xE2\\x82\\xAC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 0, "Zint manual 4.10 Ex1" },
/* 52*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\u20AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" },
@ -640,18 +671,18 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 57*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 28, "\\U005E38", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 1, "" },
/* 58*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u007F", "", 0, 10, "80 81 46 73 64 88 6A 84", 0, "" },
/* 59*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U00007F", "", 0, 10, "80 81 46 73 64 88 6A 84", 0, "" },
/* 60*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 61*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 62*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 63*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 64*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 65*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 66*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "Reversed BOM" },
/* 67*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "Surrogate" },
/* 68*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "Surrogate" },
/* 69*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 70*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input data", 0, "" },
/* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\U110000' in input data out of range", 0, "" },
/* 60*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 61*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 62*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 63*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 64*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 65*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 66*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Reversed BOM" },
/* 67*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" },
/* 68*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" },
/* 69*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 70*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\U110000' in input out of range", 0, "" },
/* 72*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 25, "\\U10FFFF", "", 0, 14, "F1 1A E7 57 C7 81 F7 AC 09 06 28 51 F3 00 E1 8C 2A 1C", 0, "" },
/* 73*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, "\\U10FFFF", "", 0, 14, "F1 1B E7 57 E0 11 D7 6C 4F 45 E2 B3 FF F1 72 AB 54 9F", 0, "" },
/* 74*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 32, "\\U10FFFF", "", 0, 14, "F1 21 EB 64 33 EB 1B 36 1D F7 B1 6D 8C A6 34 64 19 3A", 0, "" },
@ -664,9 +695,9 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 81*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" },
/* 82*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" },
/* 83*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", 0, 79, "(7) 104 60 62 36 17 52 106", 0, "Unknown special escapes passed straight thu" },
/* 84*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input data", 0, "" },
/* 84*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -767,14 +798,14 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) {
char *expected;
int expected_len;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 0, 0, "BLANK", 0, "BLANK", 5 },
/* 1*/ { 0, 0, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\\\o201\\d255", 0, "\000\004\a\b\t\n\v\f\r\033\035\036\201\\\201\377", 16 },
/* 2*/ { 0, 0, "\\U010283", 0, "\360\220\212\203", 4 },
/* 3*/ { 0, 0, "\\u007F\\u0080\\u011E\\u13C9\\U010283", 0, "\177\302\200\304\236\341\217\211\360\220\212\203", 12 },
/* 4*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, "\\^A\\^^\\^B", 0, "\\^A\\^^\\^B", 9 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@ -782,26 +813,27 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
struct zint_symbol symbol = {0};
struct zint_symbol s_symbol = {0};
struct zint_symbol *symbol = &s_symbol;
int escaped_len;
char escaped[1024];
if (testContinue(p_ctx, i)) continue;
symbol.symbology = data[i].symbology;
symbol.input_mode = data[i].input_mode;
symbol->symbology = data[i].symbology;
symbol->input_mode = data[i].input_mode;
length = (int) strlen(data[i].data);
escaped_len = length;
ret = escape_char_process_test(&symbol, (unsigned char *) data[i].data, &escaped_len, NULL);
assert_equal(ret, data[i].ret, "i:%d escape_char_process_test(NULL) ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
ret = escape_char_process_test(symbol, (unsigned char *) data[i].data, &escaped_len, NULL);
assert_equal(ret, data[i].ret, "i:%d escape_char_process_test(NULL) ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(escaped_len, data[i].expected_len, "i:%d NULL escaped_len %d != %d\n", i, escaped_len, data[i].expected_len);
memset(escaped, 0xDD, sizeof(escaped));
escaped_len = length;
ret = escape_char_process_test(&symbol, (unsigned char *) data[i].data, &escaped_len, (unsigned char *) escaped);
assert_equal(ret, data[i].ret, "i:%d escape_char_process_test(escaped) ret %d != %d (%s)\n", i, ret, data[i].ret, symbol.errtxt);
ret = escape_char_process_test(symbol, (unsigned char *) data[i].data, &escaped_len, (unsigned char *) escaped);
assert_equal(ret, data[i].ret, "i:%d escape_char_process_test(escaped) ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(escaped_len, data[i].expected_len, "i:%d escaped escaped_len %d != %d\n", i, escaped_len, data[i].expected_len);
assert_zero(memcmp(escaped, data[i].expected, escaped_len), "i:%d memcmp() != 0\n", i);
@ -819,7 +851,7 @@ static void test_cap(const testCtx *const p_ctx) {
unsigned int expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, ZINT_CAP_HRT, ZINT_CAP_HRT },
/* 1*/ { BARCODE_CODE128, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_GS1, ZINT_CAP_HRT | ZINT_CAP_STACKABLE },
/* 2*/ { BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE, ZINT_CAP_ECI | ZINT_CAP_READER_INIT },
@ -830,7 +862,7 @@ static void test_cap(const testCtx *const p_ctx) {
/* 7*/ { BARCODE_POSTNET, ZINT_CAP_HRT | ZINT_CAP_STACKABLE | ZINT_CAP_EXTENDABLE | ZINT_CAP_COMPOSITE | ZINT_CAP_ECI | ZINT_CAP_GS1 | ZINT_CAP_DOTTY | ZINT_CAP_FIXED_RATIO | ZINT_CAP_READER_INIT | ZINT_CAP_FULL_MULTIBYTE | ZINT_CAP_MASK | ZINT_CAP_STRUCTAPP, 0 },
/* 8*/ { 0, 0, 0 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i;
unsigned int uret;
@ -942,13 +974,13 @@ static void test_cap_compliant_height(const testCtx *const p_ctx) {
static void test_encode_file_empty(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char filename[] = "in.bin";
FILE *fstream;
(void)p_ctx;
testStart("test_encode_file_empty");
testStartSymbol("test_encode_file_empty", &symbol);
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -975,12 +1007,12 @@ static void test_encode_file_too_large(const testCtx *const p_ctx) {
char filename[] = "in.bin";
FILE *fstream;
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char buf[ZINT_MAX_DATA_LEN + 1] = {0};
(void)p_ctx;
testStart("test_encode_file_too_large");
testStartSymbol("test_encode_file_too_large", &symbol);
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -1009,7 +1041,7 @@ static void test_encode_file_too_large(const testCtx *const p_ctx) {
static void test_encode_file_unreadable(const testCtx *const p_ctx) {
#ifndef _WIN32
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char filename[] = "in.bin";
char buf[ZINT_MAX_DATA_LEN + 1] = {0};
@ -1018,7 +1050,7 @@ static void test_encode_file_unreadable(const testCtx *const p_ctx) {
(void)p_ctx;
testStart("test_encode_file_unreadable");
testStartSymbol("test_encode_file_unreadable", &symbol);
#ifdef _WIN32
testSkip("Test not implemented on Windows");
@ -1054,12 +1086,12 @@ static void test_encode_file_unreadable(const testCtx *const p_ctx) {
/* #181 Nico Gunkel OSS-Fuzz (buffer not freed on fread() error) Note: unable to reproduce fread() error using this method */
static void test_encode_file_directory(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char dirname[] = "in_dir";
(void)p_ctx;
testStart("test_encode_file_directory");
testStartSymbol("test_encode_file_directory", &symbol);
#if defined(__NetBSD__) || defined(_AIX)
/* Reading a directory works on NetBSD, and get `code128()` ZINT_ERROR_TOO_LONG instead */
@ -1087,7 +1119,7 @@ static void test_encode_file_directory(const testCtx *const p_ctx) {
static void test_encode_file(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char *data = "1";
char *filename = "test_encode_file_in.txt";
char *outfile = "test_encode_file_out.gif";
@ -1095,7 +1127,7 @@ static void test_encode_file(const testCtx *const p_ctx) {
(void)p_ctx;
testStart("test_encode_file");
testStartSymbol("test_encode_file", &symbol);
(void) testUtilRemove(filename); /* In case junk hanging around */
(void) testUtilRemove(outfile); /* In case junk hanging around */
@ -1152,12 +1184,13 @@ static void test_encode_file(const testCtx *const p_ctx) {
static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char dirname[] = "outdir.txt";
char expected[] = "Error 201: Could not open output file";
(void)p_ctx;
testStart("test_encode_print_outfile_directory");
testStartSymbol("test_encode_print_outfile_directory", &symbol);
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -1169,6 +1202,7 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
strcpy(symbol->outfile, dirname);
ret = ZBarcode_Encode_and_Print(symbol, TU("1"), 0, 0);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ret %d != ZINT_ERROR_FILE_ACCESS (%s)\n", ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, expected), "strcmp(%s, %s) != 0\n", symbol->errtxt, expected);
ret = testUtilRmDir(dirname);
assert_zero(ret, "testUtilRmDir(%s) %d != 0 (%d: %s)\n", dirname, ret, errno, strerror(errno));
@ -1181,17 +1215,27 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) {
static void test_bad_args(const testCtx *const p_ctx) {
int ret;
unsigned int uret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char *data = "1";
char *filename = "1.png";
char *empty = "";
struct zint_seg seg = { TU("1"), -1, 4 };
struct zint_seg seg_empty = { TU(""), -1, 4 };
struct zint_seg seg_too_long = { TU("1"), ZINT_MAX_DATA_LEN + 1, 4 };
const char *expected[] = {
"Error 772: Input segment 0 source NULL",
"Error 200: Input segments NULL",
"Error 239: Filename NULL",
"Error 778: No input data",
"Error 229: Unable to read input file (2: No such file or directory)",
"Error 771: Too many input segments (maximum 256)",
"Error 205: No input data",
"Error 777: Input too long",
};
(void)p_ctx;
testStart("test_bad_args");
testStartSymbol("test_bad_args", &symbol);
/* These just return, no error */
ZBarcode_Clear(NULL);
@ -1231,91 +1275,91 @@ static void test_bad_args(const testCtx *const p_ctx) {
/* NULL data/segs/filename */
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode(symbol, NULL, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(symbol, NULL, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode(symbol, NULL, 1) no errtxt\n");
assert_zero(strcmp(expected[0], symbol->errtxt), "ZBarcode_Encode(symbol, NULL, 1) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, NULL, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, NULL, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs(symbol, NULL, 1) no errtxt\n");
assert_zero(strcmp(expected[1], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, NULL, 1) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Print(symbol, NULL, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(symbol, NULL, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_and_Print(symbol, NULL, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[0], symbol->errtxt), "ZBarcode_Encode_and_Print(symbol, NULL, 1, 0) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Buffer(symbol, NULL, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(symbol, NULL, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_and_Buffer(symbol, NULL, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[0], symbol->errtxt), "ZBarcode_Encode_and_Buffer(symbol, NULL, 1, 0) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs_and_Buffer(symbol, NULL, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer(symbol, NULL, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer(symbol, NULL, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[1], symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer(symbol, NULL, 1, 0) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Buffer_Vector(symbol, NULL, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(symbol, NULL, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_and_Buffer_Vector(symbol, NULL, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[0], symbol->errtxt), "ZBarcode_Encode_and_Buffer_Vector(symbol, NULL, 1, 0) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, NULL, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, NULL, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, NULL, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[1], symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, NULL, 1, 0) strcmp(%s, %s) != 0\n", expected[0], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File(symbol, NULL), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File(symbol, NULL) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File(symbol, NULL) no errtxt\n");
assert_zero(strcmp(expected[2], symbol->errtxt), "ZBarcode_Encode_File(symbol, NULL) strcmp(%s, %s) != 0\n", expected[2], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File_and_Print(symbol, NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Print(symbol, NULL, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File_and_Print(symbol, NULL, 0) no errtxt\n");
assert_zero(strcmp(expected[2], symbol->errtxt), "ZBarcode_Encode_File_and_Print(symbol, NULL, 0) strcmp(%s, %s) != 0\n", expected[2], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File_and_Buffer(symbol, NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Buffer(symbol, NULL, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File_and_Buffer(symbol, NULL, 0) no errtxt\n");
assert_zero(strcmp(expected[2], symbol->errtxt), "ZBarcode_Encode_File_and_Buffer(symbol, NULL, 0) strcmp(%s, %s) != 0\n", expected[2], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File_and_Buffer_Vector(symbol, NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Buffer_Vector(symbol, NULL, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File_and_Buffer_Vector(symbol, NULL, 0) no errtxt\n");
assert_zero(strcmp(expected[2], symbol->errtxt), "ZBarcode_Encode_File_and_Buffer_Vector(symbol, NULL, 0) strcmp(%s, %s) != 0\n", expected[2], symbol->errtxt);
/* Empty data/segs/filename */
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode(symbol, TU(empty), 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode(symbol, empty, 0) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode(symbol, TU(empty), 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_empty, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Print(symbol, TU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_and_Print(symbol, empty, 0, 0) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Print(symbol, TU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Buffer(symbol, TU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_and_Buffer(symbol, empty, 0, 0) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Buffer(symbol, TU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_and_Buffer_Vector(symbol, TU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_and_Buffer_Vector(symbol, empty, 0, 0) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_and_Buffer_Vector(symbol, TU(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0) no errtxt\n");
assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File(symbol, empty), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File(symbol, empty) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File(symbol, empty) no errtxt\n");
assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File(symbol, empty) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File_and_Print(symbol, empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Print(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File_and_Print(symbol, empty, 0) no errtxt\n");
assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File_and_Print(symbol, empty, 0) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File_and_Buffer(symbol, empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Buffer(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File_and_Buffer(symbol, empty, 0) no errtxt\n");
assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File_and_Buffer(symbol, empty, 0) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0) no errtxt\n");
assert_zero(strcmp(expected[4], symbol->errtxt), "ZBarcode_Encode_File_and_Buffer_Vector(symbol, empty, 0) strcmp(%s, %s) != 0\n", expected[4], symbol->errtxt);
/* Bad seg_count */
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_empty, ZINT_MAX_SEG_COUNT + 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, &seg_empty, ZINT_MAX_SEG_COUNT + 1) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, ZINT_MAX_SEG_COUNT + 1) no errtxt\n");
assert_zero(strcmp(expected[5], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, ZINT_MAX_SEG_COUNT + 1) strcmp(%s, %s) != 0\n", expected[5], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_empty, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, &seg_empty, 0) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, 0) no errtxt\n");
assert_zero(strcmp(expected[6], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, 0) strcmp(%s, %s) != 0\n", expected[6], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_empty, -1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, &seg_empty, -1) != ZINT_ERROR_INVALID_DATA\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, -1) no errtxt\n");
assert_zero(strcmp(expected[6], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, -1) strcmp(%s, %s) != 0\n", expected[6], symbol->errtxt);
/* Data/seg too big */
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode(symbol, TU(empty), ZINT_MAX_DATA_LEN + 1), ZINT_ERROR_TOO_LONG, "ZBarcode_Encode(symbol, empty, ZINT_MAX_DATA_LEN + 1) != ZINT_ERROR_TOO_LONG\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode(symbol, empty, ZINT_MAX_DATA_LEN + 1) no errtxt\n");
assert_zero(strcmp(expected[7], symbol->errtxt), "ZBarcode_Encode(symbol, TU(empty), ZINT_MAX_DATA_LEN + 1) strcmp(%s, %s) != 0\n", expected[7], symbol->errtxt);
symbol->errtxt[0] = '\0';
assert_equal(ZBarcode_Encode_Segs(symbol, &seg_too_long, 1), ZINT_ERROR_TOO_LONG, "ZBarcode_Encode_Segs(symbol, &seg_too_long, 1) != ZINT_ERROR_TOO_LONG\n");
assert_nonzero((int) strlen(symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_too_long, 1) no errtxt\n");
assert_zero(strcmp(expected[7], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_too_long, 1) strcmp(%s, %s) != 0\n", expected[7], symbol->errtxt);
ZBarcode_Delete(symbol);
@ -1552,11 +1596,12 @@ static void test_barcode_name(const testCtx *const p_ctx) {
testFinish();
}
INTERNAL int error_tag_test(struct zint_symbol *symbol, int error_number, const char *error_string);
INTERNAL int error_tag_test(int error_number, struct zint_symbol *symbol, const int err_id, const char *error_string);
static void test_error_tag(const testCtx *const p_ctx) {
struct item {
int debug_test;
int error_number;
int warn_level;
char *data;
@ -1565,45 +1610,50 @@ static void test_error_tag(const testCtx *const p_ctx) {
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { ZINT_WARN_INVALID_OPTION, -1, "", ZINT_WARN_INVALID_OPTION, "Warning " },
/* 1*/ { ZINT_WARN_INVALID_OPTION, WARN_FAIL_ALL, "", ZINT_ERROR_INVALID_OPTION, "Error " },
/* 2*/ { ZINT_WARN_USES_ECI, -1, "", ZINT_WARN_USES_ECI, "Warning " },
/* 3*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "", ZINT_ERROR_USES_ECI, "Error " },
/* 4*/ { ZINT_WARN_NONCOMPLIANT, -1, "", ZINT_WARN_NONCOMPLIANT, "Warning " },
/* 5*/ { ZINT_WARN_NONCOMPLIANT, WARN_FAIL_ALL, "", ZINT_ERROR_NONCOMPLIANT, "Error " },
/* 6*/ { ZINT_WARN_HRT_TRUNCATED, -1, "", ZINT_WARN_HRT_TRUNCATED, "Warning " },
/* 7*/ { ZINT_WARN_HRT_TRUNCATED, WARN_FAIL_ALL, "", ZINT_ERROR_HRT_TRUNCATED, "Error " },
/* 8*/ { ZINT_ERROR_TOO_LONG, WARN_DEFAULT, "", ZINT_ERROR_TOO_LONG, "Error " },
/* 9*/ { ZINT_ERROR_TOO_LONG, WARN_FAIL_ALL, "", ZINT_ERROR_TOO_LONG, "Error " },
/* 10*/ { ZINT_WARN_USES_ECI, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 11*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 12*/ { ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 13*/ { ZINT_ERROR_INVALID_DATA, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 14*/ { ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 15*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 16*/ { ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 0*/ { 0, ZINT_WARN_INVALID_OPTION, -1, "", ZINT_WARN_INVALID_OPTION, "Warning " },
/* 1*/ { 0, ZINT_WARN_INVALID_OPTION, WARN_FAIL_ALL, "", ZINT_ERROR_INVALID_OPTION, "Error " },
/* 2*/ { 0, ZINT_WARN_USES_ECI, -1, "", ZINT_WARN_USES_ECI, "Warning " },
/* 3*/ { 0, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "", ZINT_ERROR_USES_ECI, "Error " },
/* 4*/ { 0, ZINT_WARN_NONCOMPLIANT, -1, "", ZINT_WARN_NONCOMPLIANT, "Warning " },
/* 5*/ { 0, ZINT_WARN_NONCOMPLIANT, WARN_FAIL_ALL, "", ZINT_ERROR_NONCOMPLIANT, "Error " },
/* 6*/ { 0, ZINT_WARN_HRT_TRUNCATED, -1, "", ZINT_WARN_HRT_TRUNCATED, "Warning " },
/* 7*/ { 0, ZINT_WARN_HRT_TRUNCATED, WARN_FAIL_ALL, "", ZINT_ERROR_HRT_TRUNCATED, "Error " },
/* 8*/ { 0, ZINT_ERROR_TOO_LONG, WARN_DEFAULT, "", ZINT_ERROR_TOO_LONG, "Error " },
/* 9*/ { 0, ZINT_ERROR_TOO_LONG, WARN_FAIL_ALL, "", ZINT_ERROR_TOO_LONG, "Error " },
/* 10*/ { 0, ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 11*/ { 1, ZINT_WARN_USES_ECI, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 12*/ { 0, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 13*/ { 1, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 14*/ { 0, ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 15*/ { 1, ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 16*/ { 1, ZINT_ERROR_INVALID_DATA, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 17*/ { 1, ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" },
/* 18*/ { 1, ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
/* 19*/ { 1, ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
testStart("test_error_tag");
for (i = 0; i < data_size; i++) {
struct zint_symbol symbol = {0};
struct zint_symbol s_symbol = {0};
struct zint_symbol *symbol = &s_symbol;
if (testContinue(p_ctx, i)) continue;
symbol.warn_level = data[i].warn_level;
if (data[i].debug_test) symbol->debug |= ZINT_DEBUG_TEST;
symbol->warn_level = data[i].warn_level;
ret = error_tag_test(&symbol, data[i].error_number, data[i].data);
ret = error_tag_test(data[i].error_number, symbol, -1, data[i].data);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol.errtxt, data[i].expected);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
if ((int) strlen(data[i].data) < 100) {
strcpy(symbol.errtxt, data[i].data);
ret = error_tag_test(&symbol, data[i].error_number, NULL);
strcpy(symbol->errtxt, data[i].data);
ret = error_tag_test(data[i].error_number, symbol, -1, NULL);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
assert_zero(strcmp(symbol.errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol.errtxt, data[i].expected);
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
}
@ -1644,12 +1694,12 @@ static void test_strip_bom(const testCtx *const p_ctx) {
static void test_zero_outfile(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char *data = "1234";
(void)p_ctx;
testStart("test_zero_outfile");
testStartSymbol("test_zero_outfile", &symbol);
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -1677,12 +1727,12 @@ static void test_zero_outfile(const testCtx *const p_ctx) {
static void test_clear(const testCtx *const p_ctx) {
int ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char *data = "1234";
(void)p_ctx;
testStart("test_clear");
testStartSymbol("test_clear", &symbol);
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
@ -1931,7 +1981,7 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) {
float expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX, 0.33f, 2, 50, "gif", 0.5f },
/* 1*/ { BARCODE_EANX, 0.33f, 2, 50, "emf", 0.33000001f },
/* 2*/ { BARCODE_EANX, 0.33f, 2, 50, "svg", 0.33000001f },
@ -2017,7 +2067,7 @@ static void test_scale_from_xdimdp(const testCtx *const p_ctx) {
/* 82*/ { BARCODE_CODE128, 0.5f, 300, -1, "abcd", 0 }, /* filetype unknown */
/* 83*/ { BARCODE_QRCODE, 10, 31, 800, "gif", 155 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i;
float ret;
float x_dim_from_scale;
@ -2063,7 +2113,7 @@ static void test_xdimdp_from_scale(const testCtx *const p_ctx) {
float expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX, 1, 6, 150, "gif", 0.33333334f },
/* 1*/ { BARCODE_EANX, 1.32f, 8, 200, "gif", 0.33000001f },
/* 2*/ { BARCODE_EANX, 1.5f, 8, 200, "gif", 0.375f },
@ -2092,7 +2142,7 @@ static void test_xdimdp_from_scale(const testCtx *const p_ctx) {
/* 25*/ { BARCODE_CODE128, 0.5f, 0, -1, "gif", 0 }, /* xdim_mm_or_dpmm zero */
/* 26*/ { BARCODE_CODE128, 0.5f, 1000.1f, -1, "gif", 0 }, /* xdim_mm_or_dpmm > 1000 */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i;
float ret;
float dpmm_from_dpi;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -41,7 +41,7 @@ static void test_4s_input(const testCtx *const p_ctx) {
int expected_width;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "41038422416563762XY11 ", 0, 3, 155 },
/* 1*/ { "41038422416563762XY11 ", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { "4103842241656", ZINT_ERROR_TOO_LONG, -1, -1 }, /* Too short (< 14) */
@ -100,11 +100,11 @@ static void test_4s_input(const testCtx *const p_ctx) {
/* 55*/ { "01000000000000000C 23JQ4U ", ZINT_ERROR_INVALID_DATA, -1, -1 }, /* F N N N L L N L S bad 1st N (non-alpha otherwise matches 2nd pattern) */
/* 56*/ { "41038422416563762XY1", ZINT_ERROR_INVALID_DATA, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_4s_input");
testStartSymbol("test_4s_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -146,7 +146,7 @@ static void test_4s_encode_vector(const testCtx *const p_ctx) {
char *expected_daft;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "1100000000000XY11 ", 0, 100, 30, 0, "TTDTTATTDTAATTDTAATTDTAATTDTTDDAATAADDATAATDDFAFTDDTAADDDTAAFDFAFF" }, /* Example 1 from RMMBCED */
/* 1*/ { "21B2254800659JW5O9QA6Y", 0, 100, 30, 0, "DAATATTTADTAATTFADDDDTTFTFDDDDFFDFDAFTADDTFFTDDATADTTFATTDAFDTFDDA" }, /* Example 2 from RMMBCED */
/* 2*/ { "11000000000000000XY11 ", 0, 100, 30, 0, "TTDTTATDDTTATTDTAATTDTAATDDTTATTDTTDATFTAATDDTAATDDTATATFAADDAATAATDDTAADFTFTA" }, /* Example 1 from RMMBLED */
@ -168,13 +168,13 @@ static void test_4s_encode_vector(const testCtx *const p_ctx) {
/* 18*/ { "31833333333333333C12JQ3U ", 0, 100, 30, 0, "DTTAFFDATATFAADAFDFATFFTFFTTTADTTTDTAAATDDTFFDDFTAADTTDTFFFDAFTFAADFDDAFDFTAFF" }, /* F N N L L N L S S */
/* 19*/ { "22799999999999999C123JQ4U ", 0, 100, 30, 0, "DDATTDDATATTTAFDTAADATDDFFTFFDFFDTFAADDFAADFDFFTFFTFFDFDFTATATFDDFTFFFTFFTDDTF" }, /* F N N N L L N L S */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char actual_daft[80];
testStart("test_4s_encode_vector");
testStartSymbol("test_4s_encode_vector", &symbol);
for (i = 0; i < data_size; i++) {
@ -215,20 +215,20 @@ static void test_4s_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "1100000000000XY11 ", 0, 3, 131, "Verified manually against TEC-IT",
"00000000001000000000101000000000101000000000101000000000000000101000101000001000101000000010101000000000101000000000101010001010101"
"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"00001000000000001000000000001000000000001000000000001000001010000000000010100000000000101010001000101000000010101000000010101000101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
testStart("test_4s_encode");
testStartSymbol("test_4s_encode", &symbol);
for (i = 0; i < data_size; i++) {
@ -278,23 +278,23 @@ static void test_2d_input(const testCtx *const p_ctx) {
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, "012100123412345678AB19XY1A 0", 0, 24, 24, "" },
/* 1*/ { -1, "012100123412345678ab19xy1a 0", 0, 24, 24, "" }, /* Converts to upper */
/* 2*/ { -1, "jgb 012100123412345678ab19xy1a 0", 0, 24, 24, "" },
/* 3*/ { -1, "012100123412345678AB19XY1A 0901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_TOO_LONG, -1, -1, "Error 589: Input too long (90 character maximum)" },
/* 4*/ { -1, "012100123412345678AB19XY1A ", ZINT_ERROR_TOO_LONG, -1, -1, "Error 860: Input too short (28 character minimum)" },
/* 5*/ { -1, "012100123412345678AB19XY1A 090123456789012345678901234567890123456789012345678901234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 861: Input too long (86 character maximum)" },
/* 6*/ { -1, "JGB 012100123412345678AB19XY1A ", ZINT_ERROR_TOO_LONG, -1, -1, "Error 862: Input too short (32 character minimum)" },
/* 7*/ { 9, "JGB 012100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 863: Invalid symbol size selected (8, 10, 30 only)" },
/* 3*/ { -1, "012100123412345678AB19XY1A 0901234567890123456789012345678901234567890123456789012345678901", ZINT_ERROR_TOO_LONG, -1, -1, "Error 589: Input length 91 too long (maximum 90)" },
/* 4*/ { -1, "012100123412345678AB19XY1A ", ZINT_ERROR_TOO_LONG, -1, -1, "Error 860: Input length 27 too short (minimum 28)" },
/* 5*/ { -1, "012100123412345678AB19XY1A 090123456789012345678901234567890123456789012345678901234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 861: Input length 87 too long (maximum 86)" },
/* 6*/ { -1, "JGB 012100123412345678AB19XY1A ", ZINT_ERROR_TOO_LONG, -1, -1, "Error 862: Input length 31 too short (minimum 32)" },
/* 7*/ { 9, "JGB 012100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 863: Invalid Version '9' (8, 10 or 30 only)" },
/* 8*/ { -1, "JGB 012100123412345678AB19XY1A 0 123456", 0, 24, 24, "" },
/* 9*/ { 8, "JGB 012100123412345678AB19XY1A 0 1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 864: Input too long for selected size (51 character maximum)" },
/* 9*/ { 8, "JGB 012100123412345678AB19XY1A 0 1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 864: Input length 52 too long for Version 8 (maximum 51)" },
/* 10*/ { -1, "JGB 012100123412345678AB19XY1A 0 1234567890123456789012345", 0, 16, 48, "" },
/* 11*/ { 30, "JGB 012100123412345678AB19XY1A 0 12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, -1, "Error 865: Input too long for selected size (70 character maximum)" },
/* 11*/ { 30, "JGB 012100123412345678AB19XY1A 0 12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, -1, "Error 865: Input length 71 too long for Version 30 (maximum 70)" },
/* 12*/ { -1, "JGB 012100123412345678AB19XY1A 0 123456789012345678901234567890123456789012345", 0, 32, 32, "" },
/* 13*/ { -1, "JGB 012100123412345678AB19XY1A 0 1234567890123456789012345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, -1, "Error 589: Input too long (90 character maximum)" },
/* 13*/ { -1, "JGB 012100123412345678AB19XY1A 0 1234567890123456789012345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, -1, "Error 589: Input length 91 too long (maximum 90)" },
/* 14*/ { -1, "JGB 012100123412345678AB19XY1A 0 .23456", 0, 24, 24, "" },
/* 15*/ { -1, "JGB 012100123412345678AB19XY1A 0 . 23456", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 866: Invalid character in data (alphanumerics and space only in first 45 characters)" },
/* 15*/ { -1, "JGB 012100123412345678AB19XY1A 0 . 23456", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 866: Invalid character at position 45 in input (alphanumerics and space only in first 45)" },
/* 16*/ { -1, "JGB 12100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 867: Invalid Information Type ID (cannot be space)" },
/* 17*/ { -1, " 12100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 867: Invalid Information Type ID (cannot be space)" },
/* 18*/ { -1, "JGB 022100123412345678AB19XY1A 0", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 868: Invalid Version ID (\"1\" only)" },
@ -314,11 +314,11 @@ static void test_2d_input(const testCtx *const p_ctx) {
/* 31*/ { -1, "JGB 012100123412345678AB19XY1A 0AB181XY ", 0, 24, 24, "" },
/* 32*/ { -1, "JGB 012100123412345678AB19XY1A 0AB181XYA ", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 875: Invalid Reserved field (must be spaces only)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_2d_input");
testStartSymbol("test_2d_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -362,7 +362,7 @@ static void test_2d_encode(const testCtx *const p_ctx) {
https://www.royalmailtechnical.com/rmt_docs/User_Guides_2020/Mailmark_Letters_and_Large_Letters_20200723.pdf */
/* Mailmark Barcode Definition Document 15th Feb 2021 (MBDD)
https://www.royalmailtechnical.com/rmt_docs/User_Guides_2021/Mailmark_Barcode_definition_document_20210215.pdf */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 8, "JGB 01Z999999900000001EC1A1AA1A0SN35TQ ", 0, 24, 24, 1, "MMRLLL Section 2.4 Code Type Format 7 figure **NOT SAME**, figure switches from C40 to ASC to C40 to ASC contrary to spec",
"101010101010101010101010"
"110000010100011001100001"
@ -528,9 +528,9 @@ static void test_2d_encode(const testCtx *const p_ctx) {
"11111111111111111111111111111111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[8192];
char cmp_buf[32768];
@ -539,7 +539,7 @@ static void test_2d_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_2d_encode");
testStartSymbol("test_2d_encode", &symbol);
for (i = 0; i < data_size; i++) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -45,7 +45,7 @@ static void test_large(const testCtx *const p_ctx) {
int expected_width;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, "1", 138, "", 0, 33, 30 }, /* Mode 4 (138 agrees with ISO/IEC 16023:2000) */
/* 1*/ { -1, -1, "1", 139, "", ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { -1, -1, "1", 145, "", ZINT_ERROR_TOO_LONG, -1, -1 }, /* Absolute max */
@ -81,13 +81,14 @@ static void test_large(const testCtx *const p_ctx) {
/* 32*/ { 6, -1, "A", 93, "", 0, 33, 30 },
/* 33*/ { 6, -1, "A", 94, "", ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char data_buf[256];
const char expected_errtxt[] = "Error 553: Input too long, requires too many codewords (maximum 144)";
testStart("test_large");
testStartSymbol("test_large", &symbol);
for (i = 0; i < data_size; i++) {
@ -104,10 +105,13 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
} else {
assert_zero(strcmp(symbol->errtxt, expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, expected_errtxt);
}
ZBarcode_Delete(symbol);
@ -135,21 +139,21 @@ static void test_input(const testCtx *const p_ctx) {
int zxingcpp_cmp;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 01 21 21 21 21 21 21 21 21 08 0E 19 2B 20 0C 24 06 32 1C 21 21 21 21 21 21 21 21", 1, 1, "" },
/* 1*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Invalid length for Primary Message", 1, 1, "" },
/* 1*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_DATA, 0, "Error 548: Primary Message empty", 1, 1, "" },
/* 2*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "A123456", ZINT_ERROR_INVALID_DATA, 0, "Error 555: Non-numeric postcode in Primary Message", 1, 1, "" },
/* 3*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "1123456", 0, 30, "(144) 12 00 00 00 00 10 30 1E 20 1C 1A 3D 1C 0D 1B 15 3C 17 3C 08 01 21 21 21 21 21 21 21", 1, 1, "1-digit postcode" },
/* 4*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "1 123456", 0, 30, "(144) 12 00 00 00 00 10 30 1E 20 1C 1A 3D 1C 0D 1B 15 3C 17 3C 08 01 21 21 21 21 21 21 21", 1, 0, "1-digit postcode; ZXing-C++ test can't handle space" },
/* 5*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "123456789123456", 0, 30, "(144) 12 05 0D 2F 35 11 32 1E 20 1C 0D 1D 3B 12 22 3F 30 14 23 1A 01 21 21 21 21 21 21 21", 1, 1, "9-digit postcode" },
/* 6*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "1234567890123456", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Invalid length for Primary Message", 1, 1, "10-digit postcode" },
/* 6*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "1234567890123456", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Primary Message length 16 wrong (7 to 15 only)", 1, 1, "10-digit postcode" },
/* 7*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "1123456", 0, 30, "(144) 12 00 00 00 00 10 30 1E 20 1C 1A 3D 1C 0D 1B 15 3C 17 3C 08 01 21 21 21 21 21 21 21", 0, 1, "1-digit postcode; BWIPP requires mode" },
/* 8*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "123456789123456", 0, 30, "(144) 12 05 0D 2F 35 11 32 1E 20 1C 0D 1D 3B 12 22 3F 30 14 23 1A 01 21 21 21 21 21 21 21", 0, 1, "9-digit postcode; BWIPP requires mode" },
/* 9*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "1234567890123456", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Invalid length for Primary Message", 1, 1, "10-digit postcode" },
/* 10*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "123456", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Invalid length for Primary Message", 1, 1, "0-digit postcode" },
/* 9*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "1234567890123456", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Primary Message length 16 wrong (7 to 15 only)", 1, 1, "10-digit postcode" },
/* 10*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "123456", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Primary Message length 6 wrong (7 to 15 only)", 1, 1, "0-digit postcode" },
/* 11*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "12345678123456", 0, 30, "(144) 22 13 21 31 0B 00 32 1E 20 1C 04 14 07 30 10 07 08 28 1D 09 01 21 21 21 21 21 21 21", 0, 1, "8-digit postcode; BWIPP requires mode" },
/* 12*/ { UNICODE_MODE, -1, 2, -1, { 0, 0, "" }, "A", -1, "12345678123456", 0, 30, "(144) 22 13 21 31 0B 00 32 1E 20 1C 04 14 07 30 10 07 08 28 1D 09 01 21 21 21 21 21 21 21", 1, 1, "8-digit postcode" },
/* 13*/ { UNICODE_MODE, -1, 3, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_DATA, 0, "Error 551: Invalid length for Primary Message", 1, 1, "" },
/* 13*/ { UNICODE_MODE, -1, 3, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_DATA, 0, "Error 548: Primary Message empty", 1, 1, "" },
/* 14*/ { UNICODE_MODE, -1, 3, -1, { 0, 0, "" }, "A", -1, "A123456", 0, 30, "(144) 03 08 08 08 08 18 30 1E 20 1C 22 35 1C 0F 02 1A 26 04 10 31 01 21 21 21 21 21 21 21", 1, 1, "1-alphanumeric postcode" },
/* 15*/ { UNICODE_MODE, -1, 3, -1, { 0, 0, "" }, "A", -1, "1123456", 0, 30, "(144) 03 08 08 08 08 18 3C 1E 20 1C 13 37 07 2C 26 2D 18 29 3F 2C 01 21 21 21 21 21 21 21", 1, 0, "1-digit postcode; ZXing-C++ test can't handle padding" },
/* 16*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "A", -1, "A123456", 0, 30, "(144) 03 08 08 08 08 18 30 1E 20 1C 22 35 1C 0F 02 1A 26 04 10 31 01 21 21 21 21 21 21 21", 1, 1, "1-alphanumeric postcode" },
@ -166,7 +170,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 27*/ { UNICODE_MODE, -1, 0, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_DATA, 0, "Error 554: Primary Message empty", 1, 1, "Auto-determine mode 2/3 requires primary message" },
/* 28*/ { UNICODE_MODE, -1, 0, -1, { 0, 0, "" }, "A", -1, "A23456123456", 0, 30, "(144) 23 1D 0D 3D 2C 1C 30 1E 20 1C 24 35 30 31 2A 0D 17 14 16 3D 01 21 21 21 21 21 21 21", 1, 1, "Auto-determine mode 3" },
/* 29*/ { UNICODE_MODE, -1, -1, 100, { 0, 0, "" }, "A", -1, "123456123456", 0, 30, "(144) 02 10 22 07 00 20 31 1E 20 1C 0E 29 13 1B 0D 26 36 25 3B 22 3B 2A 29 3B 28 1E 30 31", 0, 1, "SCM prefix version" },
/* 30*/ { UNICODE_MODE, -1, -1, 101, { 0, 0, "" }, "A", -1, "123456123456", ZINT_ERROR_INVALID_OPTION, 0, "Error 557: Invalid SCM prefix version", 1, 1, "SCM prefix version" },
/* 30*/ { UNICODE_MODE, -1, -1, 101, { 0, 0, "" }, "A", -1, "123456123456", ZINT_ERROR_INVALID_OPTION, 0, "Error 557: SCM prefix version '101' out of range (1 to 100)", 1, 1, "SCM prefix version" },
/* 31*/ { UNICODE_MODE, 3, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 1B 03 01 21 21 21 21 21 21 2F 14 23 21 05 24 27 00 24 0C 21 21 21 21 21 21 21 21", 1, 1, "" },
/* 32*/ { UNICODE_MODE, 31, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 1B 1F 01 21 21 21 21 21 21 00 2F 0E 09 39 3B 24 1A 21 05 21 21 21 21 21 21 21 21", 1, 1, "ECI 0x1F" },
/* 33*/ { UNICODE_MODE, 32, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 1B 20 20 01 21 21 21 21 21 3D 15 0F 30 0D 22 24 35 22 06 21 21 21 21 21 21 21 21", 1, 1, "ECI 0x20" },
@ -178,19 +182,20 @@ static void test_input(const testCtx *const p_ctx) {
/* 39*/ { UNICODE_MODE, 65536, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 1B 38 10 00 00 01 21 21 21 2B 1F 24 06 38 2E 17 1B 10 2F 21 21 21 21 21 21 21 21", 1, 1, "ECI 0x10000" },
/* 40*/ { UNICODE_MODE, 131071, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 1B 38 1F 3F 3F 01 21 21 21 0F 05 09 04 2F 3A 17 09 36 31 21 21 21 21 21 21 21 21", 1, 1, "ECI 0x1FFFF" },
/* 41*/ { UNICODE_MODE, 999999, -1, -1, { 0, 0, "" }, "A", -1, "", 0, 30, "(144) 04 1B 3B 34 08 3F 01 21 21 21 26 3B 2B 23 08 17 32 05 26 35 21 21 21 21 21 21 21 21", 1, 1, "Max ECI" },
/* 42*/ { UNICODE_MODE, -1, 1, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 550: Invalid MaxiCode Mode", 1, 1, "" },
/* 43*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015", -1, "", 0, 30, "(144) 04 00 21 21 21 21 21 21 21 21 37 32 10 01 24 1B 10 11 38 0C 21 21 21 21 21 21 21 21", 1, 0, "ZXing-C++ test can't handle LF" },
/* 44*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\001\034\001\035\001\036\001a:b", -1, "", 0, 30, "(144) 04 3E 3E 01 20 01 21 01 22 01 27 0B 35 01 08 0D 16 02 17 1A 3F 01 33 02 21 21 21 21", 1, 1, "" },
/* 45*/ { UNICODE_MODE, -1, -1, -1, { 1, 2, "" }, "A", -1, "", 0, 30, "(144) 04 21 01 01 21 21 21 21 21 21 09 0B 26 03 37 0E 25 27 07 1E 21 21 21 21 21 21 21 21", 1, 1, "" },
/* 46*/ { UNICODE_MODE, -1, -1, -1, { 0, 2, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 559: Structured Append index out of range (1-2)", 1, 1, "" },
/* 47*/ { UNICODE_MODE, -1, -1, -1, { 1, 1, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 558: Structured Append count out of range (2-8)", 1, 1, "" },
/* 48*/ { UNICODE_MODE, -1, -1, -1, { 1, 9, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 558: Structured Append count out of range (2-8)", 1, 1, "" },
/* 49*/ { UNICODE_MODE, -1, -1, -1, { 3, 2, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 559: Structured Append index out of range (1-2)", 1, 1, "" },
/* 50*/ { UNICODE_MODE, -1, -1, -1, { 1, 2, "A" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 549: Structured Append ID not available for MaxiCode", 1, 1, "" },
/* 42*/ { UNICODE_MODE, -1, 1, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 550: Mode '1' out of range (2 to 6)", 1, 1, "" },
/* 43*/ { UNICODE_MODE, -1, 7, -1, { 0, 0, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 550: Mode '7' out of range (2 to 6)", 1, 1, "" },
/* 44*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\015", -1, "", 0, 30, "(144) 04 00 21 21 21 21 21 21 21 21 37 32 10 01 24 1B 10 11 38 0C 21 21 21 21 21 21 21 21", 1, 0, "ZXing-C++ test can't handle LF" },
/* 45*/ { UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "\001\034\001\035\001\036\001a:b", -1, "", 0, 30, "(144) 04 3E 3E 01 20 01 21 01 22 01 27 0B 35 01 08 0D 16 02 17 1A 3F 01 33 02 21 21 21 21", 1, 1, "" },
/* 46*/ { UNICODE_MODE, -1, -1, -1, { 1, 2, "" }, "A", -1, "", 0, 30, "(144) 04 21 01 01 21 21 21 21 21 21 09 0B 26 03 37 0E 25 27 07 1E 21 21 21 21 21 21 21 21", 1, 1, "" },
/* 47*/ { UNICODE_MODE, -1, -1, -1, { 0, 2, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 559: Structured Append index '0' out of range (1 to count 2)", 1, 1, "" },
/* 48*/ { UNICODE_MODE, -1, -1, -1, { 1, 1, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 558: Structured Append count '1' out of range (2 to 8)", 1, 1, "" },
/* 49*/ { UNICODE_MODE, -1, -1, -1, { 1, 9, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 558: Structured Append count '9' out of range (2 to 8)", 1, 1, "" },
/* 50*/ { UNICODE_MODE, -1, -1, -1, { 3, 2, "" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 559: Structured Append index '3' out of range (1 to count 2)", 1, 1, "" },
/* 51*/ { UNICODE_MODE, -1, -1, -1, { 1, 2, "A" }, "A", -1, "", ZINT_ERROR_INVALID_OPTION, 0, "Error 549: Structured Append ID not available for MaxiCode", 1, 1, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[32768];
@ -199,7 +204,7 @@ static void test_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -289,7 +294,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, -1, -1, { 0, 0, "" }, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure 2 (and L1), same",
"011111010000001000001000100111"
"000100000001000000001010000000"
@ -1026,9 +1031,9 @@ static void test_encode(const testCtx *const p_ctx) {
"110010001001001011011111100111"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[8192];
@ -1037,7 +1042,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {
@ -1123,7 +1128,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, "", 0, 33, 30, 1, "ISO 16023:2000 4.15.4 example",
"010101010101010101010101010111"
"000000000000000000000000000000"
@ -1440,9 +1445,9 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"100101010111100011100010101000"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[8192];
@ -1451,7 +1456,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_encode_segs");
testStartSymbol("test_encode_segs", &symbol);
for (i = 0; i < data_size; i++) {
@ -1552,7 +1557,7 @@ static void test_best_supported_set(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "am.//ab,\034TA# z\015!", 0, 100, 100, 0, 33, 30, "Different encodation than BWIPP, same number of codewords",
"111010000101111000111101010111"
"111110000000010100111000000000"
@ -1589,13 +1594,13 @@ static void test_best_supported_set(const testCtx *const p_ctx) {
"010100101001110111101010110010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped_data[1024];
testStart("test_best_supported_set");
testStartSymbol("test_best_supported_set", &symbol);
for (i = 0; i < data_size; i++) {
@ -1645,7 +1650,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { -1, "\223\223\223\223\223\200\000\060\060\020\122\104\060\343\000\000\040\104\104\104\104\177\377\040\000\324\336\000\000\000\000\104\060\060\060\060\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\104\060\104\104\000\000\000\040\104\104\104\104\177\377\377\377\324\336\000\000\000\000\104\377\104\001\104\104\104\104\104\104\233\233\060\060\060\060\060\060\060\060\060\325\074", 107, ZINT_ERROR_TOO_LONG }, /* Original OSS-Fuzz triggering data */
/* 1*/ { -1, "AaAaAaAaAaAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA123456789", -1, ZINT_ERROR_TOO_LONG }, /* Add 6 lowercase a's so 6 SHIFTS inserted so 6 + 138 (max input len) = 144 and numbers come at end of buffer */
/* 2*/ { -1, "AaAaAaAaAaAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA123456789A", -1, ZINT_ERROR_TOO_LONG },
@ -1653,11 +1658,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
/* 4*/ { 32768, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, ZINT_ERROR_TOO_LONG },
/* 5*/ { -1, "AaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa", -1, ZINT_ERROR_TOO_LONG },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_fuzz");
testStartSymbol("test_fuzz", &symbol);
for (i = 0; i < data_size; i++) {
@ -1698,12 +1703,12 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_MAXICODE, UNICODE_MODE | ESCAPE_MODE, -1, -1,
"1Z34567890\\GUPSN\\G102562\\G034\\G\\G1/1\\G\\GY\\G2201 Second St\\GFt Myers\\GFL\\R\\E",
"339010000840001", 0, 33, 30, "Mode 2" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
clock_t start, total_encode = 0, total_buffer = 0, diff_encode, diff_buffer;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -44,7 +44,7 @@ static void test_large(const testCtx *const p_ctx) {
int expected_width;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++B", 103, 0, 1, 1133 },
/* 1*/ { BARCODE_CODABAR, -1, "A++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++B", 104, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_CODABAR, 1, "A+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++B", 103, 0, 1, 1143 },
@ -56,7 +56,7 @@ static void test_large(const testCtx *const p_ctx) {
/* 8*/ { BARCODE_CODE32, -1, "1", 8, 0, 1, 103 },
/* 9*/ { BARCODE_CODE32, -1, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -101,7 +101,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A1234B", "A1234B" },
/* 1*/ { BARCODE_CODABAR, -1, "a1234c", "A1234C" }, /* Converts to upper */
/* 2*/ { BARCODE_CODABAR, 1, "A1234B", "A1234B" }, /* Check not included */
@ -113,7 +113,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 8*/ { BARCODE_CODE32, -1, "123456", "A001234564" },
/* 9*/ { BARCODE_CODE32, -1, "12345678", "A123456788" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -153,35 +153,40 @@ static void test_input(const testCtx *const p_ctx) {
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABAR, "A1234B", 0, 1, 62, "", 1, "" },
/* 1*/ { BARCODE_CODABAR, "1234B", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 358: Does not begin with \"A\", \"B\", \"C\" or \"D\"", 1, "" },
/* 2*/ { BARCODE_CODABAR, "A1234", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 359: Does not end with \"A\", \"B\", \"C\" or \"D\"", 1, "" },
/* 3*/ { BARCODE_CODABAR, "A1234E", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 359: Does not end with \"A\", \"B\", \"C\" or \"D\"", 1, "" },
/* 4*/ { BARCODE_CODABAR, "C123.D", 0, 1, 63, "", 1, "" },
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 357: Invalid character in data (\"0123456789-$:/.+ABCD\" only)", 1, "" },
/* 5*/ { BARCODE_CODABAR, "C123,D", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 357: Invalid character at position 5 in input (\"0123456789-$:/.+ABCD\" only)", 1, "" },
/* 6*/ { BARCODE_CODABAR, "D:C", 0, 1, 33, "", 1, "" },
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 363: Cannot contain \"A\", \"B\", \"C\" or \"D\"", 1, "" },
/* 8*/ { BARCODE_CODABAR, "AB", ZINT_ERROR_TOO_LONG, -1, -1, "Error 362: Input too short (3 character minimum)", 1, "" },
/* 9*/ { BARCODE_PHARMA, "131070", 0, 1, 78, "", 1, "" },
/* 10*/ { BARCODE_PHARMA, "131071", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)", 1, "" },
/* 11*/ { BARCODE_PHARMA, "3", 0, 1, 4, "", 1, "" },
/* 12*/ { BARCODE_PHARMA, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)", 1, "" },
/* 13*/ { BARCODE_PHARMA, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Data out of range (3 to 131070)", 1, "" },
/* 14*/ { BARCODE_PHARMA, "12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 351: Invalid character in data (digits only)", 1, "" },
/* 15*/ { BARCODE_PHARMA_TWO, "64570080", 0, 2, 31, "", 1, "" },
/* 16*/ { BARCODE_PHARMA_TWO, "64570081", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)", 1, "" },
/* 17*/ { BARCODE_PHARMA_TWO, "4", 0, 2, 3, "", 1, "" },
/* 18*/ { BARCODE_PHARMA_TWO, "3", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)", 1, "" },
/* 19*/ { BARCODE_PHARMA_TWO, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)", 1, "" },
/* 20*/ { BARCODE_PHARMA_TWO, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Data out of range (4 to 64570080)", 1, "" },
/* 21*/ { BARCODE_PHARMA_TWO, "123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 355: Invalid character in data (digits only)", 1, "" },
/* 22*/ { BARCODE_CODE32, "12345678", 0, 1, 103, "", 1, "" },
/* 23*/ { BARCODE_CODE32, "9", 0, 1, 103, "", 0, "BWIPP requires length 8 or 9" },
/* 24*/ { BARCODE_CODE32, "0", 0, 1, 103, "", 0, "BWIPP requires length 8 or 9" },
/* 25*/ { BARCODE_CODE32, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 361: Invalid character in data (digits only)", 1, "" },
/* 7*/ { BARCODE_CODABAR, "DCC", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 363: Invalid character at position 1 in input (cannot contain \"A\", \"B\", \"C\" or \"D\")", 1, "" },
/* 8*/ { BARCODE_CODABAR, "A234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123B", ZINT_ERROR_TOO_LONG, -1, -1, "Error 356: Input length 104 too long (maximum 103)", 1, "" },
/* 9*/ { BARCODE_CODABAR, "AB", ZINT_ERROR_TOO_LONG, -1, -1, "Error 362: Input length 2 too short (minimum 3)", 1, "" },
/* 10*/ { BARCODE_PHARMA, "131070", 0, 1, 78, "", 1, "" },
/* 11*/ { BARCODE_PHARMA, "1310700", ZINT_ERROR_TOO_LONG, -1, -1, "Error 350: Input length 7 too long (maximum 6)", 1, "" },
/* 12*/ { BARCODE_PHARMA, "131071", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Input value '131071' out of range (3 to 131070)", 1, "" },
/* 13*/ { BARCODE_PHARMA, "3", 0, 1, 4, "", 1, "" },
/* 14*/ { BARCODE_PHARMA, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Input value '2' out of range (3 to 131070)", 1, "" },
/* 15*/ { BARCODE_PHARMA, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 352: Input value '1' out of range (3 to 131070)", 1, "" },
/* 16*/ { BARCODE_PHARMA, "12A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 351: Invalid character at position 3 in input (digits only)", 1, "" },
/* 17*/ { BARCODE_PHARMA_TWO, "64570080", 0, 2, 31, "", 1, "" },
/* 18*/ { BARCODE_PHARMA_TWO, "64570081", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Input value '64570081' out of range (4 to 64570080)", 1, "" },
/* 19*/ { BARCODE_PHARMA_TWO, "064570080", ZINT_ERROR_TOO_LONG, -1, -1, "Error 354: Input length 9 too long (maximum 8)", 1, "" },
/* 20*/ { BARCODE_PHARMA_TWO, "4", 0, 2, 3, "", 1, "" },
/* 21*/ { BARCODE_PHARMA_TWO, "3", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Input value '3' out of range (4 to 64570080)", 1, "" },
/* 22*/ { BARCODE_PHARMA_TWO, "2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Input value '2' out of range (4 to 64570080)", 1, "" },
/* 23*/ { BARCODE_PHARMA_TWO, "1", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 353: Input value '1' out of range (4 to 64570080)", 1, "" },
/* 24*/ { BARCODE_PHARMA_TWO, "123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 355: Invalid character at position 4 in input (digits only)", 1, "" },
/* 25*/ { BARCODE_CODE32, "12345678", 0, 1, 103, "", 1, "" },
/* 26*/ { BARCODE_CODE32, "9", 0, 1, 103, "", 0, "BWIPP requires length 8 or 9" },
/* 27*/ { BARCODE_CODE32, "0", 0, 1, 103, "", 0, "BWIPP requires length 8 or 9" },
/* 28*/ { BARCODE_CODE32, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 360: Input length 9 too long (maximum 8)", 1, "" },
/* 29*/ { BARCODE_CODE32, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 361: Invalid character at position 1 in input (digits only)", 1, "" },
/* 30*/ { BARCODE_CODE32, "99999999", 0, 1, 103, "", 1, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -245,7 +250,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODABAR, -1, "A37859B", 0, 1, 72, "BS EN 798:1995 Figure 1",
"101100100101100101010100101101010011010101101010010110100101010010010110"
},
@ -279,7 +284,7 @@ static void test_encode(const testCtx *const p_ctx) {
"1001011011010101101001011010110010110101011011010010101100101101011010010101101010101100110100101101101"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;

View file

@ -44,7 +44,7 @@ static void test_check_colour_options(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "FFFFFF", "000000", 0, "" },
/* 1*/ { "ffffff", "ffffff", 0, "" },
/* 2*/ { "77777777", "33333333", 0, "" },
@ -57,16 +57,16 @@ static void test_check_colour_options(const testCtx *const p_ctx) {
/* 9*/ { "100,,100,100", ",1,2,", 0, "" },
/* 10*/ { "100,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "882: Malformed foreground CMYK colour (4 decimal numbers, comma-separated)" },
/* 11*/ { "100,100,99,1001", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "883: Malformed foreground CMYK colour (3 digit maximum per number)" },
/* 12*/ { "101,100,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "884: Malformed foreground CMYK colour C (decimal 0-100 only)" },
/* 13*/ { "100,101,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "885: Malformed foreground CMYK colour M (decimal 0-100 only)" },
/* 14*/ { "100,100,101,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "886: Malformed foreground CMYK colour Y (decimal 0-100 only)" },
/* 15*/ { "100,100,100,101", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "887: Malformed foreground CMYK colour K (decimal 0-100 only)" },
/* 12*/ { "101,100,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "884: Malformed foreground CMYK colour C (decimal 0 to 100 only)" },
/* 13*/ { "100,101,100,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "885: Malformed foreground CMYK colour M (decimal 0 to 100 only)" },
/* 14*/ { "100,100,101,100", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "886: Malformed foreground CMYK colour Y (decimal 0 to 100 only)" },
/* 15*/ { "100,100,100,101", "0,1,2,3", ZINT_ERROR_INVALID_OPTION, "887: Malformed foreground CMYK colour K (decimal 0 to 100 only)" },
/* 16*/ { "100,100,100,100", "0,1,", ZINT_ERROR_INVALID_OPTION, "882: Malformed background CMYK colour (4 decimal numbers, comma-separated)" },
/* 17*/ { "100,100,100,100", "0,0123,3,4", ZINT_ERROR_INVALID_OPTION, "883: Malformed background CMYK colour (3 digit maximum per number)" },
/* 18*/ { "100,100,100,100", "0,1,2,101", ZINT_ERROR_INVALID_OPTION, "887: Malformed background CMYK colour K (decimal 0-100 only)" },
/* 18*/ { "100,100,100,100", "0,1,2,101", ZINT_ERROR_INVALID_OPTION, "887: Malformed background CMYK colour K (decimal 0 to 100 only)" },
/* 19*/ { "100,100,100,100", "0,1,2,3,", ZINT_ERROR_INVALID_OPTION, "882: Malformed background CMYK colour (4 decimal numbers, comma-separated)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol symbol;
@ -99,7 +99,7 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) {
char *expected_cmyk;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "FFFFFF", 0, 0xFF, 0xFF, 0xFF, 0xFF, "0,0,0,0" },
/* 1*/ { "000000", 0, 0x00, 0x00, 0x00, 0xFF, "0,0,0,100" },
/* 2*/ { "FEDCBA", 0, 0xFE, 0xDC, 0xBA, 0xFF, "0,13,27,0" },
@ -113,7 +113,7 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) {
/* 10*/ { "80,30,60,0", 0, 0x33, 0xB3, 0x66, 0xFF, "72,0,43,30" },
/* 11*/ { "50,50,50,50", 0, 0x40, 0x40, 0x40, 0xFF, "0,0,0,75" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
testStart("test_colour_get_rgb");
@ -165,7 +165,7 @@ static void test_colour_get_cmyk(const testCtx *const p_ctx) {
int ret_rgb;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "80,30,60,0", 0, 80, 30, 60, 0, 0xFF, "33B366FF", 0 },
/* 1*/ { "50,50,50,50", 0, 50, 50, 50, 50, 0xFF, "404040FF", 0 },
/* 2*/ { "0,0,0,100", 0, 0, 0, 0, 100, 0xFF, "000000FF", 0 },
@ -173,7 +173,7 @@ static void test_colour_get_cmyk(const testCtx *const p_ctx) {
/* 4*/ { "123456", 1, 79, 40, 0, 44, 0xFF, "123456FF", 0 },
/* 5*/ { "12345678", 2, 79, 40, 0, 44, 0x78, "12345678", 1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
testStart("test_colour_get_cmyk");
@ -249,7 +249,7 @@ static void test_set_whitespace_offsets(const testCtx *const p_ctx) {
float expected_qz_right;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, 1, 0, 0, 0, 0, 0, 0.0f, /*expected*/ 1.0f, 0.0f, 1.0f, 0.0f, 0.0f },
/* 1*/ { BARCODE_CODE128, 2, 0, 0, 0, 0, 0, 1.0f, /*expected*/ 2.0f, 0.0f, 2.0f, 0.0f, 0.0f },
/* 2*/ { BARCODE_CODE128, 2, 3, 0, 0, 0, 0, 1.0f, /*expected*/ 2.0f, 3.0f, 2.0f, 3.0f, 0.0f },
@ -263,7 +263,7 @@ static void test_set_whitespace_offsets(const testCtx *const p_ctx) {
/* 10*/ { BARCODE_CODE128, 2, 3, 1, BARCODE_BIND_TOP | BARCODE_BOX | BARCODE_BIND, 0, 0, 1.0f, /*expected*/ 3.0f, 4.0f, 3.0f, 3.0f, 0.0f }, /* BIND_TOP wins */
/* 11*/ { BARCODE_CODE128, 2, 3, 1, BARCODE_BOX | BARCODE_QUIET_ZONES, 0, 0, 1.0f, /*expected*/ 13.0f, 4.0f, 13.0f, 4.0f, 10.0f },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i;
struct zint_symbol symbol = {0};
float xoffset, yoffset, roffset, boffset, qz_right;
@ -329,7 +329,7 @@ static void test_fopen(const testCtx *const p_ctx) {
int succeed;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "", "", "out.png", 1 },
/* 1*/ { "out_test", "", "out.png", 1 },
/* 2*/ { "out_test_with_subdir", "out_test_subdir", "out.png", 1 },
@ -347,7 +347,7 @@ static void test_fopen(const testCtx *const p_ctx) {
/* 14*/ { "", "", "outé.png", 1 },
/* 15*/ { "outé_test", "", "outé.png", 1 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, len;
FILE *ret;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -49,14 +49,14 @@ static void test_print(const testCtx *const p_ctx) {
char *expected_file;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_GRIDMATRIX, -1, -1, -1, -1, -1, -1, "C3C3C3", "", 0.75, "Grid Matrix", "gridmatrix_fg_0.75.pcx" },
/* 1*/ { BARCODE_CODABLOCKF, -1, -1, -1, -1, -1, 20, "FFFFFF", "000000", 0, "1234567890123456789012345678901234567890", "codeblockf_reverse.pcx" },
/* 2*/ { BARCODE_QRCODE, -1, -1, -1, -1, 2, 1, "", "D2E3F4", 0, "1234567890", "qr_bg.pcx" },
/* 3*/ { BARCODE_ULTRA, 1, BARCODE_BOX, 1, 1, -1, -1, "FF0000", "0000FF", 0, "ULTRACODE_123456789!", "ultra_fg_bg_hvwsp1_box1.pcx" },
/* 4*/ { BARCODE_CODE11, -1, -1, -1, -1, -1, -1, "12345678", "FEDCBA98", 0, "123", "code11_fgbgtrans.pcx" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
@ -182,12 +182,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "621: Could not open PCX output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "pcx_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = pcx_pixel_plot(&symbol, data);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "pcx_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "pcx_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -47,19 +47,21 @@ static void test_large(const testCtx *const p_ctx) {
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, 0, -1, -1, "A", 1850, 0, 32, 562, "" },
/* 1*/ { BARCODE_PDF417, 0, -1, -1, "A", 1851, ZINT_ERROR_TOO_LONG, -1, -1, "Error 464: Input string too long" },
/* 1*/ { BARCODE_PDF417, 0, -1, -1, "A", 1851, ZINT_ERROR_TOO_LONG, -1, -1, "Error 464: Input too long, requires too many codewords (maximum 928)" },
/* 2*/ { BARCODE_PDF417, 0, -1, -1, "\200", 1108, 0, 32, 562, "" },
/* 3*/ { BARCODE_PDF417, 0, -1, -1, "\200", 1109, ZINT_ERROR_TOO_LONG, -1, -1, "Error 464: Input string too long" },
/* 3*/ { BARCODE_PDF417, 0, -1, -1, "\200", 1109, ZINT_ERROR_TOO_LONG, -1, -1, "Error 464: Input too long, requires too many codewords (maximum 928)" },
/* 4*/ { BARCODE_PDF417, 0, -1, -1, "1", 2710, 0, 32, 562, "" },
/* 5*/ { BARCODE_PDF417, 0, -1, -1, "1", 2711, ZINT_ERROR_TOO_LONG, -1, -1, "Error 463: Input string too long" },
/* 6*/ { BARCODE_PDF417, 0, -1, 59, "A", 1850, ZINT_ERROR_TOO_LONG, -1, -1, "Error 465: Data too long for specified number of rows" },
/* 7*/ { BARCODE_PDF417, 0, 1, 3, "A", 1850, ZINT_ERROR_TOO_LONG, 32, 562, "Error 745: Data too long for specified number of columns" },
/* 8*/ { BARCODE_PDF417, 0, -1, 3, "A", 1850, ZINT_WARN_INVALID_OPTION, 32, 562, "Warning 746: Rows increased from 3 to 32" },
/* 9*/ { BARCODE_PDF417, 0, 30, -1, "A", 1850, ZINT_ERROR_TOO_LONG, 32, 562, "Error 747: Data too long for specified number of columns" },
/* 5*/ { BARCODE_PDF417, 0, -1, -1, "1", 2711, ZINT_ERROR_TOO_LONG, -1, -1, "Error 463: Input length 2711 too long (maximum 2710)" },
/* 6*/ { BARCODE_PDF417, 0, -1, 59, "A", 1850, ZINT_ERROR_TOO_LONG, -1, -1, "Error 465: Input too long, requires too many codewords (maximum 928)" },
/* 7*/ { BARCODE_PDF417, 0, 1, 3, "A", 1850, ZINT_ERROR_TOO_LONG, -1, -1, "Error 745: Input too long for number of columns '1'" },
/* 8*/ { BARCODE_PDF417, 0, -1, 3, "A", 1850, ZINT_WARN_INVALID_OPTION, 32, 562, "Warning 746: Number of rows increased from 3 to 32" },
/* 9*/ { BARCODE_PDF417, 0, 30, -1, "A", 1850, ZINT_ERROR_TOO_LONG, -1, -1, "Error 747: Input too long, requires too many codewords (maximum 928)" },
/* 10*/ { BARCODE_MICROPDF417, 0, -1, -1, "A", 250, 0, 44, 99, "" },
/* 11*/ { BARCODE_MICROPDF417, 0, -1, -1, "A", 251, ZINT_ERROR_TOO_LONG, -1, -1, "Error 467: Input too long, requires 127 codewords (maximum 126)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -131,60 +133,60 @@ static void test_options(const testCtx *const p_ctx) {
int compare_previous;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, -1, -1, -1, 0, { 0, 0, "" }, "12345", 0, 0, 6, 103, "", -1 }, /* ECC auto-set to 2, cols auto-set to 2 */
/* 1*/ { BARCODE_PDF417, -1, -1, 928, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 466: Number of rows out of range (3 to 90)", -1 }, /* Option 3 no longer ignored */
/* 2*/ { BARCODE_PDF417, -1, -1, 1, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 466: Number of rows out of range (3 to 90)", -1 }, /* Option 3 no longer ignored */
/* 1*/ { BARCODE_PDF417, -1, -1, 928, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 466: Number of rows '928' out of range (3 to 90)", -1 }, /* Option 3 no longer ignored */
/* 2*/ { BARCODE_PDF417, -1, -1, 1, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 466: Number of rows '1' out of range (3 to 90)", -1 }, /* Option 3 no longer ignored */
/* 3*/ { BARCODE_PDF417, 3, -1, -1, 0, { 0, 0, "" }, "12345", 0, 0, 7, 120, "", -1 }, /* ECC 3, cols auto-set to 3 */
/* 4*/ { BARCODE_PDF417, 3, 2, -1, 0, { 0, 0, "" }, "12345", 0, 0, 10, 103, "", -1 }, /* ECC 3, cols 2 */
/* 5*/ { BARCODE_PDF417, 8, 2, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 86, 171, "Warning 748: Columns increased from 2 to 6", -1 }, /* ECC 8, cols 2, used to fail, now auto-upped to 3 with warning */
/* 6*/ { BARCODE_PDF417, 8, 2, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, 0, 86, 171, "Error 748: Columns increased from 2 to 6", -1 },
/* 7*/ { BARCODE_PDF417, 7, 2, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 87, 120, "Warning 748: Columns increased from 2 to 3", -1 }, /* ECC 7, cols 2 auto-upped to 3 but now with warning */
/* 8*/ { BARCODE_PDF417, 7, 2, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, 0, 87, 120, "Error 748: Columns increased from 2 to 3", -1 },
/* 5*/ { BARCODE_PDF417, 8, 2, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 86, 171, "Warning 748: Number of columns increased from 2 to 6", -1 }, /* ECC 8, cols 2, used to fail, now auto-upped to 3 with warning */
/* 6*/ { BARCODE_PDF417, 8, 2, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, 0, 86, 171, "Error 748: Number of columns increased from 2 to 6", -1 },
/* 7*/ { BARCODE_PDF417, 7, 2, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 87, 120, "Warning 748: Number of columns increased from 2 to 3", -1 }, /* ECC 7, cols 2 auto-upped to 3 but now with warning */
/* 8*/ { BARCODE_PDF417, 7, 2, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, 0, 87, 120, "Error 748: Number of columns increased from 2 to 3", -1 },
/* 9*/ { BARCODE_PDF417, -1, 10, -1, 0, { 0, 0, "" }, "12345", 0, 0, 3, 239, "", -1 }, /* ECC auto-set to 2, cols 10 */
/* 10*/ { BARCODE_PDF417, 9, -1, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 6, 103, "Warning 460: Security value out of range (0 to 8), ignored", -1 }, /* Invalid ECC, auto-set */
/* 11*/ { BARCODE_PDF417, -1, 31, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 6, 103, "Warning 461: Number of columns out of range (1 to 30), ignored", 0 }, /* Invalid cols, auto-set */
/* 12*/ { BARCODE_PDF417, -1, -1, 2, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 466: Number of rows out of range (3 to 90)", -1 }, /* Invalid rows, error */
/* 13*/ { BARCODE_PDF417, -1, -1, 91, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 466: Number of rows out of range (3 to 90)", -1 }, /* Invalid rows, error */
/* 14*/ { BARCODE_PDF417, 9, -1, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 462: Security value out of range (0 to 8)", -1 }, /* Invalid ECC */
/* 15*/ { BARCODE_PDF417, -1, 31, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 473: Number of columns out of range (1 to 30)", -1 }, /* Invalid cols */
/* 16*/ { BARCODE_PDF417, -1, 30, 31, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 475: Columns x rows out of range (1 to 928)", -1 }, /* Rows * cols (930) > 928 */
/* 17*/ { BARCODE_PDF417, -1, 1, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI", ZINT_WARN_INVALID_OPTION, 0, 65, 120, "Warning 748: Columns increased from 1 to 3", -1 }, /* Cols 1 too small, used to fail, now auto-upped to 3 with warning */
/* 10*/ { BARCODE_PDF417, 9, -1, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 6, 103, "Warning 460: Error correction level '9' out of range (0 to 8), ignoring", -1 }, /* Invalid ECC, auto-set */
/* 11*/ { BARCODE_PDF417, -1, 31, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 6, 103, "Warning 461: Number of columns '31' out of range (1 to 30), ignoring", 0 }, /* Invalid cols, auto-set */
/* 12*/ { BARCODE_PDF417, -1, -1, 2, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 466: Number of rows '2' out of range (3 to 90)", -1 }, /* Invalid rows, error */
/* 13*/ { BARCODE_PDF417, -1, -1, 91, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 466: Number of rows '91' out of range (3 to 90)", -1 }, /* Invalid rows, error */
/* 14*/ { BARCODE_PDF417, 9, -1, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 460: Error correction level '9' out of range (0 to 8)", -1 }, /* Invalid ECC */
/* 15*/ { BARCODE_PDF417, -1, 31, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 461: Number of columns '31' out of range (1 to 30)", -1 }, /* Invalid cols */
/* 16*/ { BARCODE_PDF417, -1, 30, 31, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 475: Columns x rows value '930' out of range (1 to 928)", -1 }, /* Rows * cols (930) > 928 */
/* 17*/ { BARCODE_PDF417, -1, 1, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI", ZINT_WARN_INVALID_OPTION, 0, 65, 120, "Warning 748: Number of columns increased from 1 to 3", -1 }, /* Cols 1 too small, used to fail, now auto-upped to 3 with warning */
/* 18*/ { BARCODE_PDF417, -1, -1, 4, 0, { 0, 0, "" }, "12345", 0, 0, 4, 120, "", -1 }, /* Specify rows 4 (cols 3) */
/* 19*/ { BARCODE_PDF417, -1, 3, 4, 0, { 0, 0, "" }, "12345", 0, 0, 4, 120, "", 0 }, /* Specify cols 3 & rows 4 */
/* 20*/ { BARCODE_PDF417, -1, -1, 90, 0, { 0, 0, "" }, "12345", 0, 0, 90, 86, "", -1 }, /* Specify rows 90 (cols 1) */
/* 21*/ { BARCODE_PDF417, 0, -1, 3, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", 0, 0, 3, 579, "", -1 }, /* Specify rows 3, max cols 30 */
/* 22*/ { BARCODE_PDF417, 0, 30, 3, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", 0, 0, 3, 579, "", 0 }, /* Specify rows 3, cols 30 */
/* 23*/ { BARCODE_PDF417, 0, 29, 3, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_WARN_INVALID_OPTION, 0, 4, 562, "Warning 746: Rows increased from 3 to 4", -1 }, /* Specify rows 3, cols 29, rows auto-upped to 4 */
/* 24*/ { BARCODE_MICROPDF417, -1, 5, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 11, 38, "Warning 468: Specified width out of range", -1 }, /* Invalid cols, auto-set to 1 */
/* 25*/ { BARCODE_MICROPDF417, -1, 5, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 468: Specified width out of range", -1 }, /* Invalid cols */
/* 23*/ { BARCODE_PDF417, 0, 29, 3, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_WARN_INVALID_OPTION, 0, 4, 562, "Warning 746: Number of rows increased from 3 to 4", -1 }, /* Specify rows 3, cols 29, rows auto-upped to 4 */
/* 24*/ { BARCODE_MICROPDF417, -1, 5, -1, 0, { 0, 0, "" }, "12345", ZINT_WARN_INVALID_OPTION, 0, 11, 38, "Warning 468: Number of columns '5' out of range (1 to 4), ignoring", -1 }, /* Invalid cols, auto-set to 1 */
/* 25*/ { BARCODE_MICROPDF417, -1, 5, -1, WARN_FAIL_ALL, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 471: Number of columns '5' out of range (1 to 4)", -1 }, /* Invalid cols */
/* 26*/ { BARCODE_MICROPDF417, -1, 5, 3, 0, { 0, 0, "" }, "12345", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 476: Cannot specify rows for MicroPDF417", -1 }, /* Rows option not available */
/* 27*/ { BARCODE_MICROPDF417, -1, 1, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_WARN_INVALID_OPTION, 0, 17, 55, "Warning 469: Specified symbol size too small for data", -1 }, /* Cols 1 too small, auto-upped to 2 with warning */
/* 28*/ { BARCODE_MICROPDF417, -1, 1, -1, WARN_FAIL_ALL, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 469: Specified symbol size too small for data", -1 }, /* Cols 1 too small */
/* 29*/ { BARCODE_MICROPDF417, -1, 2, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWX", ZINT_WARN_INVALID_OPTION, 0, 15, 99, "Warning 470: Specified symbol size too small for data", -1 }, /* Cols 2 too small, auto-upped to 4 with warning */
/* 30*/ { BARCODE_MICROPDF417, -1, 2, -1, WARN_FAIL_ALL, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWX", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 470: Specified symbol size too small for data", -1 }, /* Cols 2 too small */
/* 31*/ { BARCODE_MICROPDF417, -1, 3, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKL", ZINT_WARN_INVALID_OPTION, 0, 32, 99, "Warning 471: Specified symbol size too small for data", -1 }, /* Cols 3 too small, auto-upped to 4 with warning */
/* 32*/ { BARCODE_MICROPDF417, -1, 3, -1, WARN_FAIL_ALL, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 471: Specified symbol size too small for data", -1 }, /* Cols 3 too small */
/* 33*/ { BARCODE_PDF417, -1, 1, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Cols 1 auto-upped to 2 just fits, now with warning */
/* 34*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", ZINT_WARN_INVALID_OPTION, 0, 67, 120, "Warning 748: Columns increased from 1 to 3", -1 }, /* Cols 1 too small with Structured Append, used to fail, now auto-upped to 3 with warning */
/* 35*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Cols 1 with Structured Append auto-upped to 2 just fits, now with warning */
/* 36*/ { BARCODE_PDF417, -1, 1, -1, 0, { 2, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", ZINT_WARN_INVALID_OPTION, 0, 65, 120, "Warning 748: Columns increased from 1 to 3", -1 }, /* Cols 1 too small with Structured Append as last symbol (uses extra terminating codeword), used to fail, now auto-upped to 3 with warning */
/* 37*/ { BARCODE_PDF417, -1, 1, -1, 0, { 2, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Cols 1 with Structured Append as last symbol just fits with 1 less character pair when auto-upped to 2, now with warning */
/* 38*/ { BARCODE_PDF417, -1, 1, -1, 0, { 3, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 741: Structured Append index out of range (1-2)", -1 },
/* 39*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 1, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 740: Structured Append count out of range (2-99999)", -1 },
/* 40*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 100000, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 740: Structured Append count out of range (2-99999)", -1 },
/* 41*/ { BARCODE_PDF417, -1, 1, -1, 0, { 0, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 741: Structured Append index out of range (1-2)", -1 },
/* 42*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "1" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Now with warning */
/* 43*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "123123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Now with warning */
/* 44*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "123123123123123123123123123123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Now with warning */
/* 45*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "1231231231231231231231231231231" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 742: Structured Append ID too long (30 digit maximum)", -1 },
/* 46*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "23123123123123123123123123123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Columns increased from 1 to 2", -1 }, /* Now with warning */
/* 27*/ { BARCODE_MICROPDF417, -1, 1, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_WARN_INVALID_OPTION, 0, 17, 55, "Warning 470: Input too long for number of columns '1', ignoring", -1 }, /* Cols 1 too small, auto-upped to 2 with warning */
/* 28*/ { BARCODE_MICROPDF417, -1, 1, -1, WARN_FAIL_ALL, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 469: Input too long for number of columns '1', requires 21 codewords (maximum 20)", -1 }, /* Cols 1 too small */
/* 29*/ { BARCODE_MICROPDF417, -1, 2, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWX", ZINT_WARN_INVALID_OPTION, 0, 15, 99, "Warning 470: Input too long for number of columns '2', ignoring", -1 }, /* Cols 2 too small, auto-upped to 4 with warning */
/* 30*/ { BARCODE_MICROPDF417, -1, 2, -1, WARN_FAIL_ALL, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWX", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 469: Input too long for number of columns '2', requires 38 codewords (maximum 37)", -1 }, /* Cols 2 too small */
/* 31*/ { BARCODE_MICROPDF417, -1, 3, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKL", ZINT_WARN_INVALID_OPTION, 0, 32, 99, "Warning 470: Input too long for number of columns '3', ignoring", -1 }, /* Cols 3 too small, auto-upped to 4 with warning */
/* 32*/ { BARCODE_MICROPDF417, -1, 3, -1, WARN_FAIL_ALL, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKL", ZINT_ERROR_INVALID_OPTION, ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 469: Input too long for number of columns '3', requires 83 codewords (maximum 82)", -1 }, /* Cols 3 too small */
/* 33*/ { BARCODE_PDF417, -1, 1, -1, 0, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Cols 1 auto-upped to 2 just fits, now with warning */
/* 34*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", ZINT_WARN_INVALID_OPTION, 0, 67, 120, "Warning 748: Number of columns increased from 1 to 3", -1 }, /* Cols 1 too small with Structured Append, used to fail, now auto-upped to 3 with warning */
/* 35*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Cols 1 with Structured Append auto-upped to 2 just fits, now with warning */
/* 36*/ { BARCODE_PDF417, -1, 1, -1, 0, { 2, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", ZINT_WARN_INVALID_OPTION, 0, 65, 120, "Warning 748: Number of columns increased from 1 to 3", -1 }, /* Cols 1 too small with Structured Append as last symbol (uses extra terminating codeword), used to fail, now auto-upped to 3 with warning */
/* 37*/ { BARCODE_PDF417, -1, 1, -1, 0, { 2, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Cols 1 with Structured Append as last symbol just fits with 1 less character pair when auto-upped to 2, now with warning */
/* 38*/ { BARCODE_PDF417, -1, 1, -1, 0, { 3, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 741: Structured Append index '3' out of range (1 to count 2)", -1 },
/* 39*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 1, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 740: Structured Append count '1' out of range (2 to 99999)", -1 },
/* 40*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 100000, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 740: Structured Append count '100000' out of range (2 to 99999)", -1 },
/* 41*/ { BARCODE_PDF417, -1, 1, -1, 0, { 0, 2, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 741: Structured Append index '0' out of range (1 to count 2)", -1 },
/* 42*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "1" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Now with warning */
/* 43*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "123123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Now with warning */
/* 44*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "123123123123123123123123123123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Now with warning */
/* 45*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "1231231231231231231231231231231" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 742: Structured Append ID length 31 too long (30 digit maximum)", -1 },
/* 46*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "23123123123123123123123123123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_WARN_INVALID_OPTION, 0, 89, 103, "Warning 748: Number of columns increased from 1 to 2", -1 }, /* Now with warning */
/* 47*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "A" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 743: Invalid Structured Append ID (digits only)", -1 },
/* 48*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "900" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 744: Structured Append ID triplet 1 '900' out of range (000-899)", -1 },
/* 49*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "123123123123123123123123901123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 744: Structured Append ID triplet 9 '901' out of range (000-899)", -1 },
/* 50*/ { BARCODE_MICROPDF417, -1, -1, -1, 0, { 1, 2, "1231231231231231231231231231231" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 742: Structured Append ID too long (30 digit maximum)", -1 }, /* Micro PDF417 same error checking code */
/* 48*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "900" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 744: Structured Append ID triplet 1 value '900' out of range (000 to 899)", -1 },
/* 49*/ { BARCODE_PDF417, -1, 1, -1, 0, { 1, 2, "123123123123123123123123901123" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 744: Structured Append ID triplet 9 value '901' out of range (000 to 899)", -1 },
/* 50*/ { BARCODE_MICROPDF417, -1, -1, -1, 0, { 1, 2, "1231231231231231231231231231231" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", ZINT_ERROR_INVALID_OPTION, -1, 0, 0, "Error 742: Structured Append ID length 31 too long (30 digit maximum)", -1 }, /* Micro PDF417 same error checking code */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -251,11 +253,11 @@ static void test_reader_init(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE, READER_INIT, "A", 0, 6, 103, "(12) 4 921 29 900 209 917 46 891 522 472 822 385", "Outputs Test Alpha flag 900" },
/* 1*/ { BARCODE_MICROPDF417, UNICODE_MODE, READER_INIT, "A", 0, 11, 38, "(11) 921 900 29 900 179 499 922 262 777 478 300", "Outputs Test Alpha flag 900" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -335,7 +337,7 @@ static void test_input(const testCtx *const p_ctx) {
};
/* é U+00E9 (\351, 233), UTF-8 C3A9 */
/* β U+03B2 in ISO 8859-7 Greek (but not other ISO 8859 or Win page) (\342, 226), UTF-8 CEB2 */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "é", 0, 0, 6, 103, "(12) 4 913 233 900 398 878 279 350 217 295 231 77", 1, "" },
/* 1*/ { BARCODE_PDF417, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "é", 0, 0, 6, 103, "(12) 4 913 233 900 398 878 279 350 217 295 231 77", 1, "" },
/* 2*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 3, -1, -1, { 0, 0, "" }, "é", 0, 3, 7, 103, "(14) 6 927 3 913 233 900 162 81 551 529 607 384 164 108", 1, "" },
@ -346,7 +348,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 7*/ { BARCODE_PDF417, UNICODE_MODE, 9, -1, -1, { 0, 0, "" }, "β", 0, 9, 7, 103, "(14) 6 927 9 913 226 900 487 92 418 278 838 500 576 84", 1, "" },
/* 8*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_USES_ECI, 9, 7, 103, "Warning (14) 6 927 9 913 226 900 487 92 418 278 838 500 576 84", 1, "" },
/* 9*/ { BARCODE_PDF417, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_USES_ECI, 9, 7, 103, "Warning (14) 6 927 9 913 226 900 487 92 418 278 838 500 576 84", 1, "" },
/* 10*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 3, -1, -1, { 0, 0, "" }, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 244: Invalid character in input data for ECI 3", 1, "" },
/* 10*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 3, -1, -1, { 0, 0, "" }, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 244: Invalid character in input for ECI '3'", 1, "" },
/* 11*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 899, -1, -1, { 0, 0, "" }, "A", 0, 899, 6, 103, "(12) 4 927 899 29 567 272 3 384 796 210 839 746", 0, "BWIPP BYTE1" },
/* 12*/ { BARCODE_PDF417, UNICODE_MODE, 899, -1, -1, { 0, 0, "" }, "A", 0, 899, 6, 103, "(12) 4 927 899 29 567 272 3 384 796 210 839 746", 0, "BWIPP BYTE1" },
/* 13*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 900, -1, -1, { 0, 0, "" }, "A", 0, 900, 7, 103, "(14) 6 926 0 0 29 900 205 526 248 527 915 616 104 416", 0, "BWIPP BYTE1" },
@ -357,7 +359,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 18*/ { BARCODE_PDF417, UNICODE_MODE, 810900, -1, -1, { 0, 0, "" }, "A", 0, 810900, 6, 103, "(12) 4 925 0 29 682 61 599 519 256 742 797 153", 0, "BWIPP BYTE1" },
/* 19*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 811799, -1, -1, { 0, 0, "" }, "A", 0, 811799, 6, 103, "(12) 4 925 899 29 447 238 770 706 58 39 749 743", 0, "BWIPP BYTE1" },
/* 20*/ { BARCODE_PDF417, UNICODE_MODE, 811799, -1, -1, { 0, 0, "" }, "A", 0, 811799, 6, 103, "(12) 4 925 899 29 447 238 770 706 58 39 749 743", 0, "BWIPP BYTE1" },
/* 21*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 811800, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, 811800, 0, 0, "Error 472: Invalid ECI", 1, "" },
/* 21*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, 811800, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, 811800, 0, 0, "Error 472: ECI code '811800' out of range (0 to 811799)", 1, "" },
/* 22*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "é", 0, 0, 11, 38, "(11) 901 233 900 900 310 142 569 141 677 300 494", 1, "" },
/* 23*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "é", 0, 0, 11, 38, "(11) 901 233 900 900 310 142 569 141 677 300 494", 1, "" },
/* 24*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 3, -1, -1, { 0, 0, "" }, "é", 0, 3, 11, 38, "(11) 927 3 901 233 657 863 824 246 172 292 833", 1, "" },
@ -370,7 +372,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 31*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_USES_ECI, 9, 11, 38, "Warning (11) 927 9 901 226 806 489 813 191 671 146 327", 1, "" },
/* 32*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_USES_ECI, 9, 11, 38, "Warning (11) 927 9 901 226 806 489 813 191 671 146 327", 1, "" },
/* 33*/ { BARCODE_MICROPDF417, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_USES_ECI, 9, 11, 38, "Warning (11) 927 9 901 226 806 489 813 191 671 146 327", 1, "" },
/* 34*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 3, -1, -1, { 0, 0, "" }, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 244: Invalid character in input data for ECI 3", 1, "" },
/* 34*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 3, -1, -1, { 0, 0, "" }, "β", ZINT_ERROR_INVALID_DATA, 3, 0, 0, "Error 244: Invalid character in input for ECI '3'", 1, "" },
/* 35*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 899, -1, -1, { 0, 0, "" }, "A", 0, 899, 11, 38, "(11) 927 899 900 29 533 437 884 3 617 241 747", 0, "BWIPP BYTE" },
/* 36*/ { BARCODE_MICROPDF417, UNICODE_MODE, 899, -1, -1, { 0, 0, "" }, "A", 0, 899, 11, 38, "(11) 927 899 900 29 533 437 884 3 617 241 747", 0, "BWIPP BYTE" },
/* 37*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 900, -1, 3, { 0, 0, "" }, "A", 0, 900, 6, 82, "(18) 926 0 0 900 29 900 913 543 414 141 214 886 461 1 419 422 54 495", 0, "BWIPP BYTE" },
@ -379,9 +381,9 @@ static void test_input(const testCtx *const p_ctx) {
/* 40*/ { BARCODE_MICROPDF417, UNICODE_MODE, 810899, -1, 3, { 0, 0, "" }, "A", 0, 810899, 6, 82, "(18) 926 899 899 900 29 900 351 555 241 509 787 583 3 326 41 628 534 151", 0, "BWIPP BYTE" },
/* 41*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 810900, -1, 1, { 0, 0, "" }, "A", 0, 810900, 11, 38, "(11) 925 0 900 29 233 533 43 483 708 659 704", 0, "BWIPP BYTE" },
/* 42*/ { BARCODE_MICROPDF417, UNICODE_MODE, 810900, -1, 1, { 0, 0, "" }, "A", 0, 810900, 11, 38, "(11) 925 0 900 29 233 533 43 483 708 659 704", 0, "BWIPP BYTE" },
/* 43*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 811800, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, 811800, 0, 0, "Error 472: Invalid ECI", 0, "BWIPP BYTE" },
/* 44*/ { BARCODE_HIBC_PDF, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", 1, "" },
/* 45*/ { BARCODE_HIBC_MICPDF, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid character in data (alphanumerics, space and \"-.$/+%\" only)", 1, "" },
/* 43*/ { BARCODE_MICROPDF417, UNICODE_MODE | FAST_MODE, 811800, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, 811800, 0, 0, "Error 472: ECI code '811800' out of range (0 to 811799)", 0, "BWIPP BYTE" },
/* 44*/ { BARCODE_HIBC_PDF, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)", 1, "" },
/* 45*/ { BARCODE_HIBC_MICPDF, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, ",", ZINT_ERROR_INVALID_DATA, 0, 0, 0, "Error 203: Invalid character at position 1 in input (alphanumerics, space and \"-.$/+%\" only)", 1, "" },
/* 46*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "AB{} C#+ de{} {}F 12{} G{} H", 0, 0, 12, 120, "(36) 28 1 865 807 896 782 855 626 807 94 865 807 896 808 776 839 176 808 32 776 839 806 208", 0, "BWIPP different encodation (3 codewords shorter)" },
/* 47*/ { BARCODE_PDF417, UNICODE_MODE, -1, -1, -1, { 0, 0, "" }, "AB{} C#+ de{} {}F 12{} G{} H", 0, 0, 11, 120, "(33) 25 1 896 897 806 88 470 806 813 149 809 836 809 809 837 178 806 32 776 839 806 209 809", 0, "BWIPP different encodation, same codeword count" },
/* 48*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "{} #+ de{} 12{} {} H", 0, 0, 10, 120, "(30) 22 865 807 896 808 470 807 94 865 807 896 808 32 776 839 806 865 807 896 787 900 900", 0, "BWIPP different encodation" },
@ -421,7 +423,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 82*/ { BARCODE_PDF417, DATA_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 0, 12, 137, "(48) 40 902 491 81 137 450 302 67 15 174 492 862 667 475 869 12 434 685 326 422 57 117 339", 1, "" },
/* 83*/ { BARCODE_PDF417, DATA_MODE, -1, -1, -1, { 0, 0, "" }, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 0, 0, 12, 137, "(48) 40 902 491 81 137 450 302 67 15 174 492 862 667 475 869 12 434 685 326 422 57 117 339", 1, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int last_fast_num_cwds = 0; /* Keep clang-tidy happy */
@ -534,7 +536,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, -1, UNICODE_MODE | FAST_MODE, 1, 2, -1, "PDF417 Symbology Standard", 0, 10, 103, 0, "ISO 15438:2015 Figure 1, same, BWIPP uses different encodation, same codeword count",
"1111111101010100011101010011100000111010110011110001110111011001100011110101011110000111111101000101001"
"1111111101010100011111010100110000110100001110001001111010001010000011111010100110000111111101000101001"
@ -3922,7 +3924,7 @@ static void test_encode(const testCtx *const p_ctx) {
"1111111101010100010100011000001100110100000100001101001011110111100011010001100011100111111101000101001"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int last_fast_num_cwds = 0; /* Keep clang-tidy happy */
@ -4036,7 +4038,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, UNICODE_MODE | FAST_MODE, -1, -1, -1, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 8, 103, 1, "Standard example",
"1111111101010100011111010101111100110101000011000001111001111001010011110101011110000111111101000101001"
"1111111101010100011111101010001110101000011110010001001111110010110011110101001000000111111101000101001"
@ -4660,7 +4662,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
""
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
int last_fast_num_cwds = 0; /* Keep clang-tidy happy */
@ -4790,7 +4792,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int bwipp_cmp;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, DATA_MODE | FAST_MODE, -1, -1,
"\060\075\204\060\204\060\204\041\060\075\060\204\060\075\060\075\204\060\075\060\103\204\060\204\060\003\120\060\075\060\004\060\204\060\074\204\060\204\060\075"
"\204\060\075\060\103\204\060\214\060\204\060\075\060\031\060\073\060\025\060\075\060\204\060\103\204\060\075\060\204\060\000\075\060\226\060\100\204\060\204\060"
@ -5567,7 +5569,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
2690, ZINT_ERROR_TOO_LONG, 1, ""
}, /* #300 (#10) Andre Maute */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -5703,7 +5705,7 @@ static void test_numbprocess(const testCtx *const p_ctx) {
int expected[16];
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { TU("1"), 2, { 902, 11, }, },
/* 1*/ { TU("9"), 2, { 902, 19, }, },
/* 2*/ { TU("12"), 2, { 902, 112, }, },
@ -5757,7 +5759,7 @@ static void test_numbprocess(const testCtx *const p_ctx) {
/* 50*/ { TU("12345678901234567890123456789012345678901234"), 16, { 902, 491, 81, 137, 450, 302, 67, 15, 174, 492, 862, 667, 475, 869, 12, 434, }, },
/* 51*/ { TU("99999999999999999999999999999999999999999999"), 16, { 902, 874, 223, 532, 264, 888, 236, 358, 185, 93, 795, 72, 289, 146, 822, 199, }, },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length;
short chainemc[32];
@ -5813,7 +5815,7 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PDF417, -1, -1, -1, "1234567890", 0, 7, 103, "10 numerics" },
/* 1*/ { BARCODE_PDF417, -1, -1, -1,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz&,:#-.$/+%*=^ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM"
@ -5855,7 +5857,7 @@ static void test_perf(const testCtx *const p_ctx) {
"+E*F_2D+1.00+0005*",
0, 26, 222, "338 chars, text/numeric/byte" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,31 +42,32 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "9", 92, 0, 1, 1111 },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_MSI_PLESSEY, 1, "9", 92, 0, 1, 1123 }, /* 1 mod-10 check digit */
/* 3*/ { BARCODE_MSI_PLESSEY, 1, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 4*/ { BARCODE_MSI_PLESSEY, 2, "9", 92, 0, 1, 1135 }, /* 2 mod-10 check digits */
/* 5*/ { BARCODE_MSI_PLESSEY, 2, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_MSI_PLESSEY, 3, "9", 92, 0, 1, 1123 }, /* 1 mod-11 check digit */
/* 7*/ { BARCODE_MSI_PLESSEY, 3, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_MSI_PLESSEY, 3, "4", 92, 0, 1, 1135 }, /* 1 mod-11 double check digit "10" */
/* 9*/ { BARCODE_MSI_PLESSEY, 3, "4", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 10*/ { BARCODE_MSI_PLESSEY, 4, "9", 92, 0, 1, 1135 }, /* 1 mod-11 and 1 mod-10 check digit */
/* 11*/ { BARCODE_MSI_PLESSEY, 4, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { BARCODE_MSI_PLESSEY, 4, "4", 92, 0, 1, 1147 }, /* 1 mod-11 double check digit "10" and 1 mod-10 check digit */
/* 13*/ { BARCODE_MSI_PLESSEY, 4, "4", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_MSI_PLESSEY, 5, "9", 92, 0, 1, 1123 }, /* 1 NCR mod-11 check digit */
/* 15*/ { BARCODE_MSI_PLESSEY, 5, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { BARCODE_MSI_PLESSEY, 6, "9", 92, 0, 1, 1135 }, /* 1 NCR mod-11 and 1 mod-10 check digit */
/* 17*/ { BARCODE_MSI_PLESSEY, 6, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { BARCODE_PLESSEY, -1, "A", 67, 0, 1, 1139 },
/* 19*/ { BARCODE_PLESSEY, -1, "A", 68, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "9", 92, 0, 1, 1111, "" },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 2*/ { BARCODE_MSI_PLESSEY, 1, "9", 92, 0, 1, 1123, "" }, /* 1 mod-10 check digit */
/* 3*/ { BARCODE_MSI_PLESSEY, 1, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 4*/ { BARCODE_MSI_PLESSEY, 2, "9", 92, 0, 1, 1135, "" }, /* 2 mod-10 check digits */
/* 5*/ { BARCODE_MSI_PLESSEY, 2, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 6*/ { BARCODE_MSI_PLESSEY, 3, "9", 92, 0, 1, 1123, "" }, /* 1 mod-11 check digit */
/* 7*/ { BARCODE_MSI_PLESSEY, 3, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 8*/ { BARCODE_MSI_PLESSEY, 3, "4", 92, 0, 1, 1135, "" }, /* 1 mod-11 double check digit "10" */
/* 9*/ { BARCODE_MSI_PLESSEY, 3, "4", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 10*/ { BARCODE_MSI_PLESSEY, 4, "9", 92, 0, 1, 1135, "" }, /* 1 mod-11 and 1 mod-10 check digit */
/* 11*/ { BARCODE_MSI_PLESSEY, 4, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 12*/ { BARCODE_MSI_PLESSEY, 4, "4", 92, 0, 1, 1147, "" }, /* 1 mod-11 double check digit "10" and 1 mod-10 check digit */
/* 13*/ { BARCODE_MSI_PLESSEY, 4, "4", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 14*/ { BARCODE_MSI_PLESSEY, 5, "9", 92, 0, 1, 1123, "" }, /* 1 NCR mod-11 check digit */
/* 15*/ { BARCODE_MSI_PLESSEY, 5, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 16*/ { BARCODE_MSI_PLESSEY, 6, "9", 92, 0, 1, 1135, "" }, /* 1 NCR mod-11 and 1 mod-10 check digit */
/* 17*/ { BARCODE_MSI_PLESSEY, 6, "9", 93, ZINT_ERROR_TOO_LONG, -1, -1, "Error 372: Input length 93 too long (maximum 92)" },
/* 18*/ { BARCODE_PLESSEY, -1, "A", 67, 0, 1, 1139, "" },
/* 19*/ { BARCODE_PLESSEY, -1, "A", 68, ZINT_ERROR_TOO_LONG, -1, -1, "Error 370: Input length 68 too long (maximum 67)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -88,6 +89,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -111,7 +114,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567", "1234567" },
/* 1*/ { BARCODE_MSI_PLESSEY, 0, "1234567", "1234567" },
/* 2*/ { BARCODE_MSI_PLESSEY, 1, "1234567", "12345674" },
@ -142,7 +145,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 27*/ { BARCODE_MSI_PLESSEY, 4 + 10, "2211", "2211" },
/* 28*/ { BARCODE_PLESSEY, -1, "0123456789ABCDEF", "0123456789ABCDEF" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -178,17 +181,18 @@ static void test_input(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1", 0, 1, 19 },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 2*/ { BARCODE_MSI_PLESSEY, -2, "1", 0, 1, 19 }, /* < 0 ignored */
/* 3*/ { BARCODE_MSI_PLESSEY, 7, "1", 0, 1, 19 }, /* > 6 ignored */
/* 4*/ { BARCODE_PLESSEY, -1, "A", 0, 1, 83 },
/* 5*/ { BARCODE_PLESSEY, -1, "G", ZINT_ERROR_INVALID_DATA, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1", 0, 1, 19, "" },
/* 1*/ { BARCODE_MSI_PLESSEY, -1, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 377: Invalid character at position 1 in input (digits only)" },
/* 2*/ { BARCODE_MSI_PLESSEY, -2, "1", 0, 1, 19, "" }, /* < 0 ignored */
/* 3*/ { BARCODE_MSI_PLESSEY, 7, "1", 0, 1, 19, "" }, /* > 6 ignored */
/* 4*/ { BARCODE_PLESSEY, -1, "A", 0, 1, 83, "" },
/* 5*/ { BARCODE_PLESSEY, -1, "G", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 371: Invalid character at position 1 in input (digits and \"ABCDEF\" only)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -205,6 +209,8 @@ static void test_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -231,7 +237,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", 0, 1, 127, "Verified manually against tec-it",
"1101001001001101001001101001001001101101001101001001001101001101001101101001001101101101101001001001101001001101001001001001001"
},
@ -266,7 +272,7 @@ static void test_encode(const testCtx *const p_ctx) {
"1101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001101101001001001001001001101001"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -343,13 +349,13 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_PLESSEY, -1, "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1", 0, 1, 1107, "PLESSEY 65" },
/* 1*/ { BARCODE_PLESSEY, -1, "123456ABCD", 0, 1, 227, "PLESSEY 10" },
/* 2*/ { BARCODE_MSI_PLESSEY, -1, "12345678901234567890123456789012345678901234567890123456789012345", 0, 1, 787, "MSI_PLESSEY 65" },
/* 3*/ { BARCODE_MSI_PLESSEY, -1, "1234567890", 0, 1, 127, "MSI_PLESSEY 10" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -47,7 +47,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 1, 1, "1", 0, 0 },
/* 1*/ { 2, 1, "11", 0, 0 },
/* 2*/ { 2, 2, "10", 1, 0 },
@ -56,7 +56,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
/* 5*/ { 3, 3, "101010101", 0, 0 },
/* 6*/ { 8, 2, "CBMWKRYGGYRKWMBC", 0, 0 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol *symbol = NULL;
@ -144,7 +144,7 @@ static void test_print(const testCtx *const p_ctx) {
char *expected_file;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1.png", "" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", "", 0, "code128_latin1_2.png", "" },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, 10.0, 0, { 0, 0, "" }, "", "", 1, "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", "", 0, "code128_latin1_1_bold.png", "" },
@ -238,7 +238,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 90*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "", "", 1, "008182709980000020028101276", "", 0, "dpd_compliant.png", "Now with bind top 3X default" },
/* 91*/ { BARCODE_CHANNEL, -1, -1, CMYK_COLOUR | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, 0, 0, { 0, 0, "" }, "100,85,0,20", "FFFFFF00", 1, "123", "", 0, "channel_cmyk_nobg.png", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -386,12 +386,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "632: Could not open PNG output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "png_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = png_pixel_plot(&symbol, data);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "png_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "png_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -45,39 +45,40 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1", 128, 0, 1, 1152 },
/* 1*/ { BARCODE_FLAT, "1", 129, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_POSTNET, "1", 11, 0, 2, 123 },
/* 3*/ { BARCODE_POSTNET, "1", 12, ZINT_WARN_NONCOMPLIANT, 2, 133 },
/* 4*/ { BARCODE_POSTNET, "1", 38, ZINT_WARN_NONCOMPLIANT, 2, 393 },
/* 5*/ { BARCODE_POSTNET, "1", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 6*/ { BARCODE_FIM, "D", 1, 0, 1, 17 },
/* 7*/ { BARCODE_FIM, "D", 2, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 8*/ { BARCODE_CEPNET, "1", 8, 0, 2, 93 },
/* 9*/ { BARCODE_CEPNET, "1", 7, ZINT_WARN_NONCOMPLIANT, 2, 83 },
/* 10*/ { BARCODE_CEPNET, "1", 9, ZINT_WARN_NONCOMPLIANT, 2, 103 },
/* 11*/ { BARCODE_CEPNET, "1", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 12*/ { BARCODE_RM4SCC, "1", 50, 0, 3, 411 },
/* 13*/ { BARCODE_RM4SCC, "1", 51, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 14*/ { BARCODE_JAPANPOST, "1", 20, 0, 3, 133 },
/* 15*/ { BARCODE_JAPANPOST, "1", 21, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 16*/ { BARCODE_JAPANPOST, "A", 10, 0, 3, 133 },
/* 17*/ { BARCODE_JAPANPOST, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 18*/ { BARCODE_KOREAPOST, "1", 6, 0, 1, 162 },
/* 19*/ { BARCODE_KOREAPOST, "1", 7, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 20*/ { BARCODE_PLANET, "1", 13, 0, 2, 143 },
/* 21*/ { BARCODE_PLANET, "1", 14, ZINT_WARN_NONCOMPLIANT, 2, 153 },
/* 22*/ { BARCODE_PLANET, "1", 38, ZINT_WARN_NONCOMPLIANT, 2, 393 },
/* 23*/ { BARCODE_PLANET, "1", 39, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 24*/ { BARCODE_KIX, "1", 18, 0, 3, 143 },
/* 25*/ { BARCODE_KIX, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 26*/ { BARCODE_DAFT, "D", 576, 0, 3, 1151 },
/* 27*/ { BARCODE_DAFT, "D", 577, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1", 128, 0, 1, 1152, "" },
/* 1*/ { BARCODE_FLAT, "1", 129, ZINT_ERROR_TOO_LONG, -1, -1, "Error 494: Input length 129 too long (maximum 128)" },
/* 2*/ { BARCODE_POSTNET, "1", 11, 0, 2, 123, "" },
/* 3*/ { BARCODE_POSTNET, "1", 12, ZINT_WARN_NONCOMPLIANT, 2, 133, "Warning 479: Input length 12 is not standard (5, 9 or 11)" },
/* 4*/ { BARCODE_POSTNET, "1", 38, ZINT_WARN_NONCOMPLIANT, 2, 393, "Warning 479: Input length 38 is not standard (5, 9 or 11)" },
/* 5*/ { BARCODE_POSTNET, "1", 39, ZINT_ERROR_TOO_LONG, -1, -1, "Error 480: Input length 39 too long (maximum 38)" },
/* 6*/ { BARCODE_FIM, "D", 1, 0, 1, 17, "" },
/* 7*/ { BARCODE_FIM, "D", 2, ZINT_ERROR_TOO_LONG, -1, -1, "Error 486: Input length 2 too long (maximum 1)" },
/* 8*/ { BARCODE_CEPNET, "1", 8, 0, 2, 93, "" },
/* 9*/ { BARCODE_CEPNET, "1", 7, ZINT_WARN_NONCOMPLIANT, 2, 83, "Warning 780: Input length 7 wrong (should be 8 digits)" },
/* 10*/ { BARCODE_CEPNET, "1", 9, ZINT_WARN_NONCOMPLIANT, 2, 103, "Warning 780: Input length 9 wrong (should be 8 digits)" },
/* 11*/ { BARCODE_CEPNET, "1", 39, ZINT_ERROR_TOO_LONG, -1, -1, "Error 480: Input length 39 too long (maximum 38)" },
/* 12*/ { BARCODE_RM4SCC, "1", 50, 0, 3, 411, "" },
/* 13*/ { BARCODE_RM4SCC, "1", 51, ZINT_ERROR_TOO_LONG, -1, -1, "Error 488: Input length 51 too long (maximum 50)" },
/* 14*/ { BARCODE_JAPANPOST, "1", 20, 0, 3, 133, "" },
/* 15*/ { BARCODE_JAPANPOST, "1", 21, ZINT_ERROR_TOO_LONG, -1, -1, "Error 496: Input length 21 too long (maximum 20)" },
/* 16*/ { BARCODE_JAPANPOST, "A", 10, 0, 3, 133, "" },
/* 17*/ { BARCODE_JAPANPOST, "A", 11, ZINT_ERROR_TOO_LONG, -1, -1, "Error 477: Input too long, requires too many symbol characters (maximum 20)" },
/* 18*/ { BARCODE_KOREAPOST, "1", 6, 0, 1, 162, "" },
/* 19*/ { BARCODE_KOREAPOST, "1", 7, ZINT_ERROR_TOO_LONG, -1, -1, "Error 484: Input length 7 too long (maximum 6)" },
/* 20*/ { BARCODE_PLANET, "1", 13, 0, 2, 143, "" },
/* 21*/ { BARCODE_PLANET, "1", 14, ZINT_WARN_NONCOMPLIANT, 2, 153, "Warning 478: Input length 14 is not standard (11 or 13)" },
/* 22*/ { BARCODE_PLANET, "1", 38, ZINT_WARN_NONCOMPLIANT, 2, 393, "Warning 478: Input length 38 is not standard (11 or 13)" },
/* 23*/ { BARCODE_PLANET, "1", 39, ZINT_ERROR_TOO_LONG, -1, -1, "Error 482: Input length 39 too long (maximum 38)" },
/* 24*/ { BARCODE_KIX, "1", 18, 0, 3, 143, "" },
/* 25*/ { BARCODE_KIX, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1, "Error 490: Input length 19 too long (maximum 18)" },
/* 26*/ { BARCODE_DAFT, "D", 576, 0, 3, 1151, "" },
/* 27*/ { BARCODE_DAFT, "D", 577, ZINT_ERROR_TOO_LONG, -1, -1, "Error 492: Input length 577 too long (maximum 576)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -99,6 +100,7 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -123,10 +125,10 @@ static void test_koreapost(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "123456", 0, 0, 50, 1, 167 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -172,14 +174,14 @@ static void test_japanpost(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "123", 0, 0, 8, 3, 133, "Check 3" },
/* 1*/ { "123456-AB", 0, 0, 8, 3, 133, "Check 10" },
/* 2*/ { "123456", 0, 0, 8, 3, 133, "Check 11" },
/* 3*/ { "999980-KZ", 0, 0, 8, 3, 133, "Check 18" },
/* 4*/ { "987654-TU", 0, 0, 8, 3, 133, "Check 0" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -224,60 +226,61 @@ static void test_input(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
float expected_height;
char *expected_errtxt;
int bwipp_cmp;
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_FLAT, -1, 0, "1234567890", 0, 1, 90, 50, 1, "" },
/* 1*/ { BARCODE_FLAT, -1, 0, "A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 2*/ { BARCODE_POSTNET, -1, 0, "12345", 0, 2, 63, 12, 1, "" },
/* 3*/ { BARCODE_POSTNET, -1, 0, "123457689", 0, 2, 103, 12, 1, "" },
/* 4*/ { BARCODE_POSTNET, -1, 0, "12345768901", 0, 2, 123, 12, 1, "" },
/* 5*/ { BARCODE_POSTNET, -1, 0, "0", ZINT_WARN_NONCOMPLIANT, 2, 23, 12, 0, "BWIPP requires standard lengths" },
/* 6*/ { BARCODE_POSTNET, -1, 0, "1234", ZINT_WARN_NONCOMPLIANT, 2, 53, 12, 0, "BWIPP requires standard lengths" },
/* 7*/ { BARCODE_POSTNET, -1, 0, "123456", ZINT_WARN_NONCOMPLIANT, 2, 73, 12, 0, "BWIPP requires standard lengths" },
/* 8*/ { BARCODE_POSTNET, -1, 0, "123456789012", ZINT_WARN_NONCOMPLIANT, 2, 133, 12, 0, "BWIPP requires standard lengths" },
/* 9*/ { BARCODE_POSTNET, -1, 0, "1234A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 10*/ { BARCODE_POSTNET, -1, 0.9, "12345", 0, 2, 63, 1, 1, "" },
/* 11*/ { BARCODE_FIM, -1, 0, "a", 0, 1, 17, 50, 1, "" },
/* 12*/ { BARCODE_FIM, -1, 0, "b", 0, 1, 17, 50, 1, "" },
/* 13*/ { BARCODE_FIM, -1, 0, "c", 0, 1, 17, 50, 1, "" },
/* 14*/ { BARCODE_FIM, -1, 0, "d", 0, 1, 17, 50, 1, "" },
/* 15*/ { BARCODE_FIM, -1, 0, "ad", ZINT_ERROR_TOO_LONG, -1, -1, -1, 1, "" },
/* 16*/ { BARCODE_FIM, -1, 0, "e", 0, 1, 17, 50, 1, "" },
/* 17*/ { BARCODE_FIM, -1, 0, "f", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 18*/ { BARCODE_CEPNET, -1, 0, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 19*/ { BARCODE_RM4SCC, -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 3, 299, 8, 1, "" },
/* 20*/ { BARCODE_RM4SCC, -1, 0, "a", 0, 3, 19, 8, 1, "" }, /* Converts to upper */
/* 21*/ { BARCODE_RM4SCC, -1, 0, ",", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 22*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCD", 0, 3, 133, 8, 1, "" }, /* 19 symbol chars */
/* 23*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCD1", 0, 3, 133, 8, 1, "" }, /* 20 symbol chars */
/* 24*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCDE", ZINT_ERROR_TOO_LONG, -1, -1, -1, 1, "" }, /* 21 symbol chars */
/* 25*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCD12", ZINT_ERROR_TOO_LONG, -1, -1, -1, 1, "" }, /* 21 symbol chars */
/* 26*/ { BARCODE_JAPANPOST, -1, 0, "1234567890ABCDE", 0, 3, 133, 8, 1, "" }, /* 20 symbol chars */
/* 27*/ { BARCODE_JAPANPOST, -1, 0, "a", 0, 3, 133, 8, 1, "" }, /* Converts to upper */
/* 28*/ { BARCODE_JAPANPOST, -1, 0, ",", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 29*/ { BARCODE_KOREAPOST, -1, 0, "123456", 0, 1, 167, 50, 1, "" },
/* 30*/ { BARCODE_KOREAPOST, -1, 0, "A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 31*/ { BARCODE_PLANET, -1, 0, "12345678901", 0, 2, 123, 12, 1, "" },
/* 32*/ { BARCODE_PLANET, -1, 0, "1234567890123", 0, 2, 143, 12, 1, "" },
/* 33*/ { BARCODE_PLANET, -1, 0, "0", ZINT_WARN_NONCOMPLIANT, 2, 23, 12, 0, "BWIPP requires standard lengths" },
/* 34*/ { BARCODE_PLANET, -1, 0, "1234567890", ZINT_WARN_NONCOMPLIANT, 2, 113, 12, 0, "BWIPP requires standard lengths" },
/* 35*/ { BARCODE_PLANET, -1, 0, "123456789012", ZINT_WARN_NONCOMPLIANT, 2, 133, 12, 0, "BWIPP requires standard lengths" },
/* 36*/ { BARCODE_PLANET, -1, 0, "12345678901234", ZINT_WARN_NONCOMPLIANT, 2, 153, 12, 0, "BWIPP requires standard lengths" },
/* 37*/ { BARCODE_PLANET, -1, 0, "1234567890A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 38*/ { BARCODE_KIX, -1, 0, "0123456789ABCDEFGH", 0, 3, 143, 8, 1, "" },
/* 39*/ { BARCODE_KIX, -1, 0, "a", 0, 3, 7, 8, 1, "" }, /* Converts to upper */
/* 40*/ { BARCODE_KIX, -1, 0, ",", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 41*/ { BARCODE_DAFT, -1, 0, "DAFT", 0, 3, 7, 8, 1, "" },
/* 42*/ { BARCODE_DAFT, -1, 0, "a", 0, 3, 1, 8, 1, "" }, /* Converts to upper */
/* 43*/ { BARCODE_DAFT, -1, 0, "B", ZINT_ERROR_INVALID_DATA, -1, -1, -1, 1, "" },
/* 44*/ { BARCODE_DAFT, -1, 1.9, "DAFT", 0, 3, 7, 2, 1, "" },
/* 45*/ { BARCODE_DAFT, 500, 0.9, "DAFT", 0, 3, 7, 2, 1, "" }, /* 50% ratio */
/* 46*/ { BARCODE_DAFT, 500, 0.4, "DAFT", 0, 3, 7, 8, 1, "" }, /* 50% ratio */
static const struct item data[] = {
/* 0*/ { BARCODE_FLAT, -1, 0, "1234567890", 0, 1, 90, 50, "", 1, "" },
/* 1*/ { BARCODE_FLAT, -1, 0, "A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 495: Invalid character at position 1 in input (digits only)", 1, "" },
/* 2*/ { BARCODE_POSTNET, -1, 0, "12345", 0, 2, 63, 12, "", 1, "" },
/* 3*/ { BARCODE_POSTNET, -1, 0, "123457689", 0, 2, 103, 12, "", 1, "" },
/* 4*/ { BARCODE_POSTNET, -1, 0, "12345768901", 0, 2, 123, 12, "", 1, "" },
/* 5*/ { BARCODE_POSTNET, -1, 0, "0", ZINT_WARN_NONCOMPLIANT, 2, 23, 12, "Warning 479: Input length 1 is not standard (5, 9 or 11)", 0, "BWIPP requires standard lengths" },
/* 6*/ { BARCODE_POSTNET, -1, 0, "1234", ZINT_WARN_NONCOMPLIANT, 2, 53, 12, "Warning 479: Input length 4 is not standard (5, 9 or 11)", 0, "BWIPP requires standard lengths" },
/* 7*/ { BARCODE_POSTNET, -1, 0, "123456", ZINT_WARN_NONCOMPLIANT, 2, 73, 12, "Warning 479: Input length 6 is not standard (5, 9 or 11)", 0, "BWIPP requires standard lengths" },
/* 8*/ { BARCODE_POSTNET, -1, 0, "123456789012", ZINT_WARN_NONCOMPLIANT, 2, 133, 12, "Warning 479: Input length 12 is not standard (5, 9 or 11)", 0, "BWIPP requires standard lengths" },
/* 9*/ { BARCODE_POSTNET, -1, 0, "1234A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 481: Invalid character at position 5 in input (digits only)", 1, "" },
/* 10*/ { BARCODE_POSTNET, -1, 0.9, "12345", 0, 2, 63, 1, "", 1, "" },
/* 11*/ { BARCODE_FIM, -1, 0, "a", 0, 1, 17, 50, "", 1, "" },
/* 12*/ { BARCODE_FIM, -1, 0, "b", 0, 1, 17, 50, "", 1, "" },
/* 13*/ { BARCODE_FIM, -1, 0, "c", 0, 1, 17, 50, "", 1, "" },
/* 14*/ { BARCODE_FIM, -1, 0, "d", 0, 1, 17, 50, "", 1, "" },
/* 15*/ { BARCODE_FIM, -1, 0, "ad", ZINT_ERROR_TOO_LONG, -1, -1, -1, "Error 486: Input length 2 too long (maximum 1)", 1, "" },
/* 16*/ { BARCODE_FIM, -1, 0, "e", 0, 1, 17, 50, "", 1, "" },
/* 17*/ { BARCODE_FIM, -1, 0, "f", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 487: Invalid character in input (\"A\", \"B\", \"C\", \"D\" or \"E\" only)", 1, "" },
/* 18*/ { BARCODE_CEPNET, -1, 0, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 481: Invalid character at position 8 in input (digits only)", 1, "" },
/* 19*/ { BARCODE_RM4SCC, -1, 0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, 3, 299, 8, "", 1, "" },
/* 20*/ { BARCODE_RM4SCC, -1, 0, "a", 0, 3, 19, 8, "", 1, "" }, /* Converts to upper */
/* 21*/ { BARCODE_RM4SCC, -1, 0, ",", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 489: Invalid character at position 1 in input (alphanumerics only)", 1, "" },
/* 22*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCD", 0, 3, 133, 8, "", 1, "" }, /* 19 symbol chars */
/* 23*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCD1", 0, 3, 133, 8, "", 1, "" }, /* 20 symbol chars */
/* 24*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCDE", ZINT_ERROR_TOO_LONG, -1, -1, -1, "Error 477: Input too long, requires too many symbol characters (maximum 20)", 1, "" }, /* 21 symbol chars */
/* 25*/ { BARCODE_JAPANPOST, -1, 0, "1234567890-ABCD12", ZINT_ERROR_TOO_LONG, -1, -1, -1, "Error 477: Input too long, requires too many symbol characters (maximum 20)", 1, "" }, /* 21 symbol chars */
/* 26*/ { BARCODE_JAPANPOST, -1, 0, "1234567890ABCDE", 0, 3, 133, 8, "", 1, "" }, /* 20 symbol chars */
/* 27*/ { BARCODE_JAPANPOST, -1, 0, "a", 0, 3, 133, 8, "", 1, "" }, /* Converts to upper */
/* 28*/ { BARCODE_JAPANPOST, -1, 0, ",", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 497: Invalid character at position 1 in input (alphanumerics and \"-\" only)", 1, "" },
/* 29*/ { BARCODE_KOREAPOST, -1, 0, "123456", 0, 1, 167, 50, "", 1, "" },
/* 30*/ { BARCODE_KOREAPOST, -1, 0, "A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 485: Invalid character at position 1 in input (digits only)", 1, "" },
/* 31*/ { BARCODE_PLANET, -1, 0, "12345678901", 0, 2, 123, 12, "", 1, "" },
/* 32*/ { BARCODE_PLANET, -1, 0, "1234567890123", 0, 2, 143, 12, "", 1, "" },
/* 33*/ { BARCODE_PLANET, -1, 0, "0", ZINT_WARN_NONCOMPLIANT, 2, 23, 12, "Warning 478: Input length 1 is not standard (11 or 13)", 0, "BWIPP requires standard lengths" },
/* 34*/ { BARCODE_PLANET, -1, 0, "1234567890", ZINT_WARN_NONCOMPLIANT, 2, 113, 12, "Warning 478: Input length 10 is not standard (11 or 13)", 0, "BWIPP requires standard lengths" },
/* 35*/ { BARCODE_PLANET, -1, 0, "123456789012", ZINT_WARN_NONCOMPLIANT, 2, 133, 12, "Warning 478: Input length 12 is not standard (11 or 13)", 0, "BWIPP requires standard lengths" },
/* 36*/ { BARCODE_PLANET, -1, 0, "12345678901234", ZINT_WARN_NONCOMPLIANT, 2, 153, 12, "Warning 478: Input length 14 is not standard (11 or 13)", 0, "BWIPP requires standard lengths" },
/* 37*/ { BARCODE_PLANET, -1, 0, "1234567890A", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 483: Invalid character at position 11 in input (digits only)", 1, "" },
/* 38*/ { BARCODE_KIX, -1, 0, "0123456789ABCDEFGH", 0, 3, 143, 8, "", 1, "" },
/* 39*/ { BARCODE_KIX, -1, 0, "a", 0, 3, 7, 8, "", 1, "" }, /* Converts to upper */
/* 40*/ { BARCODE_KIX, -1, 0, ",", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 491: Invalid character at position 1 in input (alphanumerics only)", 1, "" },
/* 41*/ { BARCODE_DAFT, -1, 0, "DAFT", 0, 3, 7, 8, "", 1, "" },
/* 42*/ { BARCODE_DAFT, -1, 0, "a", 0, 3, 1, 8, "", 1, "" }, /* Converts to upper */
/* 43*/ { BARCODE_DAFT, -1, 0, "B", ZINT_ERROR_INVALID_DATA, -1, -1, -1, "Error 493: Invalid character at position 1 in input (\"D\", \"A\", \"F\" and \"T\" only)", 1, "" },
/* 44*/ { BARCODE_DAFT, -1, 1.9, "DAFT", 0, 3, 7, 2, "", 1, "" },
/* 45*/ { BARCODE_DAFT, 500, 0.9, "DAFT", 0, 3, 7, 2, "", 1, "" }, /* 50% ratio */
/* 46*/ { BARCODE_DAFT, 500, 0.4, "DAFT", 0, 3, 7, 8, "", 1, "" }, /* 50% ratio */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -302,6 +305,7 @@ static void test_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -343,7 +347,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_FLAT, "1304056", 0, 1, 63, "Verified manually against tec-it",
"100000000001000000000000000000100000000000000000010000000001000"
},
@ -473,7 +477,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100010000010001010000010000000100"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -550,12 +554,12 @@ static void test_perf(const testCtx *const p_ctx) {
int expected_width;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_POSTNET, -1, "12345678901", 0, 2, 123, "POSTNET 11" },
/* 1*/ { BARCODE_PLANET, -1, "1234567890123", 0, 2, 143, "PLANET 13" },
/* 2*/ { BARCODE_KOREAPOST, -1, "123456", 0, 1, 167, "KOREAPOST 6" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -52,7 +52,7 @@ static void test_print(const testCtx *const p_ctx) {
char *data;
char *expected_file;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 0, "Égjpqy", "code128_egrave_bold.eps" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 90, "Égjpqy", "code128_egrave_bold_rotate_90.eps" },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, 0, 0, "", "", 180, "Égjpqy", "code128_egrave_bold_rotate_180.eps" },
@ -113,7 +113,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 57*/ { BARCODE_MAXICODE, -1, -1, -1, 3, -1, -1, -1, 0, 0, "", "0000FF00", 180, "12", "maxicode_no_bg_hwsp3_rotate_180.eps" },
/* 58*/ { BARCODE_MAXICODE, -1, -1, -1, -1, -1, -1, -1, 2.4, 0, "", "", 90, "12", "maxicode_2.4_rotate_90.eps" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -229,10 +229,10 @@ static void test_ps_convert(const testCtx *const p_ctx) {
char *data;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "1\\(é)2€3¿", "1\\\\\\(\351\\)23\277" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i;
unsigned char converted[256];
@ -270,12 +270,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "645: Could not open EPS output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "ps_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = ps_plot(&symbol, 0);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ps_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "ps_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -44,7 +44,7 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
int expected_width;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, "1234567890123", 100, 30, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_DBAR_OMN, "0000004537076", 100, 30, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_DBAR_OMN, "0000004537077", 100, 30, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
@ -117,9 +117,9 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
/* 69*/ { BARCODE_DBAR_LTD, "1651257071912", 100, 30, 1, 79, "0100000111100011110101010101010111010100100101010101010101111110111111110100000" },
/* 70*/ { BARCODE_DBAR_LTD_CC, "0987144605916", 100, 30, 6, 79, "0101010101010011111000011111011010110100100101010101010100111110000111110100000" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char *text;
@ -130,7 +130,7 @@ static void test_binary_div_modulo_divisor(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_binary_div_modulo_divisor");
testStartSymbol("test_binary_div_modulo_divisor", &symbol);
for (i = 0; i < data_size; i++) {
@ -212,7 +212,7 @@ static void test_examples(const testCtx *const p_ctx) {
char *expected;
};
/* Verified manually against GS1 General Specifications 21.0.1 (GGS) and ISO/IEC 24724:2011, and verified via bwipp_dump.ps against BWIPP */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, -1, -1, -1, "0950110153001", 0, 1, 96, 1, "GGS Figure 5.5.2.1.1-1. GS1 DataBar Omnidirectional",
"010000010100000101000111110000010111101101011100100011011101000101100000000111001110110111001101"
},
@ -861,9 +861,9 @@ static void test_examples(const testCtx *const p_ctx) {
"101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[16384];
@ -872,7 +872,7 @@ static void test_examples(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_examples");
testStartSymbol("test_examples", &symbol);
for (i = 0; i < data_size; i++) {
@ -947,7 +947,7 @@ static void test_general_field(const testCtx *const p_ctx) {
char *expected;
};
/* Verified via bwipp_dump.ps against BWIPP and manually against tec-it.com (some separators differ from tec-it.com where noted) */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_EXP, "[91]1", 1, 102, "Single numeric",
"010100000001000101101111111100001011001000010000010110111110101100001011110000000010101111100001011101"
},
@ -1195,11 +1195,11 @@ static void test_general_field(const testCtx *const p_ctx) {
"101110011100010010011100111111110100111101001000011000010010001011110100001111110001100010100000100010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_general_field");
testStartSymbol("test_general_field", &symbol);
for (i = 0; i < data_size; i++) {
@ -1244,26 +1244,28 @@ static void test_binary_buffer_size(const testCtx *const p_ctx) {
int expected_rows;
int expected_width;
char *expected_errtxt;
char *comment;
};
struct item data[] = {
/* 0*/ { -1, "[91]1", 0, 1, 102, "Minimum digit" },
/* 1*/ { -1, "[91]+", 0, 1, 102, "Minimum ISO-646" },
/* 2*/ { -1, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678", 0, 1, 543, "70 == any AIs max" },
/* 3*/ { -1, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]123456789", ZINT_ERROR_TOO_LONG, 0, 0, "71 > any AIs max" },
/* 4*/ { GS1NOCHECK_MODE, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]123456789", ZINT_ERROR_TOO_LONG, 0, 0, "No check doesn't affect limit" },
/* 5*/ { -1, "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]1234567890123456", 0, 1, 543, "74 == 01 + other AIs max" },
/* 6*/ { -1, "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]12345678901234567", ZINT_ERROR_TOO_LONG, 0, 0, "75 > 01 + other AIs max" },
/* 7*/ { GS1NOCHECK_MODE, "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]12345678901234567", ZINT_ERROR_TOO_LONG, 0, 0, "No check doesn't affect limit" },
/* 8*/ { -1, "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]1234567890123456789", 0, 1, 543, "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" },
/* 9*/ { -1, "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "78 > 01 + 392x + other AIs max" },
/* 10*/ { GS1NOCHECK_MODE, "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "No check doesn't affect limit" },
static const struct item data[] = {
/* 0*/ { -1, "[91]1", 0, 1, 102, "", "Minimum digit" },
/* 1*/ { -1, "[91]+", 0, 1, 102, "", "Minimum ISO-646" },
/* 2*/ { -1, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]12345678", 0, 1, 543, "", "70 == any AIs max" },
/* 3*/ { -1, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]1234567890", ZINT_ERROR_TOO_LONG, 0, 0, "Error 387: Input too long, requires 22 symbol characters (maximum 21)", "71 > any AIs max" },
/* 4*/ { GS1NOCHECK_MODE, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]123456789", ZINT_ERROR_TOO_LONG, 0, 0, "Error 387: Input too long, requires 22 symbol characters (maximum 21)", "No check doesn't affect limit" },
/* 5*/ { -1, "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]1234567890123456", 0, 1, 543, "", "74 == 01 + other AIs max" },
/* 6*/ { -1, "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]12345678901234567", ZINT_ERROR_TOO_LONG, 0, 0, "Error 387: Input too long, requires 22 symbol characters (maximum 21)", "75 > 01 + other AIs max" },
/* 7*/ { GS1NOCHECK_MODE, "[01]12345678901231[00]123456789012345675[00]123456789012345675[91]12345678901234567", ZINT_ERROR_TOO_LONG, 0, 0, "Error 387: Input too long, requires 22 symbol characters (maximum 21)", "No check doesn't affect limit" },
/* 8*/ { -1, "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]1234567890123456789", 0, 1, 543, "", "77 (incl. FNC1 after 3920) == 01 + 392x + other AIs max" },
/* 9*/ { -1, "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "Error 378: Processed input length 78 too long (maximum 77)", "78 > 01 + 392x + other AIs max" },
/* 10*/ { GS1NOCHECK_MODE, "[01]92345678901237[3920]123456789012345[00]123456789012345675[91]12345678901234567890", ZINT_ERROR_TOO_LONG, 0, 0, "Error 378: Processed input length 78 too long (maximum 77)", "No check doesn't affect limit" },
/* 11*/ { -1, "[00]123456789012345675[00]123456789012345675[00]123456789012345675[91]123456789012345", ZINT_ERROR_TOO_LONG, 0, 0, "Error 387: Input too long, requires 23 symbol characters (maximum 21)", "Reduced length 77" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_binary_buffer_size");
testStartSymbol("test_binary_buffer_size", &symbol);
for (i = 0; i < data_size; i++) {
@ -1276,11 +1278,14 @@ static void test_binary_buffer_size(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), data[i].data, testUtilErrorName(ret), symbol->rows, symbol->width, data[i].comment);
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), data[i].data, testUtilErrorName(ret), symbol->rows,
symbol->width, symbol->errtxt, data[i].comment);
} else {
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
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);
}
@ -1303,7 +1308,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, -1, "1234567890123", 0, "(01)12345678901231" },
/* 1*/ { BARCODE_DBAR_OMN, -1, "12345678901231", 0, "(01)12345678901231" },
/* 4*/ { BARCODE_DBAR_OMN, -1, "1000000000009", 0, "(01)10000000000090" },
@ -1314,11 +1319,11 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 11*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "" },
/* 12*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_hrt");
testStartSymbol("test_hrt", &symbol);
for (i = 0; i < data_size; i++) {
@ -1355,25 +1360,25 @@ static void test_input(const testCtx *const p_ctx) {
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_DBAR_OMN, -1, -1, -1, "1234567890123", 0, 1, 96, "" },
/* 1*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 2*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 1*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 2*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 3*/ { BARCODE_DBAR_OMN, -1, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'" },
/* 4*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "12345678901234", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '4', expecting '1'" }, /* Still checked */
/* 5*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum)" },
/* 6*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum)" },
/* 5*/ { BARCODE_DBAR_OMN, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" },
/* 6*/ { BARCODE_DBAR_OMN, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" },
/* 7*/ { BARCODE_DBAR_LTD, -1, -1, -1, "1234567890123", 0, 1, 79, "" },
/* 8*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character in data (digits only)" },
/* 9*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character in data (digits only)" },
/* 8*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)" },
/* 9*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 383: Invalid character at position 13 in input (digits only)" },
/* 10*/ { BARCODE_DBAR_LTD, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'" },
/* 11*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 389: Invalid check digit '5', expecting '1'" }, /* Still checked */
/* 12*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input too long (14 character maximum)" },
/* 13*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input too long (14 character maximum)" },
/* 14*/ { BARCODE_DBAR_LTD, -1, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input out of range (0 to 1999999999999)" },
/* 15*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input out of range (0 to 1999999999999)" },
/* 16*/ { BARCODE_DBAR_LTD, -1, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input out of range (0 to 1999999999999)" },
/* 17*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input out of range (0 to 1999999999999)" },
/* 12*/ { BARCODE_DBAR_LTD, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)" },
/* 13*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 15 too long (maximum 14)" },
/* 14*/ { BARCODE_DBAR_LTD, -1, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" },
/* 15*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "2234567890123", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" },
/* 16*/ { BARCODE_DBAR_LTD, -1, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" },
/* 17*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)" },
/* 18*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'" },
/* 19*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "" },
/* 20*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231", 0, 1, 134, "" },
@ -1388,20 +1393,20 @@ static void test_input(const testCtx *const p_ctx) {
/* 29*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "" }, /* ISOIEC punc less space */
/* 30*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "" },
/* 31*/ { BARCODE_DBAR_STK, -1, -1, -1, "1234567890123", 0, 3, 50, "" },
/* 32*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 33*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 34*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 32*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 33*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 34*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 35*/ { BARCODE_DBAR_STK, -1, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'" },
/* 36*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "12345678901235", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '5', expecting '1'" }, /* Still checked */
/* 37*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum)" },
/* 38*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum)" },
/* 37*/ { BARCODE_DBAR_STK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" },
/* 38*/ { BARCODE_DBAR_STK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" },
/* 39*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "1234567890123", 0, 5, 50, "" },
/* 40*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 41*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character in data (digits only)" },
/* 40*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 41*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 381: Invalid character at position 13 in input (digits only)" },
/* 42*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'" },
/* 43*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "12345678901236", ZINT_ERROR_INVALID_CHECK, -1, -1, "Error 388: Invalid check digit '6', expecting '1'" }, /* Still checked */
/* 44*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum)" },
/* 45*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input too long (14 character maximum)" },
/* 44*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" },
/* 45*/ { BARCODE_DBAR_OMNSTK, GS1NOCHECK_MODE, -1, -1, "123456789012315", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 15 too long (maximum 14)" },
/* 46*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'" },
/* 47*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 5, 102, "" },
/* 48*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901231", 0, 5, 102, "" },
@ -1468,11 +1473,11 @@ static void test_input(const testCtx *const p_ctx) {
/*109*/ { BARCODE_DBAR_EXPSTK, -1, -1, 6, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" },
/*110*/ { BARCODE_DBAR_EXPSTK, -1, -1, 7, "[91]12345678901234567890123456789012345678901234567890123456789012", 0, 21, 102, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_input");
testStartSymbol("test_input", &symbol);
for (i = 0; i < data_size; i++) {

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -56,7 +56,7 @@ static void test_print(const testCtx *const p_ctx) {
char *expected_file;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "<>\"&'", "", 0, "code128_amperands.svg", "" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "Égjpqy", "", 0, "code128_egrave_bold.svg", "" },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, BOLD_TEXT | EMBED_VECTOR_FONT, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "Égjpqy", "", 0, "code128_egrave_bold_embed.svg", "" },
@ -140,7 +140,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 80*/ { BARCODE_DPD, -1, -1, BARCODE_QUIET_ZONES | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "", "", 0, "008182709980000020028101276", "", 0, "dpd_compliant.svg", "" },
/* 81*/ { BARCODE_CHANNEL, -1, -1, CMYK_COLOUR | COMPLIANT_HEIGHT, -1, -1, -1, -1, -1, -1, 0, "100,85,0,20", "FFFFFF00", 0, "123", "", 0, "channel_cmyk_nobg.svg", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -288,12 +288,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "680: Could not open SVG output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "svg_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = svg_plot(&symbol, 0);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "svg_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "svg_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -41,15 +41,16 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "\177", 69, 0, 1, 1152 },
/* 1*/ { BARCODE_TELEPEN, "\177", 70, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { BARCODE_TELEPEN_NUM, "1", 136, 0, 1, 1136 },
/* 3*/ { BARCODE_TELEPEN_NUM, "1", 137, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "\177", 69, 0, 1, 1152, "" },
/* 1*/ { BARCODE_TELEPEN, "\177", 70, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 70 too long (maximum 69)" },
/* 2*/ { BARCODE_TELEPEN_NUM, "1", 136, 0, 1, 1136, "" },
/* 3*/ { BARCODE_TELEPEN_NUM, "1", 137, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 137 too long (maximum 136)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -71,6 +72,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -94,7 +97,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "ABC1234.;$", -1, "ABC1234.;$" },
/* 1*/ { BARCODE_TELEPEN, "abc1234.;$", -1, "abc1234.;$" },
/* 2*/ { BARCODE_TELEPEN, "ABC1234\001", -1, "ABC1234\001" },
@ -104,7 +107,7 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 6*/ { BARCODE_TELEPEN_NUM, "123x", -1, "123X" }, /* Converts to upper */
/* 7*/ { BARCODE_TELEPEN_NUM, "12345", -1, "012345" }, /* Adds leading zero if odd */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -140,20 +143,21 @@ static void test_input(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, " !\"#$%&'()*+,-./0123456789:;<", -1, 0, 1, 512 },
/* 1*/ { BARCODE_TELEPEN, "AZaz\176\001", -1, 0, 1, 144 },
/* 2*/ { BARCODE_TELEPEN, "\000\177", 2, 0, 1, 80 },
/* 3*/ { BARCODE_TELEPEN, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 4*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128 },
/* 5*/ { BARCODE_TELEPEN_NUM, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 },
/* 6*/ { BARCODE_TELEPEN_NUM, "123456789X", -1, 0, 1, 128 }, /* [0-9]X allowed */
/* 7*/ { BARCODE_TELEPEN_NUM, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, /* X[0-9] not allowed */
/* 8*/ { BARCODE_TELEPEN_NUM, "1X34567X9X", -1, 0, 1, 128 }, /* [0-9]X allowed multiple times */
static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, " !\"#$%&'()*+,-./0123456789:;<", -1, 0, 1, 512, "" },
/* 1*/ { BARCODE_TELEPEN, "AZaz\176\001", -1, 0, 1, 144, "" },
/* 2*/ { BARCODE_TELEPEN, "\000\177", 2, 0, 1, 80, "" },
/* 3*/ { BARCODE_TELEPEN, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 391: Invalid character at position 1 in input, extended ASCII not allowed" },
/* 4*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128, "" },
/* 5*/ { BARCODE_TELEPEN_NUM, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 393: Invalid character at position 10 in input (digits and \"X\" only)" },
/* 6*/ { BARCODE_TELEPEN_NUM, "123456789X", -1, 0, 1, 128, "" }, /* [0-9]X allowed */
/* 7*/ { BARCODE_TELEPEN_NUM, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 9 of \"X\" in Telepen data" }, /* X[0-9] not allowed */
/* 8*/ { BARCODE_TELEPEN_NUM, "1X34567X9X", -1, 0, 1, 128, "" }, /* [0-9]X allowed multiple times */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -170,6 +174,8 @@ static void test_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -200,7 +206,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "1A", -1, 0, 1, 80, "Telepen BSiH Example, same",
"10101010101110001011101000100010101110111011100010100010001110101110001010101010"
},
@ -232,7 +238,7 @@ static void test_encode(const testCtx *const p_ctx) {
"10101010101110001010101010101110111011101110101011101110111011101110001010101010"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -301,7 +307,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
};
/* Note NULs where using DELs code (16 binary characters wide) */
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_TELEPEN, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 69, 0 },
/* 1*/ { BARCODE_TELEPEN, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 70, ZINT_ERROR_TOO_LONG },
/* 2*/ { BARCODE_TELEPEN_NUM, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 70, ZINT_ERROR_INVALID_DATA },
@ -311,7 +317,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
/* 6*/ { BARCODE_TELEPEN_NUM, "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", 136, 0 },
/* 7*/ { BARCODE_TELEPEN_NUM, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 4, 0 }, /* Length given, strlen > 137, so pseudo not NUL-terminated */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;

View file

@ -47,7 +47,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { 1, 1, "1", 0, 0, 0 },
/* 1*/ { 2, 1, "11", 0, 0, 0 },
/* 2*/ { 1, 2, "11", 0, 0, 0 },
@ -87,7 +87,7 @@ static void test_pixel_plot(const testCtx *const p_ctx) {
/* 36*/ { ZINT_MAX_DATA_LEN, 2, "10", 1, 1, 0 }, /* Strip Count 2, Rows Per Strip 1 */
/* 37*/ { 2, ZINT_MAX_DATA_LEN, "10", 1, 1 /*NOTE: disabled due to failing on github CI, works locally*/, 0 }, /* Strip Count 17, Rows Per Strip 1024 */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol *symbol = NULL;
@ -179,7 +179,7 @@ static void test_print(const testCtx *const p_ctx) {
char *expected_file;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "112233", "EEDDCC", "A", "", "code128_fgbg.tif", "" },
/* 1*/ { BARCODE_CODE128, -1, -1, -1, 1, -1, -1, -1, -1, 0, 0, "FFFFFF", "000000", "A", "", "code128_reverse.tif", "" },
/* 2*/ { BARCODE_CODE128, -1, -1, CMYK_COLOUR, 1, -1, -1, -1, -1, 0, 0, "112233", "CCDDEE", "A", "", "code128_cmyk_fgbg.tif", "" },
@ -205,7 +205,7 @@ static void test_print(const testCtx *const p_ctx) {
/* 22*/ { BARCODE_EANX, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, "", "", "9501234", "", "ean8_gss_5.2.2.2-1.tif", "" },
/* 23*/ { BARCODE_EANX, -1, -1, EANUPC_GUARD_WHITESPACE, -1, -1, -1, -1, -1, 0, 0, "", "", "9501234", "", "ean8_gss_5.2.2.2-1_gws.tif", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -347,12 +347,15 @@ static void test_outfile(const testCtx *const p_ctx) {
skip_readonly_test = getuid() == 0; /* Skip if running as root on Unix as can't create read-only file */
#endif
if (!skip_readonly_test) {
static char expected_errtxt[] = "672: Could not open TIF output file ("; /* Excluding OS-dependent `errno` stuff */
(void) testUtilRmROFile(symbol.outfile); /* In case lying around from previous fail */
assert_nonzero(testUtilCreateROFile(symbol.outfile), "tif_pixel_plot testUtilCreateROFile(%s) fail (%d: %s)\n", symbol.outfile, errno, strerror(errno));
ret = tif_pixel_plot(&symbol, data);
assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "tif_pixel_plot ret %d != ZINT_ERROR_FILE_ACCESS (%d) (%s)\n", ret, ZINT_ERROR_FILE_ACCESS, symbol.errtxt);
assert_zero(testUtilRmROFile(symbol.outfile), "tif_pixel_plot testUtilRmROFile(%s) != 0 (%d: %s)\n", symbol.outfile, errno, strerror(errno));
assert_zero(strncmp(symbol.errtxt, expected_errtxt, sizeof(expected_errtxt) - 1), "strncmp(%s, %s) != 0\n", symbol.errtxt, expected_errtxt);
}
symbol.output_options |= BARCODE_STDOUT;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -43,48 +43,50 @@ static void test_large(const testCtx *const p_ctx) {
int ret;
int expected_rows;
int expected_width;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { -1, -1, { 0, 0, "" }, "1", 252, 0, 31, 66 }, /* Default EC2 */
/* 1*/ { -1, -1, { 0, 0, "" }, "1", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 2*/ { -1, -1, { 0, 0, "" }, "1", ZINT_MAX_DATA_LEN, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 3*/ { -1, -1, { 1, 2, "" }, "1", 251, 0, 31, 66 }, /* Structured Append no File Number 1 codeword overhead */
/* 4*/ { -1, -1, { 1, 2, "" }, "1", 252, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 5*/ { -1, -1, { 1, 2, "1" }, "1", 249, 0, 31, 66 }, /* Structured Append with File Number 3 codewords overhead */
/* 6*/ { -1, -1, { 1, 2, "1" }, "1", 250, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 7*/ { -1, -1, { 0, 0, "" }, "A", 252, 0, 31, 66 },
/* 8*/ { -1, -1, { 0, 0, "" }, "A", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 9*/ { -1, -1, { 0, 0, "" }, "\200", 252, 0, 31, 66 },
/* 10*/ { -1, -1, { 0, 0, "" }, "\200", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 11*/ { -1, -1, { 0, 0, "" }, "\001", 252, 0, 31, 66 },
/* 12*/ { -1, -1, { 0, 0, "" }, "\001", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 13*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "1", 504, 0, 31, 66 },
/* 14*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "1", 505, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 15*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "A", 375, 0, 31, 66 },
/* 16*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "A", 376, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 17*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\200", 252, 0, 31, 66 },
/* 18*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\200", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 19*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\001", 252, 0, 31, 66 },
/* 20*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\001", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 21*/ { 1, -1, { 0, 0, "" }, "1", 276, 0, 31, 66 },
/* 22*/ { 1, -1, { 0, 0, "" }, "1", 277, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 23*/ { 1, -1, { 1, 2, "" }, "1", 275, 0, 31, 66 },
/* 24*/ { 1, -1, { 1, 2, "" }, "1", 276, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 25*/ { 1, -1, { 1, 2, "1" }, "1", 273, 0, 31, 66 },
/* 26*/ { 1, -1, { 1, 2, "1" }, "1", 274, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 27*/ { 2, -1, { 0, 0, "" }, "1", 263, 0, 31, 66 },
/* 28*/ { 2, -1, { 0, 0, "" }, "1", 264, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 29*/ { 3, -1, { 0, 0, "" }, "1", 252, 0, 31, 66 },
/* 30*/ { 3, -1, { 0, 0, "" }, "1", 253, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 31*/ { 4, -1, { 0, 0, "" }, "1", 234, 0, 31, 66 },
/* 32*/ { 4, -1, { 0, 0, "" }, "1", 235, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 33*/ { 5, -1, { 0, 0, "" }, "1", 220, 0, 31, 66 },
/* 34*/ { 5, -1, { 0, 0, "" }, "1", 221, ZINT_ERROR_TOO_LONG, -1, -1 },
/* 35*/ { 6, -1, { 0, 0, "" }, "1", 202, 0, 31, 66 },
/* 36*/ { 6, -1, { 0, 0, "" }, "1", 203, ZINT_ERROR_TOO_LONG, -1, -1 },
static const struct item data[] = {
/* 0*/ { -1, -1, { 0, 0, "" }, "1", 252, 0, 31, 66, "" }, /* Default EC2 */
/* 1*/ { -1, -1, { 0, 0, "" }, "1", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 2*/ { -1, -1, { 0, 0, "" }, "1", ZINT_MAX_DATA_LEN, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 17403 codewords (maximum 255)" },
/* 3*/ { -1, -1, { 1, 2, "" }, "1", 251, 0, 31, 66, "" }, /* Structured Append no File Number 1 codeword overhead */
/* 4*/ { -1, -1, { 1, 2, "" }, "1", 252, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 5*/ { -1, -1, { 1, 2, "1" }, "1", 249, 0, 31, 66, "" }, /* Structured Append with File Number 3 codewords overhead */
/* 6*/ { -1, -1, { 1, 2, "1" }, "1", 250, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 7*/ { -1, -1, { 0, 0, "" }, "A", 252, 0, 31, 66, "" },
/* 8*/ { -1, -1, { 0, 0, "" }, "A", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 9*/ { -1, -1, { 0, 0, "" }, "\200", 252, 0, 31, 66, "" },
/* 10*/ { -1, -1, { 0, 0, "" }, "\200", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 11*/ { -1, -1, { 0, 0, "" }, "\001", 252, 0, 31, 66, "" },
/* 12*/ { -1, -1, { 0, 0, "" }, "\001", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 13*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "1", 504, 0, 31, 66, "" },
/* 14*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "1", 505, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 15*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "A", 375, 0, 31, 66, "" },
/* 16*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "A", 376, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 17*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\200", 252, 0, 31, 66, "" },
/* 18*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\200", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 19*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\001", 252, 0, 31, 66, "" },
/* 20*/ { -1, ULTRA_COMPRESSION, { 0, 0, "" }, "\001", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 21*/ { 1, -1, { 0, 0, "" }, "1", 276, 0, 31, 66, "" },
/* 22*/ { 1, -1, { 0, 0, "" }, "1", 277, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC0, requires 280 codewords (maximum 279)" },
/* 23*/ { 1, -1, { 1, 2, "" }, "1", 275, 0, 31, 66, "" },
/* 24*/ { 1, -1, { 1, 2, "" }, "1", 276, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC0, requires 280 codewords (maximum 279)" },
/* 25*/ { 1, -1, { 1, 2, "1" }, "1", 273, 0, 31, 66, "" },
/* 26*/ { 1, -1, { 1, 2, "1" }, "1", 274, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC0, requires 280 codewords (maximum 279)" },
/* 27*/ { 2, -1, { 0, 0, "" }, "1", 263, 0, 31, 66, "" },
/* 28*/ { 2, -1, { 0, 0, "" }, "1", 264, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC1, requires 267 codewords (maximum 266)" },
/* 29*/ { 3, -1, { 0, 0, "" }, "1", 252, 0, 31, 66, "" },
/* 30*/ { 3, -1, { 0, 0, "" }, "1", 253, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)" },
/* 31*/ { 4, -1, { 0, 0, "" }, "1", 234, 0, 31, 66, "" },
/* 32*/ { 4, -1, { 0, 0, "" }, "1", 235, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC3, requires 238 codewords (maximum 237)" },
/* 33*/ { 5, -1, { 0, 0, "" }, "1", 220, 0, 31, 66, "" },
/* 34*/ { 5, -1, { 0, 0, "" }, "1", 221, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC4, requires 224 codewords (maximum 223)" },
/* 35*/ { 6, -1, { 0, 0, "" }, "1", 202, 0, 31, 66, "" },
/* 36*/ { 6, -1, { 0, 0, "" }, "1", 203, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC5, requires 206 codewords (maximum 205)" },
/* 37*/ { 6, -1, { 0, 0, "" }, "A", ZINT_MAX_DATA_LEN / 2, ZINT_ERROR_TOO_LONG, -1, -1, "Error 591: Input too long for ECC level EC5, requires 8703 codewords (maximum 205)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -109,6 +111,8 @@ static void test_large(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
if (ret < ZINT_ERROR) {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
@ -135,11 +139,11 @@ static void test_reader_init(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, READER_INIT, 0, "A", 0, 13, 14, "(3) 257 269 65", "8-bit FNC3 A" },
/* 1*/ { UNICODE_MODE, READER_INIT, ULTRA_COMPRESSION, "A", 0, 13, 14, "(3) 272 271 65", "ASCII FNC3 A Note: draft spec inconsistent and FNC3 may be 272 in ASCII mode (and FNC1 271)" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -196,7 +200,7 @@ static void test_input(const testCtx *const p_ctx) {
char *expected;
char *comment;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "A", 0, "(2) 257 65", "Default (Revision 1)" },
/* 1*/ { UNICODE_MODE, 0, -1, 1, -1, { 0, 0, "" }, "A", 0, "(2) 257 65", "Revision 1" },
/* 2*/ { UNICODE_MODE, 0, -1, 2, -1, { 0, 0, "" }, "A", 0, "(2) 257 65", "Revision 2 (no codeword changes)" },
@ -209,9 +213,9 @@ static void test_input(const testCtx *const p_ctx) {
/* 9*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "ABC", 0, "(4) 272 65 66 67", "" },
/* 10*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "ULTRACODE_123456789!", 0, "(17) 272 85 76 84 82 65 67 79 68 69 95 140 162 184 206 57 33", "" },
/* 11*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(253) 257 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "252 chars EC2" },
/* 12*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Data too long for selected error correction capacity", "253 chars EC2" },
/* 12*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Input too long for ECC level EC2, requires 256 codewords (maximum 255)", "253 chars EC2" },
/* 13*/ { UNICODE_MODE, 0, 1, -1, -1, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", 0, "(277) 257 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65", "276 chars EC0" },
/* 14*/ { UNICODE_MODE, 0, 1, -1, -1, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Data too long for selected error correction capacity", "277 chars EC0" },
/* 14*/ { UNICODE_MODE, 0, 1, -1, -1, { 0, 0, "" }, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", ZINT_ERROR_TOO_LONG, "Error 591: Input too long for ECC level EC0, requires 280 codewords (maximum 279)", "277 chars EC0" },
/* 15*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "é", 0, "(2) 257 233", "" },
/* 16*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_USES_ECI, "Warning (2) 263 226", "" },
/* 17*/ { UNICODE_MODE, 9, -1, -1, -1, { 0, 0, "" }, "β", 0, "(2) 263 226", "" },
@ -224,7 +228,7 @@ static void test_input(const testCtx *const p_ctx) {
/* 24*/ { DATA_MODE, 9999, -1, -1, -1, { 0, 0, "" }, "\001\002\003\004\377", 0, "(9) 257 274 227 227 1 2 3 4 255", "" },
/* 25*/ { DATA_MODE, 10000, -1, -1, -1, { 0, 0, "" }, "\001\002\003\004\377", 0, "(10) 257 275 129 128 128 1 2 3 4 255", "" },
/* 26*/ { DATA_MODE, 811799, -1, -1, -1, { 0, 0, "" }, "\001\002\003\004\377", 0, "(10) 257 275 209 145 227 1 2 3 4 255", "" },
/* 27*/ { DATA_MODE, 811800, -1, -1, -1, { 0, 0, "" }, "\001\002\003\004\377", ZINT_ERROR_INVALID_OPTION, "Error 590: ECI value not supported by Ultracode", "" },
/* 27*/ { DATA_MODE, 811800, -1, -1, -1, { 0, 0, "" }, "\001\002\003\004\377", ZINT_ERROR_INVALID_OPTION, "Error 590: ECI code '811800' out of range (0 to 811799)", "" },
/* 28*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "123,456,789/12,/3,4,/5//", 0, "(15) 272 140 231 173 234 206 257 140 44 262 242 44 264 47 47", "Mode: a (24)" },
/* 29*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, "(32) 257 256 46 151 78 210 205 208 258 5 148 28 72 2 167 52 127 193 83 75 211 267 76 65 32", "Mode: cccccc88cccccccccc8888aaa8cccccc (32)" },
/* 30*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 0, "" }, "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS", 0, "(33) 257 72 69 73 77 65 83 205 208 65 32 75 69 78 78 65 82 65 72 193 83 75 211 76 65 32 205", "" },
@ -254,18 +258,18 @@ static void test_input(const testCtx *const p_ctx) {
/* 54*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "https://url.com", 0, "(6) 282 262 133 216 269 251", "Mode: ccccccc (7)" },
/* 55*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "{", 0, "(2) 272 123", "Mode: a (1)" },
/* 56*/ { UNICODE_MODE, 0, -1, -1, -1, { 2, 3, "" }, "A", 0, "(2) 257 65", "" },
/* 57*/ { UNICODE_MODE, 0, -1, -1, -1, { 1, 1, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 596: Structured Append count out of range (2-8)", "" },
/* 58*/ { UNICODE_MODE, 0, -1, -1, -1, { 1, 9, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 596: Structured Append count out of range (2-8)", "" },
/* 59*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 3, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 597: Structured Append index out of range (1-3)", "" },
/* 60*/ { UNICODE_MODE, 0, -1, -1, -1, { 4, 3, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 597: Structured Append index out of range (1-3)", "" },
/* 57*/ { UNICODE_MODE, 0, -1, -1, -1, { 1, 1, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 596: Structured Append count '1' out of range (2 to 8)", "" },
/* 58*/ { UNICODE_MODE, 0, -1, -1, -1, { 1, 9, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 596: Structured Append count '9' out of range (2 to 8)", "" },
/* 59*/ { UNICODE_MODE, 0, -1, -1, -1, { 0, 3, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 597: Structured Append index '0' out of range (1 to count 3)", "" },
/* 60*/ { UNICODE_MODE, 0, -1, -1, -1, { 4, 3, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 597: Structured Append index '4' out of range (1 to count 3)", "" },
/* 61*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "0" }, "A", 0, "(2) 257 65", "" },
/* 62*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "80088" }, "A", 0, "(2) 257 65", "" },
/* 63*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "123456" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 593: Structured Append ID too long (5 digit maximum)", "" },
/* 63*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "123456" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 593: Structured Append ID length 6 too long (5 digit maximum)", "" },
/* 64*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "A" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 594: Invalid Structured Append ID (digits only)", "" },
/* 65*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "80089" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 595: Structured Append ID '80089' out of range (1-80088)", "" },
/* 66*/ { UNICODE_MODE, 0, -1, 3, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 592: Revision must be 1 or 2", "" },
/* 65*/ { UNICODE_MODE, 0, -1, -1, -1, { 8, 8, "80089" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 595: Structured Append ID value '80089' out of range (1 to 80088)", "" },
/* 66*/ { UNICODE_MODE, 0, -1, 3, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, "Error 592: Revision '3' out of range (1 or 2 only)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -330,7 +334,7 @@ static void test_encode(const testCtx *const p_ctx) {
/* Based on AIMD/TSC15032-43 (v 0.99c), with values updated from BWIPP update 2021-07-14
https://github.com/bwipp/postscriptbarcode/commit/4255810845fa8d45c6192dd30aee1fdad1aaf0cc
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, 0, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, "ULTRACODE_123456789!", 0, 13, 22, 1, "AIMD/TSC15032-43 Figure G.1 **NOT SAME** different compression",
"7777777777777777777777"
"7857865353533131551857"
@ -776,7 +780,7 @@ static void test_encode(const testCtx *const p_ctx) {
"777777777777777777777777"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
@ -863,7 +867,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
/* Based on AIMD/TSC15032-43 (v 0.99c), with values updated from BWIPP update 2021-07-14
https://github.com/bwipp/postscriptbarcode/commit/4255810845fa8d45c6192dd30aee1fdad1aaf0cc
*/
struct item data[] = {
static const struct item data[] = {
/* 0*/ { UNICODE_MODE, -1, -1, ULTRA_COMPRESSION, { 0, 0, "" }, { { TU(""), -1, 0 }, { TU("Ж"), -1, 7 }, { TU(""), 0, 0 } }, 0, 13, 15, 0, "Standard example; BWIPP no ECI support for Ultracode",
"777777777777777"
"785786131155157"
@ -1018,7 +1022,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
"777777777777777777777777777"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,7 +42,7 @@ static void test_upce_input(const testCtx *const p_ctx) {
char *hrt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCE, "12345", 0, "00123457" }, /* equivalent: 00123400005, Check digit: 7 */
/* 1*/ { BARCODE_UPCE_CHK, "12345", ZINT_ERROR_INVALID_CHECK, "" },
/* 2*/ { BARCODE_UPCE_CHK, "12344", 0, "00012344" }, /* equivalent: 00012000003, Check digit: 4 */
@ -94,9 +94,9 @@ static void test_upce_input(const testCtx *const p_ctx) {
/* 48*/ { BARCODE_UPCE, "000001", 0, "00000019" },
/* 49*/ { BARCODE_UPCE, "000002", 0, "00000028" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[4096];
@ -105,7 +105,7 @@ static void test_upce_input(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_upce_input");
testStartSymbol("test_upce_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -159,14 +159,14 @@ static void test_upca_print(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCA, "01234567890", 0 },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_upca_print");
testStartSymbol("test_upca_print", &symbol);
for (i = 0; i < data_size; i++) {
@ -199,90 +199,94 @@ static void test_upca_input(const testCtx *const p_ctx) {
int symbology;
char *data;
int ret;
char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { BARCODE_UPCA, "12345678901", 0 },
/* 1*/ { BARCODE_UPCA, "1234567890", 0 },
/* 2*/ { BARCODE_UPCA, "123456789012", 0 }, /* UPC-A accepts CHK */
/* 3*/ { BARCODE_UPCA, "123456789011", ZINT_ERROR_INVALID_CHECK },
/* 4*/ { BARCODE_UPCA, "1234567890123", ZINT_ERROR_TOO_LONG },
/* 5*/ { BARCODE_UPCA, "123456789012A", ZINT_ERROR_INVALID_DATA },
/* 6*/ { BARCODE_UPCA, "12345678901A", ZINT_ERROR_INVALID_DATA },
/* 7*/ { BARCODE_UPCA, "12345678901+1", 0 },
/* 8*/ { BARCODE_UPCA, "123456789012+1", 0 },
/* 9*/ { BARCODE_UPCA, "123456789013+1", ZINT_ERROR_INVALID_CHECK },
/* 10*/ { BARCODE_UPCA, "12345678901+12", 0 },
/* 11*/ { BARCODE_UPCA, "123456789012+12", 0 },
/* 12*/ { BARCODE_UPCA, "123456789014+12", ZINT_ERROR_INVALID_CHECK },
/* 13*/ { BARCODE_UPCA, "12345678901+123", 0 },
/* 14*/ { BARCODE_UPCA, "123456789012+123", 0 },
/* 15*/ { BARCODE_UPCA, "123456789015+123", ZINT_ERROR_INVALID_CHECK },
/* 16*/ { BARCODE_UPCA, "123456789012+1234", 0 },
/* 17*/ { BARCODE_UPCA, "123456789016+1234", ZINT_ERROR_INVALID_CHECK },
/* 18*/ { BARCODE_UPCA, "123456789012+12345", 0 },
/* 19*/ { BARCODE_UPCA, "123456789017+12345", ZINT_ERROR_INVALID_CHECK },
/* 20*/ { BARCODE_UPCA, "123456789012+123456", ZINT_ERROR_TOO_LONG },
/* 21*/ { BARCODE_UPCA, "123456789017+123456", ZINT_ERROR_TOO_LONG },
/* 22*/ { BARCODE_UPCA, "123456789017+12345A", ZINT_ERROR_INVALID_DATA },
/* 23*/ { BARCODE_UPCA_CHK, "123456789012", 0 },
/* 24*/ { BARCODE_UPCA_CHK, "123456789011", ZINT_ERROR_INVALID_CHECK },
/* 25*/ { BARCODE_UPCA_CHK, "1234567890123", ZINT_ERROR_TOO_LONG },
/* 26*/ { BARCODE_UPCA_CHK, "123456789012A", ZINT_ERROR_INVALID_DATA },
/* 27*/ { BARCODE_UPCA_CHK, "12345678901A", ZINT_ERROR_INVALID_DATA },
/* 28*/ { BARCODE_UPCA_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK },
/* 29*/ { BARCODE_UPCA_CHK, "12345678905", 0 },
/* 30*/ { BARCODE_UPCA_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK },
/* 31*/ { BARCODE_UPCA_CHK, "1234567895", 0 },
/* 32*/ { BARCODE_UPCA_CHK, "123456789", ZINT_ERROR_INVALID_CHECK },
/* 33*/ { BARCODE_UPCA_CHK, "123456784", 0 },
/* 34*/ { BARCODE_UPCA_CHK, "12345678", ZINT_ERROR_INVALID_CHECK },
/* 35*/ { BARCODE_UPCA_CHK, "12345670", 0 },
/* 36*/ { BARCODE_UPCA_CHK, "1234567", ZINT_ERROR_INVALID_CHECK },
/* 37*/ { BARCODE_UPCA_CHK, "1234565", 0 },
/* 38*/ { BARCODE_UPCA_CHK, "123456", ZINT_ERROR_INVALID_CHECK },
/* 39*/ { BARCODE_UPCA_CHK, "123457", 0 },
/* 40*/ { BARCODE_UPCA_CHK, "12345", ZINT_ERROR_INVALID_CHECK },
/* 41*/ { BARCODE_UPCA_CHK, "12348", 0 },
/* 42*/ { BARCODE_UPCA_CHK, "1234", ZINT_ERROR_INVALID_CHECK },
/* 43*/ { BARCODE_UPCA_CHK, "1236", 0 },
/* 44*/ { BARCODE_UPCA_CHK, "123", 0 }, /* Happens to be correct check digit */
/* 45*/ { BARCODE_UPCA_CHK, "124", ZINT_ERROR_INVALID_CHECK },
/* 46*/ { BARCODE_UPCA_CHK, "12", ZINT_ERROR_INVALID_CHECK },
/* 47*/ { BARCODE_UPCA_CHK, "17", 0 },
/* 48*/ { BARCODE_UPCA_CHK, "1", ZINT_ERROR_INVALID_CHECK },
/* 49*/ { BARCODE_UPCA_CHK, "0", 0 },
/* 50*/ { BARCODE_UPCA_CHK, "12345678905+12", 0 },
/* 51*/ { BARCODE_UPCA_CHK, "12345678905+12345", 0 },
/* 52*/ { BARCODE_UPCA_CHK, "12345678905+123456", ZINT_ERROR_TOO_LONG },
/* 53*/ { BARCODE_UPCA_CHK, "12345678905+12345A", ZINT_ERROR_INVALID_DATA },
/* 54*/ { BARCODE_UPCA_CHK, "12345678905+1234A", ZINT_ERROR_INVALID_DATA },
/* 55*/ { BARCODE_UPCA_CHK, "1234567895+12345", 0 },
/* 56*/ { BARCODE_UPCA_CHK, "1234567891+12345", ZINT_ERROR_INVALID_CHECK },
/* 57*/ { BARCODE_UPCA_CHK, "123456784+12345", 0 },
/* 58*/ { BARCODE_UPCA_CHK, "123456782+12345", ZINT_ERROR_INVALID_CHECK },
/* 59*/ { BARCODE_UPCA_CHK, "12345670+12345", 0 },
/* 60*/ { BARCODE_UPCA_CHK, "12345673+12345", ZINT_ERROR_INVALID_CHECK },
/* 61*/ { BARCODE_UPCA_CHK, "1234565+12345", 0 },
/* 62*/ { BARCODE_UPCA_CHK, "1234564+12345", ZINT_ERROR_INVALID_CHECK },
/* 63*/ { BARCODE_UPCA_CHK, "123457+12345", 0 },
/* 64*/ { BARCODE_UPCA_CHK, "123455+12345", ZINT_ERROR_INVALID_CHECK },
/* 65*/ { BARCODE_UPCA_CHK, "12348+12345", 0 },
/* 66*/ { BARCODE_UPCA_CHK, "12346+12345", ZINT_ERROR_INVALID_CHECK },
/* 67*/ { BARCODE_UPCA_CHK, "1236+12345", 0 },
/* 68*/ { BARCODE_UPCA_CHK, "1237+12345", ZINT_ERROR_INVALID_CHECK },
/* 69*/ { BARCODE_UPCA_CHK, "123+12345", 0 },
/* 70*/ { BARCODE_UPCA_CHK, "128+12345", ZINT_ERROR_INVALID_CHECK },
/* 71*/ { BARCODE_UPCA_CHK, "17+12345", 0 },
/* 72*/ { BARCODE_UPCA_CHK, "19+12345", ZINT_ERROR_INVALID_CHECK },
/* 73*/ { BARCODE_UPCA_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK },
/* 74*/ { BARCODE_UPCA_CHK, "0+12345", 0 },
static const struct item data[] = {
/* 0*/ { BARCODE_UPCA, "12345678901", 0, "" },
/* 1*/ { BARCODE_UPCA, "1234567890", 0, "" },
/* 2*/ { BARCODE_UPCA, "123456789012", 0, "" }, /* UPC-A accepts CHK */
/* 3*/ { BARCODE_UPCA, "123456789011", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '1', expecting '2'" },
/* 4*/ { BARCODE_UPCA, "1234567890123", ZINT_ERROR_TOO_LONG, "Error 288: Input length 13 wrong (11 or 12 only)" },
/* 5*/ { BARCODE_UPCA, "123456789012A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 13 in input (digits and \"+\" only)" },
/* 6*/ { BARCODE_UPCA, "12345678901A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 12 in input (digits and \"+\" only)" },
/* 7*/ { BARCODE_UPCA, "12345", 0, "" },
/* 8*/ { BARCODE_UPCA, "1X345", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 2 in input (digits and \"+\" only)" },
/* 9*/ { BARCODE_UPCA, "01A345", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 3 in input (digits and \"+\" only)" },
/* 10*/ { BARCODE_UPCA, "12345678901+1", 0, "" },
/* 11*/ { BARCODE_UPCA, "123456789012+1", 0, "" },
/* 12*/ { BARCODE_UPCA, "123456789013+1", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '3', expecting '2'" },
/* 13*/ { BARCODE_UPCA, "12345678901+12", 0, "" },
/* 14*/ { BARCODE_UPCA, "123456789012+12", 0, "" },
/* 15*/ { BARCODE_UPCA, "123456789014+12", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '4', expecting '2'" },
/* 16*/ { BARCODE_UPCA, "12345678901+123", 0, "" },
/* 17*/ { BARCODE_UPCA, "123456789012+123", 0, "" },
/* 18*/ { BARCODE_UPCA, "123456789015+123", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '5', expecting '2'" },
/* 19*/ { BARCODE_UPCA, "123456789012+1234", 0, "" },
/* 20*/ { BARCODE_UPCA, "123456789016+1234", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '6', expecting '2'" },
/* 21*/ { BARCODE_UPCA, "123456789012+12345", 0, "" },
/* 22*/ { BARCODE_UPCA, "123456789017+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '7', expecting '2'" },
/* 23*/ { BARCODE_UPCA, "123456789012+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)" },
/* 24*/ { BARCODE_UPCA, "123456789017+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)" },
/* 25*/ { BARCODE_UPCA, "123456789017+12345A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 19 in input (digits and \"+\" only)" },
/* 26*/ { BARCODE_UPCA_CHK, "123456789012", 0, "" },
/* 27*/ { BARCODE_UPCA_CHK, "123456789011", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '1', expecting '2'" },
/* 28*/ { BARCODE_UPCA_CHK, "1234567890123", ZINT_ERROR_TOO_LONG, "Error 288: Input length 13 wrong (11 or 12 only)" },
/* 29*/ { BARCODE_UPCA_CHK, "123456789012A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 13 in input (digits and \"+\" only)" },
/* 30*/ { BARCODE_UPCA_CHK, "12345678901A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 12 in input (digits and \"+\" only)" },
/* 31*/ { BARCODE_UPCA_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '1', expecting '5'" },
/* 32*/ { BARCODE_UPCA_CHK, "12345678905", 0, "" },
/* 33*/ { BARCODE_UPCA_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '0', expecting '5'" },
/* 34*/ { BARCODE_UPCA_CHK, "1234567895", 0, "" },
/* 35*/ { BARCODE_UPCA_CHK, "123456789", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '9', expecting '4'" },
/* 36*/ { BARCODE_UPCA_CHK, "123456784", 0, "" },
/* 37*/ { BARCODE_UPCA_CHK, "12345678", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '8', expecting '0'" },
/* 38*/ { BARCODE_UPCA_CHK, "12345670", 0, "" },
/* 39*/ { BARCODE_UPCA_CHK, "1234567", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '7', expecting '5'" },
/* 40*/ { BARCODE_UPCA_CHK, "1234565", 0, "" },
/* 41*/ { BARCODE_UPCA_CHK, "123456", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '6', expecting '7'" },
/* 42*/ { BARCODE_UPCA_CHK, "123457", 0, "" },
/* 43*/ { BARCODE_UPCA_CHK, "12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '5', expecting '8'" },
/* 44*/ { BARCODE_UPCA_CHK, "12348", 0, "" },
/* 45*/ { BARCODE_UPCA_CHK, "1234", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '4', expecting '6'" },
/* 46*/ { BARCODE_UPCA_CHK, "1236", 0, "" },
/* 47*/ { BARCODE_UPCA_CHK, "123", 0, "" }, /* Happens to be correct check digit */
/* 48*/ { BARCODE_UPCA_CHK, "124", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '4', expecting '3'" },
/* 49*/ { BARCODE_UPCA_CHK, "12", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '2', expecting '7'" },
/* 50*/ { BARCODE_UPCA_CHK, "17", 0, "" },
/* 51*/ { BARCODE_UPCA_CHK, "1", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '1', expecting '0'" },
/* 52*/ { BARCODE_UPCA_CHK, "0", 0, "" },
/* 53*/ { BARCODE_UPCA_CHK, "12345678905+12", 0, "" },
/* 54*/ { BARCODE_UPCA_CHK, "12345678905+12345", 0, "" },
/* 55*/ { BARCODE_UPCA_CHK, "12345678905+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)" },
/* 56*/ { BARCODE_UPCA_CHK, "12345678905+12345A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 18 in input (digits and \"+\" only)" },
/* 57*/ { BARCODE_UPCA_CHK, "12345678905+1234A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 17 in input (digits and \"+\" only)" },
/* 58*/ { BARCODE_UPCA_CHK, "1234567895+12345", 0, "" },
/* 59*/ { BARCODE_UPCA_CHK, "1234567891+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '1', expecting '5'" },
/* 60*/ { BARCODE_UPCA_CHK, "123456784+12345", 0, "" },
/* 61*/ { BARCODE_UPCA_CHK, "123456782+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '2', expecting '4'" },
/* 62*/ { BARCODE_UPCA_CHK, "12345670+12345", 0, "" },
/* 63*/ { BARCODE_UPCA_CHK, "12345673+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '3', expecting '0'" },
/* 64*/ { BARCODE_UPCA_CHK, "1234565+12345", 0, "" },
/* 65*/ { BARCODE_UPCA_CHK, "1234564+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '4', expecting '5'" },
/* 66*/ { BARCODE_UPCA_CHK, "123457+12345", 0, "" },
/* 67*/ { BARCODE_UPCA_CHK, "123455+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '5', expecting '7'" },
/* 68*/ { BARCODE_UPCA_CHK, "12348+12345", 0, "" },
/* 69*/ { BARCODE_UPCA_CHK, "12346+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '6', expecting '8'" },
/* 70*/ { BARCODE_UPCA_CHK, "1236+12345", 0, "" },
/* 71*/ { BARCODE_UPCA_CHK, "1237+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '7', expecting '6'" },
/* 72*/ { BARCODE_UPCA_CHK, "123+12345", 0, "" },
/* 73*/ { BARCODE_UPCA_CHK, "128+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '8', expecting '3'" },
/* 74*/ { BARCODE_UPCA_CHK, "17+12345", 0, "" },
/* 75*/ { BARCODE_UPCA_CHK, "19+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '9', expecting '7'" },
/* 76*/ { BARCODE_UPCA_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK, "Error 270: Invalid check digit '1', expecting '0'" },
/* 77*/ { BARCODE_UPCA_CHK, "0+12345", 0, "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_upca_input");
testStartSymbol("test_upca_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -295,6 +299,7 @@ static void test_upca_input(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
ZBarcode_Delete(symbol);
}
@ -313,145 +318,147 @@ static void test_eanx_input(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX, "123456789012", 0, "", "" },
/* 1*/ { BARCODE_EANX, "12345678901A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/* 2*/ { BARCODE_EANX, "12345678901", 0, "", "" },
/* 3*/ { BARCODE_EANX, "1234567890128", 0, "", "EANX accepts CHK (treated as such if no leading zeroes required)" },
/* 4*/ { BARCODE_EANX, "1234567890120", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '8'", "" },
/* 5*/ { BARCODE_EANX, "123456789012+1", 0, "", "" },
/* 6*/ { BARCODE_EANX, "1234567890128+1", 0, "", "" },
/* 7*/ { BARCODE_EANX, "1234567890121+1", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '8'", "" },
/* 8*/ { BARCODE_EANX, "123456789012+12", 0, "", "" },
/* 9*/ { BARCODE_EANX, "1234567890128+12", 0, "", "" },
/* 10*/ { BARCODE_EANX, "1234567890122+12", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '2', expecting '8'", "" },
/* 11*/ { BARCODE_EANX, "12345678901234+12", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 12*/ { BARCODE_EANX, "123456789012345+12", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 13*/ { BARCODE_EANX, "1234567890123456+12", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 14*/ { BARCODE_EANX, "123456789012+123", 0, "", "" },
/* 15*/ { BARCODE_EANX, "1234567890128+123", 0, "", "" },
/* 16*/ { BARCODE_EANX, "1234567890123+123", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '3', expecting '8'", "" },
/* 17*/ { BARCODE_EANX, "12345678901234+123", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 18*/ { BARCODE_EANX, "123456789012345+123", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 19*/ { BARCODE_EANX, "123456789012+1234", 0, "", "" },
/* 20*/ { BARCODE_EANX, "1234567890128+1234", 0, "", "" },
/* 21*/ { BARCODE_EANX, "1234567890124+1234", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '4', expecting '8'", "" },
/* 22*/ { BARCODE_EANX, "12345678901234+1234", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 23*/ { BARCODE_EANX, "123456789012+12345", 0, "", "" },
/* 24*/ { BARCODE_EANX, "1234567890128+12345", 0, "", "" },
/* 25*/ { BARCODE_EANX, "12345678901234+12345", ZINT_ERROR_TOO_LONG, "Error 283: Input too long (19 character maximum)", "" },
/* 26*/ { BARCODE_EANX, "1234567890125+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '5', expecting '8'", "" },
/* 27*/ { BARCODE_EANX, "123456789012+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 28*/ { BARCODE_EANX, "1234567890128+123456", ZINT_ERROR_TOO_LONG, "Error 283: Input too long (19 character maximum)", "" },
/* 29*/ { BARCODE_EANX, "12345678901+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 30*/ { BARCODE_EANX, "12345678901+1234567", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 31*/ { BARCODE_EANX, "1234567890+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 32*/ { BARCODE_EANX, "1234567890+1234567", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 33*/ { BARCODE_EANX, "123456789+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 34*/ { BARCODE_EANX, "123456789+1234567", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 35*/ { BARCODE_EANX, "12345678+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 36*/ { BARCODE_EANX, "1234567+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "EAN-8" },
/* 37*/ { BARCODE_EANX, "123456+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 38*/ { BARCODE_EANX, "12345+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 39*/ { BARCODE_EANX, "1234+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 40*/ { BARCODE_EANX, "123+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 41*/ { BARCODE_EANX, "12+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 42*/ { BARCODE_EANX, "1+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 43*/ { BARCODE_EANX, "1+12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 44*/ { BARCODE_EANX, "1+12345", 0, "", "" },
/* 45*/ { BARCODE_EANX, "1+", 0, "", "EAN-2" },
/* 46*/ { BARCODE_EANX, "+1", 0, "", "EAN-8" },
/* 47*/ { BARCODE_EANX, "+", 0, "", "EAN-2" },
/* 48*/ { BARCODE_EANX, "1", 0, "", "EAN-2" },
/* 49*/ { BARCODE_EANX, "12", 0, "", "EAN-2" },
/* 50*/ { BARCODE_EANX, "123", 0, "", "EAN-5" },
/* 51*/ { BARCODE_EANX, "12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 52*/ { BARCODE_EANX, "1234567890123A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/* 53*/ { BARCODE_EANX, "123456789012345", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 54*/ { BARCODE_EANX, "12345678901234A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/* 55*/ { BARCODE_EANX, "1234567890123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 56*/ { BARCODE_EANX, "12345678901234567", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 57*/ { BARCODE_EANX, "123456789012345678", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 58*/ { BARCODE_EANX, "1234567890123456789", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 59*/ { BARCODE_EANX_CHK, "1234567890128", 0, "", "" },
/* 60*/ { BARCODE_EANX_CHK, "1234567890126", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '6', expecting '8'", "" },
/* 61*/ { BARCODE_EANX_CHK, "123456789012A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/* 62*/ { BARCODE_EANX_CHK, "123456789012", 0, "", "Note: this is '0123456789012' with '2' happening to be the correct check digit" },
/* 63*/ { BARCODE_EANX_CHK, "123456789013", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '3', expecting '2'", "" },
/* 64*/ { BARCODE_EANX_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '5'", "" },
/* 65*/ { BARCODE_EANX_CHK, "12345678905", 0, "", "" },
/* 66*/ { BARCODE_EANX_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '5'", "" },
/* 67*/ { BARCODE_EANX_CHK, "123456789", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '9', expecting '4'", "" },
/* 68*/ { BARCODE_EANX_CHK, "12345678", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '8', expecting '0'", "EAN-8" },
/* 69*/ { BARCODE_EANX_CHK, "1234567", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '7', expecting '5'", "" },
/* 70*/ { BARCODE_EANX_CHK, "123456", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '6', expecting '7'", "" },
/* 71*/ { BARCODE_EANX_CHK, "12345", 0, "", "EAN-5" },
/* 72*/ { BARCODE_EANX_CHK, "1234", 0, "", "" },
/* 73*/ { BARCODE_EANX_CHK, "123", 0, "", "" },
/* 74*/ { BARCODE_EANX_CHK, "12", 0, "", "EAN-2" },
/* 75*/ { BARCODE_EANX_CHK, "1", 0, "", "" },
/* 76*/ { BARCODE_EANX_CHK, "123456789012+1", 0, "", "" },
/* 77*/ { BARCODE_EANX_CHK, "1234567890128+1", 0, "", "" },
/* 78*/ { BARCODE_EANX_CHK, "1234567890127+1", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '7', expecting '8'", "" },
/* 79*/ { BARCODE_EANX_CHK, "123456789012+12", 0, "", "" },
/* 80*/ { BARCODE_EANX_CHK, "1234567890128+12", 0, "", "" },
/* 81*/ { BARCODE_EANX_CHK, "1234567890129+12", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '9', expecting '8'", "" },
/* 82*/ { BARCODE_EANX_CHK, "123456789012+123", 0, "", "" },
/* 83*/ { BARCODE_EANX_CHK, "1234567890128+123", 0, "", "" },
/* 84*/ { BARCODE_EANX_CHK, "1234567890120+1234", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '8'", "" },
/* 85*/ { BARCODE_EANX_CHK, "123456789012+1234", 0, "", "" },
/* 86*/ { BARCODE_EANX_CHK, "1234567890128+1234", 0, "", "" },
/* 87*/ { BARCODE_EANX_CHK, "1234567890121+1234", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '8'", "" },
/* 88*/ { BARCODE_EANX_CHK, "123456789012+12345", 0, "", "" },
/* 89*/ { BARCODE_EANX_CHK, "1234567890128+12345", 0, "", "" },
/* 90*/ { BARCODE_EANX_CHK, "1234567890122+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '2', expecting '8'", "" },
/* 91*/ { BARCODE_EANX_CHK, "1234567890122+1234A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/* 92*/ { BARCODE_EANX_CHK, "123456789012+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 93*/ { BARCODE_EANX_CHK, "123456789012+12345A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/* 94*/ { BARCODE_EANX_CHK, "1234567890128+123456", ZINT_ERROR_TOO_LONG, "Error 283: Input too long (19 character maximum)", "" },
/* 95*/ { BARCODE_EANX_CHK, "12345678901+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 96*/ { BARCODE_EANX_CHK, "12345678901+1234567", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 97*/ { BARCODE_EANX_CHK, "12345678901+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '5'", "" },
/* 98*/ { BARCODE_EANX_CHK, "1234567890+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '5'", "" },
/* 99*/ { BARCODE_EANX_CHK, "1234567890+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/*100*/ { BARCODE_EANX_CHK, "123456789+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '9', expecting '4'", "" },
/*101*/ { BARCODE_EANX_CHK, "12345678+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '8', expecting '0'", "EAN-8" },
/*102*/ { BARCODE_EANX_CHK, "12345670+12345", 0, "", "" },
/*103*/ { BARCODE_EANX_CHK, "1234567+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '7', expecting '5'", "" },
/*104*/ { BARCODE_EANX_CHK, "1234565+12345", 0, "", "" },
/*105*/ { BARCODE_EANX_CHK, "123456+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '6', expecting '7'", "" },
/*106*/ { BARCODE_EANX_CHK, "123457+12345", 0, "", "" },
/*107*/ { BARCODE_EANX_CHK, "12345+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '5', expecting '8'", "" },
/*108*/ { BARCODE_EANX_CHK, "12348+12345", 0, "", "" },
/*109*/ { BARCODE_EANX_CHK, "1234+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '4', expecting '6'", "" },
/*110*/ { BARCODE_EANX_CHK, "1236+12345", 0, "", "" },
/*111*/ { BARCODE_EANX_CHK, "123+12345", 0, "", "3 happens to be correct check digit" },
/*112*/ { BARCODE_EANX_CHK, "124+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '4', expecting '3'", "" },
/*113*/ { BARCODE_EANX_CHK, "12+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '2', expecting '7'", "" },
/*114*/ { BARCODE_EANX_CHK, "17+12345", 0, "", "" },
/*115*/ { BARCODE_EANX_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '1', expecting '0'", "" },
/*116*/ { BARCODE_EANX_CHK, "0+12345", 0, "", "" },
/*117*/ { BARCODE_EANX_CHK, "0+123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/*118*/ { BARCODE_EANX_CHK, "1+12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/*119*/ { BARCODE_EANX_CHK, "0+12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (5 character maximum for add-on)", "" },
/*120*/ { BARCODE_EANX_CHK, "1+", 0, "", "EAN-2" },
/*121*/ { BARCODE_EANX_CHK, "+1", 0, "", "EAN-8" },
/*122*/ { BARCODE_EANX_CHK, "+", 0, "", "EAN-2" },
/*123*/ { BARCODE_EANX_CHK, "12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/*124*/ { BARCODE_EANX_CHK, "1234567890123A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character in data (digits and \"+\" only)", "" },
/*125*/ { BARCODE_EANX_CHK, "123456789012345", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/*126*/ { BARCODE_EANX_CHK, "1234567890123456", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/*127*/ { BARCODE_EANX_CHK, "12345678901234567", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/*128*/ { BARCODE_EANX_CHK, "123456789012345678", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/*129*/ { BARCODE_EANX_CHK, "1234567890123456789", ZINT_ERROR_TOO_LONG, "Error 294: Input too long (13 character maximum)", "" },
/* 1*/ { BARCODE_EANX, "12345678901A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 12 in input (digits and \"+\" only)", "" },
/* 2*/ { BARCODE_EANX, "12345A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 6 in input (digits and \"+\" only)", "" },
/* 3*/ { BARCODE_EANX, "123A56", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 4 in input (digits and \"+\" only)", "" },
/* 4*/ { BARCODE_EANX, "12345678901", 0, "", "" },
/* 5*/ { BARCODE_EANX, "1234567890128", 0, "", "EANX accepts CHK (treated as such if no leading zeroes required)" },
/* 6*/ { BARCODE_EANX, "1234567890120", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '8'", "" },
/* 7*/ { BARCODE_EANX, "123456789012+1", 0, "", "" },
/* 8*/ { BARCODE_EANX, "1234567890128+1", 0, "", "" },
/* 9*/ { BARCODE_EANX, "1234567890121+1", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '8'", "" },
/* 10*/ { BARCODE_EANX, "123456789012+12", 0, "", "" },
/* 11*/ { BARCODE_EANX, "1234567890128+12", 0, "", "" },
/* 12*/ { BARCODE_EANX, "1234567890122+12", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '2', expecting '8'", "" },
/* 13*/ { BARCODE_EANX, "12345678901234+12", ZINT_ERROR_TOO_LONG, "Error 298: Input EAN length 14 too long (maximum 13)", "" },
/* 14*/ { BARCODE_EANX, "123456789012345+12", ZINT_ERROR_TOO_LONG, "Error 298: Input EAN length 15 too long (maximum 13)", "" },
/* 15*/ { BARCODE_EANX, "1234567890123456+12", ZINT_ERROR_TOO_LONG, "Error 298: Input EAN length 16 too long (maximum 13)", "" },
/* 16*/ { BARCODE_EANX, "123456789012+123", 0, "", "" },
/* 17*/ { BARCODE_EANX, "1234567890128+123", 0, "", "" },
/* 18*/ { BARCODE_EANX, "1234567890123+123", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '3', expecting '8'", "" },
/* 19*/ { BARCODE_EANX, "12345678901234+123", ZINT_ERROR_TOO_LONG, "Error 298: Input EAN length 14 too long (maximum 13)", "" },
/* 20*/ { BARCODE_EANX, "123456789012345+123", ZINT_ERROR_TOO_LONG, "Error 298: Input EAN length 15 too long (maximum 13)", "" },
/* 21*/ { BARCODE_EANX, "123456789012+1234", 0, "", "" },
/* 22*/ { BARCODE_EANX, "1234567890128+1234", 0, "", "" },
/* 23*/ { BARCODE_EANX, "1234567890124+1234", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '4', expecting '8'", "" },
/* 24*/ { BARCODE_EANX, "12345678901234+1234", ZINT_ERROR_TOO_LONG, "Error 298: Input EAN length 14 too long (maximum 13)", "" },
/* 25*/ { BARCODE_EANX, "123456789012+12345", 0, "", "" },
/* 26*/ { BARCODE_EANX, "1234567890128+12345", 0, "", "" },
/* 27*/ { BARCODE_EANX, "12345678901234+12345", ZINT_ERROR_TOO_LONG, "Error 283: Input length 20 too long (maximum 19)", "" },
/* 28*/ { BARCODE_EANX, "1234567890125+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '5', expecting '8'", "" },
/* 29*/ { BARCODE_EANX, "123456789012+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 30*/ { BARCODE_EANX, "1234567890128+123456", ZINT_ERROR_TOO_LONG, "Error 283: Input length 20 too long (maximum 19)", "" },
/* 31*/ { BARCODE_EANX, "12345678901+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 32*/ { BARCODE_EANX, "12345678901+1234567", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 7 too long (maximum 5)", "" },
/* 33*/ { BARCODE_EANX, "1234567890+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 34*/ { BARCODE_EANX, "1234567890+1234567", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 7 too long (maximum 5)", "" },
/* 35*/ { BARCODE_EANX, "123456789+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 36*/ { BARCODE_EANX, "123456789+1234567", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 7 too long (maximum 5)", "" },
/* 37*/ { BARCODE_EANX, "12345678+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 38*/ { BARCODE_EANX, "1234567+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "EAN-8" },
/* 39*/ { BARCODE_EANX, "123456+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 40*/ { BARCODE_EANX, "12345+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 41*/ { BARCODE_EANX, "1234+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 42*/ { BARCODE_EANX, "123+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 43*/ { BARCODE_EANX, "12+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 44*/ { BARCODE_EANX, "1+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 45*/ { BARCODE_EANX, "1+12345678901234", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 14 too long (maximum 5)", "" },
/* 46*/ { BARCODE_EANX, "1+12345", 0, "", "" },
/* 47*/ { BARCODE_EANX, "1+", 0, "", "EAN-2" },
/* 48*/ { BARCODE_EANX, "+1", 0, "", "EAN-8" },
/* 49*/ { BARCODE_EANX, "+", 0, "", "EAN-2" },
/* 50*/ { BARCODE_EANX, "1", 0, "", "EAN-2" },
/* 51*/ { BARCODE_EANX, "12", 0, "", "EAN-2" },
/* 52*/ { BARCODE_EANX, "123", 0, "", "EAN-5" },
/* 53*/ { BARCODE_EANX, "12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input length 14 too long (maximum 13)", "" },
/* 54*/ { BARCODE_EANX, "1234567890123A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 14 in input (digits and \"+\" only)", "" },
/* 55*/ { BARCODE_EANX, "123456789012345", ZINT_ERROR_TOO_LONG, "Error 294: Input length 15 too long (maximum 13)", "" },
/* 56*/ { BARCODE_EANX, "12345678901234A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 15 in input (digits and \"+\" only)", "" },
/* 57*/ { BARCODE_EANX, "1234567890123456", ZINT_ERROR_TOO_LONG, "Error 294: Input length 16 too long (maximum 13)", "" },
/* 58*/ { BARCODE_EANX, "12345678901234567", ZINT_ERROR_TOO_LONG, "Error 294: Input length 17 too long (maximum 13)", "" },
/* 59*/ { BARCODE_EANX, "123456789012345678", ZINT_ERROR_TOO_LONG, "Error 294: Input length 18 too long (maximum 13)", "" },
/* 60*/ { BARCODE_EANX, "1234567890123456789", ZINT_ERROR_TOO_LONG, "Error 294: Input length 19 too long (maximum 13)", "" },
/* 61*/ { BARCODE_EANX_CHK, "1234567890128", 0, "", "" },
/* 62*/ { BARCODE_EANX_CHK, "1234567890126", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '6', expecting '8'", "" },
/* 63*/ { BARCODE_EANX_CHK, "123456789012A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 13 in input (digits and \"+\" only)", "" },
/* 64*/ { BARCODE_EANX_CHK, "123456789012", 0, "", "Note: this is '0123456789012' with '2' happening to be the correct check digit" },
/* 65*/ { BARCODE_EANX_CHK, "123456789013", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '3', expecting '2'", "" },
/* 66*/ { BARCODE_EANX_CHK, "12345678901", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '5'", "" },
/* 67*/ { BARCODE_EANX_CHK, "12345678905", 0, "", "" },
/* 68*/ { BARCODE_EANX_CHK, "1234567890", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '5'", "" },
/* 69*/ { BARCODE_EANX_CHK, "123456789", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '9', expecting '4'", "" },
/* 70*/ { BARCODE_EANX_CHK, "12345678", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '8', expecting '0'", "EAN-8" },
/* 71*/ { BARCODE_EANX_CHK, "1234567", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '7', expecting '5'", "" },
/* 72*/ { BARCODE_EANX_CHK, "123456", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '6', expecting '7'", "" },
/* 73*/ { BARCODE_EANX_CHK, "12345", 0, "", "EAN-5" },
/* 74*/ { BARCODE_EANX_CHK, "1234", 0, "", "" },
/* 75*/ { BARCODE_EANX_CHK, "123", 0, "", "" },
/* 76*/ { BARCODE_EANX_CHK, "12", 0, "", "EAN-2" },
/* 77*/ { BARCODE_EANX_CHK, "1", 0, "", "" },
/* 78*/ { BARCODE_EANX_CHK, "123456789012+1", 0, "", "" },
/* 79*/ { BARCODE_EANX_CHK, "1234567890128+1", 0, "", "" },
/* 80*/ { BARCODE_EANX_CHK, "1234567890127+1", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '7', expecting '8'", "" },
/* 81*/ { BARCODE_EANX_CHK, "123456789012+12", 0, "", "" },
/* 82*/ { BARCODE_EANX_CHK, "1234567890128+12", 0, "", "" },
/* 83*/ { BARCODE_EANX_CHK, "1234567890129+12", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '9', expecting '8'", "" },
/* 84*/ { BARCODE_EANX_CHK, "123456789012+123", 0, "", "" },
/* 85*/ { BARCODE_EANX_CHK, "1234567890128+123", 0, "", "" },
/* 86*/ { BARCODE_EANX_CHK, "1234567890120+1234", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '8'", "" },
/* 87*/ { BARCODE_EANX_CHK, "123456789012+1234", 0, "", "" },
/* 88*/ { BARCODE_EANX_CHK, "1234567890128+1234", 0, "", "" },
/* 89*/ { BARCODE_EANX_CHK, "1234567890121+1234", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '8'", "" },
/* 90*/ { BARCODE_EANX_CHK, "123456789012+12345", 0, "", "" },
/* 91*/ { BARCODE_EANX_CHK, "1234567890128+12345", 0, "", "" },
/* 92*/ { BARCODE_EANX_CHK, "1234567890122+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '2', expecting '8'", "" },
/* 93*/ { BARCODE_EANX_CHK, "1234567890122+1234A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 19 in input (digits and \"+\" only)", "" },
/* 94*/ { BARCODE_EANX_CHK, "123456789012+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 95*/ { BARCODE_EANX_CHK, "123456789012+12345A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 19 in input (digits and \"+\" only)", "" },
/* 96*/ { BARCODE_EANX_CHK, "1234567890128+123456", ZINT_ERROR_TOO_LONG, "Error 283: Input length 20 too long (maximum 19)", "" },
/* 97*/ { BARCODE_EANX_CHK, "12345678901+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 98*/ { BARCODE_EANX_CHK, "12345678901+1234567", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 7 too long (maximum 5)", "" },
/* 99*/ { BARCODE_EANX_CHK, "12345678901+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '1', expecting '5'", "" },
/*100*/ { BARCODE_EANX_CHK, "1234567890+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '0', expecting '5'", "" },
/*101*/ { BARCODE_EANX_CHK, "1234567890+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/*102*/ { BARCODE_EANX_CHK, "123456789+12345", ZINT_ERROR_INVALID_CHECK, "Error 275: Invalid check digit '9', expecting '4'", "" },
/*103*/ { BARCODE_EANX_CHK, "12345678+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '8', expecting '0'", "EAN-8" },
/*104*/ { BARCODE_EANX_CHK, "12345670+12345", 0, "", "" },
/*105*/ { BARCODE_EANX_CHK, "1234567+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '7', expecting '5'", "" },
/*106*/ { BARCODE_EANX_CHK, "1234565+12345", 0, "", "" },
/*107*/ { BARCODE_EANX_CHK, "123456+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '6', expecting '7'", "" },
/*108*/ { BARCODE_EANX_CHK, "123457+12345", 0, "", "" },
/*109*/ { BARCODE_EANX_CHK, "12345+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '5', expecting '8'", "" },
/*110*/ { BARCODE_EANX_CHK, "12348+12345", 0, "", "" },
/*111*/ { BARCODE_EANX_CHK, "1234+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '4', expecting '6'", "" },
/*112*/ { BARCODE_EANX_CHK, "1236+12345", 0, "", "" },
/*113*/ { BARCODE_EANX_CHK, "123+12345", 0, "", "3 happens to be correct check digit" },
/*114*/ { BARCODE_EANX_CHK, "124+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '4', expecting '3'", "" },
/*115*/ { BARCODE_EANX_CHK, "12+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '2', expecting '7'", "" },
/*116*/ { BARCODE_EANX_CHK, "17+12345", 0, "", "" },
/*117*/ { BARCODE_EANX_CHK, "1+12345", ZINT_ERROR_INVALID_CHECK, "Error 276: Invalid check digit '1', expecting '0'", "" },
/*118*/ { BARCODE_EANX_CHK, "0+12345", 0, "", "" },
/*119*/ { BARCODE_EANX_CHK, "0+123456", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/*120*/ { BARCODE_EANX_CHK, "1+12345678901234", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 14 too long (maximum 5)", "" },
/*121*/ { BARCODE_EANX_CHK, "0+12345678901234", ZINT_ERROR_TOO_LONG, "Error 297: Input add-on length 14 too long (maximum 5)", "" },
/*122*/ { BARCODE_EANX_CHK, "1+", 0, "", "EAN-2" },
/*123*/ { BARCODE_EANX_CHK, "+1", 0, "", "EAN-8" },
/*124*/ { BARCODE_EANX_CHK, "+", 0, "", "EAN-2" },
/*125*/ { BARCODE_EANX_CHK, "12345678901234", ZINT_ERROR_TOO_LONG, "Error 294: Input length 14 too long (maximum 13)", "" },
/*126*/ { BARCODE_EANX_CHK, "1234567890123A", ZINT_ERROR_INVALID_DATA, "Error 284: Invalid character at position 14 in input (digits and \"+\" only)", "" },
/*127*/ { BARCODE_EANX_CHK, "123456789012345", ZINT_ERROR_TOO_LONG, "Error 294: Input length 15 too long (maximum 13)", "" },
/*128*/ { BARCODE_EANX_CHK, "1234567890123456", ZINT_ERROR_TOO_LONG, "Error 294: Input length 16 too long (maximum 13)", "" },
/*129*/ { BARCODE_EANX_CHK, "12345678901234567", ZINT_ERROR_TOO_LONG, "Error 294: Input length 17 too long (maximum 13)", "" },
/*130*/ { BARCODE_EANX_CHK, "123456789012345678", ZINT_ERROR_TOO_LONG, "Error 294: Input length 18 too long (maximum 13)", "" },
/*131*/ { BARCODE_EANX_CHK, "1234567890123456789", ZINT_ERROR_TOO_LONG, "Error 294: Input length 19 too long (maximum 13)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char errtxt_escaped[256];
testStart("test_eanx_input");
testStartSymbol("test_eanx_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -491,37 +498,37 @@ static void test_isbn_input(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { "0", 0, 0, "", "Left zero-padded if < 10 chars" },
/* 1*/ { "1", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '1', expecting '0'", "" },
/* 2*/ { "X", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit 'X', expecting '0'", "" },
/* 3*/ { "12", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '2', expecting '9'", "" },
/* 4*/ { "19", 0, 0, "", "" },
/* 5*/ { "X9", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 5*/ { "X9", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 6*/ { "123", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '3', expecting '4'", "" },
/* 7*/ { "124", 0, 0, "", "" },
/* 8*/ { "1X4", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 8*/ { "1X4", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 9*/ { "1234", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '4', expecting '6'", "" },
/* 10*/ { "1236", 0, 0, "", "" },
/* 11*/ { "12X6", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 11*/ { "12X6", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 12*/ { "12345", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '5', expecting '3'", "" },
/* 13*/ { "12343", 0, 0, "", "" },
/* 14*/ { "123X3", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 14*/ { "123X3", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 15*/ { "123456", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '6', expecting '5'", "" },
/* 16*/ { "123455", 0, 0, "", "" },
/* 17*/ { "1234X5", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 17*/ { "1234X5", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 18*/ { "1234567", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '7', expecting '0'", "" },
/* 19*/ { "1234560", 0, 0, "", "" },
/* 20*/ { "12345X0", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 20*/ { "12345X0", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 21*/ { "12345678", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '8', expecting '9'", "" },
/* 22*/ { "12345679", 0, 0, "", "9 is correct check digit" },
/* 23*/ { "98765434", 0, 0, "", "4 is correct check digit" },
/* 24*/ { "123456X9", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 24*/ { "123456X9", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 25*/ { "123456789", 0, 0, "", "" },
/* 26*/ { "340013817", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '7', expecting '8'", "" },
/* 27*/ { "340013818", 0, 0, "", "8 is correct check digit" },
/* 28*/ { "902888455", 0, 0, "", "5 is correct check digit" },
/* 29*/ { "9028884X5", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 29*/ { "9028884X5", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 30*/ { "0123456789", 0, 0, "", "" },
/* 31*/ { "1234567890", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid ISBN check digit '0', expecting 'X'", "" },
/* 32*/ { "123456789X", 0, 0, "", "X is correct check digit" },
@ -532,13 +539,13 @@ static void test_isbn_input(const testCtx *const p_ctx) {
/* 37*/ { "0140430016", 0, 0, "", "6 is correct check digit" },
/* 38*/ { "0571086187", 0, 0, "", "7 is correct check digit" },
/* 39*/ { "0486600882", 0, 0, "", "2 is correct check digit" },
/* 40*/ { "04866008X2", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 41*/ { "123456789A", ZINT_ERROR_INVALID_DATA, -1, "Error 285: Invalid character in data (digits, \"X\" and \"+\" only)", "" },
/* 42*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input wrong length (9, 10, or 13 characters only)", "" },
/* 43*/ { "1234567890A", ZINT_ERROR_INVALID_DATA, -1, "Error 285: Invalid character in data (digits, \"X\" and \"+\" only)", "" },
/* 44*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input wrong length (9, 10, or 13 characters only)", "" },
/* 45*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input wrong length (9, 10, or 13 characters only)", "" },
/* 46*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input wrong length (9, 10, or 13 characters only)", "" },
/* 40*/ { "04866008X2", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 41*/ { "123456789A", ZINT_ERROR_INVALID_DATA, -1, "Error 285: Invalid character at position 10 in input (digits, \"X\" and \"+\" only)", "" },
/* 42*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input length 11 wrong (9, 10, or 13 only)", "" },
/* 43*/ { "1234567890A", ZINT_ERROR_INVALID_DATA, -1, "Error 285: Invalid character at position 11 in input (digits, \"X\" and \"+\" only)", "" },
/* 44*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input length 12 wrong (9, 10, or 13 only)", "" },
/* 45*/ { "12345678901", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input length 11 wrong (9, 10, or 13 only)", "" },
/* 46*/ { "123456789012", ZINT_ERROR_TOO_LONG, -1, "Error 278: Input length 12 wrong (9, 10, or 13 only)", "" },
/* 47*/ { "1234567890123", ZINT_ERROR_INVALID_DATA, -1, "Error 279: Invalid ISBN (must begin with \"978\" or \"979\")", "" },
/* 48*/ { "9784567890123", ZINT_ERROR_INVALID_CHECK, -1, "Error 280: Invalid ISBN check digit '3', expecting '0'", "" },
/* 49*/ { "9784567890120", 0, 0, "", "0 is correct check digit" },
@ -547,64 +554,64 @@ static void test_isbn_input(const testCtx *const p_ctx) {
/* 52*/ { "9781847657954", 0, 0, "", "4 is correct check digit" },
/* 53*/ { "9781846688188", 0, 0, "", "8 is correct check digit" },
/* 54*/ { "9781847659293", 0, 0, "", "3 is correct check digit" },
/* 55*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input too long (13 character maximum)", "" },
/* 56*/ { "978456789012012", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input too long (13 character maximum)", "" },
/* 55*/ { "97845678901201", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input length 14 too long (maximum 13)", "" },
/* 56*/ { "978456789012012", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input length 15 too long (maximum 13)", "" },
/* 57*/ { "3954994+12", 0, 0, "", "" },
/* 58*/ { "3954994+1X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 59*/ { "39549X4+12", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 59*/ { "39549X4+12", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 60*/ { "3954994+12345", 0, 0, "", "" },
/* 61*/ { "3954994+1234X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 62*/ { "39549X4+12345", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 63*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input too long (5 character maximum for add-on)", "" },
/* 62*/ { "39549X4+12345", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 63*/ { "3954994+123456", ZINT_ERROR_TOO_LONG, -1, "Error 297: Input add-on length 6 too long (maximum 5)", "" },
/* 64*/ { "3954994+", 0, 0, "", "" },
/* 65*/ { "3954X94+", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 65*/ { "3954X94+", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 66*/ { "61954993+1", 0, 0, "", "" },
/* 67*/ { "61954993+X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 68*/ { "619549X3+1", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 68*/ { "619549X3+1", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 69*/ { "61954992+123", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '2', expecting '3'", "" },
/* 70*/ { "61954993+123", 0, 0, "", "" },
/* 71*/ { "61954993+12X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 72*/ { "619549X3+123", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 72*/ { "619549X3+123", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 73*/ { "361954990+12", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid SBN check digit '0', expecting '9'", "" },
/* 74*/ { "361954999+12", 0, 0, "", "" },
/* 75*/ { "361954999+1X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 76*/ { "3619549X9+12", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 76*/ { "3619549X9+12", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 77*/ { "361954999+1234", 0, 0, "", "" },
/* 78*/ { "361954999+123X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 79*/ { "3619549X9+1234", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 79*/ { "3619549X9+1234", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 80*/ { "1999000030+12", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid ISBN check digit '0', expecting 'X'", "" },
/* 81*/ { "199900003X+12", 0, 0, "", "" },
/* 82*/ { "199900003x+12", 0, 0, "", "" },
/* 83*/ { "19990000XX+12", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 83*/ { "19990000XX+12", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 84*/ { "199900003X+1X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 85*/ { "1999000031+12345", ZINT_ERROR_INVALID_CHECK, -1, "Error 281: Invalid ISBN check digit '1', expecting 'X'", "" },
/* 86*/ { "199900003X+12345", 0, 0, "", "" },
/* 87*/ { "199900003x+12345", 0, 0, "", "" },
/* 88*/ { "199900003X+1234X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 89*/ { "19990000XX+12345", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in data, \"X\" allowed in last position only", "" },
/* 90*/ { "199900003X+1234A", ZINT_ERROR_INVALID_DATA, -1, "Error 285: Invalid character in data (digits, \"X\" and \"+\" only)", "" },
/* 89*/ { "19990000XX+12345", ZINT_ERROR_INVALID_DATA, -1, "Error 296: Invalid character in input, \"X\" allowed in last position only", "" },
/* 90*/ { "199900003X+1234A", ZINT_ERROR_INVALID_DATA, -1, "Error 285: Invalid character at position 16 in input (digits, \"X\" and \"+\" only)", "" },
/* 91*/ { "9791234567895+12", ZINT_ERROR_INVALID_CHECK, -1, "Error 280: Invalid ISBN check digit '5', expecting '6'", "" },
/* 92*/ { "9791234567896+12", 0, 0, "", "" },
/* 93*/ { "9791234567896+1X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 94*/ { "97912345678X6+12", ZINT_ERROR_INVALID_DATA, -1, "Error 282: Invalid character in data, \"X\" not allowed in ISBN-13", "" },
/* 94*/ { "97912345678X6+12", ZINT_ERROR_INVALID_DATA, -1, "Error 282: Invalid character in input, \"X\" not allowed in ISBN-13", "" },
/* 95*/ { "9791234567897+12345", ZINT_ERROR_INVALID_CHECK, -1, "Error 280: Invalid ISBN check digit '7', expecting '6'", "" },
/* 96*/ { "9791234567896+12345", 0, 0, "", "" },
/* 97*/ { "9791234567896+1234X", ZINT_ERROR_INVALID_DATA, -1, "Error 295: Invalid add-on data (digits only)", "" },
/* 98*/ { "979123456X896+12345", ZINT_ERROR_INVALID_DATA, -1, "Error 282: Invalid character in data, \"X\" not allowed in ISBN-13", "" },
/* 98*/ { "979123456X896+12345", ZINT_ERROR_INVALID_DATA, -1, "Error 282: Invalid character in input, \"X\" not allowed in ISBN-13", "" },
/* 99*/ { "9791234567892+", ZINT_ERROR_INVALID_CHECK, -1, "Error 280: Invalid ISBN check digit '2', expecting '6'", "" },
/*100*/ { "9791234567896+", 0, 0, "", "" },
/*101*/ { "97912345678X6+", ZINT_ERROR_INVALID_DATA, -1, "Error 282: Invalid character in data, \"X\" not allowed in ISBN-13", "" },
/*102*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input too long (13 character maximum)", "" },
/*103*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1, "Error 283: Input too long (19 character maximum)", "" },
/*104*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1, "Error 283: Input too long (19 character maximum)", "" },
/*101*/ { "97912345678X6+", ZINT_ERROR_INVALID_DATA, -1, "Error 282: Invalid character in input, \"X\" not allowed in ISBN-13", "" },
/*102*/ { "97912345678961+", ZINT_ERROR_TOO_LONG, -1, "Error 294: Input length 14 too long (maximum 13)", "" },
/*103*/ { "97912345678961+12345", ZINT_ERROR_TOO_LONG, -1, "Error 283: Input length 20 too long (maximum 19)", "" },
/*104*/ { "9791234567896+123456", ZINT_ERROR_TOO_LONG, -1, "Error 283: Input length 20 too long (maximum 19)", "" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char errtxt_escaped[256];
testStart("test_isbn_input");
testStartSymbol("test_isbn_input", &symbol);
for (i = 0; i < data_size; i++) {
@ -648,7 +655,7 @@ static void test_hrt(const testCtx *const p_ctx) {
char *expected;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX, "12345678901", 0, "0123456789012" },
/* 1*/ { BARCODE_EANX, "123456789012", 0, "1234567890128" },
/* 2*/ { BARCODE_EANX, "1234567890128", 0, "1234567890128" }, /* EANX accepts CHK (treated as such if no leading zeroes required) */
@ -707,11 +714,11 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 55*/ { BARCODE_UPCE_CHK, "12345670+1", 0, "12345670+01" },
/* 56*/ { BARCODE_UPCE_CHK, "1234565+1", 0, "01234565+01" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_hrt");
testStartSymbol("test_hrt", &symbol);
for (i = 0; i < data_size; i++) {
@ -742,16 +749,16 @@ static void test_vector_same(const testCtx *const p_ctx) {
int ret_encode;
int ret_vector;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCE, "123456", 0, 0 },
/* 1*/ { BARCODE_UPCE_CHK, "1234565", 0, 0 }, /* 5 is correct check digit */
/* 2*/ { BARCODE_ISBNX, "0195049969", 0, 0 }, /* 9 is correct check digit */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_vector_same");
testStartSymbol("test_vector_same", &symbol);
for (i = 0; i < data_size; i++) {
struct zint_vector *vectors[4];
@ -809,7 +816,7 @@ static void test_encode(const testCtx *const p_ctx) {
char *comment;
char *expected;
};
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_UPCA, -1, "01234567890", 0, 1, 95, "GGS Figure 5.1-1 UPC-A (also Figure 5.2.2.3-1., 5.2.6.6-2., 6.4.9-1. and BS EN 797:1996 Figure 3)",
"10100011010011001001001101111010100011011000101010101000010001001001000111010011100101001110101"
},
@ -919,9 +926,9 @@ static void test_encode(const testCtx *const p_ctx) {
"10101110110010111011001100100110100001010001101010100111010100001000100100100011101001010000101000000010110011001010010011"
},
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[4096];
@ -930,7 +937,7 @@ static void test_encode(const testCtx *const p_ctx) {
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStart("test_encode");
testStartSymbol("test_encode", &symbol);
for (i = 0; i < data_size; i++) {
@ -998,7 +1005,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX, "55++15", -1, ZINT_ERROR_INVALID_DATA },
/* 1*/ { BARCODE_EANX, "+123456789012345678", -1, ZINT_ERROR_TOO_LONG },
/* 2*/ { BARCODE_EANX_CHK, "+123456789012345678", -1, ZINT_ERROR_TOO_LONG },
@ -1011,11 +1018,11 @@ static void test_fuzz(const testCtx *const p_ctx) {
/* 9*/ { BARCODE_EANX, "+123456", -1, ZINT_ERROR_TOO_LONG },
/*10*/ { BARCODE_EANX, "000002000000200+203", -1, ZINT_ERROR_TOO_LONG }, /* #218 Jan Schrewe CI-Fuzz */
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;
struct zint_symbol *symbol = NULL;
testStart("test_fuzz");
testStartSymbol("test_fuzz", &symbol);
for (i = 0; i < data_size; i++) {
@ -1056,7 +1063,7 @@ static void test_perf(const testCtx *const p_ctx) {
char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
static const struct item data[] = {
/* 0*/ { BARCODE_EANX, -1, "123456789012+12345", 0, 1, 149, "EAN-13 add-on 5" },
/* 1*/ { BARCODE_EANX, -1, "123456789012", 0, 1, 95, "EAN-13 no add-on" },
/* 2*/ { BARCODE_UPCA, -1, "12345678901+12345", 0, 1, 151, "UPC-A add-on 5" },
@ -1068,7 +1075,7 @@ static void test_perf(const testCtx *const p_ctx) {
/* 8*/ { BARCODE_EANX, -1, "12345", 0, 1, 47, "EAN-5" },
/* 9*/ { BARCODE_EANX, -1, "12", 0, 1, 20, "EAN-2" },
};
int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol;

View file

@ -381,6 +381,7 @@ int testContinue(const testCtx *const p_ctx, const int i) {
}
if ((p_ctx->debug & ZINT_DEBUG_TEST_PRINT) && !(p_ctx->debug & ZINT_DEBUG_TEST_LESS_NOISY)) {
printf("i:%d\n", i);
fflush(stdout); /* For assertion failures */
}
return 0;
}
@ -451,7 +452,7 @@ const char *testUtilErrorName(int error_number) {
{ "ZINT_ERROR_NONCOMPLIANT", ZINT_ERROR_NONCOMPLIANT, 14 },
{ "ZINT_ERROR_HRT_TRUNCATED", ZINT_ERROR_HRT_TRUNCATED, 15 },
};
static const int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
if (error_number < 0 || error_number >= data_size) {
return "";
@ -482,7 +483,7 @@ const char *testUtilInputModeName(int input_mode) {
{ "FAST_MODE", FAST_MODE, 0x0080 },
{ "EXTRA_ESCAPE_MODE", EXTRA_ESCAPE_MODE, 0x0100 },
};
static const int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
int set, i;
if (input_mode < 0) {
@ -2302,7 +2303,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
{ "rectangularmicroqrcode", BARCODE_RMQR, 145, 1, 1, 1, 0, 0, },
{ "bc412", BARCODE_BC412, 146, 1, 1, 0, 0, 0, },
};
static const int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
const int symbology = symbol->symbology;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
@ -2449,6 +2450,9 @@ static void testUtilBwippCvtGS1Data(char *bwipp_data, const int upcean, const in
}
}
#define z_isxdigit(c) (z_isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
#define z_isodigit(c) ((c) <= '7' && (c) >= '0')
/* Convert data to Ghostscript format for passing to bwipp_dump.ps */
static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const char *data, int length,
int zint_escape_mode, int eci, int *parse, int *parsefnc) {
@ -2491,9 +2495,24 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch
case 'e': val = 0x1b; /* Escape */ break;
case 'G': val = 0x1d; /* Group Separator */ break;
case 'R': val = 0x1e; /* Record Separator */ break;
/*case 'x': val = 0; TODO: implement break; */
case 'x':
val = d + 1 + 2 < de && z_isxdigit(d[1]) && z_isxdigit(d[2]) ? (ctoi(d[1]) << 4) | ctoi(d[2]) : -1;
if (val != -1) d+= 2;
break;
case 'd':
val = d + 1 + 3 < de ? to_int(d + 1, 3) : -1;
if (val > 255) val = -1;
if (val != -1) d += 3;
break;
case 'o':
val = d + 1 + 3 < de && z_isodigit(d[1]) && z_isodigit(d[2]) && z_isodigit(d[3])
? (ctoi(d[1]) << 6) | (ctoi(d[2]) << 3) | ctoi(d[3]) : -1;
if (val > 255) val = -1;
if (val != -1) d += 3;
break;
case '\\': val = '\\'; break;
/*case 'u': val = 0; TODO: implement break; */
/*case 'U': val = 0; TODO: implement break; */
case '^': val = -1; break; /* Code 128 special escapes */
default: fprintf(stderr, "testUtilBwippEscape: unknown escape %c\n", *d); return NULL; break;
}
@ -3602,7 +3621,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "", -1, 27, },
{ "", BARCODE_FLAT, 28, },
{ "DataBar", BARCODE_DBAR_OMN, 29, },
{ "", BARCODE_DBAR_LTD, 30, },
{ "DataBarLimited", BARCODE_DBAR_LTD, 30, },
{ "DataBarExpanded", BARCODE_DBAR_EXP, 31, },
{ "", BARCODE_TELEPEN, 32, },
{ "", -1, 33, },
@ -3719,7 +3738,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "", BARCODE_ULTRA, 144, },
{ "RMQRCode", BARCODE_RMQR, 145, },
};
static const int data_size = ARRAY_SIZE(data);
const int data_size = ARRAY_SIZE(data);
const int symbology = symbol->symbology;
@ -4011,8 +4030,8 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
hibc[0] = '+';
memcpy(hibc + 1, expected, expected_len);
to_upper((unsigned char *) (hibc + 1), expected_len);
if (!is_sane_lookup(TECHNETIUM, sizeof(TECHNETIUM) - 1, (unsigned char *) (hibc + 1), expected_len, posns)) {
sprintf(msg, "HIBC is_sane_lookup(TECHNETIUM) failed");
if (not_sane_lookup(TECHNETIUM, sizeof(TECHNETIUM) - 1, (unsigned char *) (hibc + 1), expected_len, posns)) {
sprintf(msg, "HIBC not_sane_lookup(TECHNETIUM) failed");
return 5;
}
counter = 41;
@ -4122,10 +4141,15 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
c25inter[++expected_len] = '\0';
expected = c25inter;
}
} else if (symbology == BARCODE_DBAR_OMN || symbology == BARCODE_DBAR_OMNSTK || symbology == BARCODE_DBAR_STK) {
} else if (symbology == BARCODE_DBAR_OMN || symbology == BARCODE_DBAR_LTD || symbology == BARCODE_DBAR_OMNSTK
|| symbology == BARCODE_DBAR_STK) {
if (expected_len == 13) {
cmp_len--; /* Too messy to calc the check digit so ignore */
}
if (symbology == BARCODE_DBAR_LTD) {
cmp_buf += 2; /* Ignore prefixed "01" */
cmp_len -= 2;
}
} else if (is_upcean) {
if (symbology == BARCODE_UPCA && (expected_len == 11 || expected_len == 14 || expected_len == 17)) {
memcpy(upcean, expected, 11);

View file

@ -305,14 +305,13 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
}
if (free_memory > 0xffff0000) {
strcpy(symbol->errtxt, "670: Output file size too big");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 670, "TIF output file size too big");
}
/* Open output file in binary mode */
if (!fm_open(fmp, symbol, "wb")) {
sprintf(symbol->errtxt, "672: Could not open output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_ACCESS;
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 672, "Could not open TIF output file (%1$d: %2$s)", fmp->err,
strerror(fmp->err));
}
if (!output_to_stdout) {
compression = TIF_LZW;
@ -374,8 +373,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
if (!tif_lzw_encode(&lzw_state, fmp, strip_buf, bytes_put)) { /* Only fails if can't malloc */
tif_lzw_cleanup(&lzw_state);
(void) fm_close(fmp, symbol);
strcpy(symbol->errtxt, "673: Failed to malloc LZW hash table");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 673, "Insufficient memory for TIF LZW hash table");
}
bytes_put = fm_tell(fmp) - file_pos;
if (bytes_put != strip_bytes[strip]) {
@ -411,9 +409,8 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
temp32 = (uint32_t) free_memory;
/* Shouldn't happen as `free_memory` checked above to be <= 0xffff0000 & should only decrease */
if (free_memory != temp32 || (long) free_memory != file_pos) {
strcpy(symbol->errtxt, "982: Output file size too big");
(void) fm_close(fmp, symbol);
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 982, "TIF output file size too big");
}
out_le_u32(temp32, temp32);
fm_write(&temp32, 4, 1, fmp);
@ -592,7 +589,7 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
}
if (fm_error(fmp)) {
sprintf(symbol->errtxt, "679: Incomplete write to output (%d: %.30s)", fmp->err, strerror(fmp->err));
errtxtf(0, symbol, 679, "Incomplete write of TIF output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
(void) fm_close(fmp, symbol);
return ZINT_ERROR_FILE_WRITE;
}
@ -600,13 +597,12 @@ INTERNAL int tif_pixel_plot(struct zint_symbol *symbol, const unsigned char *pix
if (!output_to_stdout) {
if (fm_tell(fmp) != total_bytes_put) {
(void) fm_close(fmp, symbol);
strcpy(symbol->errtxt, "674: Failed to write all output");
return ZINT_ERROR_FILE_WRITE;
return errtxt(ZINT_ERROR_FILE_WRITE, symbol, 674, "Failed to write all TIF output");
}
}
if (!fm_close(fmp, symbol)) {
sprintf(symbol->errtxt, "981: Failure on closing output file (%d: %.30s)", fmp->err, strerror(fmp->err));
return ZINT_ERROR_FILE_WRITE;
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 981, "Failure on closing TIF output file (%1$d: %2$s)",
fmp->err, strerror(fmp->err));
}
return 0;

View file

@ -937,20 +937,21 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
(void)seg_count;
if (symbol->eci > 811799) {
strcpy(symbol->errtxt, "590: ECI value not supported by Ultracode");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 590, "ECI code '%d' out of range (0 to 811799)",
symbol->eci);
}
if (symbol->structapp.count) {
int link2 = 2; /* Draft Table 7, Structured Append Group (SAG) with no File Number */
if (symbol->structapp.count < 2 || symbol->structapp.count > 8) {
strcpy(symbol->errtxt, "596: Structured Append count out of range (2-8)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 596,
"Structured Append count '%d' out of range (2 to 8)", symbol->structapp.count);
}
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
sprintf(symbol->errtxt, "597: Structured Append index out of range (1-%d)", symbol->structapp.count);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 597,
"Structured Append index '%1$d' out of range (1 to count %2$d)",
symbol->structapp.index, symbol->structapp.count);
}
scr_cw_count = 1;
@ -960,18 +961,17 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
for (id_len = 1; id_len < 6 && symbol->structapp.id[id_len]; id_len++);
if (id_len > 5) { /* 282 * 283 + 282 = 80088 */
strcpy(symbol->errtxt, "593: Structured Append ID too long (5 digit maximum)");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 593,
"Structured Append ID length %d too long (5 digit maximum)", id_len);
}
id = to_int((const unsigned char *) symbol->structapp.id, id_len);
if (id == -1) {
strcpy(symbol->errtxt, "594: Invalid Structured Append ID (digits only)");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 594, "Invalid Structured Append ID (digits only)");
}
if (id > 80088) {
sprintf(symbol->errtxt, "595: Structured Append ID '%d' out of range (1-80088)", id);
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 595,
"Structured Append ID value '%d' out of range (1 to 80088)", id);
}
if (id) {
link2 = 3; /* Missing from draft Table 7 but mentioned 7.4.3 - SAG with File Number */
@ -1010,8 +1010,8 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
if (symbol->option_2 > 0) {
if (symbol->option_2 > 2) {
strcpy(symbol->errtxt, "592: Revision must be 1 or 2");
return ZINT_ERROR_INVALID_OPTION;
return errtxtf(ZINT_ERROR_INVALID_OPTION, symbol, 592, "Revision '%d' out of range (1 or 2 only)",
symbol->option_2);
}
if (symbol->option_2 == 2) { /* Revision 2, swop and inversion of DCCU/DCCL tiles */
revision_idx = 1;
@ -1030,9 +1030,9 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
qcc = 3;
} else {
if ((data_cw_count % 25) == 0) {
qcc = (ult_kec[ecc_level] * (data_cw_count / 25)) + 3 + 2;
qcc = ult_kec[ecc_level] * (data_cw_count / 25) + 3 + 2;
} else {
qcc = (ult_kec[ecc_level] * ((data_cw_count / 25) + 1)) + 3 + 2;
qcc = ult_kec[ecc_level] * ((data_cw_count / 25) + 1) + 3 + 2;
}
}
@ -1058,8 +1058,10 @@ INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int
/* Maximum capacity is 282 codewords */
total_cws = data_cw_count + qcc + 3; /* 3 == TCC pattern + RSEC pattern + QCC pattern */
if (total_cws - 3 > 282) {
strcpy(symbol->errtxt, "591: Data too long for selected error correction capacity");
return ZINT_ERROR_TOO_LONG;
static const int max_data_cws_by_ecc[6] = { 279, 266, 255, 237, 223, 205 };
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 591,
"Input too long for ECC level EC%1$d, requires %2$d codewords (maximum %3$d)",
ecc_level, data_cw_count, max_data_cws_by_ecc[ecc_level]);
}
rows = 5;

View file

@ -34,6 +34,7 @@
#define ISBNX_SANE_F (IS_NUM_F | IS_UX__F) /* ISBNX_SANE "0123456789X" */
#define ISBNX_ADDON_SANE_F (IS_NUM_F | IS_UX__F | IS_LX__F | IS_PLS_F) /* ISBNX_ADDON_SANE "0123456789Xx+" */
#include <assert.h>
#include <stdio.h>
#include "common.h"
#include "gs1.h"
@ -120,9 +121,8 @@ static int upca_cc(struct zint_symbol *symbol, const unsigned char source[], int
gtin[length] = '\0';
} else {
if (source[length - 1] != gs1_check_digit(gtin, 11)) {
sprintf(symbol->errtxt, "270: Invalid check digit '%c', expecting '%c'",
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 270, "Invalid check digit '%1$c', expecting '%2$c'",
source[length - 1], gs1_check_digit(gtin, 11));
return ZINT_ERROR_INVALID_CHECK;
}
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
@ -177,13 +177,16 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
hrt[0] = '\0';
if (length == 7) {
switch (source[0]) {
case '0': num_system = 0;
case '0':
num_system = 0;
ustrncat(hrt, source, length);
break;
case '1': num_system = 1;
case '1':
num_system = 1;
ustrncat(hrt, source, length);
break;
default: num_system = 0;
default:
num_system = 0;
/* First source char ignored */
ustrncat(hrt, source, length);
hrt[0] = '0'; /* Overwrite HRT first char with '0' to correct TODO: error/warn in future */
@ -228,10 +231,9 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
equivalent[10] = source[4];
if (((source[2] == '0') || (source[2] == '1')) || (source[2] == '2')) {
/* Note 1 - "X3 shall not be equal to 0, 1 or 2" */
sprintf(symbol->errtxt,
"271: For this UPC-E zero suppression, 3rd character cannot be \"0\", \"1\" or \"2\" (%.*s)",
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 271,
"For this UPC-E zero suppression, 3rd character cannot be \"0\", \"1\" or \"2\" (%.*s)",
length, source);
return ZINT_ERROR_INVALID_DATA;
}
break;
case '4':
@ -240,9 +242,9 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
equivalent[10] = source[4];
if (source[3] == '0') {
/* Note 2 - "X4 shall not be equal to 0" */
sprintf(symbol->errtxt, "272: For this UPC-E zero suppression, 4th character cannot be \"0\" (%.*s)",
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 272,
"For this UPC-E zero suppression, 4th character cannot be \"0\" (%.*s)",
length, source);
return ZINT_ERROR_INVALID_DATA;
}
break;
case '5':
@ -256,9 +258,9 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
equivalent[10] = emode;
if (source[4] == '0') {
/* Note 3 - "X5 shall not be equal to 0" */
sprintf(symbol->errtxt, "273: For this UPC-E zero suppression, 5th character cannot be \"0\" (%.*s)",
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 273,
"For this UPC-E zero suppression, 5th character cannot be \"0\" (%.*s)",
length, source);
return ZINT_ERROR_INVALID_DATA;
}
break;
}
@ -268,8 +270,8 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
check_digit = gs1_check_digit(equivalent, 11);
if (src_check_digit && src_check_digit != check_digit) {
sprintf(symbol->errtxt, "274: Invalid check digit '%c', expecting '%c'", src_check_digit, check_digit);
return ZINT_ERROR_INVALID_CHECK;
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 274, "Invalid check digit '%1$c', expecting '%2$c'",
src_check_digit, check_digit);
}
/* Use the number system and check digit information to choose a parity scheme */
@ -287,9 +289,11 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
for (i = 0; i < length; i++, d += 4) {
switch (parity[i]) {
case 'A': memcpy(d, EANsetA[source[i] - '0'], 4);
case 'A':
memcpy(d, EANsetA[source[i] - '0'], 4);
break;
case 'B': memcpy(d, EANsetB[source[i] - '0'], 4);
case 'B':
memcpy(d, EANsetB[source[i] - '0'], 4);
break;
}
}
@ -368,10 +372,12 @@ static void ean_add_on(const unsigned char source[], const int length, char dest
for (i = 0; i < length; i++) {
switch (parity[i]) {
case 'A': memcpy(d, EANsetA[source[i] - '0'], 4);
case 'A':
memcpy(d, EANsetA[source[i] - '0'], 4);
d += 4;
break;
case 'B': memcpy(d, EANsetB[source[i] - '0'], 4);
case 'B':
memcpy(d, EANsetB[source[i] - '0'], 4);
d += 4;
break;
}
@ -403,9 +409,8 @@ static int ean13_cc(struct zint_symbol *symbol, const unsigned char source[], in
gtin[length] = '\0';
} else {
if (source[length - 1] != gs1_check_digit(gtin, 12)) {
sprintf(symbol->errtxt, "275: Invalid check digit '%c', expecting '%c'",
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 275, "Invalid check digit '%1$c', expecting '%2$c'",
source[length - 1], gs1_check_digit(gtin, 12));
return ZINT_ERROR_INVALID_CHECK;
}
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
@ -477,9 +482,8 @@ static int ean8_cc(struct zint_symbol *symbol, const unsigned char source[], int
gtin[length] = '\0';
} else {
if (source[length - 1] != gs1_check_digit(gtin, 7)) {
sprintf(symbol->errtxt, "276: Invalid check digit '%c', expecting '%c'",
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 276, "Invalid check digit '%1$c', expecting '%2$c'",
source[length - 1], gs1_check_digit(gtin, 7));
return ZINT_ERROR_INVALID_CHECK;
}
}
if (symbol->debug & ZINT_DEBUG_PRINT) {
@ -537,44 +541,41 @@ static char isbnx_check(const unsigned char source[], const int length) {
}
/* Make an EAN-13 barcode from an SBN or ISBN */
static int isbnx(struct zint_symbol *symbol, unsigned char source[], const int src_len, char dest[]) {
static int isbnx(struct zint_symbol *symbol, unsigned char source[], const int length, char dest[]) {
int i;
char check_digit;
to_upper(source, src_len);
if (!is_sane(ISBNX_SANE_F, source, src_len)) {
strcpy(symbol->errtxt, "277: Invalid character in data (digits and \"X\" only)");
return ZINT_ERROR_INVALID_DATA;
to_upper(source, length);
if (not_sane(ISBNX_SANE_F, source, length)) { /* As source has been zero-padded, don't report position */
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 277, "Invalid character in input (digits and \"X\" only)");
}
/* Input must be 9, 10 or 13 characters */
if (src_len != 9 && src_len != 10 && src_len != 13) {
strcpy(symbol->errtxt, "278: Input wrong length (9, 10, or 13 characters only)");
return ZINT_ERROR_TOO_LONG;
if (length != 9 && length != 10 && length != 13) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 278, "Input length %d wrong (9, 10, or 13 only)", length);
}
if (src_len == 13) /* Using 13 character ISBN */ {
if (length == 13) /* Using 13 character ISBN */ {
if (!(((source[0] == '9') && (source[1] == '7')) &&
((source[2] == '8') || (source[2] == '9')))) {
strcpy(symbol->errtxt, "279: Invalid ISBN (must begin with \"978\" or \"979\")");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 279, "Invalid ISBN (must begin with \"978\" or \"979\")");
}
/* "X" cannot occur */
if (!is_sane(NEON_F, source, 13)) {
strcpy(symbol->errtxt, "282: Invalid character in data, \"X\" not allowed in ISBN-13");
return ZINT_ERROR_INVALID_DATA;
if (not_sane(NEON_F, source, 13)) {
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 282,
"Invalid character in input, \"X\" not allowed in ISBN-13");
}
check_digit = gs1_check_digit(source, 12);
if (source[12] != check_digit) {
sprintf(symbol->errtxt, "280: Invalid ISBN check digit '%c', expecting '%c'", source[12], check_digit);
return ZINT_ERROR_INVALID_CHECK;
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 280, "Invalid ISBN check digit '%1$c', expecting '%2$c'",
source[12], check_digit);
}
source[12] = '\0';
} else { /* Using 10 digit ISBN or 9 digit SBN padded with leading zero */
if (src_len == 9) /* Using 9 digit SBN */ {
if (length == 9) /* Using 9 digit SBN */ {
/* Add leading zero */
for (i = 10; i > 0; i--) {
source[i] = source[i - 1];
@ -583,16 +584,16 @@ static int isbnx(struct zint_symbol *symbol, unsigned char source[], const int s
}
/* "X" can only occur in last position */
if (!is_sane(NEON_F, source, 9)) {
strcpy(symbol->errtxt, "296: Invalid character in data, \"X\" allowed in last position only");
return ZINT_ERROR_INVALID_DATA;
if (not_sane(NEON_F, source, 9)) {
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 296,
"Invalid character in input, \"X\" allowed in last position only");
}
check_digit = isbnx_check(source, 9);
if (check_digit != source[9]) {
sprintf(symbol->errtxt, "281: Invalid %s check digit '%c', expecting '%c'", src_len == 9 ? "SBN" : "ISBN",
return errtxtf(ZINT_ERROR_INVALID_CHECK, symbol, 281,
"Invalid %1$s check digit '%2$c', expecting '%3$c'", length == 9 ? "SBN" : "ISBN",
source[9], check_digit);
return ZINT_ERROR_INVALID_CHECK;
}
for (i = 11; i > 2; i--) { /* This drops the check digit */
source[i] = source[i - 3];
@ -627,8 +628,17 @@ INTERNAL int ean_leading_zeroes(struct zint_symbol *symbol, const unsigned char
}
}
if (first_len > 13 || second_len > 5) {
if (first_len > 13) {
if (!second_len) {
errtxtf(0, symbol, 294, "Input length %d too long (maximum 13)", first_len);
} else {
errtxtf(0, symbol, 298, "Input EAN length %d too long (maximum 13)", first_len);
}
} else {
errtxtf(0, symbol, 297, "Input add-on length %d too long (maximum 5)", second_len);
}
if (p_with_addon) {
*p_with_addon = second_len > 5 ? with_addon : 0;
*p_with_addon = with_addon;
}
return 0;
}
@ -751,7 +761,7 @@ INTERNAL int ean_leading_zeroes(struct zint_symbol *symbol, const unsigned char
return 1; /* Success */
}
INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src_len, int cc_rows) {
INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int length, int cc_rows) {
unsigned char first_part[14], second_part[6];
unsigned char local_source[20]; /* Allow 13 + "+" + 5 + 1 */
char dest[1000] = {0};
@ -760,41 +770,37 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
int addon_gap = 0;
int first_part_len, second_part_len;
if (src_len > 19) {
strcpy(symbol->errtxt, "283: Input too long (19 character maximum)");
return ZINT_ERROR_TOO_LONG;
if (length > 19) {
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 283, "Input length %d too long (maximum 19)", length);
}
if (symbol->symbology != BARCODE_ISBNX) {
/* ISBN has its own sanity routine */
if (!is_sane(SODIUM_PLS_F, source, src_len)) {
strcpy(symbol->errtxt, "284: Invalid character in data (digits and \"+\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(SODIUM_PLS_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 284,
"Invalid character at position %d in input (digits and \"+\" only)", i);
}
} else {
if (!is_sane(ISBNX_ADDON_SANE_F, source, src_len)) {
strcpy(symbol->errtxt, "285: Invalid character in data (digits, \"X\" and \"+\" only)");
return ZINT_ERROR_INVALID_DATA;
if ((i = not_sane(ISBNX_ADDON_SANE_F, source, length))) {
return errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 285,
"Invalid character at position %d in input (digits, \"X\" and \"+\" only)", i);
}
/* Add-on will be checked separately to be numeric only below */
}
/* Check for multiple '+' characters */
plus_count = 0;
for (i = 0; i < src_len; i++) {
for (i = 0; i < length; i++) {
if (source[i] == '+') {
plus_count++;
if (plus_count > 1) {
strcpy(symbol->errtxt, "293: Invalid add-on data (one \"+\" only)");
return ZINT_ERROR_INVALID_DATA;
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 293, "Invalid add-on data (one \"+\" only)");
}
}
}
/* Add leading zeroes, checking max lengths of parts */
if (!ean_leading_zeroes(symbol, source, local_source, &with_addon, first_part, second_part)) {
sprintf(symbol->errtxt, "294: Input too long (%s)",
with_addon ? "5 character maximum for add-on" : "13 character maximum");
return ZINT_ERROR_TOO_LONG;
return ZINT_ERROR_TOO_LONG; /* `ean_leading_zeroes()` sets `errtxt` */
}
if (with_addon) {
@ -813,7 +819,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
case BARCODE_EANX_CHK:
switch (first_part_len) {
case 2:
case 5: ean_add_on(first_part, first_part_len, dest, 0);
case 5:
ean_add_on(first_part, first_part_len, dest, 0);
ustrcpy(symbol->text, first_part);
if (symbol->output_options & COMPLIANT_HEIGHT) {
/* 21.9mm from GS1 General Specifications 5.2.6.6, Figure 5.2.6.6-6 */
@ -824,18 +831,23 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
}
break;
case 7:
case 8: error_number = ean8(symbol, first_part, first_part_len, dest);
case 8:
error_number = ean8(symbol, first_part, first_part_len, dest);
break;
case 12:
case 13: error_number = ean13(symbol, first_part, first_part_len, dest);
case 13:
error_number = ean13(symbol, first_part, first_part_len, dest);
break;
default:
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 286,
"Input length %d wrong (2, 5, 7, 8, 12 or 13 only)", first_part_len);
break;
default: strcpy(symbol->errtxt, "286: Input wrong length (2, 5, 7, 8, 12 or 13 characters only)");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_EANX_CC:
switch (first_part_len) { /* Adds vertical separator bars according to ISO/IEC 24723 section 11.4 */
case 7: set_module(symbol, symbol->rows, 1);
case 7:
set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 67);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 68);
@ -848,7 +860,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
error_number = ean8_cc(symbol, first_part, first_part_len, dest, cc_rows);
break;
case 12:
case 13:set_module(symbol, symbol->rows, 1);
case 13:
set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
set_module(symbol, symbol->rows + 1, 0);
set_module(symbol, symbol->rows + 1, 96);
@ -860,8 +873,10 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
symbol->rows += 3;
error_number = ean13_cc(symbol, first_part, first_part_len, dest, cc_rows);
break;
default: strcpy(symbol->errtxt, "287: Input wrong length (7, 12 or 13 characters only)");
return ZINT_ERROR_TOO_LONG;
default:
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 287, "Input length %d wrong (7, 12 or 13 only)",
first_part_len);
break;
}
break;
case BARCODE_UPCA:
@ -869,8 +884,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
if ((first_part_len == 11) || (first_part_len == 12)) {
error_number = upca(symbol, first_part, first_part_len, dest);
} else {
strcpy(symbol->errtxt, "288: Input wrong length (12 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 288, "Input length %d wrong (11 or 12 only)",
first_part_len);
}
break;
case BARCODE_UPCA_CC:
@ -887,8 +902,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
symbol->rows += 3;
error_number = upca_cc(symbol, first_part, first_part_len, dest, cc_rows);
} else {
strcpy(symbol->errtxt, "289: Input wrong length (12 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 289, "Input length %d wrong (11 or 12 only)",
first_part_len);
}
break;
case BARCODE_UPCE:
@ -896,8 +911,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
if ((first_part_len >= 6) && (first_part_len <= 8)) {
error_number = upce(symbol, first_part, first_part_len, dest);
} else {
strcpy(symbol->errtxt, "290: Input wrong length (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 290, "Input length %d wrong (6, 7 or 8 only)",
first_part_len);
}
break;
case BARCODE_UPCE_CC:
@ -914,8 +929,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
symbol->rows += 3;
error_number = upce_cc(symbol, first_part, first_part_len, dest, cc_rows);
} else {
strcpy(symbol->errtxt, "291: Input wrong length (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
return errtxtf(ZINT_ERROR_TOO_LONG, symbol, 291, "Input length %d wrong (6, 7 or 8 only)",
first_part_len);
}
break;
case BARCODE_ISBNX:
@ -930,27 +945,15 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
second_part_len = (int) ustrlen(second_part);
if (symbol->symbology == BARCODE_ISBNX) { /* Need to further check that add-on numeric only */
if (!is_sane(NEON_F, second_part, second_part_len)) {
strcpy(symbol->errtxt, "295: Invalid add-on data (digits only)");
return ZINT_ERROR_INVALID_DATA;
if (not_sane(NEON_F, second_part, second_part_len)) {
return errtxt(ZINT_ERROR_INVALID_DATA, symbol, 295, "Invalid add-on data (digits only)");
}
}
switch (second_part_len) {
case 0: break;
case 2:
if (second_part_len) {
ean_add_on(second_part, second_part_len, dest, addon_gap);
ustrcat(symbol->text, "+");
ustrcat(symbol->text, second_part);
break;
case 5:
ean_add_on(second_part, second_part_len, dest, addon_gap);
ustrcat(symbol->text, "+");
ustrcat(symbol->text, second_part);
break;
default:
strcpy(symbol->errtxt, "292: Add-on data wrong length (2 or 5 characters only)");
return ZINT_ERROR_TOO_LONG;
}
expand(symbol, dest, (int) strlen(dest));
@ -976,8 +979,8 @@ INTERNAL int eanx_cc(struct zint_symbol *symbol, unsigned char source[], int src
}
/* Handle UPC, EAN, ISBN */
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
return eanx_cc(symbol, source, src_len, 0 /*cc_rows*/);
INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int length) {
return eanx_cc(symbol, source, length, 0 /*cc_rows*/);
}
/* vim: set ts=4 sw=4 et : */

View file

@ -43,7 +43,9 @@ static int vector_add_rect(struct zint_symbol *symbol, const float x, const floa
struct zint_vector_rect *rect;
if (!(rect = (struct zint_vector_rect *) malloc(sizeof(struct zint_vector_rect)))) {
strcpy(symbol->errtxt, "691: Insufficient memory for vector rectangle");
/* NOTE: clang-tidy-20 gets confused about return value of function returning a function unfortunately,
so put on 2 lines (see also "postal.c" `postnet_enc()` & `planet_enc()`, same issue) */
errtxt(0, symbol, 691, "Insufficient memory for vector rectangle");
return 0;
}
@ -69,8 +71,7 @@ static int vector_add_hexagon(struct zint_symbol *symbol, const float x, const f
struct zint_vector_hexagon *hexagon;
if (!(hexagon = (struct zint_vector_hexagon *) malloc(sizeof(struct zint_vector_hexagon)))) {
strcpy(symbol->errtxt, "692: Insufficient memory for vector hexagon");
return 0;
return errtxt(0, symbol, 692, "Insufficient memory for vector hexagon");
}
hexagon->next = NULL;
hexagon->x = x;
@ -93,8 +94,7 @@ static int vector_add_circle(struct zint_symbol *symbol, const float x, const fl
struct zint_vector_circle *circle;
if (!(circle = (struct zint_vector_circle *) malloc(sizeof(struct zint_vector_circle)))) {
strcpy(symbol->errtxt, "693: Insufficient memory for vector circle");
return 0;
return errtxt(0, symbol, 693, "Insufficient memory for vector circle");
}
circle->next = NULL;
circle->x = x;
@ -119,8 +119,7 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te
struct zint_vector_string *string;
if (!(string = (struct zint_vector_string *) malloc(sizeof(struct zint_vector_string)))) {
strcpy(symbol->errtxt, "694: Insufficient memory for vector string");
return 0;
return errtxt(0, symbol, 694, "Insufficient memory for vector string");
}
string->next = NULL;
string->x = x;
@ -132,8 +131,7 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te
string->halign = halign;
if (!(string->text = (unsigned char *) malloc(string->length + 1))) {
free(string);
strcpy(symbol->errtxt, "695: Insufficient memory for vector string text");
return 0;
return errtxt(0, symbol, 695, "Insufficient memory for vector string text");
}
memcpy(string->text, text, string->length);
string->text[string->length] = '\0';
@ -439,14 +437,12 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
return error_number;
}
if (symbol->rows <= 0) {
strcpy(symbol->errtxt, "697: No rows");
return ZINT_ERROR_INVALID_OPTION;
return errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 697, "No rows");
}
/* Allocate memory */
if (!(vector = symbol->vector = (struct zint_vector *) malloc(sizeof(struct zint_vector)))) {
strcpy(symbol->errtxt, "696: Insufficient memory for vector header");
return ZINT_ERROR_MEMORY;
return errtxt(ZINT_ERROR_MEMORY, symbol, 696, "Insufficient memory for vector header");
}
vector->rectangles = NULL;
vector->hexagons = NULL;

View file

@ -437,7 +437,7 @@ private slots:
QTest::newRow("BARCODE_QRCODE") << BARCODE_QRCODE << "1234" << 0.0f << 0 << "" << 21 << 21 << 21.0f << 42.0f << 42.0f;
QTest::newRow("BARCODE_QRCODE Scale 1.5") << BARCODE_QRCODE << "1234" << 1.5f << 0 << "" << 21 << 21 << 21.0f << 63.0f << 63.0f;
if (!m_skipIfFontUsed) {
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << 0.0f << ZINT_ERROR_INVALID_DATA << "Error 778: No input data (segment 0 empty)" << 0 << 0 << 0.0f << 0.0f << 0.0f;
QTest::newRow("BARCODE_QRCODE no text") << BARCODE_QRCODE << "" << 0.0f << ZINT_ERROR_INVALID_DATA << "Error 228: No input data (segment 0 empty)" << 0 << 0 << 0.0f << 0.0f << 0.0f;
}
QTest::newRow("BARCODE_MAXICODE") << BARCODE_MAXICODE << "1234" << 0.0f << 0 << "" << 30 << 33 << 28.578f << 60.0f << 57.7334f;
QTest::newRow("BARCODE_MAXICODE Scale 2") << BARCODE_MAXICODE << "1234" << 2.0f << 0 << "" << 30 << 33 << 28.578f << 120.0f << 115.467f;

View file

@ -1,13 +1,20 @@
% docs/README 2024-09-29
% docs/README 2024-10-27
For generation of "docs/manual.pdf" and "docs/manual.txt" from "manual.pmd" using a recent version of pandoc
On Ubuntu/Debian (tested on Ubuntu 22.04)
On Ubuntu/Debian (tested on Ubuntu 22.04 and Ubuntu 24.04)
wget https://github.com/jgm/pandoc/releases/download/3.4/pandoc-3.4-1-amd64.deb
sudo dpkg -i pandoc-3.4-1-amd64.deb
wget https://github.com/jgm/pandoc/releases/download/3.5/pandoc-3.5-1-amd64.deb
sudo dpkg -i pandoc-3.5-1-amd64.deb
For Ubuntu 22.04 (python < 3.12)
sudo apt install python3-pip
pip install pandoc-tablenos --user
Else for Ubuntu 24.04 (one way around "externally-managed-environment" error, PEP 668)
sudo apt install python3-full
python3 -m venv ~/py_envs
source ~/py_envs/bin/activate
pip install pandoc-tablenos
Then
export PATH=~/.local/bin:"$PATH"
# Temporary fix for version regex - see https://github.com/tomduck/pandoc-xnos/pull/29
python -m pip install --force-reinstall \
@ -18,11 +25,11 @@ On Ubuntu/Debian (tested on Ubuntu 22.04)
sudo apt install fonts-wqy-microhei
make
On Fedora (tested on Fedora Linux 38 (Workstation Edition))
On Fedora (tested on Fedora Linux 38 (Workstation Edition) and Fedora Linux 40 (Workstation Edition))
wget https://github.com/jgm/pandoc/releases/download/3.4/pandoc-3.4-linux-amd64.tar.gz
tar xf pandoc-3.4-linux-amd64.tar.gz
sudo mv -i pandoc-3.4/bin/pandoc /usr/local/bin
wget https://github.com/jgm/pandoc/releases/download/3.5/pandoc-3.5-linux-amd64.tar.gz
tar xf pandoc-3.5-linux-amd64.tar.gz
sudo mv -i pandoc-3.5/bin/pandoc /usr/local/bin
sudo dnf install python3-pip
pip install pandoc-tablenos --user
export PATH=~/.local/bin:"$PATH"

View file

@ -332,7 +332,7 @@
<h1 class="title">Zint Barcode Generator and Zint Barcode Studio User
Manual</h1>
<p class="author">Version 2.13.0.9</p>
<p class="date">September 2024</p>
<p class="date">October 2024</p>
</header>
<nav id="TOC" role="doc-toc">
<ul>
@ -5196,12 +5196,15 @@ alt="zint -b CODABLOCKF -d &quot;CODABLOCK F Symbology&quot; --rows=3" />
aria-hidden="true"><code>zint -b CODABLOCKF -d "CODABLOCK F Symbology" --rows=3</code></figcaption>
</figure>
<p>This is a stacked symbology based on Code 128 which can encode
Latin-1 data up to a maximum length of 2725 characters. The width of the
Codablock-F symbol can be set using the <code>--cols</code> option (API
<code>option_2</code>), to a value between 9 and 67. The height (number
of rows) can be set using the <code>--rows</code> option (API
<code>option_1</code>), with a maximum of 44. Zint does not currently
support encoding of GS1 data in Codablock-F symbols.</p>
Latin-1 data up to a maximum length of 2726 symbol characters, meaning
for instance up to 2726 all ASCII characters, or 5452 all numeric, or up
to 1363 all extended ASCII (ISO/IEC 8859-1).</p>
<p>The width of the Codablock-F symbol can be set using the
<code>--cols</code> option (API <code>option_2</code>), to a value
between 9 and 67. The height (number of rows) can be set using the
<code>--rows</code> option (API <code>option_1</code>), with a maximum
of 44. Zint does not currently support encoding of GS1 data in
Codablock-F symbols.</p>
<p>A separate symbology ID (<code>BARCODE_HIBC_BLOCKF</code>) can be
used to encode Health Industry Barcode (HIBC) data which adds a leading
<code>'+'</code> character and a modulo-49 check digit to the encoded

View file

@ -1,6 +1,6 @@
% Zint Barcode Generator and Zint Barcode Studio User Manual
% Version 2.13.0.9
% September 2024
% October 2024
# 1. Introduction
@ -3430,11 +3430,14 @@ demonstrated by the symbologies below.
--rows=3`](images/codablockf.svg){.lin}
This is a stacked symbology based on Code 128 which can encode Latin-1 data up
to a maximum length of 2725 characters. The width of the Codablock-F symbol can
be set using the `--cols` option (API `option_2`), to a value between 9 and 67.
The height (number of rows) can be set using the `--rows` option (API
`option_1`), with a maximum of 44. Zint does not currently support encoding of
GS1 data in Codablock-F symbols.
to a maximum length of 2726 symbol characters, meaning for instance up to 2726
all ASCII characters, or 5452 all numeric, or up to 1363 all extended ASCII
(ISO/IEC 8859-1).
The width of the Codablock-F symbol can be set using the `--cols` option (API
`option_2`), to a value between 9 and 67. The height (number of rows) can be set
using the `--rows` option (API `option_1`), with a maximum of 44. Zint does not
currently support encoding of GS1 data in Codablock-F symbols.
A separate symbology ID (`BARCODE_HIBC_BLOCKF`) can be used to encode Health
Industry Barcode (HIBC) data which adds a leading `'+'` character and a

View file

@ -1,6 +1,6 @@
Zint Barcode Generator and Zint Barcode Studio User Manual
Version 2.13.0.9
September 2024
October 2024
*******************************************************************************
* For reference the following is a text-only version of the Zint manual, *
@ -3298,11 +3298,14 @@ demonstrated by the symbologies below.
[zint -b CODABLOCKF -d "CODABLOCK F Symbology" --rows=3]
This is a stacked symbology based on Code 128 which can encode Latin-1 data up
to a maximum length of 2725 characters. The width of the Codablock-F symbol can
be set using the --cols option (API option_2), to a value between 9 and 67. The
height (number of rows) can be set using the --rows option (API option_1), with
a maximum of 44. Zint does not currently support encoding of GS1 data in
Codablock-F symbols.
to a maximum length of 2726 symbol characters, meaning for instance up to 2726
all ASCII characters, or 5452 all numeric, or up to 1363 all extended ASCII
(ISO/IEC 8859-1).
The width of the Codablock-F symbol can be set using the --cols option (API
option_2), to a value between 9 and 67. The height (number of rows) can be set
using the --rows option (API option_1), with a maximum of 44. Zint does not
currently support encoding of GS1 data in Codablock-F symbols.
A separate symbology ID (BARCODE_HIBC_BLOCKF) can be used to encode Health
Industry Barcode (HIBC) data which adds a leading '+' character and a modulo-49
@ -4823,7 +4826,7 @@ configured barcode is displayed once the "Generate" button is pressed.
Annex D. Man Page ZINT(1)
% ZINT(1) Version 2.13.0.9 % % September 2024
% ZINT(1) Version 2.13.0.9 % % October 2024
NAME

View file

@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.3
.\" Automatically generated by Pandoc 3.5
.\"
.TH "ZINT" "1" "September 2024" "Version 2.13.0.9"
.TH "ZINT" "1" "October 2024" "Version 2.13.0.9"
.SH NAME
\f[CR]zint\f[R] \- encode data as a barcode image
.SH SYNOPSIS

Some files were not shown because too many files have changed in this diff Show more