mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
More code cleanup
Patch 7 of 7 from "Ismael Luceno" <ismael.luceno@gmail.com>
This commit is contained in:
parent
fc83343133
commit
7da2041cfd
@ -194,7 +194,7 @@ int interleaved_two_of_five(struct zint_symbol *symbol, unsigned char source[],
|
|||||||
ustrcpy(temp, (unsigned char *) "");
|
ustrcpy(temp, (unsigned char *) "");
|
||||||
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
|
/* Input must be an even number of characters for Interlaced 2 of 5 to work:
|
||||||
if an odd number of characters has been entered then add a leading zero */
|
if an odd number of characters has been entered then add a leading zero */
|
||||||
if ((length % 2) != 0)
|
if (length & 1)
|
||||||
{
|
{
|
||||||
ustrcpy(temp, (unsigned char *) "0");
|
ustrcpy(temp, (unsigned char *) "0");
|
||||||
length++;
|
length++;
|
||||||
@ -262,12 +262,10 @@ int itf14(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
|
|
||||||
/* Calculate the check digit - the same method used for EAN-13 */
|
/* Calculate the check digit - the same method used for EAN-13 */
|
||||||
|
|
||||||
for (i = 12; i >= 0; i--)
|
for (i = 12; i >= 0; i--) {
|
||||||
{
|
|
||||||
count += ctoi(localstr[i]);
|
count += ctoi(localstr[i]);
|
||||||
|
|
||||||
if ((i%2) == 0)
|
if (!(i & 1)) {
|
||||||
{
|
|
||||||
count += 2 * ctoi(localstr[i]);
|
count += 2 * ctoi(localstr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,8 +306,7 @@ int dpleit(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
{
|
{
|
||||||
count += 4 * ctoi(localstr[i]);
|
count += 4 * ctoi(localstr[i]);
|
||||||
|
|
||||||
if (!((i%2) == 0))
|
if (i & 1) {
|
||||||
{
|
|
||||||
count += 5 * ctoi(localstr[i]);
|
count += 5 * ctoi(localstr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,8 +345,7 @@ int dpident(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
{
|
{
|
||||||
count += 4 * ctoi(localstr[i]);
|
count += 4 * ctoi(localstr[i]);
|
||||||
|
|
||||||
if (!((i%2) == 0))
|
if (i & 1) {
|
||||||
{
|
|
||||||
count += 5 * ctoi(localstr[i]);
|
count += 5 * ctoi(localstr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
dxsmooth(&indexliste);
|
dxsmooth(&indexliste);
|
||||||
|
|
||||||
/* Resolve odd length LATCHC blocks */
|
/* Resolve odd length LATCHC blocks */
|
||||||
if((list[1][0] == LATCHC) && ((list[0][0] % 2) == 1)) {
|
if((list[1][0] == LATCHC) && (list[0][0] & 1)) {
|
||||||
/* Rule 2 */
|
/* Rule 2 */
|
||||||
list[0][1]++;
|
list[0][1]++;
|
||||||
list[0][0]--;
|
list[0][0]--;
|
||||||
@ -302,7 +302,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
}
|
}
|
||||||
if(indexliste > 1) {
|
if(indexliste > 1) {
|
||||||
for(i = 1; i < indexliste; i++) {
|
for(i = 1; i < indexliste; i++) {
|
||||||
if((list[1][i] == LATCHC) && ((list[0][i] % 2) == 1)) {
|
if((list[1][i] == LATCHC) && (list[0][i] & 1)) {
|
||||||
/* Rule 3b */
|
/* Rule 3b */
|
||||||
list[0][i - 1]++;
|
list[0][i - 1]++;
|
||||||
list[0][i]--;
|
list[0][i]--;
|
||||||
@ -688,7 +688,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
for(i = 0; i < read; i++) {
|
for(i = 0; i < read; i++) {
|
||||||
if(set[i] == 'C') {
|
if(set[i] == 'C') {
|
||||||
if(reduced[i] == '[') {
|
if(reduced[i] == '[') {
|
||||||
if(c_count % 2) {
|
if(c_count & 1) {
|
||||||
if((i - c_count) != 0) {
|
if((i - c_count) != 0) {
|
||||||
set[i - c_count] = 'B';
|
set[i - c_count] = 'B';
|
||||||
} else {
|
} else {
|
||||||
@ -700,7 +700,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
c_count++;
|
c_count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(c_count % 2) {
|
if(c_count & 1) {
|
||||||
if((i - c_count) != 0) {
|
if((i - c_count) != 0) {
|
||||||
set[i - c_count] = 'B';
|
set[i - c_count] = 'B';
|
||||||
} else {
|
} else {
|
||||||
@ -710,7 +710,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
c_count = 0;
|
c_count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c_count % 2) {
|
if(c_count & 1) {
|
||||||
if((i - c_count) != 0) {
|
if((i - c_count) != 0) {
|
||||||
set[i - c_count] = 'B';
|
set[i - c_count] = 'B';
|
||||||
} else {
|
} else {
|
||||||
@ -941,7 +941,7 @@ int nve_18(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
{
|
{
|
||||||
total_sum += ctoi(source[i]);
|
total_sum += ctoi(source[i]);
|
||||||
|
|
||||||
if(!((i%2) == 1)) {
|
if(!(i & 1)) {
|
||||||
total_sum += 2 * ctoi(source[i]);
|
total_sum += 2 * ctoi(source[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -979,12 +979,10 @@ int ean_14(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
ustrcpy(ean128_equiv + 4 + zeroes, source);
|
ustrcpy(ean128_equiv + 4 + zeroes, source);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (i = length - 1; i >= 0; i--)
|
for (i = length - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
count += ctoi(source[i]);
|
count += ctoi(source[i]);
|
||||||
|
|
||||||
if (!((i % 2) == 1))
|
if (!(i & 1)) {
|
||||||
{
|
|
||||||
count += 2 * ctoi(source[i]);
|
count += 2 * ctoi(source[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
for(i = 0; i < read; i++) {
|
for(i = 0; i < read; i++) {
|
||||||
if(set[i] == 'C') {
|
if(set[i] == 'C') {
|
||||||
if(source[i] == '[') {
|
if(source[i] == '[') {
|
||||||
if(c_count % 2) {
|
if(c_count & 1) {
|
||||||
if((i - c_count) != 0) {
|
if((i - c_count) != 0) {
|
||||||
set[i - c_count] = 'B';
|
set[i - c_count] = 'B';
|
||||||
} else {
|
} else {
|
||||||
@ -306,7 +306,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
c_count++;
|
c_count++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(c_count % 2) {
|
if(c_count & 1) {
|
||||||
if((i - c_count) != 0) {
|
if((i - c_count) != 0) {
|
||||||
set[i - c_count] = 'B';
|
set[i - c_count] = 'B';
|
||||||
} else {
|
} else {
|
||||||
@ -316,7 +316,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
c_count = 0;
|
c_count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c_count % 2) {
|
if(c_count & 1) {
|
||||||
if((i - c_count) != 0) {
|
if((i - c_count) != 0) {
|
||||||
set[i - c_count] = 'B';
|
set[i - c_count] = 'B';
|
||||||
} else {
|
} else {
|
||||||
|
@ -201,11 +201,8 @@ void expand(struct zint_symbol *symbol, char data[])
|
|||||||
if(latch == '1') { set_module(symbol, symbol->rows, writer); }
|
if(latch == '1') { set_module(symbol, symbol->rows, writer); }
|
||||||
writer++;
|
writer++;
|
||||||
}
|
}
|
||||||
if(latch == '1') {
|
|
||||||
latch = '0';
|
latch = (latch == '1' ? '0' : '1');
|
||||||
} else {
|
|
||||||
latch = '1';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(symbol->symbology != BARCODE_PHARMA) {
|
if(symbol->symbology != BARCODE_PHARMA) {
|
||||||
@ -325,7 +322,7 @@ int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned
|
|||||||
|
|
||||||
int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length)
|
int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[], int *length)
|
||||||
{
|
{
|
||||||
int bpos, jpos, error_number, done;
|
int bpos, jpos, error_number;
|
||||||
int next;
|
int next;
|
||||||
|
|
||||||
bpos = 0;
|
bpos = 0;
|
||||||
@ -334,51 +331,33 @@ int utf8toutf16(struct zint_symbol *symbol, unsigned char source[], int vals[],
|
|||||||
next = 0;
|
next = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
done = 0;
|
|
||||||
|
|
||||||
if(source[bpos] <= 0x7f) {
|
if(source[bpos] <= 0x7f) {
|
||||||
/* 1 byte mode (7-bit ASCII) */
|
/* 1 byte mode (7-bit ASCII) */
|
||||||
vals[jpos] = source[bpos];
|
vals[jpos] = source[bpos];
|
||||||
next = bpos + 1;
|
next = bpos + 1;
|
||||||
jpos++;
|
jpos++;
|
||||||
done = 1;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if(done == 0) {
|
|
||||||
if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) {
|
if((source[bpos] >= 0x80) && (source[bpos] <= 0xbf)) {
|
||||||
strcpy(symbol->errtxt, "Corrupt Unicode data");
|
strcpy(symbol->errtxt, "Corrupt Unicode data");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(done == 0) {
|
|
||||||
if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) {
|
if((source[bpos] >= 0xc0) && (source[bpos] <= 0xc1)) {
|
||||||
strcpy(symbol->errtxt, "Overlong encoding not supported");
|
strcpy(symbol->errtxt, "Overlong encoding not supported");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(done == 0) {
|
|
||||||
if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) {
|
if((source[bpos] >= 0xc2) && (source[bpos] <= 0xdf)) {
|
||||||
/* 2 byte mode */
|
/* 2 byte mode */
|
||||||
vals[jpos] = ((source[bpos] & 0x1f) << 6) + (source[bpos + 1] & 0x3f);
|
vals[jpos] = ((source[bpos] & 0x1f) << 6) + (source[bpos + 1] & 0x3f);
|
||||||
next = bpos + 2;
|
next = bpos + 2;
|
||||||
jpos++;
|
jpos++;
|
||||||
done = 1;
|
} else
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(done == 0) {
|
|
||||||
if((source[bpos] >= 0xe0) && (source[bpos] <= 0xef)) {
|
if((source[bpos] >= 0xe0) && (source[bpos] <= 0xef)) {
|
||||||
/* 3 byte mode */
|
/* 3 byte mode */
|
||||||
vals[jpos] = ((source[bpos] & 0x0f) << 12) + ((source[bpos + 1] & 0x3f) << 6) + (source[bpos + 2] & 0x3f);
|
vals[jpos] = ((source[bpos] & 0x0f) << 12) + ((source[bpos + 1] & 0x3f) << 6) + (source[bpos + 2] & 0x3f);
|
||||||
next = bpos + 3;
|
next = bpos + 3;
|
||||||
jpos ++;
|
jpos ++;
|
||||||
done = 1;
|
} else
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(done == 0) {
|
|
||||||
if(source[bpos] >= 0xf0) {
|
if(source[bpos] >= 0xf0) {
|
||||||
strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported");
|
strcpy(symbol->errtxt, "Unicode sequences of more than 3 bytes not supported");
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
|
@ -71,7 +71,7 @@ int _min(int first, int second) {
|
|||||||
|
|
||||||
/* gets bit in bitString at bitPos */
|
/* gets bit in bitString at bitPos */
|
||||||
int getBit(UINT *bitStr, int bitPos) {
|
int getBit(UINT *bitStr, int bitPos) {
|
||||||
return(((bitStr[bitPos/16] & (0x8000>>(bitPos%16))) == 0) ? 0 : 1);
|
return !!(bitStr[bitPos >> 4] & (0x8000 >> (bitPos & 15)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize pwr928 encoding table */
|
/* initialize pwr928 encoding table */
|
||||||
|
@ -758,7 +758,7 @@ void gm_add_ecc(char binary[], int data_posn, int layers, int ecc_level, int wor
|
|||||||
/* Add padding codewords */
|
/* Add padding codewords */
|
||||||
data[data_posn] = 0x00;
|
data[data_posn] = 0x00;
|
||||||
for(i = (data_posn + 1); i < data_cw; i++) {
|
for(i = (data_posn + 1); i < data_cw; i++) {
|
||||||
if(i % 2) {
|
if(i & 1) {
|
||||||
data[i] = 0x7e;
|
data[i] = 0x7e;
|
||||||
toggle = 1;
|
toggle = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -1055,7 +1055,7 @@ int grid_matrix(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
|
|
||||||
/* Add macromodule frames */
|
/* Add macromodule frames */
|
||||||
for(x = 0; x < modules; x++) {
|
for(x = 0; x < modules; x++) {
|
||||||
dark = 1 - (x % 2);
|
dark = 1 - (x & 1);
|
||||||
for(y = 0; y < modules; y++) {
|
for(y = 0; y < modules; y++) {
|
||||||
if(dark == 1) {
|
if(dark == 1) {
|
||||||
for(i = 0; i < 5; i++) {
|
for(i = 0; i < 5; i++) {
|
||||||
|
106
backend/gs1.c
106
backend/gs1.c
@ -170,48 +170,68 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
|
|||||||
for(i = 0; i < ai_count; i++) {
|
for(i = 0; i < ai_count; i++) {
|
||||||
switch (ai_value[i]) {
|
switch (ai_value[i]) {
|
||||||
case 0: if(data_length[i] != 18) { error_latch = 1; } break;
|
case 0: if(data_length[i] != 18) { error_latch = 1; } break;
|
||||||
case 1: if(data_length[i] != 14) { error_latch = 1; } break;
|
case 1:
|
||||||
case 2: if(data_length[i] != 14) { error_latch = 1; } break;
|
case 2:
|
||||||
case 3: if(data_length[i] != 14) { error_latch = 1; } break;
|
case 3: if(data_length[i] != 14) { error_latch = 1; } break;
|
||||||
case 4: if(data_length[i] != 16) { error_latch = 1; } break;
|
case 4: if(data_length[i] != 16) { error_latch = 1; } break;
|
||||||
case 11: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 11:
|
||||||
case 12: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 12:
|
||||||
case 13: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 13:
|
||||||
case 14: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 14:
|
||||||
case 15: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 15:
|
||||||
case 16: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 16:
|
||||||
case 17: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 17:
|
||||||
case 18: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 18:
|
||||||
case 19: if(data_length[i] != 6) { error_latch = 1; } break;
|
case 19: if(data_length[i] != 6) { error_latch = 1; } break;
|
||||||
case 20: if(data_length[i] != 2) { error_latch = 1; } break;
|
case 20: if(data_length[i] != 2) { error_latch = 1; } break;
|
||||||
case 23: error_latch = 2; break;
|
case 23:
|
||||||
case 24: error_latch = 2; break;
|
case 24:
|
||||||
case 25: error_latch = 2; break;
|
case 25:
|
||||||
case 39: error_latch = 2; break;
|
case 39:
|
||||||
case 40: error_latch = 2; break;
|
case 40:
|
||||||
case 41: error_latch = 2; break;
|
case 41:
|
||||||
case 42: error_latch = 2; break;
|
case 42:
|
||||||
case 70: error_latch = 2; break;
|
case 70:
|
||||||
case 80: error_latch = 2; break;
|
case 80:
|
||||||
case 81: error_latch = 2; break;
|
case 81: error_latch = 2; break;
|
||||||
}
|
}
|
||||||
if((ai_value[i] >= 100) && (ai_value[i] <= 179)) { error_latch = 2; }
|
if(
|
||||||
if((ai_value[i] >= 1000) && (ai_value[i] <= 1799)) { error_latch = 2; }
|
((ai_value[i] >= 100) && (ai_value[i] <= 179))
|
||||||
if((ai_value[i] >= 200) && (ai_value[i] <= 229)) { error_latch = 2; }
|
|| ((ai_value[i] >= 1000) && (ai_value[i] <= 1799))
|
||||||
if((ai_value[i] >= 2000) && (ai_value[i] <= 2299)) { error_latch = 2; }
|
|| ((ai_value[i] >= 200) && (ai_value[i] <= 229))
|
||||||
if((ai_value[i] >= 300) && (ai_value[i] <= 309)) { error_latch = 2; }
|
|| ((ai_value[i] >= 2000) && (ai_value[i] <= 2299))
|
||||||
if((ai_value[i] >= 3000) && (ai_value[i] <= 3099)) { error_latch = 2; }
|
|| ((ai_value[i] >= 300) && (ai_value[i] <= 309))
|
||||||
if((ai_value[i] >= 31) && (ai_value[i] <= 36)) { error_latch = 2; }
|
|| ((ai_value[i] >= 3000) && (ai_value[i] <= 3099))
|
||||||
if((ai_value[i] >= 310) && (ai_value[i] <= 369)) { error_latch = 2; }
|
|| ((ai_value[i] >= 31) && (ai_value[i] <= 36))
|
||||||
if((ai_value[i] >= 3100) && (ai_value[i] <= 3699)) { if(data_length[i] != 6) { error_latch = 1; } }
|
|| ((ai_value[i] >= 310) && (ai_value[i] <= 369))
|
||||||
if((ai_value[i] >= 370) && (ai_value[i] <= 379)) { error_latch = 2; }
|
) {
|
||||||
if((ai_value[i] >= 3700) && (ai_value[i] <= 3799)) { error_latch = 2; }
|
error_latch = 2;
|
||||||
if((ai_value[i] >= 410) && (ai_value[i] <= 415)) { if(data_length[i] != 13) { error_latch = 1; } }
|
}
|
||||||
if((ai_value[i] >= 4100) && (ai_value[i] <= 4199)) { error_latch = 2; }
|
if((ai_value[i] >= 3100) && (ai_value[i] <= 3699)) {
|
||||||
if((ai_value[i] >= 700) && (ai_value[i] <= 703)) { error_latch = 2; }
|
if(data_length[i] != 6) {
|
||||||
if((ai_value[i] >= 800) && (ai_value[i] <= 810)) { error_latch = 2; }
|
error_latch = 1;
|
||||||
if((ai_value[i] >= 900) && (ai_value[i] <= 999)) { error_latch = 2; }
|
}
|
||||||
if((ai_value[i] >= 9000) && (ai_value[i] <= 9999)) { error_latch = 2; }
|
}
|
||||||
|
if(
|
||||||
|
((ai_value[i] >= 370) && (ai_value[i] <= 379))
|
||||||
|
|| ((ai_value[i] >= 3700) && (ai_value[i] <= 3799))
|
||||||
|
) {
|
||||||
|
error_latch = 2;
|
||||||
|
}
|
||||||
|
if((ai_value[i] >= 410) && (ai_value[i] <= 415)) {
|
||||||
|
if(data_length[i] != 13) {
|
||||||
|
error_latch = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(
|
||||||
|
((ai_value[i] >= 4100) && (ai_value[i] <= 4199))
|
||||||
|
|| ((ai_value[i] >= 700) && (ai_value[i] <= 703))
|
||||||
|
|| ((ai_value[i] >= 800) && (ai_value[i] <= 810))
|
||||||
|
|| ((ai_value[i] >= 900) && (ai_value[i] <= 999))
|
||||||
|
|| ((ai_value[i] >= 9000) && (ai_value[i] <= 9999))
|
||||||
|
) {
|
||||||
|
error_latch = 2;
|
||||||
|
}
|
||||||
if((error_latch < 4) && (error_latch > 0)) {
|
if((error_latch < 4) && (error_latch > 0)) {
|
||||||
/* error has just been detected: capture AI */
|
/* error has just been detected: capture AI */
|
||||||
itostr(ai_string, ai_value[i]);
|
itostr(ai_string, ai_value[i]);
|
||||||
@ -251,11 +271,15 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], const unsigne
|
|||||||
ai_latch = 0;
|
ai_latch = 0;
|
||||||
/* The following values from "GS-1 General Specification version 8.0 issue 2, May 2008"
|
/* The following values from "GS-1 General Specification version 8.0 issue 2, May 2008"
|
||||||
figure 5.4.8.2.1 - 1 "Element Strings with Pre-Defined Length Using Application Identifiers" */
|
figure 5.4.8.2.1 - 1 "Element Strings with Pre-Defined Length Using Application Identifiers" */
|
||||||
if((last_ai >= 0) && (last_ai <= 4)) { ai_latch = 1; }
|
if(
|
||||||
if((last_ai >= 11) && (last_ai <= 20)) { ai_latch = 1; }
|
((last_ai >= 0) && (last_ai <= 4))
|
||||||
if(last_ai == 23) { ai_latch = 1; } /* legacy support - see 5.3.8.2.2 */
|
|| ((last_ai >= 11) && (last_ai <= 20))
|
||||||
if((last_ai >= 31) && (last_ai <= 36)) { ai_latch = 1; }
|
|| (last_ai == 23) /* legacy support - see 5.3.8.2.2 */
|
||||||
if(last_ai == 41) { ai_latch = 1; }
|
|| ((last_ai >= 31) && (last_ai <= 36))
|
||||||
|
|| (last_ai == 41)
|
||||||
|
) {
|
||||||
|
ai_latch = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* The ']' character is simply dropped from the input */
|
/* The ']' character is simply dropped from the input */
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ void maxi_do_secondary_chk_odd( int ecclen )
|
|||||||
datalen = 84;
|
datalen = 84;
|
||||||
|
|
||||||
for(j = 0; j < datalen; j += 1)
|
for(j = 0; j < datalen; j += 1)
|
||||||
if ((j % 2) == 1) // odd
|
if (j & 1) // odd
|
||||||
data[(j-1)/2] = maxi_codeword[j + 20];
|
data[(j-1)/2] = maxi_codeword[j + 20];
|
||||||
|
|
||||||
rs_encode(datalen/2, data, results);
|
rs_encode(datalen/2, data, results);
|
||||||
@ -96,7 +96,7 @@ void maxi_do_secondary_chk_even(int ecclen )
|
|||||||
rs_init_code(ecclen, 1);
|
rs_init_code(ecclen, 1);
|
||||||
|
|
||||||
for(j = 0; j < datalen + 1; j += 1)
|
for(j = 0; j < datalen + 1; j += 1)
|
||||||
if ((j % 2) == 0) // even
|
if (!(j & 1)) // even
|
||||||
data[j/2] = maxi_codeword[j + 20];
|
data[j/2] = maxi_codeword[j + 20];
|
||||||
|
|
||||||
rs_encode(datalen/2, data, results);
|
rs_encode(datalen/2, data, results);
|
||||||
|
@ -73,7 +73,7 @@ int pharma_one(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(tester % 2 == 0) {
|
if(!(tester & 1)) {
|
||||||
concat(inter, "W");
|
concat(inter, "W");
|
||||||
tester = (tester - 2) / 2;
|
tester = (tester - 2) / 2;
|
||||||
} else {
|
} else {
|
||||||
|
@ -289,7 +289,7 @@ void textprocess(int *chainemc, int *mclength, char chaine[], int start, int len
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 663 */
|
/* 663 */
|
||||||
if ((wnet % 2) > 0) {
|
if (wnet & 1) {
|
||||||
chainet[wnet] = 29;
|
chainet[wnet] = 29;
|
||||||
wnet++;
|
wnet++;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int le
|
|||||||
|
|
||||||
/* caluculate check digit */
|
/* caluculate check digit */
|
||||||
wright = 0;
|
wright = 0;
|
||||||
n = ((length % 2) == 0) ? 1 : 0;
|
n = !(length & 1);
|
||||||
for(i = n; i < length; i += 2)
|
for(i = n; i < length; i += 2)
|
||||||
{
|
{
|
||||||
un[wright++] = source[i];
|
un[wright++] = source[i];
|
||||||
@ -170,7 +170,7 @@ int msi_plessey_mod10(struct zint_symbol *symbol, unsigned char source[], int le
|
|||||||
pedwar += ctoi(tri[i]);
|
pedwar += ctoi(tri[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = length % 2;
|
n = length & 1;
|
||||||
for(i = n; i < length; i+=2)
|
for(i = n; i < length; i+=2)
|
||||||
{
|
{
|
||||||
pedwar += ctoi(source[i]);
|
pedwar += ctoi(source[i]);
|
||||||
@ -223,7 +223,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], cons
|
|||||||
/* calculate first check digit */
|
/* calculate first check digit */
|
||||||
wright = 0;
|
wright = 0;
|
||||||
|
|
||||||
n = ((src_len %2) == 0) ? 1 : 0;
|
n = !(src_len & 1);
|
||||||
for(i = n; i < src_len; i += 2)
|
for(i = n; i < src_len; i += 2)
|
||||||
{
|
{
|
||||||
un[wright++] = source[i];
|
un[wright++] = source[i];
|
||||||
@ -242,7 +242,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], cons
|
|||||||
pedwar += ctoi(tri[i]);
|
pedwar += ctoi(tri[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
n = src_len % 2;
|
n = src_len & 1;
|
||||||
for(i = n; i < src_len; i += 2)
|
for(i = n; i < src_len; i += 2)
|
||||||
{
|
{
|
||||||
pedwar += ctoi(source[i]);
|
pedwar += ctoi(source[i]);
|
||||||
@ -256,7 +256,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], cons
|
|||||||
|
|
||||||
/* calculate second check digit */
|
/* calculate second check digit */
|
||||||
wright = 0;
|
wright = 0;
|
||||||
n = src_len % 2;
|
n = src_len & 1;
|
||||||
for(i = n; i < src_len; i += 2)
|
for(i = n; i < src_len; i += 2)
|
||||||
{
|
{
|
||||||
un[wright++] = source[i];
|
un[wright++] = source[i];
|
||||||
@ -277,7 +277,7 @@ int msi_plessey_mod1010(struct zint_symbol *symbol, unsigned char source[], cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
i = ((src_len % 2) == 0) ? 1 : 0;
|
i = !(src_len & 1);
|
||||||
for(; i < src_len; i += 2)
|
for(; i < src_len; i += 2)
|
||||||
{
|
{
|
||||||
pedwar += ctoi(source[i]);
|
pedwar += ctoi(source[i]);
|
||||||
@ -424,7 +424,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], cons
|
|||||||
|
|
||||||
/* caluculate second (mod 10) check digit */
|
/* caluculate second (mod 10) check digit */
|
||||||
wright = 0;
|
wright = 0;
|
||||||
i = ((temp_len % 2) == 0) ? 1 : 0;
|
i = !(temp_len & 1);
|
||||||
for(; i < temp_len; i += 2)
|
for(; i < temp_len; i += 2)
|
||||||
{
|
{
|
||||||
un[wright++] = temp[i];
|
un[wright++] = temp[i];
|
||||||
@ -443,7 +443,7 @@ int msi_plessey_mod1110(struct zint_symbol *symbol, unsigned char source[], cons
|
|||||||
pedwar += ctoi(tri[i]);
|
pedwar += ctoi(tri[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = temp_len % 2;
|
i = temp_len & 1;
|
||||||
for(; i < temp_len; i+=2)
|
for(; i < temp_len; i+=2)
|
||||||
{
|
{
|
||||||
pedwar += ctoi(temp[i]);
|
pedwar += ctoi(temp[i]);
|
||||||
|
@ -635,13 +635,13 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
|||||||
for(column = 0; column < symbol->width; column++) {
|
for(column = 0; column < symbol->width; column++) {
|
||||||
xposn = column * 10;
|
xposn = column * 10;
|
||||||
if(module_is_set(symbol, row, column)) {
|
if(module_is_set(symbol, row, column)) {
|
||||||
if((row % 2) == 0) {
|
if(row & 1) {
|
||||||
/* Even (full) row */
|
|
||||||
draw_hexagon(pixelbuf, image_width, xposn + (2 * xoffset), yposn + (2 * yoffset));
|
|
||||||
} else {
|
|
||||||
/* Odd (reduced) row */
|
/* Odd (reduced) row */
|
||||||
xposn += 5;
|
xposn += 5;
|
||||||
draw_hexagon(pixelbuf, image_width, xposn + (2 * xoffset), yposn + (2 * yoffset));
|
draw_hexagon(pixelbuf, image_width, xposn + (2 * xoffset), yposn + (2 * yoffset));
|
||||||
|
} else {
|
||||||
|
/* Even (full) row */
|
||||||
|
draw_hexagon(pixelbuf, image_width, xposn + (2 * xoffset), yposn + (2 * yoffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,11 +256,9 @@ int ps_plot(struct zint_symbol *symbol)
|
|||||||
dy = my - 1.0 + yoffset;
|
dy = my - 1.0 + yoffset;
|
||||||
ey = my - 0.5 + yoffset;
|
ey = my - 0.5 + yoffset;
|
||||||
fy = my + 0.5 + yoffset;
|
fy = my + 0.5 + yoffset;
|
||||||
if(r % 2 == 1) {
|
|
||||||
mx = (2.46 * i) + 1.23 + 1.23;
|
mx = 2.46 * i + 1.23 + (r & 1 ? 1.23 : 0);
|
||||||
} else {
|
|
||||||
mx = (2.46 * i) + 1.23;
|
|
||||||
}
|
|
||||||
ax = mx + xoffset;
|
ax = mx + xoffset;
|
||||||
bx = mx + 0.86 + xoffset;
|
bx = mx + 0.86 + xoffset;
|
||||||
cx = mx + 0.86 + xoffset;
|
cx = mx + 0.86 + xoffset;
|
||||||
|
59
backend/qr.c
59
backend/qr.c
@ -133,7 +133,7 @@ int estimate_binary_length(char mode[], int length, int gs1)
|
|||||||
case 'B': count += 8; break;
|
case 'B': count += 8; break;
|
||||||
case 'A':
|
case 'A':
|
||||||
a_count++;
|
a_count++;
|
||||||
if((a_count % 2) == 0) {
|
if((a_count & 1) == 0) {
|
||||||
count += 5; // 11 in total
|
count += 5; // 11 in total
|
||||||
a_count = 0;
|
a_count = 0;
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ int estimate_binary_length(char mode[], int length, int gs1)
|
|||||||
count += 3; // 10 in total
|
count += 3; // 10 in total
|
||||||
n_count = 0;
|
n_count = 0;
|
||||||
}
|
}
|
||||||
else if ((n_count % 2) == 0)
|
else if ((n_count & 1) == 0)
|
||||||
count += 3; // 7 in total
|
count += 3; // 7 in total
|
||||||
else
|
else
|
||||||
count += 4;
|
count += 4;
|
||||||
@ -186,11 +186,9 @@ void qr_binary(int datastream[], int version, int target_binlen, char mode[], in
|
|||||||
|
|
||||||
if(version <= 9) {
|
if(version <= 9) {
|
||||||
scheme = 1;
|
scheme = 1;
|
||||||
}
|
} else if((version >= 10) && (version <= 26)) {
|
||||||
if((version >= 10) && (version <= 26)) {
|
|
||||||
scheme = 2;
|
scheme = 2;
|
||||||
}
|
} else if(version >= 27) {
|
||||||
if(version >= 27) {
|
|
||||||
scheme = 3;
|
scheme = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,14 +877,14 @@ int apply_bitmask(unsigned char *grid, int size)
|
|||||||
mask[(y * size) + x] = 0x00;
|
mask[(y * size) + x] = 0x00;
|
||||||
|
|
||||||
if (!(grid[(y * size) + x] & 0xf0)) {
|
if (!(grid[(y * size) + x] & 0xf0)) {
|
||||||
if(((y + x) % 2) == 0) { mask[(y * size) + x] += 0x01; }
|
if(((y + x) & 1) == 0) { mask[(y * size) + x] += 0x01; }
|
||||||
if((y % 2) == 0) { mask[(y * size) + x] += 0x02; }
|
if((y & 1) == 0) { mask[(y * size) + x] += 0x02; }
|
||||||
if((x % 3) == 0) { mask[(y * size) + x] += 0x04; }
|
if((x % 3) == 0) { mask[(y * size) + x] += 0x04; }
|
||||||
if(((y + x) % 3) == 0) { mask[(y * size) + x] += 0x08; }
|
if(((y + x) % 3) == 0) { mask[(y * size) + x] += 0x08; }
|
||||||
if((((y / 2) + (x / 3)) % 2) == 0) { mask[(y * size) + x] += 0x10; }
|
if((((y / 2) + (x / 3)) & 1) == 0) { mask[(y * size) + x] += 0x10; }
|
||||||
if((((y * x) % 2) + ((y * x) % 3)) == 0) { mask[(y * size) + x] += 0x20; }
|
if((((y * x) & 1) + ((y * x) % 3)) == 0) { mask[(y * size) + x] += 0x20; }
|
||||||
if(((((y * x) % 2) + ((y * x) % 3)) % 2) == 0) { mask[(y * size) + x] += 0x40; }
|
if(((((y * x) & 1) + ((y * x) % 3)) & 1) == 0) { mask[(y * size) + x] += 0x40; }
|
||||||
if(((((y + x) % 2) + ((y * x) % 3)) % 2) == 0) { mask[(y * size) + x] += 0x80; }
|
if(((((y + x) & 1) + ((y * x) % 3)) & 1) == 0) { mask[(y * size) + x] += 0x80; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1010,11 +1008,7 @@ int qr_code(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||||||
char* mode = (char *)_alloca(length + 1);
|
char* mode = (char *)_alloca(length + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(symbol->input_mode == GS1_MODE) {
|
gs1 = (symbol->input_mode == GS1_MODE);
|
||||||
gs1 = 1;
|
|
||||||
} else {
|
|
||||||
gs1 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(symbol->input_mode) {
|
switch(symbol->input_mode) {
|
||||||
case DATA_MODE:
|
case DATA_MODE:
|
||||||
@ -1520,8 +1514,7 @@ void micro_qr_m1(char binary_data[])
|
|||||||
if(bits_left > 4) {
|
if(bits_left > 4) {
|
||||||
remainder = (bits_left - 4) / 8;
|
remainder = (bits_left - 4) / 8;
|
||||||
for(i = 0; i < remainder; i++) {
|
for(i = 0; i < remainder; i++) {
|
||||||
if((i % 2) == 0) { concat(binary_data, "11101100"); }
|
concat(binary_data, i & 1 ? "00010001" : "11101100");
|
||||||
if((i % 2) == 1) { concat(binary_data, "00010001"); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
concat(binary_data, "0000");
|
concat(binary_data, "0000");
|
||||||
@ -1595,8 +1588,7 @@ void micro_qr_m2(char binary_data[], int ecc_mode)
|
|||||||
bits_left = bits_total - strlen(binary_data);
|
bits_left = bits_total - strlen(binary_data);
|
||||||
remainder = bits_left / 8;
|
remainder = bits_left / 8;
|
||||||
for(i = 0; i < remainder; i++) {
|
for(i = 0; i < remainder; i++) {
|
||||||
if((i % 2) == 0) { concat(binary_data, "11101100"); }
|
concat(binary_data, i & 1 ? "00010001" : "11101100");
|
||||||
if((i % 2) == 1) { concat(binary_data, "00010001"); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1677,8 +1669,7 @@ void micro_qr_m3(char binary_data[], int ecc_mode)
|
|||||||
if(bits_left > 4) {
|
if(bits_left > 4) {
|
||||||
remainder = (bits_left - 4) / 8;
|
remainder = (bits_left - 4) / 8;
|
||||||
for(i = 0; i < remainder; i++) {
|
for(i = 0; i < remainder; i++) {
|
||||||
if((i % 2) == 0) { concat(binary_data, "11101100"); }
|
concat(binary_data, i & 1 ? "00010001" : "11101100");
|
||||||
if((i % 2) == 1) { concat(binary_data, "00010001"); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
concat(binary_data, "0000");
|
concat(binary_data, "0000");
|
||||||
@ -1766,8 +1757,7 @@ void micro_qr_m4(char binary_data[], int ecc_mode)
|
|||||||
bits_left = bits_total - strlen(binary_data);
|
bits_left = bits_total - strlen(binary_data);
|
||||||
remainder = bits_left / 8;
|
remainder = bits_left / 8;
|
||||||
for(i = 0; i < remainder; i++) {
|
for(i = 0; i < remainder; i++) {
|
||||||
if((i % 2) == 0) { concat(binary_data, "11101100"); }
|
concat(binary_data, i & 1 ? "00010001" : "11101100");
|
||||||
if((i % 2) == 1) { concat(binary_data, "00010001"); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1930,10 +1920,21 @@ int micro_apply_bitmask(unsigned char *grid, int size)
|
|||||||
mask[(y * size) + x] = 0x00;
|
mask[(y * size) + x] = 0x00;
|
||||||
|
|
||||||
if (!(grid[(y * size) + x] & 0xf0)) {
|
if (!(grid[(y * size) + x] & 0xf0)) {
|
||||||
if((y % 2) == 0) { mask[(y * size) + x] += 0x01; }
|
if((y & 1) == 0) {
|
||||||
if((((y / 2) + (x / 3)) % 2) == 0) { mask[(y * size) + x] += 0x02; }
|
mask[(y * size) + x] += 0x01;
|
||||||
if(((((y * x) % 2) + ((y * x) % 3)) % 2) == 0) { mask[(y * size) + x] += 0x04; }
|
}
|
||||||
if(((((y + x) % 2) + ((y * x) % 3)) % 2) == 0) { mask[(y * size) + x] += 0x08; }
|
|
||||||
|
if((((y / 2) + (x / 3)) & 1) == 0) {
|
||||||
|
mask[(y * size) + x] += 0x02;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((((y * x) & 1) + ((y * x) % 3)) & 1) == 0) {
|
||||||
|
mask[(y * size) + x] += 0x04;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((((y + x) & 1) + ((y * x) % 3)) & 1) == 0) {
|
||||||
|
mask[(y * size) + x] += 0x08;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,11 +334,7 @@ int render_plot(struct zint_symbol *symbol, float width, float height)
|
|||||||
for(r = 0; r < symbol->rows; r++) {
|
for(r = 0; r < symbol->rows; r++) {
|
||||||
for(i = 0; i < symbol->width; i++) {
|
for(i = 0; i < symbol->width; i++) {
|
||||||
if(module_is_set(symbol, r, i)) {
|
if(module_is_set(symbol, r, i)) {
|
||||||
if(r % 2 == 1) {
|
hexagon = render_plot_create_hexagon(((i * 0.88) + (r & 1 ? 1.76 : 1.32)) * scaler, ((r * 0.76) + 0.76) * scaler);
|
||||||
hexagon = render_plot_create_hexagon(((i * 0.88) + 1.76) * scaler, ((r * 0.76) + 0.76) * scaler);
|
|
||||||
} else {
|
|
||||||
hexagon = render_plot_create_hexagon(((i * 0.88) + 1.32) * scaler, ((r * 0.76) + 0.76) * scaler);
|
|
||||||
}
|
|
||||||
render_plot_add_hexagon(symbol, hexagon, &last_hexagon);
|
render_plot_add_hexagon(symbol, hexagon, &last_hexagon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
197
backend/rss.c
197
backend/rss.c
@ -112,7 +112,7 @@ void getRSSwidths(int val, int n, int elements, int maxWidth, int noNarrow)
|
|||||||
/* get all combinations */
|
/* get all combinations */
|
||||||
subVal = combins(n-elmWidth-1, elements-bar-2);
|
subVal = combins(n-elmWidth-1, elements-bar-2);
|
||||||
/* less combinations with no single-module element */
|
/* less combinations with no single-module element */
|
||||||
if ((!noNarrow) && (narrowMask == 0) &&
|
if ((!noNarrow) && (!narrowMask) &&
|
||||||
(n-elmWidth-(elements-bar-1) >= elements-bar-1))
|
(n-elmWidth-(elements-bar-1) >= elements-bar-1))
|
||||||
{
|
{
|
||||||
subVal -= combins(n-elmWidth-(elements-bar), elements-bar-2);
|
subVal -= combins(n-elmWidth-(elements-bar), elements-bar-2);
|
||||||
@ -440,12 +440,10 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
}
|
}
|
||||||
hrt[14] = '\0';
|
hrt[14] = '\0';
|
||||||
|
|
||||||
for (i = 0; i < 13; i++)
|
for (i = 0; i < 13; i++) {
|
||||||
{
|
|
||||||
count += ctoi(hrt[i]);
|
count += ctoi(hrt[i]);
|
||||||
|
|
||||||
if ((i%2) == 0)
|
if (!(i & 1)) {
|
||||||
{
|
|
||||||
count += 2 * (ctoi(hrt[i]));
|
count += 2 * (ctoi(hrt[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -550,11 +548,7 @@ int rss14(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
|
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
|
||||||
writer++;
|
writer++;
|
||||||
}
|
}
|
||||||
if(latch == '1') {
|
latch = (latch == '1' ? '0' : '1');
|
||||||
latch = '0';
|
|
||||||
} else {
|
|
||||||
latch = '1';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
set_module(symbol, symbol->rows, writer);
|
set_module(symbol, symbol->rows, writer);
|
||||||
unset_module(symbol, symbol->rows, writer + 1);
|
unset_module(symbol, symbol->rows, writer + 1);
|
||||||
@ -901,11 +895,7 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
|
if(latch == '1') { set_module(symbol, symbol->rows, writer); } else { unset_module(symbol, symbol->rows, writer); }
|
||||||
writer++;
|
writer++;
|
||||||
}
|
}
|
||||||
if(latch == '1') {
|
latch = (latch == '1' ? '0' : '1');
|
||||||
latch = '0';
|
|
||||||
} else {
|
|
||||||
latch = '1';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(symbol->width < writer) { symbol->width = writer; }
|
if(symbol->width < writer) { symbol->width = writer; }
|
||||||
symbol->rows = symbol->rows + 1;
|
symbol->rows = symbol->rows + 1;
|
||||||
@ -932,12 +922,10 @@ int rsslimited(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
hrt[12 - i] = source[src_len - i - 1];
|
hrt[12 - i] = source[src_len - i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 13; i++)
|
for (i = 0; i < 13; i++) {
|
||||||
{
|
|
||||||
count += ctoi(hrt[i]);
|
count += ctoi(hrt[i]);
|
||||||
|
|
||||||
if ((i%2) == 0)
|
if (!(i & 1)) {
|
||||||
{
|
|
||||||
count += 2 * (ctoi(hrt[i]));
|
count += 2 * (ctoi(hrt[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1045,7 +1033,7 @@ int general_rules(char field[], char type[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < block_count - 1; i++) {
|
for(i = 0; i < block_count - 1; i++) {
|
||||||
if((block[1][i] == NUMERIC) && (block[0][i] % 2 == 1)) {
|
if((block[1][i] == NUMERIC) && (block[0][i] & 1)) {
|
||||||
/* Odd size numeric block */
|
/* Odd size numeric block */
|
||||||
block[0][i] = block[0][i] - 1;
|
block[0][i] = block[0][i] - 1;
|
||||||
block[0][i + 1] = block[0][i + 1] + 1;
|
block[0][i + 1] = block[0][i + 1] + 1;
|
||||||
@ -1060,7 +1048,7 @@ int general_rules(char field[], char type[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((block[1][block_count - 1] == NUMERIC) && (block[0][block_count - 1] % 2 == 1)) {
|
if((block[1][block_count - 1] == NUMERIC) && (block[0][block_count - 1] & 1)) {
|
||||||
/* If the last block is numeric and an odd size, further
|
/* If the last block is numeric and an odd size, further
|
||||||
processing needs to be done outside this procedure */
|
processing needs to be done outside this procedure */
|
||||||
return 1;
|
return 1;
|
||||||
@ -1274,11 +1262,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x08;
|
mask = 0x08;
|
||||||
for(j = 0; j < 4; j++) {
|
for(j = 0; j < 4; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1291,11 +1275,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1320,11 +1300,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1337,11 +1313,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x4000;
|
mask = 0x4000;
|
||||||
for(j = 0; j < 15; j++) {
|
for(j = 0; j < 15; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1364,11 +1336,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1385,11 +1353,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x4000;
|
mask = 0x4000;
|
||||||
for(j = 0; j < 15; j++) {
|
for(j = 0; j < 15; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1413,11 +1377,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1432,11 +1392,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x80000;
|
mask = 0x80000;
|
||||||
for(j = 0; j < 20; j++) {
|
for(j = 0; j < 20; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1460,11 +1416,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x8000;
|
mask = 0x8000;
|
||||||
for(j = 0; j < 16; j++) {
|
for(j = 0; j < 16; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1484,11 +1436,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1518,11 +1466,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1542,11 +1486,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x200;
|
mask = 0x200;
|
||||||
for(j = 0; j < 10; j++) {
|
for(j = 0; j < 10; j++) {
|
||||||
if((group_val & mask) == 0x00) {
|
concat(binary_string, (group_val & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1689,12 +1629,9 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x40;
|
mask = 0x40;
|
||||||
for(j = 0; j < 7; j++) {
|
for(j = 0; j < 7; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
if (debug) {
|
||||||
if(debug) printf("0");
|
printf("%d", !!(value & mask));
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
if(debug) printf("1");
|
|
||||||
}
|
}
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
@ -1721,11 +1658,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x10;
|
mask = 0x10;
|
||||||
for(j = 0; j < 5; j++) {
|
for(j = 0; j < 5; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1736,11 +1669,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x20;
|
mask = 0x20;
|
||||||
for(j = 0; j < 6; j++) {
|
for(j = 0; j < 6; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1774,11 +1703,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x10;
|
mask = 0x10;
|
||||||
for(j = 0; j < 5; j++) {
|
for(j = 0; j < 5; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1789,11 +1714,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x40;
|
mask = 0x40;
|
||||||
for(j = 0; j < 7; j++) {
|
for(j = 0; j < 7; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1804,11 +1725,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x40;
|
mask = 0x40;
|
||||||
for(j = 0; j < 7; j++) {
|
for(j = 0; j < 7; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1859,11 +1776,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x08;
|
mask = 0x08;
|
||||||
for(j = 0; j < 4; j++) {
|
for(j = 0; j < 4; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1874,11 +1787,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x40;
|
mask = 0x40;
|
||||||
for(j = 0; j < 7; j++) {
|
for(j = 0; j < 7; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1887,11 +1796,7 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
|
|
||||||
mask = 0x10;
|
mask = 0x10;
|
||||||
for(j = 0; j < 5; j++) {
|
for(j = 0; j < 5; j++) {
|
||||||
if((value & mask) == 0x00) {
|
concat(binary_string, (value & mask) ? "1" : "0");
|
||||||
concat(binary_string, "0");
|
|
||||||
} else {
|
|
||||||
concat(binary_string, "1");
|
|
||||||
}
|
|
||||||
mask = mask >> 1;
|
mask = mask >> 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1924,20 +1829,20 @@ int rss_binary_string(struct zint_symbol *symbol, char source[], char binary_str
|
|||||||
concat(binary_string, padstring);
|
concat(binary_string, padstring);
|
||||||
|
|
||||||
/* Patch variable length symbol bit field */
|
/* Patch variable length symbol bit field */
|
||||||
d1 = ((strlen(binary_string) / 12) + 1) % 2;
|
d1 = ((strlen(binary_string) / 12) + 1) & 1;
|
||||||
if(strlen(binary_string) <= 156) { d2 = 0; } else { d2 = 1; }
|
if(strlen(binary_string) <= 156) { d2 = 0; } else { d2 = 1; }
|
||||||
|
|
||||||
if(encoding_method == 1) {
|
if(encoding_method == 1) {
|
||||||
if(d1 == 0) { binary_string[2] = '0'; } else { binary_string[2] = '1'; }
|
binary_string[2] = d1 ? '1' : '0';
|
||||||
if(d2 == 0) { binary_string[3] = '0'; } else { binary_string[3] = '1'; }
|
binary_string[3] = d2 ? '1' : '0';
|
||||||
}
|
}
|
||||||
if(encoding_method == 2) {
|
if(encoding_method == 2) {
|
||||||
if(d1 == 0) { binary_string[3] = '0'; } else { binary_string[3] = '1'; }
|
binary_string[3] = d1 ? '1' : '0';
|
||||||
if(d2 == 0) { binary_string[4] = '0'; } else { binary_string[4] = '1'; }
|
binary_string[4] = d2 ? '1' : '0';
|
||||||
}
|
}
|
||||||
if((encoding_method == 5) || (encoding_method == 6)) {
|
if((encoding_method == 5) || (encoding_method == 6)) {
|
||||||
if(d1 == 0) { binary_string[6] = '0'; } else { binary_string[6] = '1'; }
|
binary_string[6] = d1 ? '1' : '0';
|
||||||
if(d2 == 0) { binary_string[7] = '0'; } else { binary_string[7] = '1'; }
|
binary_string[7] = d2 ? '1' : '0';
|
||||||
}
|
}
|
||||||
if(debug) printf("Resultant binary = %s\n", binary_string);
|
if(debug) printf("Resultant binary = %s\n", binary_string);
|
||||||
if(debug) printf("\tLength: %d\n", (int)strlen(binary_string));
|
if(debug) printf("\tLength: %d\n", (int)strlen(binary_string));
|
||||||
@ -2070,7 +1975,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
check_widths[7] = widths[3];
|
check_widths[7] = widths[3];
|
||||||
|
|
||||||
/* Initialise element array */
|
/* Initialise element array */
|
||||||
pattern_width = ((((data_chars + 1) / 2) + ((data_chars + 1) % 2)) * 5) + ((data_chars + 1) * 8) + 4;
|
pattern_width = ((((data_chars + 1) / 2) + ((data_chars + 1) & 1)) * 5) + ((data_chars + 1) * 8) + 4;
|
||||||
for(i = 0; i < pattern_width; i++) {
|
for(i = 0; i < pattern_width; i++) {
|
||||||
elements[i] = 0;
|
elements[i] = 0;
|
||||||
}
|
}
|
||||||
@ -2081,8 +1986,8 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
elements[pattern_width - 1] = 1;
|
elements[pattern_width - 1] = 1;
|
||||||
|
|
||||||
/* Put finder patterns in element array */
|
/* Put finder patterns in element array */
|
||||||
for(i = 0; i < (((data_chars + 1) / 2) + ((data_chars + 1) % 2)); i++) {
|
for(i = 0; i < (((data_chars + 1) / 2) + ((data_chars + 1) & 1)); i++) {
|
||||||
k = ((((((data_chars + 1) - 2) / 2) + ((data_chars + 1) % 2)) - 1) * 11) + i;
|
k = ((((((data_chars + 1) - 2) / 2) + ((data_chars + 1) & 1)) - 1) * 11) + i;
|
||||||
for(j = 0; j < 5; j++) {
|
for(j = 0; j < 5; j++) {
|
||||||
elements[(21 * i) + j + 10] = finder_pattern_exp[((finder_sequence[k] - 1) * 5) + j];
|
elements[(21 * i) + j + 10] = finder_pattern_exp[((finder_sequence[k] - 1) * 5) + j];
|
||||||
}
|
}
|
||||||
@ -2194,9 +2099,9 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
/* Row Data */
|
/* Row Data */
|
||||||
reader = 0;
|
reader = 0;
|
||||||
do {
|
do {
|
||||||
if(((symbol->option_2 % 2 == 1) || (current_row % 2 == 1)) ||
|
if(((symbol->option_2 & 1) || (current_row & 1)) ||
|
||||||
((current_row == stack_rows) && (codeblocks != (current_row * symbol->option_2)) &&
|
((current_row == stack_rows) && (codeblocks != (current_row * symbol->option_2)) &&
|
||||||
((((current_row * symbol->option_2) - codeblocks) % 2) == 1) )) {
|
(((current_row * symbol->option_2) - codeblocks) & 1))) {
|
||||||
/* left to right */
|
/* left to right */
|
||||||
left_to_right = 1;
|
left_to_right = 1;
|
||||||
i = 2 + (current_block * 21);
|
i = 2 + (current_block * 21);
|
||||||
@ -2234,14 +2139,10 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
sub_elements[elements_in_sub + 1] = 1;
|
sub_elements[elements_in_sub + 1] = 1;
|
||||||
elements_in_sub += 2;
|
elements_in_sub += 2;
|
||||||
|
|
||||||
if(current_row % 2 == 1) {
|
latch = current_row & 1 ? '0' : '1';
|
||||||
latch = '0';
|
|
||||||
} else {
|
|
||||||
latch = '1';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((current_row == stack_rows) && (codeblocks != (current_row * symbol->option_2)) &&
|
if ((current_row == stack_rows) && (codeblocks != (current_row * symbol->option_2)) &&
|
||||||
((((current_row * symbol->option_2) - codeblocks) % 2) == 1) ) {
|
(((current_row * symbol->option_2) - codeblocks) & 1) ) {
|
||||||
/* Special case bottom row */
|
/* Special case bottom row */
|
||||||
special_case_row = 1;
|
special_case_row = 1;
|
||||||
sub_elements[0] = 2;
|
sub_elements[0] = 2;
|
||||||
@ -2279,11 +2180,7 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
symbol->row_height[symbol->rows - 1] = 1;
|
symbol->row_height[symbol->rows - 1] = 1;
|
||||||
/* finder bar adjustment */
|
/* finder bar adjustment */
|
||||||
for(j = 0; j < reader; j++) {
|
for(j = 0; j < reader; j++) {
|
||||||
if(special_case_row == 0) {
|
k = (49 * j) + (special_case_row ? 19 : 18);
|
||||||
k = (49 * j) + 18;
|
|
||||||
} else {
|
|
||||||
k = (49 * j) + 19;
|
|
||||||
}
|
|
||||||
if(left_to_right) {
|
if(left_to_right) {
|
||||||
for(i = 0; i < 15; i++) {
|
for(i = 0; i < 15; i++) {
|
||||||
if((!(module_is_set(symbol, symbol->rows, i + k - 1))) &&
|
if((!(module_is_set(symbol, symbol->rows, i + k - 1))) &&
|
||||||
|
@ -240,7 +240,7 @@ int svg_plot(struct zint_symbol *symbol)
|
|||||||
dy = my - 1.0 + yoffset;
|
dy = my - 1.0 + yoffset;
|
||||||
ey = my - 0.5 + yoffset;
|
ey = my - 0.5 + yoffset;
|
||||||
fy = my + 0.5 + yoffset;
|
fy = my + 0.5 + yoffset;
|
||||||
if(r % 2 == 1) {
|
if(r & 1) {
|
||||||
mx = (2.46 * i) + 1.23 + 1.23;
|
mx = (2.46 * i) + 1.23 + 1.23;
|
||||||
} else {
|
} else {
|
||||||
mx = (2.46 * i) + 1.23;
|
mx = (2.46 * i) + 1.23;
|
||||||
|
@ -114,7 +114,7 @@ int telepen_num(struct zint_symbol *symbol, unsigned char source[], int src_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add a leading zero if required */
|
/* Add a leading zero if required */
|
||||||
if ((temp_length % 2) != 0)
|
if (temp_length & 1)
|
||||||
{
|
{
|
||||||
memmove(temp + 1, temp, temp_length);
|
memmove(temp + 1, temp, temp_length);
|
||||||
temp[0] = '0';
|
temp[0] = '0';
|
||||||
|
@ -49,12 +49,10 @@ char upc_check(char source[])
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
for (i = 0; i < strlen(source); i++)
|
for (i = 0; i < strlen(source); i++) {
|
||||||
{
|
|
||||||
count += ctoi(source[i]);
|
count += ctoi(source[i]);
|
||||||
|
|
||||||
if ((i%2) == 0)
|
if (!(i & 1)) {
|
||||||
{
|
|
||||||
count += 2 * (ctoi(source[i]));
|
count += 2 * (ctoi(source[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,12 +288,10 @@ char ean_check(char source[])
|
|||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
h = strlen(source);
|
h = strlen(source);
|
||||||
for (i = h - 1; i >= 0; i--)
|
for (i = h - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
count += ctoi(source[i]);
|
count += ctoi(source[i]);
|
||||||
|
|
||||||
if (!((i%2) == 0))
|
if (i & 1) {
|
||||||
{
|
|
||||||
count += 2 * ctoi(source[i]);
|
count += 2 * ctoi(source[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user