mirror of
https://git.code.sf.net/p/zint/code
synced 2025-12-18 18:37:07 +00:00
library: use "filemem" for TXT dump_plot() -> txt_hex_plot()
filemem: remove NOLINTS (clang-tidy-20 bug fixed) QRCODE: eliminate NOLINTs using some more asserts (clang-tidy-20); some "de-branching" of loops general: various code fiddlings, in particular lessen no. of redundant parenthesized expressions, especially in conditionals, which reduce rather than aid readibility IMNSHO manual: mention "--dump" option
This commit is contained in:
@@ -402,7 +402,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
|
||||
}
|
||||
cnt_1 = b256_count + DM_MULT_1;
|
||||
if (cnt_1 <= ascii_count || (cnt_1 < edf_count && cnt_1 < text_count && cnt_1 < x12_count
|
||||
&& cnt_1 < c40_count)) {
|
||||
&& cnt_1 < c40_count)) {
|
||||
if (debug_print) fputs("BAS->", stdout);
|
||||
return DM_BASE256; /* step (r)(2) */
|
||||
}
|
||||
@@ -535,7 +535,7 @@ static int dm_edi_buffer_xfer(int process_buffer[8], int process_p, unsigned cha
|
||||
|
||||
for (i = 0; i < process_e; i += 4) {
|
||||
target[tp++] = (unsigned char) (process_buffer[i] << 2 | (process_buffer[i + 1] & 0x30) >> 4);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0f) << 4 | (process_buffer[i + 2] & 0x3c) >> 2);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0F) << 4 | (process_buffer[i + 2] & 0x3C) >> 2);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 2] & 0x03) << 6 | process_buffer[i + 3]);
|
||||
if (debug_print) {
|
||||
printf("[%d %d %d %d (%d %d %d)] ", process_buffer[i], process_buffer[i + 1], process_buffer[i + 2],
|
||||
@@ -550,8 +550,8 @@ static int dm_edi_buffer_xfer(int process_buffer[8], int process_p, unsigned cha
|
||||
if (empty) {
|
||||
if (process_p == 3) {
|
||||
target[tp++] = (unsigned char) (process_buffer[i] << 2 | (process_buffer[i + 1] & 0x30) >> 4);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0f) << 4
|
||||
| (process_buffer[i + 2] & 0x3c) >> 2);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0F) << 4
|
||||
| (process_buffer[i + 2] & 0x3C) >> 2);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 2] & 0x03) << 6);
|
||||
if (debug_print) {
|
||||
printf("[%d %d %d (%d %d %d)] ", process_buffer[i], process_buffer[i + 1], process_buffer[i + 2],
|
||||
@@ -559,7 +559,7 @@ static int dm_edi_buffer_xfer(int process_buffer[8], int process_p, unsigned cha
|
||||
}
|
||||
} else if (process_p == 2) {
|
||||
target[tp++] = (unsigned char) (process_buffer[i] << 2 | (process_buffer[i + 1] & 0x30) >> 4);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0f) << 4);
|
||||
target[tp++] = (unsigned char) ((process_buffer[i + 1] & 0x0F) << 4);
|
||||
if (debug_print) {
|
||||
printf("[%d %d (%d %d)] ", process_buffer[i], process_buffer[i + 1], target[tp - 2],
|
||||
target[tp - 1]);
|
||||
@@ -582,7 +582,7 @@ static int dm_edi_buffer_xfer(int process_buffer[8], int process_p, unsigned cha
|
||||
static int dm_get_symbolsize(struct zint_symbol *symbol, const int minimum) {
|
||||
int i;
|
||||
|
||||
if ((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) {
|
||||
if (symbol->option_2 >= 1 && symbol->option_2 <= DMSIZESCOUNT) {
|
||||
return dm_intsymbol[symbol->option_2 - 1];
|
||||
}
|
||||
if (minimum > 1304) {
|
||||
@@ -1098,7 +1098,7 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
|
||||
tp = dm_update_b256_field_length(target, tp, *p_b256_start);
|
||||
/* B.2.1 255-state randomising algorithm */
|
||||
for (i = *p_b256_start; i < tp; i++) {
|
||||
const int prn = ((149 * (i + 1)) % 255) + 1;
|
||||
const int prn = (149 * (i + 1)) % 255 + 1;
|
||||
target[i] = (unsigned char) ((target[i] + prn) & 0xFF);
|
||||
}
|
||||
break;
|
||||
@@ -1457,7 +1457,7 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
|
||||
tp = dm_update_b256_field_length(target, tp, *p_b256_start);
|
||||
/* B.2.1 255-state randomising algorithm */
|
||||
for (i = *p_b256_start; i < tp; i++) {
|
||||
const int prn = ((149 * (i + 1)) % 255) + 1;
|
||||
const int prn = (149 * (i + 1)) % 255 + 1;
|
||||
target[i] = (unsigned char) ((target[i] + prn) & 0xFF);
|
||||
}
|
||||
/* We switch directly here to avoid flipping back to Base 256 due to `dm_text_sp_cnt()` */
|
||||
@@ -1607,7 +1607,7 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
|
||||
|
||||
} else if (current_mode == DM_X12) {
|
||||
if (debug_print) fputs("X12 ", stdout);
|
||||
if ((symbols_left == 1) && (process_p == 1)) {
|
||||
if (symbols_left == 1 && process_p == 1) {
|
||||
/* Unlatch not required! */
|
||||
target[tp++] = source[length - 1] + 1;
|
||||
if (debug_print) printf("A%02X ", target[tp - 1] - 1);
|
||||
@@ -1652,7 +1652,7 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
|
||||
}
|
||||
/* B.2.1 255-state randomising algorithm */
|
||||
for (i = b256_start; i < tp; i++) {
|
||||
int prn = ((149 * (i + 1)) % 255) + 1;
|
||||
const int prn = (149 * (i + 1)) % 255 + 1;
|
||||
target[i] = (unsigned char) ((target[i] + prn) & 0xFF);
|
||||
}
|
||||
}
|
||||
@@ -1833,15 +1833,15 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
|
||||
/* add pad bits */
|
||||
static void dm_add_tail(unsigned char target[], int tp, const int tail_length) {
|
||||
int i, prn, temp;
|
||||
int i;
|
||||
|
||||
target[tp++] = 129; /* Pad */
|
||||
for (i = 1; i < tail_length; i++) {
|
||||
/* B.1.1 253-state randomising algorithm */
|
||||
prn = ((149 * (tp + 1)) % 253) + 1;
|
||||
temp = 129 + prn;
|
||||
const int prn = (149 * (tp + 1)) % 253 + 1;
|
||||
const int temp = 129 + prn;
|
||||
if (temp <= 254) {
|
||||
target[tp++] = (unsigned char) (temp);
|
||||
target[tp++] = (unsigned char) temp;
|
||||
} else {
|
||||
target[tp++] = (unsigned char) (temp - 254);
|
||||
}
|
||||
@@ -1866,7 +1866,7 @@ static int dm_ecc200(struct zint_symbol *symbol, struct zint_seg segs[], const i
|
||||
symbolsize = dm_get_symbolsize(symbol, binlen);
|
||||
|
||||
if (binlen > dm_matrixbytes[symbolsize]) {
|
||||
if ((symbol->option_2 >= 1) && (symbol->option_2 <= DMSIZESCOUNT)) {
|
||||
if (symbol->option_2 >= 1 && symbol->option_2 <= DMSIZESCOUNT) {
|
||||
/* The symbol size was given by --ver (option_2) */
|
||||
return ZEXT z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 522,
|
||||
"Input too long for Version %1$d, requires %2$d codewords (maximum %3$d)",
|
||||
|
||||
Reference in New Issue
Block a user