MAXICODE: add minimal encoding by Bue Jensen (BWIPP PR #279),

around 20% slower than current but much better;
  numerous other fiddlings
reedsol: reverse result in `rs_*encode*()` routines & adjust
  clients appropriately (may replace later with something faster)
test suite: cater for MAXICODE SCM better; add assert & dataset
  totals
BWIPP: update to latest
gen_gs1_lint.php: restrict line length to 118 for func calls
This commit is contained in:
gitlost 2024-11-25 09:22:37 +00:00
parent 1ae7815d95
commit e94727f07d
22 changed files with 1317 additions and 1172 deletions

View file

@ -1,4 +1,4 @@
Version 2.13.0.9 (dev) not released yet (2024-11-18)
Version 2.13.0.9 (dev) not released yet (2024-11-23)
====================================================
**Incompatible changes**
@ -14,7 +14,7 @@ Version 2.13.0.9 (dev) not released yet (2024-11-18)
- Add-ons for UPC-A and UPC-E now descend to be level with the main symbol guard
bars, and the righthand outside digit is now placed 1X less from main symbol
to avoid touching any add-on
- GS1_128 now warns if READER_INIT option used
- GS1-128 symbols now warn if READER_INIT option used
Changes
-------
@ -41,8 +41,7 @@ Changes
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;
use code set E for padding as well, saves codeword, props Bue Jensen (BWIPP PR
#279)
add minimal encodation algorithm, props Bue Jensen (BWIPP)
- 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

View file

@ -90,8 +90,8 @@ static char *aus_rs_error(char data_pattern[], char *d) {
rs_init_code(&rs, 4, 1);
rs_encode(&rs, triple_writer, triple, result);
for (reader = 4; reader > 0; reader--, d += 3) {
memcpy(d, AusBarTable[result[reader - 1]], 3);
for (reader = 0; reader < 4; reader++, d += 3) {
memcpy(d, AusBarTable[result[reader]], 3);
}
return d;

View file

@ -1159,7 +1159,7 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
break;
}
for (i = (ecc_blocks - 1); i >= 0; i--) {
for (i = 0; i < ecc_blocks; i++) {
adjusted_length = bin_append_posn(ecc_part[i], codeword_size, adjusted_string, adjusted_length);
}
@ -1214,19 +1214,19 @@ INTERNAL int aztec(struct zint_symbol *symbol, struct zint_seg segs[], const int
rs_init_code(&rs, 5, 1);
rs_encode(&rs, 2, desc_data, desc_ecc);
for (i = 0; i < 5; i++) {
descriptor[(i * 4) + 8] = (desc_ecc[4 - i] & 0x08) ? '1' : '0';
descriptor[(i * 4) + 9] = (desc_ecc[4 - i] & 0x04) ? '1' : '0';
descriptor[(i * 4) + 10] = (desc_ecc[4 - i] & 0x02) ? '1' : '0';
descriptor[(i * 4) + 11] = (desc_ecc[4 - i] & 0x01) ? '1' : '0';
descriptor[(i * 4) + 8] = (desc_ecc[i] & 0x08) ? '1' : '0';
descriptor[(i * 4) + 9] = (desc_ecc[i] & 0x04) ? '1' : '0';
descriptor[(i * 4) + 10] = (desc_ecc[i] & 0x02) ? '1' : '0';
descriptor[(i * 4) + 11] = (desc_ecc[i] & 0x01) ? '1' : '0';
}
} else {
rs_init_code(&rs, 6, 1);
rs_encode(&rs, 4, desc_data, desc_ecc);
for (i = 0; i < 6; i++) {
descriptor[(i * 4) + 16] = (desc_ecc[5 - i] & 0x08) ? '1' : '0';
descriptor[(i * 4) + 17] = (desc_ecc[5 - i] & 0x04) ? '1' : '0';
descriptor[(i * 4) + 18] = (desc_ecc[5 - i] & 0x02) ? '1' : '0';
descriptor[(i * 4) + 19] = (desc_ecc[5 - i] & 0x01) ? '1' : '0';
descriptor[(i * 4) + 16] = (desc_ecc[i] & 0x08) ? '1' : '0';
descriptor[(i * 4) + 17] = (desc_ecc[i] & 0x04) ? '1' : '0';
descriptor[(i * 4) + 18] = (desc_ecc[i] & 0x02) ? '1' : '0';
descriptor[(i * 4) + 19] = (desc_ecc[i] & 0x01) ? '1' : '0';
}
}
@ -1320,7 +1320,7 @@ INTERNAL int azrune(struct zint_symbol *symbol, unsigned char source[], int leng
rs_encode(&rs, 2, data_codewords, ecc_codewords);
for (i = 0; i < 5; i++) {
bp = bin_append_posn(ecc_codewords[4 - i], 4, binary_string, bp);
bp = bin_append_posn(ecc_codewords[i], 4, binary_string, bp);
}
for (i = 0; i < 28; i += 2) {

View file

@ -1106,7 +1106,7 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
rs_encode_uint(&rs, codewords, target, ecc);
for (i = 0; i < codewords; i++) {
target[i + codewords] = ecc[codewords - i - 1];
target[i + codewords] = ecc[i];
}
if (debug_print) {
@ -1195,7 +1195,7 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
rs_encode_uint(&rs, data_cw, target, ecc);
for (i = 0; i < ecc_cw; i++) {
target[data_cw + i] = ecc[ecc_cw - i - 1];
target[data_cw + i] = ecc[i];
}
if (debug_print) {
@ -1285,7 +1285,7 @@ INTERNAL int codeone(struct zint_symbol *symbol, struct zint_seg segs[], const i
}
rs_encode_uint(&rs, data_blocks, sub_data, sub_ecc);
for (j = 0; j < ecc_blocks; j++) {
target[data_cw + j * blocks + i] = sub_ecc[ecc_blocks - 1 - j];
target[data_cw + j * blocks + i] = sub_ecc[j];
}
}

View file

@ -154,7 +154,7 @@ INTERNAL int not_sane_lookup(const char test_string[], const int test_length, co
return 0;
}
/* Returns the position of `data` in `set_string` */
/* Returns the position of `data` in `set_string`, or -1 if not found */
INTERNAL int posn(const char set_string[], const char data) {
const char *s;

View file

@ -195,7 +195,7 @@ INTERNAL int not_sane(const unsigned int flg, const unsigned char source[], cons
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` */
/* Returns the position of `data` in `set_string`, or -1 if not found */
INTERNAL int posn(const char set_string[], const char data);

View file

@ -179,19 +179,20 @@ static void dm_ecc(unsigned char *binary, const int bytes, const int datablock,
for (n = b; n < bytes; n += blocks)
buf[p++] = binary[n];
rs_encode(&rs, p, buf, ecc);
p = rsblock - 1; /* comes back reversed */
for (n = b; n < rsblocks; n += blocks) {
if (skew) {
/* Rotate ecc data to make 144x144 size symbols acceptable */
/* See http://groups.google.com/group/postscriptbarcode/msg/5ae8fda7757477da
or https://github.com/nu-book/zxing-cpp/issues/259 */
if (skew) {
/* Rotate ecc data to make 144x144 size symbols acceptable */
/* See http://groups.google.com/group/postscriptbarcode/msg/5ae8fda7757477da
or https://github.com/nu-book/zxing-cpp/issues/259 */
for (n = b, p = 0; n < rsblocks; n += blocks, p++) {
if (b < 8) {
binary[bytes + n + 2] = ecc[p--];
binary[bytes + n + 2] = ecc[p];
} else {
binary[bytes + n - 8] = ecc[p--];
binary[bytes + n - 8] = ecc[p];
}
} else {
binary[bytes + n] = ecc[p--];
}
} else {
for (n = b, p = 0; n < rsblocks; n += blocks, p++) {
binary[bytes + n] = ecc[p];
}
}
}

View file

@ -886,12 +886,12 @@ static void gm_add_ecc(const char binary[], const int data_posn, const int layer
rs_init_code(&rs, ecc_size, 1);
rs_encode(&rs, data_size, data_block, ecc_block);
/* Correct error correction data but in reverse order */
/* Add error correction data */
for (j = 0; j < data_size; j++) {
block[j] = data_block[j];
}
for (j = 0; j < ecc_size; j++) {
block[(j + data_size)] = ecc_block[ecc_size - j - 1];
block[j + data_size] = ecc_block[j];
}
for (j = 0; j < n2; j++) {

View file

@ -751,7 +751,8 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
return n3_iso3166(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 423 || ai == 425) {
return n3_iso3166__n3__iso3166__n3__iso3166__n3__iso3166__n3__iso3166(data, data_len, p_err_no, p_err_posn, err_msg);
return n3_iso3166__n3__iso3166__n3__iso3166__n3__iso3166__n3__iso3166(data,
data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 427) {
return x__3(data, data_len, p_err_no, p_err_posn, err_msg);

View file

@ -1118,8 +1118,8 @@ static void hx_add_ecc(unsigned char fullstream[], const unsigned char datastrea
unsigned char data_block[180];
unsigned char ecc_block[36];
int i, j, block;
int input_position = -1;
int output_position = -1;
int input_position = 0;
int output_position = 0;
const int table_d1_pos = ((version - 1) * 36) + ((ecc_level - 1) * 9);
rs_t rs;
@ -1134,17 +1134,15 @@ static void hx_add_ecc(unsigned char fullstream[], const unsigned char datastrea
for (block = 0; block < batch_size; block++) {
for (j = 0; j < data_length; j++) {
input_position++;
output_position++;
data_block[j] = input_position < data_codewords ? datastream[input_position] : 0;
fullstream[output_position] = data_block[j];
fullstream[output_position++] = data_block[j];
input_position++;
}
rs_encode(&rs, data_length, data_block, ecc_block);
for (j = 0; j < ecc_length; j++) {
output_position++;
fullstream[output_position] = ecc_block[ecc_length - j - 1];
fullstream[output_position++] = ecc_block[j];
}
}
}
@ -1177,7 +1175,7 @@ static void hx_set_function_info(unsigned char *grid, const int size, const int
rs_init_code(&rs, 4, 1);
rs_encode(&rs, 3, fi_cw, fi_ecc);
for (i = 3; i >= 0; i--) {
for (i = 0; i < 4; i++) {
bp = bin_append_posn(fi_ecc[i], 4, function_information, bp);
}

View file

@ -402,16 +402,15 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
/* Generation of Reed-Solomon Check Numbers */
rs_init_gf(&rs, 0x25);
rs_init_code(&rs, check_count, 1);
rs_encode(&rs, (data_top + 1), data, check);
data_top++;
rs_encode(&rs, data_top, data, check);
/* Append check digits to data */
for (i = 1; i <= check_count; i++) {
data[data_top + i] = check[check_count - i];
}
memcpy(data + data_top, check, check_count);
if (symbol->debug & ZINT_DEBUG_PRINT) {
fputs("Codewords:", stdout);
for (i = 0; i <= data_top + check_count; i++) {
for (i = 0; i < data_top + check_count; i++) {
printf(" %d", (int) data[i]);
}
fputc('\n', stdout);
@ -421,7 +420,7 @@ INTERNAL int mailmark_4s(struct zint_symbol *symbol, unsigned char source[], int
for (i = 0; i <= data_step; i++) {
data[i] = mailmark_data_symbol_even[data[i]];
}
for (i = data_step + 1; i <= (data_top + check_count); i++) {
for (i = data_step + 1; i < (data_top + check_count); i++) {
data[i] = mailmark_data_symbol_odd[data[i]];
}

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/* maxicode.h - Handles Maxicode */
/*
libzint - the open source barcode library
Copyright (C) 2008-2022 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
@ -33,9 +33,9 @@
#ifndef Z_MAXICODE_H
#define Z_MAXICODE_H
static const unsigned short MaxiGrid[] = {
/* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence */ /* 30 x 33 data grid */
122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0,
/* ISO/IEC 16023 Figure 5 - MaxiCode Module Sequence */
static const unsigned short maxiGrid[] = { /* 33 x 30 data grid */
122, 121, 128, 127, 134, 133, 140, 139, 146, 145, 152, 151, 158, 157, 164, 163, 170, 169, 176, 175, 182, 181, 188, 187, 194, 193, 200, 199, 0, 0,
124, 123, 130, 129, 136, 135, 142, 141, 148, 147, 154, 153, 160, 159, 166, 165, 172, 171, 178, 177, 184, 183, 190, 189, 196, 195, 202, 201, 817, 0,
126, 125, 132, 131, 138, 137, 144, 143, 150, 149, 156, 155, 162, 161, 168, 167, 174, 173, 180, 179, 186, 185, 192, 191, 198, 197, 204, 203, 819, 818,
284, 283, 278, 277, 272, 271, 266, 265, 260, 259, 254, 253, 248, 247, 242, 241, 236, 235, 230, 229, 224, 223, 218, 217, 212, 211, 206, 205, 820, 0,
@ -70,39 +70,49 @@ static const unsigned short MaxiGrid[] = {
738, 737, 744, 743, 750, 749, 756, 755, 762, 761, 768, 767, 774, 773, 780, 779, 786, 785, 792, 791, 798, 797, 804, 803, 810, 809, 816, 815, 864, 863
};
/* From Appendix A - ASCII character to Code Set bit flag (MX_OP_SETX): A 0x01; B 0x02; E 0x04; C 0x08; D 0x10 */
/* Chars that fit in more than one set have flags OR-ed together: A/E "CR"; All "FS GS RS SP"; A/B ",./:" */
static const char maxiCodeSet[256] = {
/* from Appendix A - ASCII character to Code Set (e.g. 2 = Set B) */
/* set 0 refers to special characters that fit into more than one set (e.g. GS) */
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 5, 0, 2, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2,
2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 4, 5, 5, 5, 5, 5, 5, 4, 5, 3, 4, 3, 5, 5, 4, 4, 3, 3, 3,
4, 3, 5, 4, 4, 3, 3, 4, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
/* CR */
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x04, 0x04, /* 0- 15 */
/* FS GS RS */
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1F, 0x1F, 0x1F, 0x04, /* 16- 31 */
/*SP , . / */
0x1F, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x03, 0x03, /* 32- 47 */
/* : */
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, /* 48- 63 */
0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, /* 64- 79 */
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, /* 80- 95 */
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 96-111 */
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 112-127 */
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, /* 128-143 */
0x10, 0x10, 0x10, 0x10, 0x10, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 144-159 */
0x04, 0x10, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x10, 0x04, 0x08, 0x10, 0x08, 0x04, 0x04, 0x10, /* 160-175 */
0x10, 0x08, 0x08, 0x08, 0x10, 0x08, 0x04, 0x10, 0x10, 0x08, 0x08, 0x10, 0x08, 0x08, 0x08, 0x10, /* 176-191 */
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 192-207 */
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, /* 208-223 */
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, /* 224-249 */
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 /* 250-255 */
};
/* From Appendix A - ASCII character to symbol value. For those in multiple sets, Code A value */
static const char maxiSymbolChar[256] = {
/* from Appendix A - ASCII character to symbol value */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 30, 28, 29, 30, 35, 32, 53, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 37,
38, 39, 40, 41, 52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 42, 43, 44, 45, 46, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 32, 54, 34, 35, 36, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 36,
37, 37, 38, 39, 40, 41, 42, 43, 38, 44, 37, 39, 38, 45, 46, 40, 41, 39, 40, 41,
42, 42, 47, 43, 44, 43, 44, 45, 45, 46, 47, 46, 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32,
33, 34, 35, 36, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 14, 15, /* 0- 15 */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 30, 28, 29, 30, 35, /* 16- 31 */
32, 53, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 32- 47 */
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 37, 38, 39, 40, 41, /* 48- 63 */
52, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 64- 79 */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 42, 43, 44, 45, 46, /* 80- 95 */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 96-111 */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 54, 34, 35, 36, /* 112-127 */
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 47, 48, 49, 50, 51, 52, /* 128-143 */
53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 36, /* 144-159 */
37, 37, 38, 39, 40, 41, 42, 43, 38, 44, 37, 39, 38, 45, 46, 40, /* 160-175 */
41, 39, 40, 41, 42, 42, 47, 43, 44, 43, 44, 45, 45, 46, 47, 46, /* 176-191 */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 192-207 */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36, /* 208-223 */
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 224-249 */
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36 /* 250-255 */
};
/* vim: set ts=4 sw=4 et : */

View file

@ -839,7 +839,7 @@ static void qr_add_ecc(unsigned char fullstream[], const unsigned char datastrea
}
fputs(" // ", stdout);
for (j = 0; j < ecc_block_length; j++) {
printf("%2X ", ecc_block[ecc_block_length - j - 1]);
printf("%2X ", ecc_block[j]);
}
fputc('\n', stdout);
}
@ -855,7 +855,7 @@ static void qr_add_ecc(unsigned char fullstream[], const unsigned char datastrea
}
for (j = 0; j < ecc_block_length; j++) {
interleaved_ecc[(j * blocks) + i] = ecc_block[ecc_block_length - j - 1];
interleaved_ecc[(j * blocks) + i] = ecc_block[j];
}
in_posn += length_this_block;
@ -1955,7 +1955,7 @@ static int microqr_end(struct zint_symbol *symbol, char binary_data[], int bp, c
/* Add Reed-Solomon codewords to binary data */
for (i = 0; i < ecc_codewords; i++) {
bp = bin_append_posn(ecc_blocks[ecc_codewords - i - 1], 8, binary_data, bp);
bp = bin_append_posn(ecc_blocks[i], 8, binary_data, bp);
}
return bp;

View file

@ -132,8 +132,7 @@ INTERNAL void rs_init_code(rs_t *rs, const int nsym, int index) {
}
}
/* rs_encode(&rs, datalen, data, res) generates nsym Reed-Solomon codes (nsym as given in rs_init_code())
* and places them in reverse order in res */
/* rs_encode(&rs, datalen, data, res) generates nsym Reed-Solomon codes (nsym as given in rs_init_code()) */
INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *data, unsigned char *res) {
int i, k;
const unsigned char *const logt = rs->logt;
@ -141,6 +140,7 @@ INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *
const unsigned char *const rspoly = rs->rspoly;
const unsigned char *const log_rspoly = rs->log_rspoly;
const int nsym = rs->nsym;
const int nsym_halved = nsym >> 1;
memset(res, 0, nsym);
if (rs->zero) { /* Poly has a zero coeff so need to check in inner loop */
@ -175,6 +175,12 @@ INTERNAL void rs_encode(const rs_t *rs, const int datalen, const unsigned char *
}
}
}
/* Reverse the result */
for (i = 0; i < nsym_halved; i++) {
const unsigned char tmp = res[i];
res[i] = res[nsym - 1 - i];
res[nsym - 1 - i] = tmp;
}
}
/* The same as above but for unsigned int data and result - Aztec code compatible */
@ -186,6 +192,7 @@ INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned i
const unsigned char *const rspoly = rs->rspoly;
const unsigned char *const log_rspoly = rs->log_rspoly;
const int nsym = rs->nsym;
const int nsym_halved = nsym >> 1;
memset(res, 0, sizeof(unsigned int) * nsym);
if (rs->zero) { /* Poly has a zero coeff so need to check in inner loop */
@ -220,6 +227,12 @@ INTERNAL void rs_encode_uint(const rs_t *rs, const int datalen, const unsigned i
}
}
}
/* Reverse the result */
for (i = 0; i < nsym_halved; i++) {
const unsigned int tmp = res[i];
res[i] = res[nsym - 1 - i];
res[nsym - 1 - i] = tmp;
}
}
/* Versions of the above for bitlengths > 8 and <= 30 and unsigned int data and results - Aztec code compatible */
@ -303,6 +316,7 @@ INTERNAL void rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, const
const unsigned short *const rspoly = rs_uint->rspoly;
const unsigned int *const log_rspoly = rs_uint->log_rspoly;
const int nsym = rs_uint->nsym;
const int nsym_halved = nsym >> 1;
memset(res, 0, sizeof(unsigned int) * nsym);
if (logt == NULL || alog == NULL) {
@ -340,6 +354,12 @@ INTERNAL void rs_uint_encode(const rs_uint_t *rs_uint, const int datalen, const
}
}
}
/* Reverse the result */
for (i = 0; i < nsym_halved; i++) {
const unsigned int tmp = res[i];
res[i] = res[nsym - 1 - i];
res[nsym - 1 - i] = tmp;
}
}
INTERNAL void rs_uint_free(rs_uint_t *rs_uint) {

View file

@ -620,7 +620,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 3*/ { BARCODE_DOTCODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 28, "65 40 44 47 48 49 4A 4B 4C 4D 5B 5D 5E 6E 41 3C 6A", 0, "" },
/* 4*/ { BARCODE_GRIDMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 30, "30 1A 00 02 01 61 00 48 28 16 0C 06 46 63 51 74 05 38 00", 0, "" },
/* 5*/ { BARCODE_HANXIN, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 23, "2F 80 10 72 09 28 B3 0D 6F F3 00 20 E8 F4 0A E0 00", 0, "" },
/* 6*/ { BARCODE_MAXICODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 30, "(144) 04 3E 3E 00 04 07 08 09 0A 0B 03 3D 2C 24 19 1E 23 1B 18 0E 0C 0D 1E 21 3C 1E 3C 31", 0, "" },
/* 6*/ { BARCODE_MAXICODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 30, "(144) 04 3E 3E 00 04 07 08 09 0A 0B 03 3D 2C 24 19 1E 23 1B 18 0E 0C 0D 1E 3F 1D 1E 3C 31", 0, "" },
/* 7*/ { BARCODE_PDF417, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 120, "(24) 16 901 0 23 655 318 98 18 461 639 893 122 129 92 900 900 872 438 359 646 522 773 831", 0, "" },
/* 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, "" },

File diff suppressed because it is too large Load diff

View file

@ -124,25 +124,25 @@ static void test_encoding(const testCtx *const p_ctx) {
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { 0x43, 4, 1, 7, { 4, 20, 49, 37, 49, 38, 23 }, { 54, 17, 53, 58 } }, /* AUSPOST Australia Post Customer Barcoding Technical Specifications Diagram 10 */
/* 1*/ { 0x43, 7, 1, 10, { 9, 50, 1, 41, 47, 2, 39, 37, 1, 27 }, { 38, 50, 8, 16, 10, 20, 40 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 */
/* 2*/ { 0x13, 5, 1, 2, { 0, 9 }, { 12, 2, 3, 1, 9 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 Mode Message */
/* 3*/ { 0x12d, 5, 1, 3, { 142, 164, 186 }, { 114, 25, 5, 88, 102 } }, /* DATAMATRIX ISO/IEC 16022:2006 Annex O */
/* 4*/ { 0x89, 25, 1, 25, { 42, 13, 54, 39, 124, 91, 121, 65, 28, 40, 95, 48, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0 }, { 123, 47, 2, 20, 54, 112, 35, 23, 100, 89, 55, 17, 101, 4, 14, 33, 48, 62, 98, 52, 2, 79, 92, 70, 102 } }, /* GRIDMATRIX AIMD014 Section 6.8 */
/* 5*/ { 0x163, 4, 1, 21, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4 }, { 0xEB, 0xB4, 0x68, 0x1D } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.1 */
/* 6*/ { 0x163, 24, 1, 27, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4, 0x8A, 0x2C, 0xC3, 0x4E, 0x3D, 0x09, 0x25, 0x9A, 0x7A, 0x29, 0xAB, 0xEA, 0x3E, 0x46, 0x4C, 0x7E, 0x73, 0xE8, 0x6C, 0xC7 }, { 0x08, 0x57, 0x0C, 0xE0, 0x7A, 0xA5, 0xDD, 0xA2, 0x99, 0xCF, 0xA4, 0x82, 0xAD, 0x11, 0xB0, 0x84, 0x74, 0x5D, 0x9A, 0x99, 0x0B, 0xCD, 0x49, 0x77 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 1st block */
/* 7*/ { 0x163, 24, 1, 27, { 0xE7, 0x3E, 0x33, 0x29, 0xE8, 0xFC, }, { 0xA2, 0xA7, 0x68, 0x8A, 0x5F, 0xE6, 0xAA, 0x11, 0xA6, 0x69, 0x4A, 0xCF, 0xCF, 0x20, 0x5D, 0x00, 0x1B, 0x79, 0xA1, 0xFE, 0xB7, 0x94, 0x03, 0x9B } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 2nd block */
/* 0*/ { 0x43, 4, 1, 7, { 4, 20, 49, 37, 49, 38, 23 }, { 58, 53, 17, 54 } }, /* AUSPOST Australia Post Customer Barcoding Technical Specifications Diagram 10 */
/* 1*/ { 0x43, 7, 1, 10, { 9, 50, 1, 41, 47, 2, 39, 37, 1, 27 }, { 40, 20, 10, 16, 8, 50, 38 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 */
/* 2*/ { 0x13, 5, 1, 2, { 0, 9 }, { 9, 1, 3, 2, 12 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 Mode Message */
/* 3*/ { 0x12d, 5, 1, 3, { 142, 164, 186 }, { 102, 88, 5, 25, 114 } }, /* DATAMATRIX ISO/IEC 16022:2006 Annex O */
/* 4*/ { 0x89, 25, 1, 25, { 42, 13, 54, 39, 124, 91, 121, 65, 28, 40, 95, 48, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0 }, { 102, 70, 92, 79, 2, 52, 98, 62, 48, 33, 14, 4, 101, 17, 55, 89, 100, 23, 35, 112, 54, 20, 2, 47, 123 } }, /* GRIDMATRIX AIMD014 Section 6.8 */
/* 5*/ { 0x163, 4, 1, 21, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4 }, { 0x1D, 0x68, 0xB4, 0xEB } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.1 */
/* 6*/ { 0x163, 24, 1, 27, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4, 0x8A, 0x2C, 0xC3, 0x4E, 0x3D, 0x09, 0x25, 0x9A, 0x7A, 0x29, 0xAB, 0xEA, 0x3E, 0x46, 0x4C, 0x7E, 0x73, 0xE8, 0x6C, 0xC7 }, { 0x77, 0x49, 0xCD, 0x0B, 0x99, 0x9A, 0x5D, 0x74, 0x84, 0xB0, 0x11, 0xAD, 0x82, 0xA4, 0xCF, 0x99, 0xA2, 0xDD, 0xA5, 0x7A, 0xE0, 0x0C, 0x57, 0x08 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 1st block */
/* 7*/ { 0x163, 24, 1, 27, { 0xE7, 0x3E, 0x33, 0x29, 0xE8, 0xFC, }, { 0x9B, 0x03, 0x94, 0xB7, 0xFE, 0xA1, 0x79, 0x1B, 0x00, 0x5D, 0x20, 0xCF, 0xCF, 0x4A, 0x69, 0xA6, 0x11, 0xAA, 0xE6, 0x5F, 0x8A, 0x68, 0xA7, 0xA2 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 2nd block */
/* 8*/ { 0x163, 24, 1, 29, { 0x00 }, { 0x00 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 3rd block */
/* 9*/ { 0x25, 6, 1, 16, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 14, 7, 23, 3, 23, 15 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.1 */
/* 10*/ { 0x25, 6, 1, 16, { 15, 22, 3, 25, 23, 26, 7, 3, 20, 14, 1, 4, 16, 3, 9, 28 }, { 27, 22, 24, 16, 6, 24 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.2 */
/* 11*/ { 0x25, 7, 1, 19, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 20, 1, 20, 7, 14, 11, 18 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.1 */
/* 12*/ { 0x25, 7, 1, 19, { 0, 8, 21, 10, 29, 1, 29, 21, 2, 24, 15, 2, 19, 1, 4, 15, 11, 4, 16 }, { 19, 7, 9, 8, 6, 16, 16 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.2 */
/* 13*/ { 0x43, 10, 1, 10, { 4, 13, 63, 1, 24, 9, 59, 3, 15, 4 }, { 50, 2, 42, 51, 53, 34, 22, 20, 5, 16 } }, /* MAXICODE Annex H Primary */
/* 14*/ { 0x43, 20, 1, 42, { 5, 57, 49, 47, 8, 18, 59, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 31, 2, 58, 6, 6, 39, 13, 63, 2, 30, 19, 19, 14, 19, 23, 17, 62, 8, 2, 23 } }, /* MAXICODE Annex H Secondary odd */
/* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 1, 15, 22, 28, 39, 17, 60, 5, 35, 35, 4, 8, 0, 32, 51, 45, 63, 53, 61, 14 } }, /* MAXICODE Annex H Secondary even */
/* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0xA5, 0x24, 0xD4, 0xC1, 0xED, 0x36, 0xC7, 0x87, 0x2C, 0x55 } }, /* QRCODE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mailmark barcode C encoding and decoding Example 2.3.1 */
/* 10*/ { 0x25, 6, 1, 16, { 15, 22, 3, 25, 23, 26, 7, 3, 20, 14, 1, 4, 16, 3, 9, 28 }, { 24, 6, 16, 24, 22, 27 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.2 */
/* 11*/ { 0x25, 7, 1, 19, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 18, 11, 14, 7, 20, 1, 20 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.1 */
/* 12*/ { 0x25, 7, 1, 19, { 0, 8, 21, 10, 29, 1, 29, 21, 2, 24, 15, 2, 19, 1, 4, 15, 11, 4, 16 }, { 16, 16, 6, 8, 9, 7, 19 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.2 */
/* 13*/ { 0x43, 10, 1, 10, { 4, 13, 63, 1, 24, 9, 59, 3, 15, 4 }, { 16, 5, 20, 22, 34, 53, 51, 42, 2, 50 } }, /* MAXICODE Annex H Primary */
/* 14*/ { 0x43, 20, 1, 42, { 5, 57, 49, 47, 8, 18, 59, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 23, 2, 8, 62, 17, 23, 19, 14, 19, 19, 30, 2, 63, 13, 39, 6, 6, 58, 2, 31 } }, /* MAXICODE Annex H Secondary odd */
/* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 14, 61, 53, 63, 45, 51, 32, 0, 8, 4, 35, 35, 5, 60, 17, 39, 28, 22, 15, 1 } }, /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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, 255 } },
};
int data_size = ARRAY_SIZE(data);
int i;
@ -187,25 +187,25 @@ static void test_encoding_uint(const testCtx *const p_ctx) {
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { 0x43, 4, 1, 7, { 4, 20, 49, 37, 49, 38, 23 }, { 54, 17, 53, 58 } }, /* AUSPOST Australia Post Customer Barcoding Technical Specifications Diagram 10 */
/* 1*/ { 0x43, 7, 1, 10, { 9, 50, 1, 41, 47, 2, 39, 37, 1, 27 }, { 38, 50, 8, 16, 10, 20, 40 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 */
/* 2*/ { 0x13, 5, 1, 2, { 0, 9 }, { 12, 2, 3, 1, 9 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 Mode Message */
/* 3*/ { 0x12d, 5, 1, 3, { 142, 164, 186 }, { 114, 25, 5, 88, 102 } }, /* DATAMATRIX ISO/IEC 16022:2006 Annex O */
/* 4*/ { 0x89, 25, 1, 25, { 42, 13, 54, 39, 124, 91, 121, 65, 28, 40, 95, 48, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0 }, { 123, 47, 2, 20, 54, 112, 35, 23, 100, 89, 55, 17, 101, 4, 14, 33, 48, 62, 98, 52, 2, 79, 92, 70, 102 } }, /* GRIDMATRIX AIMD014 Section 6.8 */
/* 5*/ { 0x163, 4, 1, 21, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4 }, { 0xEB, 0xB4, 0x68, 0x1D } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.1 */
/* 6*/ { 0x163, 24, 1, 27, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4, 0x8A, 0x2C, 0xC3, 0x4E, 0x3D, 0x09, 0x25, 0x9A, 0x7A, 0x29, 0xAB, 0xEA, 0x3E, 0x46, 0x4C, 0x7E, 0x73, 0xE8, 0x6C, 0xC7 }, { 0x08, 0x57, 0x0C, 0xE0, 0x7A, 0xA5, 0xDD, 0xA2, 0x99, 0xCF, 0xA4, 0x82, 0xAD, 0x11, 0xB0, 0x84, 0x74, 0x5D, 0x9A, 0x99, 0x0B, 0xCD, 0x49, 0x77 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 1st block */
/* 7*/ { 0x163, 24, 1, 27, { 0xE7, 0x3E, 0x33, 0x29, 0xE8, 0xFC, }, { 0xA2, 0xA7, 0x68, 0x8A, 0x5F, 0xE6, 0xAA, 0x11, 0xA6, 0x69, 0x4A, 0xCF, 0xCF, 0x20, 0x5D, 0x00, 0x1B, 0x79, 0xA1, 0xFE, 0xB7, 0x94, 0x03, 0x9B } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 2nd block */
/* 0*/ { 0x43, 4, 1, 7, { 4, 20, 49, 37, 49, 38, 23 }, { 58, 53, 17, 54 } }, /* AUSPOST Australia Post Customer Barcoding Technical Specifications Diagram 10 */
/* 1*/ { 0x43, 7, 1, 10, { 9, 50, 1, 41, 47, 2, 39, 37, 1, 27 }, { 40, 20, 10, 16, 8, 50, 38 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 */
/* 2*/ { 0x13, 5, 1, 2, { 0, 9 }, { 9, 1, 3, 2, 12 } }, /* AZTEC ISO/IEC 24778:2008 Section G.4 Mode Message */
/* 3*/ { 0x12d, 5, 1, 3, { 142, 164, 186 }, { 102, 88, 5, 25, 114 } }, /* DATAMATRIX ISO/IEC 16022:2006 Annex O */
/* 4*/ { 0x89, 25, 1, 25, { 42, 13, 54, 39, 124, 91, 121, 65, 28, 40, 95, 48, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0, 126, 0 }, { 102, 70, 92, 79, 2, 52, 98, 62, 48, 33, 14, 4, 101, 17, 55, 89, 100, 23, 35, 112, 54, 20, 2, 47, 123 } }, /* GRIDMATRIX AIMD014 Section 6.8 */
/* 5*/ { 0x163, 4, 1, 21, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4 }, { 0x1D, 0x68, 0xB4, 0xEB } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.1 */
/* 6*/ { 0x163, 24, 1, 27, { 0x11, 0xED, 0xC8, 0xC5, 0x40, 0x0F, 0xF4, 0x8A, 0x2C, 0xC3, 0x4E, 0x3D, 0x09, 0x25, 0x9A, 0x7A, 0x29, 0xAB, 0xEA, 0x3E, 0x46, 0x4C, 0x7E, 0x73, 0xE8, 0x6C, 0xC7 }, { 0x77, 0x49, 0xCD, 0x0B, 0x99, 0x9A, 0x5D, 0x74, 0x84, 0xB0, 0x11, 0xAD, 0x82, 0xA4, 0xCF, 0x99, 0xA2, 0xDD, 0xA5, 0x7A, 0xE0, 0x0C, 0x57, 0x08 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 1st block */
/* 7*/ { 0x163, 24, 1, 27, { 0xE7, 0x3E, 0x33, 0x29, 0xE8, 0xFC, }, { 0x9B, 0x03, 0x94, 0xB7, 0xFE, 0xA1, 0x79, 0x1B, 0x00, 0x5D, 0x20, 0xCF, 0xCF, 0x4A, 0x69, 0xA6, 0x11, 0xAA, 0xE6, 0x5F, 0x8A, 0x68, 0xA7, 0xA2 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 2nd block */
/* 8*/ { 0x163, 24, 1, 29, { 0x00 }, { 0x00 } }, /* HANXIN ISO/IEC DIS 20830:2019 Annex K.2 3rd block */
/* 9*/ { 0x25, 6, 1, 16, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 14, 7, 23, 3, 23, 15 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.1 */
/* 10*/ { 0x25, 6, 1, 16, { 15, 22, 3, 25, 23, 26, 7, 3, 20, 14, 1, 4, 16, 3, 9, 28 }, { 27, 22, 24, 16, 6, 24 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.2 */
/* 11*/ { 0x25, 7, 1, 19, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 20, 1, 20, 7, 14, 11, 18 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.1 */
/* 12*/ { 0x25, 7, 1, 19, { 0, 8, 21, 10, 29, 1, 29, 21, 2, 24, 15, 2, 19, 1, 4, 15, 11, 4, 16 }, { 19, 7, 9, 8, 6, 16, 16 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.2 */
/* 13*/ { 0x43, 10, 1, 10, { 4, 13, 63, 1, 24, 9, 59, 3, 15, 4 }, { 50, 2, 42, 51, 53, 34, 22, 20, 5, 16 } }, /* MAXICODE Annex H Primary */
/* 14*/ { 0x43, 20, 1, 42, { 5, 57, 49, 47, 8, 18, 59, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 31, 2, 58, 6, 6, 39, 13, 63, 2, 30, 19, 19, 14, 19, 23, 17, 62, 8, 2, 23 } }, /* MAXICODE Annex H Secondary odd */
/* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 1, 15, 22, 28, 39, 17, 60, 5, 35, 35, 4, 8, 0, 32, 51, 45, 63, 53, 61, 14 } }, /* MAXICODE Annex H Secondary even */
/* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC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 { 0x25, 6, 1, 16, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 15, 23, 3, 23, 7, 14 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.1 */
/* 10*/ { 0x25, 6, 1, 16, { 15, 22, 3, 25, 23, 26, 7, 3, 20, 14, 1, 4, 16, 3, 9, 28 }, { 24, 6, 16, 24, 22, 27 } }, /* MAILMARK_4S Royal Mail Mailmark barcode C encoding and decoding Example 2.3.2 */
/* 11*/ { 0x25, 7, 1, 19, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 18, 11, 14, 7, 20, 1, 20 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.1 */
/* 12*/ { 0x25, 7, 1, 19, { 0, 8, 21, 10, 29, 1, 29, 21, 2, 24, 15, 2, 19, 1, 4, 15, 11, 4, 16 }, { 16, 16, 6, 8, 9, 7, 19 } }, /* MAILMARK_4S Royal Mail Mailmark barcode L encoding and decoding Example 2.3.2 */
/* 13*/ { 0x43, 10, 1, 10, { 4, 13, 63, 1, 24, 9, 59, 3, 15, 4 }, { 16, 5, 20, 22, 34, 53, 51, 42, 2, 50 } }, /* MAXICODE Annex H Primary */
/* 14*/ { 0x43, 20, 1, 42, { 5, 57, 49, 47, 8, 18, 59, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 23, 2, 8, 62, 17, 23, 19, 14, 19, 19, 30, 2, 63, 13, 39, 6, 6, 58, 2, 31 } }, /* MAXICODE Annex H Secondary odd */
/* 15*/ { 0x43, 20, 1, 42, { 47, 40, 57, 3, 1, 19, 41, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 }, { 14, 61, 53, 63, 45, 51, 32, 0, 8, 4, 35, 35, 5, 60, 17, 39, 28, 22, 15, 1 } }, /* MAXICODE Annex H Secondary even */
/* 16*/ { 0x11d, 10, 0, 16, { 0x10, 0x20, 0x0C, 0x56, 0x61, 0x80, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11 }, { 0x55, 0x2C, 0x87, 0xC7, 0x36, 0xED, 0xC1, 0xD4, 0x24, 0xA5 } }, /* QRCODE Annex I.2 */
/* 17*/ { 0x11d, 5, 0, 5, { 0x40, 0x18, 0xAC, 0xC3, 0x00 }, { 0x30, 0xAE, 0x22, 0x0D, 0x86 } }, /* QRCODE Annex I.3 */
/* 18*/ { 0x163, 256, 0, 1, { 0xFF }, { 255, 255, 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, 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, 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, 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, 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, 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, 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, 255 } },
};
int data_size = ARRAY_SIZE(data);
int i;
@ -251,10 +251,10 @@ static void test_uint_encoding(const testCtx *const p_ctx) {
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
struct item data[] = {
/* 0*/ { 0x409, 1023, 4, 1, 7, { 0x3FF, 0x000, 0x100, 0x1FF, 0x3FF, 0x000, 0x123 }, { 229, 153, 993, 674 } },
/* 1*/ { 0x1069, 4095, 4, 1, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 3472, 2350, 3494, 575 } },
/* 2*/ { 0x1000, 4095, 4, 0, 7, { 0xFFF, 0x000, 0x700, 0x7FF, 0xFFF, 0x000, 0x123 }, { 1, 65, 0, 64 } },
/* 3*/ { 0x1000, 4095, 256, 0, 1, { 0xFFF }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 512, 0, 2048, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2048, 0, 512, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 } },
};
int data_size = ARRAY_SIZE(data);
int i;

View file

@ -52,13 +52,17 @@
#include "../eci.h"
#include "../output.h"
static int tests = 0;
static int failed = 0;
static int skipped = 0;
int assertionFailed = 0;
int assertionNum = 0;
struct zint_symbol **assertionPPSymbol = NULL;
const char *assertionFilename = "";
static int testTests = 0;
static int testFailed = 0;
static int testSkipped = 0;
static int testDataset = 0;
static int testDatasetNum = 0;
static int testDatasetTot = 0;
int testAssertFailed = 0;
int testAssertNum = 0;
static int testAssertTot = 0;
struct zint_symbol **testAssertPPSymbol = NULL;
const char *testAssertFilename = "";
static const char *testName = NULL;
static const char *testFunc = NULL;
@ -67,52 +71,52 @@ static const char *testFunc = NULL;
#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(ZINT_IS_C89) /* VC6 or C89 */
#include <stdarg.h>
void assert_zero(int exp, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (exp != 0) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
void assert_nonzero(int exp, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (exp == 0) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
void assert_null(const void *exp, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (exp != NULL) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
void assert_nonnull(const void *exp, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (exp == NULL) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
void assert_equal(int e1, int e2, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (e1 != e2) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
void assert_equalu64(uint64_t e1, uint64_t e2, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (e1 != e2) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
void assert_notequal(int e1, int e2, const char *fmt, ...) {
assertionNum++;
testAssertNum++;
if (e1 == e2) {
va_list args; assertionFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; };
va_list args; testAssertFailed++; va_start(args, fmt); vprintf(fmt, args); va_end(args); testFinish();
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; };
}
}
#endif
@ -129,66 +133,93 @@ void assert_notequal(int e1, int e2, const char *fmt, ...) {
/* Begin individual test function */
void testStartReal(const char *func, const char *name, struct zint_symbol **pp_symbol) {
tests++;
testTests++;
if (func && *func && name && *name && strcmp(func, name) == 0) {
testName = "";
} else {
testName = name;
}
testFunc = func ? func : "";
assertionFailed = 0;
assertionNum = 0;
assertionPPSymbol = pp_symbol;
printf("_____%d: %s: %s...\n", tests, testFunc, testName ? testName : "");
testDataset = 0;
testDatasetNum = 0;
testAssertFailed = 0;
testAssertNum = 0;
testAssertPPSymbol = pp_symbol;
printf("_____%d: %s: %s...\n", testTests, testFunc, testName ? testName : "");
}
/* End individual test function */
void testFinish(void) {
fputs(assertionFailed ? "*****" : ".....", stdout);
testAssertTot += testAssertNum;
testDatasetTot += testDatasetNum;
fputs(testAssertFailed ? "*****" : ".....", stdout);
if (testName && *testName) {
printf("%d: %s: %s ", tests, testFunc, testName);
printf("%d: %s: %s ", testTests, testFunc, testName);
} else {
printf("%d: %s: ", tests, testFunc);
printf("%d: %s: ", testTests, testFunc);
}
if (assertionFailed) {
printf("FAILED. (%d assertions failed.)\n", assertionFailed);
failed++;
if (testAssertFailed) {
printf("FAILED. (%d assertions failed)\n", testAssertFailed);
testFailed++;
} else if (testDataset) {
if (testAssertNum) {
printf("PASSED. (%d assertions, %d dataset items)\n", testAssertNum, testDatasetNum);
} else {
printf("EMPTY. (***No assertions executed***)\n");
}
} else {
printf("PASSED. (%d assertions passed.)\n", assertionNum);
if (testAssertNum) {
printf("PASSED. (%d assertions)\n", testAssertNum);
} else {
printf("EMPTY. (***No assertions executed***)\n");
}
}
}
/* Skip (and end) individual test function */
void testSkip(const char *msg) {
skipped++;
fputs(assertionFailed ? "*****" : ".....", stdout);
testSkipped++;
testAssertTot += testAssertNum;
testDatasetTot += testDatasetNum;
fputs(testAssertFailed ? "*****" : ".....", stdout);
if (testName && *testName) {
printf("%d: %s: %s ", tests, testFunc, testName);
printf("%d: %s: %s ", testTests, testFunc, testName);
} else {
printf("%d: %s: ", tests, testFunc);
printf("%d: %s: ", testTests, testFunc);
}
if (assertionFailed) {
printf("FAILED. (%d assertions failed.)\n", assertionFailed);
failed++;
if (testAssertFailed) {
printf("FAILED. (%d assertions failed)\n", testAssertFailed);
testFailed++;
} else if (testDataset) {
printf("SKIPPED. %s. (%d assertions, %d dataset items)\n", msg, testAssertNum, testDatasetNum);
} else {
printf("SKIPPED. %s. (%d assertions passed.)\n", msg, assertionNum);
printf("SKIPPED. %s. (%d assertions)\n", msg, testAssertNum);
}
}
/* End test program */
void testReport(void) {
if (failed && skipped) {
printf("Total %d tests, %d skipped, %d **fails**.\n", tests, skipped, failed);
if (testFailed && testSkipped) {
printf("Total %d tests, %d skipped, %d **fails**.\n", testTests, testSkipped, testFailed);
exit(-1);
}
if (failed) {
printf("Total %d tests, %d **fails**.\n", tests, failed);
if (testFailed) {
printf("Total %d tests, %d **fails**.\n", testTests, testFailed);
exit(-1);
}
if (skipped) {
printf("Total %d tests, %d skipped.\n", tests, skipped);
} else if (tests) {
printf("Total %d tests, all passed.\n", tests);
if (testSkipped) {
printf("Total %d tests, %d skipped.\n", testTests, testSkipped);
} else if (testTests) {
if (testAssertTot) {
if (testDatasetTot) {
printf("Total %d tests (%d assertions, %d dataset items), all passed.\n",
testTests, testAssertTot, testDatasetTot);
} else {
printf("Total %d tests (%d assertions), all passed.\n", testTests, testAssertTot);
}
} else {
printf("***No assertions executed in %d tests.***\n", testTests);
}
} else {
fputs("***No tests run.***\n", stdout);
}
@ -281,28 +312,28 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
filename = strrchr(argv[0], '/');
#endif
if (filename) {
assertionFilename = filename + 1;
testAssertFilename = filename + 1;
} else {
assertionFilename = argv[0];
testAssertFilename = argv[0];
}
}
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-d") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "testRun: -d debug value missing, ignoring\n");
fprintf(stderr, "***testRun: -d debug value missing, ignoring***\n");
} else {
int d; /* Allow multiple debug flags, OR-ing */
optarg = argv[++i];
if (!validate_int(optarg, &d)) {
fprintf(stderr, "testRun: -d debug value invalid, ignoring\n");
fprintf(stderr, "***testRun: -d debug value invalid, ignoring***\n");
} else {
ctx.debug |= d;
}
}
} else if (strcmp(argv[i], "-f") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "testRun: -f func value missing, ignoring\n");
fprintf(stderr, "***testRun: -f func value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (strlen(optarg) < 256) {
@ -314,13 +345,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
}
func = func_buf;
} else {
fprintf(stderr, "testRun: -f func value too long, ignoring\n");
fprintf(stderr, "***testRun: -f func value too long, ignoring***\n");
func = NULL;
}
}
} else if (strcmp(argv[i], "-n") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "testRun: -n func exclude value missing, ignoring\n");
fprintf(stderr, "***testRun: -n func exclude value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (strlen(optarg) < 256) {
@ -332,13 +363,13 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
}
func_not = func_not_buf;
} else {
fprintf(stderr, "testRun: -p func exclude value too long, ignoring\n");
fprintf(stderr, "***testRun: -p func exclude value too long, ignoring***\n");
func_not = NULL;
}
}
} else if (strcmp(argv[i], "-m") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "testRun: -m func match value missing, ignoring\n");
fprintf(stderr, "***testRun: -m func match value missing, ignoring***\n");
} else {
func_match = argv[++i];
}
@ -346,30 +377,30 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
ctx.generate = 1;
} else if (strcmp(argv[i], "-i") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "testRun: -i index value missing, ignoring\n");
fprintf(stderr, "***testRun: -i index value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (!validate_int_range(optarg, &ctx.index, &ctx.index_end)) {
fprintf(stderr, "testRun: -i index value invalid, ignoring\n");
fprintf(stderr, "***testRun: -i index value invalid, ignoring***\n");
ctx.index = ctx.index_end = -1;
}
}
} else if (strcmp(argv[i], "-x") == 0) {
if (i + 1 == argc) {
fprintf(stderr, "testRun: -x exclude value missing, ignoring\n");
fprintf(stderr, "***testRun: -x exclude value missing, ignoring***\n");
} else {
optarg = argv[++i];
if (exclude_idx + 1 == ZINT_TEST_CTX_EXC_MAX) {
fprintf(stderr, "testRun: too many -x exclude values, ignoring\n");
fprintf(stderr, "***testRun: too many -x exclude values, ignoring***\n");
} else if (!validate_int_range(optarg, &ctx.exclude[exclude_idx], &ctx.exclude_end[exclude_idx])) {
fprintf(stderr, "testRun: -x exclude value invalid, ignoring\n");
fprintf(stderr, "***testRun: -x exclude value invalid, ignoring***\n");
ctx.exclude[exclude_idx] = ctx.exclude_end[exclude_idx] = -1;
} else {
exclude_idx++;
}
}
} else {
fprintf(stderr, "testRun: unknown arg '%s', ignoring\n", argv[i]);
fprintf(stderr, "***testRun: unknown arg '%s', ignoring***\n", argv[i]);
}
}
@ -389,16 +420,17 @@ void testRun(int argc, char *argv[], testFunction funcs[], int funcs_size) {
}
if (func && !ran) {
fprintf(stderr, "testRun: unknown -f func arg '%s'\n", func);
fprintf(stderr, "***testRun: unknown -f func arg '%s'***\n", func);
}
if (func_match && !ran) {
fprintf(stderr, "testRun: no funcs matched -m arg '%s'\n", func_match);
fprintf(stderr, "***testRun: no funcs matched -m arg '%s'***\n", func_match);
}
}
/* Call in a dataset loop to determine if a datum should be tested according to -i & -x args */
int testContinue(const testCtx *const p_ctx, const int i) {
int j;
testDataset = 1;
if (p_ctx->index != -1) {
if (p_ctx->index_end != -1) {
if (i < p_ctx->index || (p_ctx->index_end && i > p_ctx->index_end)) {
@ -421,6 +453,7 @@ int testContinue(const testCtx *const p_ctx, const int i) {
printf("i:%d\n", i);
fflush(stdout); /* For assertion failures */
}
testDatasetNum++;
return 0;
}
@ -3102,12 +3135,18 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
bwipp_opts = bwipp_opts_buf;
}
} else if (symbology == BARCODE_MAXICODE) {
int have_scm = memcmp(bwipp_data, "[)>^03001^02996", 15) == 0;
int have_eci = memcmp(bwipp_data, "^ECI", 4) == 0;
int have_scm = memcmp(bwipp_data + have_eci * 10, "[)>^03001^029", 13) == 0
&& z_isdigit(bwipp_data[13 + have_eci * 10])
&& z_isdigit(bwipp_data[14 + have_eci * 10]);
int mode = option_1;
char prefix_buf[30];
int prefix_len = 0;
if (mode <= 0) {
if (primary_len == 0) {
mode = 4;
} else {
mode = 2;
for (i = 0; i < primary_len - 6; i++) {
if (!z_isdigit(symbol->primary[i]) && (symbol->primary[i] != ' ')) {
mode = 3;
@ -3121,9 +3160,21 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
strlen(bwipp_opts_buf) ? " " : "", mode);
bwipp_opts = bwipp_opts_buf;
}
if (option_2 > 0) {
char scm_vv_buf[40];
sprintf(scm_vv_buf, "[)>^03001^029%02d", option_2 - 1); /* [)>\R01\Gvv */
memmove(bwipp_data + 15, bwipp_data, strlen(bwipp_data) + 1);
memcpy(bwipp_data, scm_vv_buf, 15);
have_scm = 1;
have_eci = 0;
if (!parse) {
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sparse",
strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
parse = 1;
}
}
if (primary_len >= 6) { /* Keep gcc happy */
char prefix_buf[30];
int prefix_len;
int postcode_len = primary_len - 6;
char postcode[10];
if (postcode_len >= 10) postcode_len = 9;
@ -3144,31 +3195,27 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
sprintf(prefix_buf, "%s^029%.3s^029%.3s^029",
postcode, primary + primary_len - 6, primary + primary_len - 3);
prefix_len = (int) strlen(prefix_buf);
if (have_scm) {
memmove(bwipp_data + 15 + prefix_len, bwipp_data, strlen(bwipp_data) - 15 + 1);
memcpy(bwipp_data + 15, prefix_buf, prefix_len);
} else {
memmove(bwipp_data + prefix_len, bwipp_data, strlen(bwipp_data) + 1);
memcpy(bwipp_data, prefix_buf, prefix_len);
}
if (prefix_len || have_scm) {
char eci_buf[10];
int offset = 15 * have_scm;
if (have_eci) {
memcpy(eci_buf, bwipp_data, 10);
memmove(bwipp_data, bwipp_data + 10, strlen(bwipp_data) - 10 + 1);
}
if (!parse) {
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sparse",
strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
parse = 1;
memmove(bwipp_data + offset + prefix_len, bwipp_data + offset, strlen(bwipp_data) - offset + 1);
memcpy(bwipp_data + offset, prefix_buf, prefix_len);
if (have_eci) {
memmove(bwipp_data + offset + prefix_len + 10, bwipp_data + offset + prefix_len,
strlen(bwipp_data) - (offset + prefix_len) + 1);
memcpy(bwipp_data + offset + prefix_len, eci_buf, 10);
}
}
if (option_2 > 0) {
char scm_vv_buf[40];
sprintf(scm_vv_buf, "[^041>^03001^029%02d", option_2 - 1); /* [)>\R01\Gvv */
memmove(bwipp_data + 18, bwipp_data, strlen(bwipp_data) + 1);
memcpy(bwipp_data, scm_vv_buf, 18);
if (!parse) {
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sparse",
strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
parse = 1;
}
if (!parse) {
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sparse",
strlen(bwipp_opts_buf) ? " " : "");
bwipp_opts = bwipp_opts_buf;
parse = 1;
}
if (symbol->structapp.count) {
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%ssam=%c%c",
@ -3759,7 +3806,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
{ "", -1, 105, },
{ "PDF417", BARCODE_HIBC_PDF, 106, },
{ "", -1, 107, },
{ "", BARCODE_HIBC_MICPDF, 108, },
{ "MicroPDF417", BARCODE_HIBC_MICPDF, 108, },
{ "", -1, 109, },
{ "CodablockF", BARCODE_HIBC_BLOCKF, 110, },
{ "", -1, 111, },
@ -4110,6 +4157,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
if (primary && primary[0]) {
int primary_len = (int) strlen(primary);
int maxi_len = 0;
int have_manual_scm = 0;
if (symbol->option_2 >= 1 && symbol->option_2 <= 100) {
/* Suppress gcc warning null destination pointer [-Wformat-overflow=] false-positive */
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7
@ -4121,8 +4169,10 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
#pragma GCC diagnostic pop
#endif
maxi_len = (int) strlen(maxi);
} else if (expected_len >= 9 && strncmp(expected, "[)>\03601\035", 7) == 0
&& z_isdigit(expected[7]) && z_isdigit(expected[8])) {
have_manual_scm = 1;
}
#if 1
if (primary[0] > '9') {
sprintf(maxi + maxi_len, "%-6.*s\035%.*s\035%.*s\035", primary_len - 6, primary,
3, primary + primary_len - 6, 3, primary + primary_len - 3);
@ -4135,14 +4185,17 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
3, primary + primary_len - 6, 3, primary + primary_len - 3);
}
}
#else
sprintf(maxi + maxi_len, "%.*s\035%.*s\035%.*s\035", primary_len - 6, primary,
3, primary + primary_len - 6, 3, primary + primary_len - 3);
#endif
maxi_len = (int) strlen(maxi);
memcpy(maxi + maxi_len, expected, expected_len);
if (have_manual_scm) {
memmove(maxi + 9, maxi, maxi_len);
memcpy(maxi, expected, 9);
memcpy(maxi + maxi_len + 9, expected + 9, expected_len - 9);
} else {
memcpy(maxi + maxi_len, expected, expected_len);
}
expected = maxi;
expected_len += maxi_len;
maxi[expected_len] = '\0';
}
} else if (symbology == BARCODE_CODABAR) {
/* Ignore start A/B/C/D and stop A/B/C/D chars to avoid upper/lowercase issues */

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
@ -71,10 +71,10 @@ extern int pclose(FILE *stream);
# pragma warning(disable: 4702) /* unreachable code */
#endif
extern int assertionFailed;
extern int assertionNum;
extern struct zint_symbol **assertionPPSymbol;
extern const char *assertionFilename;
extern int testAssertFailed;
extern int testAssertNum;
extern struct zint_symbol **testAssertPPSymbol;
extern const char *testAssertFilename;
#if defined(_MSC_VER) && _MSC_VER < 1900 /* MSVC 2015 */
#define testStart(name) (testStartReal("", name, NULL))
@ -114,9 +114,9 @@ void assert_equalu64(uint64_t e1, uint64_t e2, const char *fmt, ...);
void assert_notequal(int e1, int e2, const char *fmt, ...);
#else
#define assert_exp(exp, ...) \
{ assertionNum++; if (!(exp)) { assertionFailed++; printf("%s:%d ", assertionFilename, __LINE__); \
{ testAssertNum++; if (!(exp)) { testAssertFailed++; printf("%s:%d ", testAssertFilename, __LINE__); \
printf(__VA_ARGS__); testFinish(); \
if (assertionPPSymbol) { ZBarcode_Delete(*assertionPPSymbol); assertionPPSymbol = NULL; } return; } }
if (testAssertPPSymbol) { ZBarcode_Delete(*testAssertPPSymbol); testAssertPPSymbol = NULL; } return; } }
#define assert_zero(exp, ...) assert_exp((exp) == 0, __VA_ARGS__)
#define assert_nonzero(exp, ...) assert_exp((exp) != 0, __VA_ARGS__)

View file

@ -452,9 +452,14 @@ foreach ($batches as $batch => $batch_specs) {
$width += strlen($str);
}
$spec_func = $spec_funcs[$spec];
$str = "$tab$tab{$tab}return $spec_func(data, data_len, p_err_no, p_err_posn, err_msg);";
if (strlen($str) > 118) {
print ") {\n$tab$tab{$tab}return $spec_func(data,\n";
print "$tab$tab$tab$tab$tab{$tab}data_len, p_err_no, p_err_posn, err_msg);\n";
} else {
print ") {\n$str\n";
}
print <<<EOD
) {
$tab$tab{$tab}return $spec_func(data, data_len, p_err_no, p_err_posn, err_msg);
$tab$tab}
EOD;