1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-08-01 02:49:52 +00:00

GS1: new GS1RAW_MODE (CLI "--gs1raw") and GS1 Syntax Engine

"Unbracketed AI" (caret) options for specifying GS1 input
  (ticket #350, props Mario Verbruggen)
DBAR_EXP_CC/DBAR_EXPSTK_CC: fix separator over finder patterns
  when linear part is greater than 4 codeblocks
general: left-over raw_text -> content_segs in comments;
  update & expand some GS1 General Specs refs;
  some minor code fiddling
test suite: suppress some additional ZINT_SANITIZEM false positives
  (& add new ZINT_TESTUTIL_SANITIZEM_INIT helpers)
This commit is contained in:
gitlost
2026-02-26 15:05:45 +00:00
parent 3b24d129d7
commit 0a8a79fa6c
59 changed files with 7504 additions and 4206 deletions
+1 -1
View File
@@ -4934,7 +4934,7 @@ static void test_encode(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[8192];
char cmp_buf[32768];
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
+4 -4
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -2897,7 +2897,7 @@ static void test_encode(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[8192];
char bwipp_buf[32768];
char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@@ -3286,7 +3286,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[8192];
char bwipp_buf[32768];
char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@@ -3574,7 +3574,7 @@ static void test_fuzz(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char bwipp_buf[32768];
char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
+2 -2
View File
@@ -104,7 +104,7 @@ static void test_large(const testCtx *const p_ctx) {
char escaped2[1024];
char cmp_buf[8192];
char cmp_msg[1024];
char ret_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char ret_buf[8192] ZINT_TESTUTIL_SANITIZEM_INIT;
/* Only do BWIPP/zxing-cpp tests if asked, too slow otherwise */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
@@ -937,7 +937,7 @@ static void test_hibc_input(const testCtx *const p_ctx) {
char escaped[1024];
char escaped2[1024];
char cmp_buf[8192];
char cmp_buf[8192] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
char ret_buf[8192];
File diff suppressed because it is too large Load Diff
+13 -11
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -360,7 +360,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[ZINT_MAX_DATA_LEN];
char escaped[8192];
char escaped[8192] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_buf[32768];
char cmp_msg[1024];
@@ -1304,7 +1304,7 @@ static void test_input(const testCtx *const p_ctx) {
&& data[i].option_3 == data[i - 1].option_3
&& data[i].output_options == data[i - 1].output_options
&& strcmp(data[i].data, data[i - 1].data) == 0) {
unsigned char binary[2][2200];
unsigned char binary[2][2200] ZINT_TESTUTIL_SANITIZEM_INIT_2D;
int gs1;
int binlen;
int binlens[2] = {0};
@@ -1319,7 +1319,7 @@ static void test_input(const testCtx *const p_ctx) {
i, expected_rows_width, prev_expected_rows_width);
if ((data[i].input_mode & 0x07) == GS1_MODE) {
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, reduced, &length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, reduced, &length, 0 /*set_hrt*/);
assert_zero(ret, "i:%d zint_gs1_verify() ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
text = reduced;
} else {
@@ -6395,7 +6395,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
testFinish();
}
static void test_rt(const testCtx *const p_ctx) {
static void test_ct(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
@@ -6427,9 +6427,11 @@ static void test_rt(const testCtx *const p_ctx) {
/* 11*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, BARCODE_CONTENT_SEGS, "é", -1, 0, 899, "é", -1, 899 },
/* 12*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
/* 13*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
/* 14*/ { BARCODE_DATAMATRIX, GS1_MODE, 28, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 28, "01049123451234591597033130128\03510ABC123", -1, 3 }, /* Note: content seg ECI rremains at default 3 */
/* 15*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 },
/* 16*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 },
/* 14*/ { BARCODE_DATAMATRIX, GS1_MODE, 28, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 28, "01049123451234591597033130128\03510ABC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */
/* 15*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "https://example.com/01/09506000134369", -1, 0, 0, "", -1, 0 },
/* 16*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "https://example.com/01/09506000134369", -1, 0, 0, "https://example.com/01/09506000134369", -1, 3 },
/* 17*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 },
/* 18*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -6487,7 +6489,7 @@ static void test_rt(const testCtx *const p_ctx) {
testFinish();
}
static void test_rt_segs(const testCtx *const p_ctx) {
static void test_ct_segs(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
@@ -7686,8 +7688,8 @@ int main(int argc, char *argv[]) {
{ "test_input", test_input },
{ "test_encode", test_encode },
{ "test_encode_segs", test_encode_segs },
{ "test_rt", test_rt },
{ "test_rt_segs", test_rt_segs },
{ "test_ct", test_ct },
{ "test_ct_segs", test_ct_segs },
#ifdef ZINT_TEST_ENCODING
{ "test_minimalenc", test_minimalenc },
#endif
+2 -2
View File
@@ -71,7 +71,7 @@ static void test_large(const testCtx *const p_ctx) {
char data_buf[4096];
char escaped[8192];
char cmp_buf[50000];
char cmp_buf[50000] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/zxing-cpp tests if asked, too slow otherwise */
@@ -294,7 +294,7 @@ static void test_input(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[32768];
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
+2949 -2247
View File
File diff suppressed because it is too large Load Diff
+854 -416
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -195,15 +195,15 @@ static void test_checks(const testCtx *const p_ctx) {
/*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*132*/ { BARCODE_MAXICODE, -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 },
/*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*134*/ { 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 },
/*135*/ { 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 },
/*134*/ { 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) data position 14: Bad checksum '4', expected '1'", -1 },
/*135*/ { 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) data position 14: Bad checksum '4', expected '1'", -1 },
/*136*/ { BARCODE_QRCODE, -1, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
/*137*/ { BARCODE_QRCODE, -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 },
/*138*/ { BARCODE_QRCODE, -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 },
/*139*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 },
/*140*/ { BARCODE_CODEONE, -1, "[01]12345678901231", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 512: ECI ignored for GS1 mode", -1 },
/*141*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 512: ECI ignored for GS1 mode", -1 }, /* Warning in encoder overrides library warnings */
/*142*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 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 }, /* But not errors */
/*142*/ { BARCODE_CODEONE, -1, "[01]12345678901234", -1, GS1_MODE, 3, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 }, /* But not errors */
/*143*/ { BARCODE_AZTEC, -1, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
/*144*/ { 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 },
/*145*/ { 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 },
@@ -2105,7 +2105,7 @@ static int test_prev_ZBarcode_BarcodeName(int symbol_id, char name[32]) {
static void test_barcode_name(const testCtx *const p_ctx) {
int ret;
char name[32] = {0}; /* Suppress clang -fsanitize=memory false positive */
char name[32] ZINT_TESTUTIL_SANITIZEM_INIT;
int symbol_id;
(void)p_ctx;
@@ -2810,8 +2810,8 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
int ret_dest;
unsigned char dest[1024];
int dest_length;
unsigned char dest[1024] ZINT_TESTUTIL_SANITIZEM_INIT;
int dest_length ZINT_TESTUTIL_SANITIZEM_INIT;
if (testContinue(p_ctx, i)) continue;
+2 -2
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -648,7 +648,7 @@ static void test_2d_encode(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[8192];
char cmp_buf[32768];
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
+10 -10
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -70,10 +70,10 @@ static void test_qr_large(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[ZINT_MAX_DATA_LEN];
char data_buf[ZINT_MAX_DATA_LEN] ZINT_TESTUTIL_SANITIZEM_INIT;
char escaped[ZINT_MAX_DATA_LEN] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[177 * 177 + 1] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[ZINT_MAX_DATA_LEN] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_buf[177 * 177 + 1] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
@@ -489,7 +489,7 @@ static void test_qr_input(const testCtx *const p_ctx) {
char escaped[4096];
char escaped2[4096];
char ret_buf[4096];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
@@ -856,7 +856,7 @@ static void test_qr_optimize(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
@@ -4740,7 +4740,7 @@ static void test_qr_encode_segs(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768];
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
@@ -7369,7 +7369,7 @@ static void test_upnqr_encode(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768];
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
#if 0 /* Need to add "force binary mode" to BWIPP for this to work */
@@ -8078,7 +8078,7 @@ static void test_rmqr_large(const testCtx *const p_ctx) {
char data_buf[ZINT_MAX_DATA_LEN];
char escaped[4096];
char cmp_buf[32768];
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do ZXing-C++ test if asked, too slow otherwise */
@@ -9397,7 +9397,7 @@ static void test_rmqr_encode_segs(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
+21 -19
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -790,7 +790,7 @@ static void test_examples(const testCtx *const p_ctx) {
"00000100010110000110100000001010101010111100111101110010110001110011101000000000100010000011010010000100011110111011001000101010101010011101111111010000000000000000000000000000000000000000000000000000"
"00100011101001111001001111110000010101000011000010001101001110001100010111111111001101111100101101111011100001000100110011000000000101100010000000101010000000000000000000000000000000000000000000000000"
},
/* 90*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141416543213500110000310123196000", 0, 5, 200, 1, "NACAG Figure 1 (& Appendix C: Example 6) specifying max rows",
/* 90*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141416543213500110000310123196000", 0, 5, 200, 0, "NACAG Figure 1 (& Appendix C: Example 6) specifying max rows; BWIPP need segments arg, see above",
"01001100101110001110111111110000101000001101000001010111100110111000101111100000011011010001000000110000111100001010100011111100001010000010101111000111010000011001101011111111001110000001101101000101"
"00000011010001110001000000001010010111110010111110101000011001000111010000010101000100101110111111001111000011110101010100000010100101111101010000111000101111100110010100000000100001111110010010110000"
"00000101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
@@ -804,7 +804,7 @@ static void test_examples(const testCtx *const p_ctx) {
"0000001000100001011010000000010000111001101101100001100111100100100010100001010100100001101011111000000000000000000000000000000000000000000000000000000"
"1011110111011110100101111111100111000110010010011110011000011011011100011110000001011110010100000100100000000000000000000000000000000000000000000000000"
},
/* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]10614141011111275110111", 0, 5, 151, 1, "NACAG Figure 3 specifying max rows",
/* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]10614141011111275110111", 0, 5, 151, 0, "NACAG Figure 3 specifying max rows; BWIPP need segments arg, see above",
"0101011110011100001011111111000010100000110100000101011110011011100010111110000001101101000100000011000011100001101010001111110000101010000011000111010"
"0000100001100011110100000000101001011111001011111010100001100100011101000001010100010010111011111100111100011110010101010000001010010101111100111000000"
"0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000"
@@ -818,7 +818,7 @@ static void test_examples(const testCtx *const p_ctx) {
"0000011010011011100010100101010100100111000100000101010000111000110010100000101010001111000101110100011001110001101000100000001010101011011110000111010111110001101011101000000000100011110100100010000110101100111000001000101010101000000000000000000000000000000000000000000000000000000000000000000000"
"0010000101100100011100011000000001011000111011111010101111000111001101011111000000110000111010001011100110001110010111001111110000010100100001111000101000001110010100010111111111001100001011011101111001010011000111110011000000000101000000000000000000000000000000000000000000000000000000000000000000"
},
/* 94*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141410222223100110222111101231023456721104561045678991201", 0, 5, 298, 1, "NACAG Figure 4, specifying max rows",
/* 94*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]106141410222223100110222111101231023456721104561045678991201", 0, 5, 298, 0, "NACAG Figure 4, specifying max rows; BWIPP need segments arg, see above",
"0100101111101001111011111111000010110010000011001101011110011011100010111100000000101101000100000011000011100001101010001111110000101011000011100001010111000011011110101111000000111010011111000101110001110110011001100011110000001011100110000101000110101111110111001011111111001110011010011100001101"
"0000010000010110000100000000101001001101111100110010100001100100011101000010101010010010111011111100111100011110010101010000001010010100111100011110101000111100100001010000101010000101100000111010001110001001100110010100001010100100011001111010111001010000001000110100000000100001100101100011110000"
"0000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
@@ -832,7 +832,7 @@ static void test_examples(const testCtx *const p_ctx) {
"000001110000100101101000000101000011110100100011100111100001001101001010010101010010011111110101101100010010110011111010000010101000111101010000010001110001001100110010001010101010100011000111001011000010011010000010100000000010000000000000000000000"
"101110001111011010010111111000011100001011011100011000011110110010110001100000000101100000001010010011101101001100000101111100000011000010101111101110001110110011001100110000000001011100111000110100111101100101111101011111111100110100000000000000000"
},
/* 96*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]1061414165432131501101201211014092110256100126663101231", 0, 5, 249, 1, "NACAG Appendix C: Example 1, specifying max row",
/* 96*/ { BARCODE_DBAR_EXPSTK, -1, -1, 2, "[8110]1061414165432131501101201211014092110256100126663101231", 0, 5, 249, 0, "NACAG Appendix C: Example 1, specifying max row; BWIPP need segments arg, see above",
"010111101100011011101111111100001011001000001100110101111001101110001011110000000010110100010000001100001111000010101000111111000010100000101011110001110100000110011010111100000011101001111000101111000111011001001110001111000000101011001000001110010"
"000000010011100100010000000010100100110111110011001010000110010001110100001010101001001011101111110011110000111101010101000000101001011111010100001110001011111001100101000010101000010110000111010000111000100110110001010000101010010100110111110000000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100000"
@@ -872,8 +872,8 @@ static void test_examples(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char escaped[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[16384];
char escaped[4096] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_buf[16384] ZINT_TESTUTIL_SANITIZEM_INIT;
char cmp_msg[1024];
/* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */
@@ -1332,12 +1332,14 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 9*/ { BARCODE_DBAR_LTD, BARCODE_CONTENT_SEGS, "13410567901384", 0, "(01)13410567901384", "0113410567901384" },
/* 10*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", 0, "(01)12345678901231", "" }, /* See test_hrt() in "test_gs1.c" for full HRT tests */
/* 11*/ { BARCODE_DBAR_EXP, BARCODE_CONTENT_SEGS, "[01]12345678901231", 0, "(01)12345678901231", "0112345678901231" },
/* 12*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "", "" }, /* No HRT for stacked */
/* 13*/ { BARCODE_DBAR_STK, BARCODE_CONTENT_SEGS, "12345678901231", 0, "", "0112345678901231" }, /* But have content segs */
/* 14*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "", "" },
/* 15*/ { BARCODE_DBAR_OMNSTK, BARCODE_CONTENT_SEGS, "10000000000090", 0, "", "0110000000000090" },
/* 16*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "", "" },
/* 17*/ { BARCODE_DBAR_EXPSTK, BARCODE_CONTENT_SEGS, "[01]12345678901231", 0, "", "0112345678901231" },
/* 12*/ { BARCODE_DBAR_EXP, -1, "^0112345678901231", 0, "(01)12345678901231", "" },
/* 13*/ { BARCODE_DBAR_EXP, BARCODE_CONTENT_SEGS, "^0112345678901231", 0, "(01)12345678901231", "0112345678901231" },
/* 14*/ { BARCODE_DBAR_STK, -1, "12345678901231", 0, "", "" }, /* No HRT for stacked */
/* 15*/ { BARCODE_DBAR_STK, BARCODE_CONTENT_SEGS, "12345678901231", 0, "", "0112345678901231" }, /* But have content segs */
/* 16*/ { BARCODE_DBAR_OMNSTK, -1, "10000000000090", 0, "", "" },
/* 17*/ { BARCODE_DBAR_OMNSTK, BARCODE_CONTENT_SEGS, "10000000000090", 0, "", "0110000000000090" },
/* 18*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", 0, "", "" },
/* 19*/ { BARCODE_DBAR_EXPSTK, BARCODE_CONTENT_SEGS, "[01]12345678901231", 0, "", "0112345678901231" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -1441,16 +1443,16 @@ static void test_input(const testCtx *const p_ctx) {
/* 34*/ { BARCODE_DBAR_LTD, -1, -1, -1, "[01)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 18 too long (maximum 14)", 0, 0 },
/* 35*/ { BARCODE_DBAR_LTD, -1, -1, -1, "[10]12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 382: Input length 18 too long (maximum 14)", 0, 0 },
/* 36*/ { BARCODE_DBAR_LTD, GS1NOCHECK_MODE, -1, -1, "22345678901238", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 384: Input value out of range (0 to 1999999999999)", 0, 0 },
/* 37*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", 0, 0 },
/* 37*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 },
/* 38*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "", 0, 0 },
/* 39*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231", 0, 1, 134, "", 0, 0 },
/* 40*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 41*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 42*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01)", 0, 0 },
/* 42*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01) at position 1", 0, 0 },
/* 43*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 1, 151, "", 0, 0 },
/* 44*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", 0, 0 },
/* 44*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 1, 134, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 0, 0 },
/* 45*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 1, 134, "", 0, 0 },
/* 46*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", ZINT_WARN_NONCOMPLIANT, 1, 526, "Warning 261: AI (91) position 21: Invalid CSET 82 character ' '", 0, 0 }, /* ISOIEC punc */
/* 46*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", ZINT_WARN_NONCOMPLIANT, 1, 526, "Warning 261: AI (91) data position 21: Invalid CSET 82 character ' '", 0, 0 }, /* ISOIEC punc */
/* 47*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_ ", 0, 1, 526, "", 0, 0 },
/* 48*/ { BARCODE_DBAR_EXP, -1, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 }, /* ISOIEC punc less space */
/* 49*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, -1, "[01]12345678901231[91]!\"%&'()*+,-./:;<=>?_", 0, 1, 494, "", 0, 0 },
@@ -1486,12 +1488,12 @@ static void test_input(const testCtx *const p_ctx) {
/* 79*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "(01)12345678901231", 0, 5, 50, "", 0, 0 }, /* Allow '(01)' prefix if check digit given */
/* 80*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "(01)1234567890123", 0, 5, 50, "", 0, 0 }, /* Or not */
/* 81*/ { BARCODE_DBAR_OMNSTK, -1, -1, -1, "(00)12345678901231", ZINT_ERROR_TOO_LONG, -1, -1, "Error 380: Input length 18 too long (maximum 14)", 0, 0 },
/* 82*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) position 14: Bad checksum '4', expected '1'", 2, 0 },
/* 82*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901234", ZINT_WARN_NONCOMPLIANT, 5, 102, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", 2, 0 },
/* 83*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]12345678901234", 0, 5, 102, "", 2, 0 },
/* 84*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 },
/* 85*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 86*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]1234567890123A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 385: Invalid character in Compressed Field data (digits only)", 0, 0 },
/* 87*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01)", 0, 0 },
/* 87*/ { BARCODE_DBAR_EXPSTK, -1, -1, -1, "[01]123456789012315", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 259: Invalid data length for AI (01) at position 1", 0, 0 },
/* 88*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, -1, "[01]123456789012315", 0, 5, 102, "", 2, 0 },
/* 89*/ { BARCODE_DBAR_EXPSTK, -1, 12, -1, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Cols > 11 ignored */
/* 90*/ { BARCODE_DBAR_EXPSTK, -1, -1, 12, "[01]12345678901231", 0, 5, 102, "", 2, 0 }, /* Rows > 11 ignored */
+2 -2
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2026 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -810,7 +810,7 @@ static void test_encode(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[1024];
char bwipp_buf[32768];
char bwipp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT;
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
+54 -34
View File
@@ -570,6 +570,7 @@ const char *testUtilInputModeName(int input_mode) {
{ "FAST_MODE", FAST_MODE, 0x0080 },
{ "EXTRA_ESCAPE_MODE", EXTRA_ESCAPE_MODE, 0x0100 },
{ "GS1SYNTAXENGINE_MODE", GS1SYNTAXENGINE_MODE, 0x0200 },
{ "GS1RAW_MODE", GS1RAW_MODE, 0x0400 },
};
const int data_size = ARRAY_SIZE(data);
int set, i;
@@ -2296,7 +2297,7 @@ int testUtilVerifyTiffInfo(const char *filename, int debug) {
/* Map Zint symbology to BWIPP routine */
static const char *testUtilBwippName(int index, const struct zint_symbol *symbol, int option_1, int option_2,
int option_3, int debug, int *linear_row_height, int *gs1_cvt) {
int option_3, int debug, int *p_linear_row_height, int *p_gs1_cvt) {
struct item {
const char *name;
int define;
@@ -2324,7 +2325,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
{ "ean13", BARCODE_EANX, 13, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
{ "ean13", BARCODE_EANX_CHK, 14, 0, 1, 0, 0, 1, },
{ "ean13", BARCODE_EAN13, 15, 0, 1, 0, 0, 1, },
{ "gs1-128", BARCODE_GS1_128, 16, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "gs1-128", BARCODE_GS1_128, 16, 0, 0, 1 /*GS1CARET*/, 0, 1 /*gs1_cvt*/, },
{ "", -1, 17, 0, 0, 0, 0, 0, },
{ "rationalizedCodabar", BARCODE_CODABAR, 18, 0, 1, 0, 0, 0, },
{ "", -1, 19, 0, 0, 0, 0, 0, },
@@ -2339,7 +2340,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
{ "flattermarken", BARCODE_FLAT, 28, 0, 0, 0, 0, 0, },
{ "databaromni", BARCODE_DBAR_OMN, 29, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "databarlimited", BARCODE_DBAR_LTD, 30, 0, 0, 0, 0, 1, },
{ "databarexpanded", BARCODE_DBAR_EXP, 31, 0, 1, 0, 1 /*linear_row_height*/, 1, },
{ "databarexpanded", BARCODE_DBAR_EXP, 31, 0, 1, 1 /*GS1CARET*/, 1 /*linear_row_height*/, 1, },
{ "telepen", BARCODE_TELEPEN, 32, 0, 0, 0, 0, 0, },
{ "", -1, 33, 0, 0, 0, 0, 0, },
{ "upca", BARCODE_UPCA, 34, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
@@ -2380,7 +2381,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
{ "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
{ "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, },
{ "datamatrix", BARCODE_DATAMATRIX, 71, 0, 1, 1, 1, 0, },
{ "ean14", BARCODE_EAN14, 72, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "ean14", BARCODE_EAN14, 72, 0, 0, 1 /*GS1CARET*/, 0, 1 /*gs1_cvt*/, },
{ "code39", BARCODE_VIN, 73, 0, 0, 0, 0, 0, },
{ "codablockf", BARCODE_CODABLOCKF, 74, 1, 1, 0, 10 /*linear_row_height*/, 0, },
{ "sscc18", BARCODE_NVE18, 75, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
@@ -2389,7 +2390,7 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
{ "", -1, 78, 0, 0, 0, 0, 0, },
{ "databarstacked", BARCODE_DBAR_STK, 79, 0, 0, 0, 0, 1 /*gs1_cvt*/, },
{ "databarstackedomni", BARCODE_DBAR_OMNSTK, 80, 0, 0, 0, 33 /*linear_row_height*/, 1, },
{ "databarexpandedstacked", BARCODE_DBAR_EXPSTK, 81, 0, 1, 0, 34 /*linear_row_height*/, 1, },
{ "databarexpandedstacked", BARCODE_DBAR_EXPSTK, 81, 0, 1, 1 /*GS1CARET*/, 34 /*linear_row_height*/, 1, },
{ "planet", BARCODE_PLANET, 82, 0, 0, 0, 0, 0, },
{ "", -1, 83, 0, 0, 0, 0, 0, },
{ "micropdf417", BARCODE_MICROPDF417, 84, 0, 1, 0, 0, 0, },
@@ -2439,15 +2440,15 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
{ "aztecrune", BARCODE_AZRUNE, 128, 0, 0, 0, 0, 0, },
{ "code32", BARCODE_CODE32, 129, 0, 0, 0, 0, 0, },
{ "ean13composite", BARCODE_EANX_CC, 130, 1, 1, 0, 72 /*linear_row_height*/, 1 /*gs1_cvt*/, },
{ "gs1-128composite", BARCODE_GS1_128_CC, 131, 1, 0, 0, 36, 1, },
{ "gs1-128composite", BARCODE_GS1_128_CC, 131, 1, 0, 1 /*GS1CARET*/, 36, 1, },
{ "databaromnicomposite", BARCODE_DBAR_OMN_CC, 132, 1, 0, 0, 33, 1, },
{ "databarlimitedcomposite", BARCODE_DBAR_LTD_CC, 133, 1, 0, 0, 10 /*linear_row_height*/, 1, },
{ "databarexpandedcomposite", BARCODE_DBAR_EXP_CC, 134, 1, 1, 0, 34 /*linear_row_height*/, 1, },
{ "databarexpandedcomposite", BARCODE_DBAR_EXP_CC, 134, 1, 1, 1 /*GS1CARET*/, 34 /*linear_row_height*/, 1, },
{ "upcacomposite", BARCODE_UPCA_CC, 135, 1, 1, 0, 72, 1, },
{ "upcecomposite", BARCODE_UPCE_CC, 136, 1, 1, 0, 72, 1, },
{ "databarstackedcomposite", BARCODE_DBAR_STK_CC, 137, 1, 0, 0, 0, 1, },
{ "databarstackedomnicomposite", BARCODE_DBAR_OMNSTK_CC, 138, 1, 0, 0, 33 /*linear_row_height*/, 1, },
{ "databarexpandedstackedcomposite", BARCODE_DBAR_EXPSTK_CC, 139, 1, 1, 0, 34 /*linear_row_height*/, 1, },
{ "databarexpandedstackedcomposite", BARCODE_DBAR_EXPSTK_CC, 139, 1, 1, 1 /*GS1CARET*/, 34 /*lin_r_h*/, 1, },
{ "channelcode", BARCODE_CHANNEL, 140, 0, 0, 0, 0, 0, },
{ "codeone", BARCODE_CODEONE, 141, 0, 1, 0, 0, 0, },
{ "", BARCODE_GRIDMATRIX, 142, 0, 0, 0, 0, 0, },
@@ -2462,7 +2463,9 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
const int data_size = ARRAY_SIZE(data);
const int symbology = symbol->symbology;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
const int gs1raw_mode = !!(symbol->input_mode & GS1RAW_MODE);
const int gs1_caret = option_3 != -1 && !!(option_3 & ZINT_TESTUTIL_GS1CARET); /* Hack indicator */
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE || gs1raw_mode || gs1_caret;
if (symbology < 0 || symbology >= data_size) {
fprintf(stderr, "testUtilBwippName: unknown symbology (%d)\n", symbology);
@@ -2544,16 +2547,30 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
}
}
if (linear_row_height) {
*linear_row_height = data[symbology].linear_row_height;
if (p_linear_row_height) {
*p_linear_row_height = data[symbology].linear_row_height;
}
if (gs1_cvt) {
*gs1_cvt = data[symbology].gs1_cvt;
if (p_gs1_cvt) {
*p_gs1_cvt = data[symbology].gs1_cvt;
}
if (gs1) {
if (gs1raw_mode) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, GS1RAW_MODE not supported\n",
index, testUtilBarcodeName(symbology));
}
return NULL;
}
if (gs1_caret) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible, GS1 Syntax Engine caret input not supported\n",
index, testUtilBarcodeName(symbology));
}
return NULL;
}
if (symbology == BARCODE_DATAMATRIX) {
if (gs1_cvt) {
*gs1_cvt = 1;
if (p_gs1_cvt) {
*p_gs1_cvt = 1;
}
return "gs1datamatrix";
} else if (symbology == BARCODE_AZTEC || symbology == BARCODE_CODE16K || symbology == BARCODE_ULTRA
@@ -2564,13 +2581,13 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
}
return NULL;
} else if (symbology == BARCODE_QRCODE) {
if (gs1_cvt) {
*gs1_cvt = 1;
if (p_gs1_cvt) {
*p_gs1_cvt = 1;
}
return "gs1qrcode";
} else if (symbology == BARCODE_DOTCODE) {
if (gs1_cvt) {
*gs1_cvt = 1;
if (p_gs1_cvt) {
*p_gs1_cvt = 1;
}
return "gs1dotcode";
}
@@ -3876,8 +3893,8 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "", -1, 5, },
{ "", BARCODE_C25LOGIC, 6, },
{ "", BARCODE_C25IND, 7, },
{ "Code39", BARCODE_CODE39, 8, },
{ "Code39", BARCODE_EXCODE39, 9, }, /* TODO: Code39 with specially encoded chars */
{ "Code39Std", BARCODE_CODE39, 8, },
{ "Code39", BARCODE_EXCODE39, 9, },
{ "EAN8", BARCODE_EAN8, 10, },
{ "", BARCODE_EAN_2ADDON, 11, },
{ "", BARCODE_EAN_5ADDON, 12, },
@@ -3918,9 +3935,9 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "", BARCODE_MSI_PLESSEY, 47, },
{ "", -1, 48, },
{ "", BARCODE_FIM, 49, },
{ "Code39", BARCODE_LOGMARS, 50, },
{ "Code39Std", BARCODE_LOGMARS, 50, },
{ "", BARCODE_PHARMA, 51, },
{ "Code39", BARCODE_PZN, 52, },
{ "Code39Std", BARCODE_PZN, 52, },
{ "", BARCODE_PHARMA_TWO, 53, },
{ "", -1, 54, },
{ "PDF417", BARCODE_PDF417, 55, },
@@ -3941,7 +3958,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "", BARCODE_RM4SCC, 70, },
{ "DataMatrix", BARCODE_DATAMATRIX, 71, },
{ "Code128", BARCODE_EAN14, 72, },
{ "Code39", BARCODE_VIN, 73, },
{ "Code39Std", BARCODE_VIN, 73, },
{ "CodablockF", BARCODE_CODABLOCKF, 74, },
{ "Code128", BARCODE_NVE18, 75, },
{ "", BARCODE_JAPANPOST, 76, },
@@ -3967,7 +3984,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "Code128", BARCODE_DPD, 96, },
{ "MicroQRCode", BARCODE_MICROQR, 97, },
{ "Code128", BARCODE_HIBC_128, 98, },
{ "Code39", BARCODE_HIBC_39, 99, },
{ "Code39Std", BARCODE_HIBC_39, 99, },
{ "", -1, 100, },
{ "", -1, 101, },
{ "DataMatrix", BARCODE_HIBC_DM, 102, },
@@ -4127,12 +4144,12 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
if (symbology == BARCODE_EXCODE39) {
if (symbol->option_2 == 1) {
opts = "tryCode39ExtendedMode,validateCode39CheckSum";
opts = "tryCode39ExtendedMode,validateOptionalChecksum";
} else {
opts = "tryCode39ExtendedMode";
}
} else if ((symbology == BARCODE_CODE39 || symbology == BARCODE_LOGMARS) && symbol->option_2 == 1) {
opts = "validateCode39CheckSum";
opts = "validateOptionalChecksum";
}
if (zxingcpp_cmp > 1 && symbol->eci == 0) {
@@ -4283,8 +4300,8 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128;
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
const int is_hibc = symbology >= BARCODE_HIBC_128 && symbology <= BARCODE_HIBC_AZTEC;
const int have_c25checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2;
const int have_c25inter = (symbology == BARCODE_C25INTER && ((expected_len & 1) || have_c25checkdigit))
const int have_ccheckdigit = symbol->option_2 == 1 || symbol->option_2 == 2; /* Good for C25, CODE39, CODABAR */
const int have_c25inter = (symbology == BARCODE_C25INTER && ((expected_len & 1) || have_ccheckdigit))
|| symbology == BARCODE_ITF14 || symbology == BARCODE_DPLEIT
|| symbology == BARCODE_DPIDENT;
const int is_upcean = (ZBarcode_Cap(symbology, ZINT_CAP_EANUPC) & ZINT_CAP_EANUPC) == ZINT_CAP_EANUPC;
@@ -4362,7 +4379,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
expected = escaped;
}
if (gs1 && symbology != BARCODE_EAN14 && symbology != BARCODE_NVE18) {
ret = zint_gs1_verify(symbol, ZUCP(expected), expected_len, ZUCP(reduced), &expected_len);
ret = zint_gs1_verify(symbol, ZUCP(expected), expected_len, ZUCP(reduced), &expected_len, 0 /*set_hrt*/);
if (ret >= ZINT_ERROR) {
sprintf(msg, "zint_gs1_verify %d != 0", ret);
return 3;
@@ -4441,7 +4458,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
cmp_len -= 2;
expected++;
expected_len -= 2;
if (symbol->option_2 == 1 || symbol->option_2 == 2) {
if (have_ccheckdigit) {
cmp_len--; /* Too messy to calc the check digit so ignore */
}
} else if (is_vin_international) {
@@ -4451,15 +4468,15 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
expected = vin;
} else if (have_c25inter) {
if (symbology == BARCODE_C25INTER) {
if ((expected_len & 1) || have_c25checkdigit) {
if (((expected_len & 1) && !have_c25checkdigit) || (!(expected_len & 1) && have_c25checkdigit)) {
if ((expected_len & 1) || have_ccheckdigit) {
if (((expected_len & 1) && !have_ccheckdigit) || (!(expected_len & 1) && have_ccheckdigit)) {
c25inter[0] = '0';
memcpy(c25inter + 1, expected, expected_len);
expected_len++;
} else {
memcpy(c25inter, expected, expected_len);
}
if (have_c25checkdigit) {
if (have_ccheckdigit) {
c25inter[expected_len] = zint_gs1_check_digit((const unsigned char *) c25inter, expected_len);
expected_len++;
}
@@ -4652,6 +4669,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
expected = azrune;
expected_len = 3;
}
} else if ((symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_LOGMARS)
&& have_ccheckdigit) {
cmp_len--; /* Too tedious to calculate so ignore */
}
if (ret_buf) {
+12 -1
View File
@@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2026 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,6 +49,17 @@ extern "C" {
#define ZINT_DEBUG_TEST_ZXINGCPP 512
#define ZINT_DEBUG_TEST_BWIPP_ZXINGCPP 1024
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positives */
#define ZINT_TESTUTIL_SANITIZEM_INIT = {0}
#define ZINT_TESTUTIL_SANITIZEM_INIT_2D = {{0}}
#else
#define ZINT_TESTUTIL_SANITIZEM_INIT
#define ZINT_TESTUTIL_SANITIZEM_INIT_2D
#endif
/* Hack `option_3` flag to indicate GS1 Syntax Engine caret input */
#define ZINT_TESTUTIL_GS1CARET (1 << 24)
#include <errno.h>
#include <stdio.h>
#include "../common.h"
Binary file not shown.