mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
MICROQR: some debug output, test case for ticket #241
This commit is contained in:
parent
b7adbf4e5b
commit
b568201574
46
backend/qr.c
46
backend/qr.c
@ -1797,7 +1797,7 @@ static void micro_qr_m1(struct zint_symbol *symbol, char binary_data[]) {
|
||||
latch = 0;
|
||||
|
||||
/* Add terminator */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left <= 3) {
|
||||
for (i = 0; i < bits_left; i++) {
|
||||
strcat(binary_data, "0");
|
||||
@ -1807,9 +1807,13 @@ static void micro_qr_m1(struct zint_symbol *symbol, char binary_data[]) {
|
||||
strcat(binary_data, "000");
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M1 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Manage last (4-bit) block */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left <= 4) {
|
||||
for (i = 0; i < bits_left; i++) {
|
||||
strcat(binary_data, "0");
|
||||
@ -1829,7 +1833,7 @@ static void micro_qr_m1(struct zint_symbol *symbol, char binary_data[]) {
|
||||
}
|
||||
|
||||
/* Add padding */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left > 4) {
|
||||
remainder = (bits_left - 4) / 8;
|
||||
for (i = 0; i < remainder; i++) {
|
||||
@ -1859,8 +1863,6 @@ static void micro_qr_m1(struct zint_symbol *symbol, char binary_data[]) {
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -1892,7 +1894,7 @@ static void micro_qr_m2(struct zint_symbol *symbol, char binary_data[], const in
|
||||
else assert(0);
|
||||
|
||||
/* Add terminator */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left <= 5) {
|
||||
for (i = 0; i < bits_left; i++) {
|
||||
strcat(binary_data, "0");
|
||||
@ -1902,6 +1904,10 @@ static void micro_qr_m2(struct zint_symbol *symbol, char binary_data[], const in
|
||||
bin_append(0, 5, binary_data);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M2 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Complete current byte */
|
||||
int remainder = 8 - (strlen(binary_data) % 8);
|
||||
@ -1913,7 +1919,7 @@ static void micro_qr_m2(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
|
||||
/* Add padding */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
remainder = bits_left / 8;
|
||||
for (i = 0; i < remainder; i++) {
|
||||
strcat(binary_data, (i & 1) ? "00010001" : "11101100");
|
||||
@ -1942,8 +1948,6 @@ static void micro_qr_m2(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -1977,7 +1981,7 @@ static void micro_qr_m3(struct zint_symbol *symbol, char binary_data[], const in
|
||||
else assert(0);
|
||||
|
||||
/* Add terminator */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left <= 7) {
|
||||
for (i = 0; i < bits_left; i++) {
|
||||
strcat(binary_data, "0");
|
||||
@ -1987,9 +1991,13 @@ static void micro_qr_m3(struct zint_symbol *symbol, char binary_data[], const in
|
||||
bin_append(0, 7, binary_data);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M3 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Manage last (4-bit) block */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left <= 4) {
|
||||
for (i = 0; i < bits_left; i++) {
|
||||
strcat(binary_data, "0");
|
||||
@ -2009,7 +2017,7 @@ static void micro_qr_m3(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
|
||||
/* Add padding */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left > 4) {
|
||||
remainder = (bits_left - 4) / 8;
|
||||
for (i = 0; i < remainder; i++) {
|
||||
@ -2059,8 +2067,6 @@ static void micro_qr_m3(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -2097,7 +2103,7 @@ static void micro_qr_m4(struct zint_symbol *symbol, char binary_data[], const in
|
||||
else assert(0);
|
||||
|
||||
/* Add terminator */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
if (bits_left <= 9) {
|
||||
for (i = 0; i < bits_left; i++) {
|
||||
strcat(binary_data, "0");
|
||||
@ -2107,6 +2113,10 @@ static void micro_qr_m4(struct zint_symbol *symbol, char binary_data[], const in
|
||||
bin_append(0, 9, binary_data);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("M4 Terminated binary (%d): %s (bits_left %d)\n", (int) strlen(binary_data), binary_data, bits_left);
|
||||
}
|
||||
|
||||
if (latch == 0) {
|
||||
/* Complete current byte */
|
||||
int remainder = 8 - (strlen(binary_data) % 8);
|
||||
@ -2118,7 +2128,7 @@ static void micro_qr_m4(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
|
||||
/* Add padding */
|
||||
bits_left = bits_total - (int)strlen(binary_data);
|
||||
bits_left = bits_total - (int) strlen(binary_data);
|
||||
remainder = bits_left / 8;
|
||||
for (i = 0; i < remainder; i++) {
|
||||
strcat(binary_data, (i & 1) ? "00010001" : "11101100");
|
||||
@ -2151,8 +2161,6 @@ static void micro_qr_m4(struct zint_symbol *symbol, char binary_data[], const in
|
||||
}
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) debug_test_codeword_dump(symbol, data_blocks, data_codewords);
|
||||
#else
|
||||
(void)symbol; /* Unused */
|
||||
#endif
|
||||
|
||||
/* Calculate Reed-Solomon error codewords */
|
||||
@ -2562,6 +2570,8 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
|
||||
qr_binary((unsigned char *) full_stream, MICROQR_VERSION + version, 0 /*target_codewords*/, mode, jisdata, length,
|
||||
0 /*gs1*/, 0 /*eci*/, binary_count[version], debug_print);
|
||||
|
||||
if (debug_print) printf("Binary (%d): %s\n", (int) strlen(full_stream), full_stream);
|
||||
|
||||
switch (version) {
|
||||
case 0: micro_qr_m1(symbol, full_stream);
|
||||
break;
|
||||
|
@ -2179,6 +2179,25 @@ static void test_microqr_encode(int index, int generate, int debug) {
|
||||
"01011000000010111"
|
||||
"11001111011101001"
|
||||
},
|
||||
/* 16*/ { UNICODE_MODE | ESCAPE_MODE, 1, -1, -1, "P-5-B223G846\015", 0, 17, 17, 1, "Ticket #241, 2.6.7 dropping off last character if mode different (MR #21)",
|
||||
"11111110101010101"
|
||||
"10000010100001100"
|
||||
"10111010011110010"
|
||||
"10111010100000101"
|
||||
"10111010011011111"
|
||||
"10000010111110100"
|
||||
"11111110110111101"
|
||||
"00000000011001000"
|
||||
"10010111011010100"
|
||||
"01110111000001110"
|
||||
"10100011001110111"
|
||||
"00011111000101010"
|
||||
"10011111101100110"
|
||||
"01110000111010100"
|
||||
"11001010110000000"
|
||||
"00011110011010001"
|
||||
"11101010111111111"
|
||||
},
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
Loading…
Reference in New Issue
Block a user