mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-16 16:14:36 -04:00
code cleanup and minor fixes
This commit is contained in:
parent
8c78216dc1
commit
1d241cca05
26 changed files with 1048 additions and 1092 deletions
|
@ -69,13 +69,13 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
int block_count, c;
|
||||
int block_remain;
|
||||
int block_value;
|
||||
|
||||
|
||||
codewords[codeword_count] = 48; /* Numeric Shift */
|
||||
codeword_count++;
|
||||
|
||||
|
||||
block_count = j / 5;
|
||||
block_remain = j % 5;
|
||||
|
||||
|
||||
for(c = 0; c < block_count; c++) {
|
||||
if((c == block_count - 1) && (block_remain == 2)) {
|
||||
/* Rule (d) */
|
||||
|
@ -84,7 +84,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
block_value += ctoi(intermediate[i + 1]) * 100;
|
||||
block_value += ctoi(intermediate[i + 2]) * 10;
|
||||
block_value += ctoi(intermediate[i + 3]);
|
||||
|
||||
|
||||
codewords[codeword_count] = block_value / (48 * 48);
|
||||
block_value = block_value - (48 * 48) * codewords[codeword_count];
|
||||
codeword_count++;
|
||||
|
@ -97,20 +97,20 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
block_value = ctoi(intermediate[i]) * 100;
|
||||
block_value += ctoi(intermediate[i + 1]) * 10;
|
||||
block_value += ctoi(intermediate[i + 2]);
|
||||
|
||||
|
||||
codewords[codeword_count] = block_value / 48;
|
||||
block_value = block_value - 48 * codewords[codeword_count];
|
||||
codeword_count++;
|
||||
codewords[codeword_count] = block_value;
|
||||
codeword_count++;
|
||||
i += 3;
|
||||
} else {
|
||||
} else {
|
||||
block_value = ctoi(intermediate[i]) * 10000;
|
||||
block_value += ctoi(intermediate[i + 1]) * 1000;
|
||||
block_value += ctoi(intermediate[i + 2]) * 100;
|
||||
block_value += ctoi(intermediate[i + 3]) * 10;
|
||||
block_value += ctoi(intermediate[i + 4]);
|
||||
|
||||
|
||||
codewords[codeword_count] = block_value / (48 * 48);
|
||||
block_value = block_value - (48 * 48) * codewords[codeword_count];
|
||||
codeword_count++;
|
||||
|
@ -122,7 +122,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
i += 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch(block_remain) {
|
||||
case 1:
|
||||
/* Rule (a) */
|
||||
|
@ -135,7 +135,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
block_value = ctoi(intermediate[i]) * 100;
|
||||
block_value += ctoi(intermediate[i + 1]) * 10;
|
||||
block_value += ctoi(intermediate[i + 2]);
|
||||
|
||||
|
||||
codewords[codeword_count] = block_value / 48;
|
||||
block_value = block_value - 48 * codewords[codeword_count];
|
||||
codeword_count++;
|
||||
|
@ -150,7 +150,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
block_value += ctoi(intermediate[i + 1]) * 100;
|
||||
block_value += ctoi(intermediate[i + 2]) * 10;
|
||||
block_value += ctoi(intermediate[i + 3]);
|
||||
|
||||
|
||||
codewords[codeword_count] = block_value / (48 * 48);
|
||||
block_value = block_value - (48 * 48) * codewords[codeword_count];
|
||||
codeword_count++;
|
||||
|
@ -178,26 +178,26 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
i++;
|
||||
}
|
||||
} while(i < h);
|
||||
|
||||
|
||||
switch(codewords[0]) { /* Set starting mode value */
|
||||
case 48: M = 2; break;
|
||||
case 43: M = 4; break;
|
||||
case 44: M = 5; break;
|
||||
default: M = 0; break;
|
||||
}
|
||||
|
||||
|
||||
if(M != 0) {
|
||||
for(i = 0; i < codeword_count; i++) {
|
||||
codewords[i] = codewords[i + 1];
|
||||
}
|
||||
codeword_count--;
|
||||
}
|
||||
|
||||
|
||||
if(codeword_count > 49) {
|
||||
strcpy(symbol->errtxt, "Input too long");
|
||||
return ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
|
||||
/* Place codewords in code character array (c grid) */
|
||||
rows = 0;
|
||||
do{
|
||||
|
@ -211,7 +211,7 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
}
|
||||
rows++;
|
||||
} while ((rows * 7) < codeword_count);
|
||||
|
||||
|
||||
if((((rows <= 6) && (pad_count < 5))) || (rows > 6) || (rows == 1)) {
|
||||
/* Add a row */
|
||||
for(i = 0; i < 7; i++) {
|
||||
|
@ -219,20 +219,20 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
}
|
||||
rows++;
|
||||
}
|
||||
|
||||
|
||||
/* Add row count and mode character */
|
||||
c_grid[rows - 1][6] = (7 * (rows - 2)) + M;
|
||||
|
||||
|
||||
/* Add row check character */
|
||||
for(i = 0; i < rows - 1; i++) {
|
||||
int row_sum = 0;
|
||||
|
||||
|
||||
for(j = 0; j < 7; j++) {
|
||||
row_sum += c_grid[i][j];
|
||||
}
|
||||
c_grid[i][7] = row_sum % 49;
|
||||
}
|
||||
|
||||
|
||||
/* Calculate Symbol Check Characters */
|
||||
posn_val = 0;
|
||||
x_count = c_grid[rows - 1][6] * 20;
|
||||
|
@ -247,43 +247,43 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
posn_val++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(rows > 6) {
|
||||
/* Add Z Symbol Check */
|
||||
c_grid[rows - 1][0] = (z_count % 2401) / 49;
|
||||
c_grid[rows - 1][1] = (z_count % 2401) % 49;
|
||||
}
|
||||
|
||||
|
||||
local_value = (c_grid[rows - 1][0] * 49) + c_grid[rows - 1][1];
|
||||
x_count += c49_x_weight[posn_val] * local_value;
|
||||
y_count += c49_y_weight[posn_val] * local_value;
|
||||
posn_val++;
|
||||
|
||||
|
||||
/* Add Y Symbol Check */
|
||||
c_grid[rows - 1][2] = (y_count % 2401) / 49;
|
||||
c_grid[rows - 1][3] = (y_count % 2401) % 49;
|
||||
|
||||
|
||||
local_value = (c_grid[rows - 1][2] * 49) + c_grid[rows - 1][3];
|
||||
x_count += c49_x_weight[posn_val] * local_value;
|
||||
|
||||
|
||||
/* Add X Symbol Check */
|
||||
c_grid[rows - 1][4] = (x_count % 2401) / 49;
|
||||
c_grid[rows - 1][5] = (x_count % 2401) % 49;
|
||||
|
||||
|
||||
/* Add last row check character */
|
||||
j = 0;
|
||||
for(i = 0; i < 7; i++) {
|
||||
j += c_grid[rows - 1][i];
|
||||
}
|
||||
c_grid[rows - 1][7] = j % 49;
|
||||
|
||||
|
||||
/* Transfer data to symbol character array (w grid) */
|
||||
for(i = 0; i < rows; i++) {
|
||||
for(j = 0; j < 4; j ++) {
|
||||
w_grid[i][j] = (c_grid[i][2 * j] * 49) + c_grid[i][(2 * j) + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < rows; i++) {
|
||||
strcpy(pattern, "11"); /* Start character */
|
||||
for(j = 0; j < 4; j++) {
|
||||
|
@ -301,12 +301,12 @@ int code_49(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
}
|
||||
}
|
||||
concat(pattern, "4"); /* Stop character */
|
||||
|
||||
|
||||
/* Expand into symbol */
|
||||
symbol->row_height[i] = 10;
|
||||
expand(symbol, pattern);
|
||||
}
|
||||
|
||||
|
||||
symbol->whitespace_width = 10;
|
||||
symbol->output_options = BARCODE_BIND;
|
||||
symbol->border_width = 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue