mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Fixed 'FNC1 in Code Set C' bug in EAN128
This commit is contained in:
parent
31dce82f3b
commit
b6ac39172b
@ -615,13 +615,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
list[0][indexliste]++;
|
list[0][indexliste]++;
|
||||||
indexchaine++;
|
indexchaine++;
|
||||||
mode = parunmodd(reduced[indexchaine], 0x00);
|
mode = parunmodd(reduced[indexchaine], 0x00);
|
||||||
if(reduced[indexchaine] == '[') {
|
if(reduced[indexchaine] == '[') { mode = ABORC; }
|
||||||
if(indexchaine % 2 == 0) {
|
|
||||||
mode = ABORC;
|
|
||||||
} else {
|
|
||||||
mode = AORB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
indexliste++;
|
indexliste++;
|
||||||
} while (indexchaine < strlen(reduced));
|
} while (indexchaine < strlen(reduced));
|
||||||
@ -665,6 +659,21 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We have a problem with FNC1 in Code Set C to resolve */
|
||||||
|
for(i = 0; i < read; i++) {
|
||||||
|
if((set[i] == 'C') && (reduced[i] == '[')) {
|
||||||
|
int c_count;
|
||||||
|
|
||||||
|
c_count = 0;
|
||||||
|
for(j = 0; j < i; j++) {
|
||||||
|
if(set[j] == 'C') { c_count++; } else { c_count = 0; }
|
||||||
|
}
|
||||||
|
if((c_count % 2) == 1) {
|
||||||
|
set[i - 1] = 'B';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Now we can calculate how long the barcode is going to be - and stop it from
|
/* Now we can calculate how long the barcode is going to be - and stop it from
|
||||||
being too long */
|
being too long */
|
||||||
last_set = ' ';
|
last_set = ' ';
|
||||||
@ -736,7 +745,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((set[i] == 'a') || (set[i] == 'b')) {
|
if((set[read] == 'a') || (set[read] == 'b')) {
|
||||||
/* Insert shift character */
|
/* Insert shift character */
|
||||||
concat(dest, C128Table[98]);
|
concat(dest, C128Table[98]);
|
||||||
values[bar_characters] = 98;
|
values[bar_characters] = 98;
|
||||||
@ -746,12 +755,16 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
if(reduced[read] != '[') {
|
if(reduced[read] != '[') {
|
||||||
switch(set[read])
|
switch(set[read])
|
||||||
{ /* Encode data characters */
|
{ /* Encode data characters */
|
||||||
case 'A': c128_set_a(reduced[read], dest, values, &bar_characters, 0x00);
|
case 'A':
|
||||||
read++;
|
case 'a':
|
||||||
break;
|
c128_set_a(reduced[read], dest, values, &bar_characters, 0x00);
|
||||||
case 'B': c128_set_b(reduced[read], dest, values, &bar_characters);
|
read++;
|
||||||
read++;
|
break;
|
||||||
break;
|
case 'B':
|
||||||
|
case 'b':
|
||||||
|
c128_set_b(reduced[read], dest, values, &bar_characters);
|
||||||
|
read++;
|
||||||
|
break;
|
||||||
case 'C': c128_set_c(reduced[read], reduced[read + 1], dest, values, &bar_characters);
|
case 'C': c128_set_c(reduced[read], reduced[read + 1], dest, values, &bar_characters);
|
||||||
read += 2;
|
read += 2;
|
||||||
break;
|
break;
|
||||||
@ -795,6 +808,11 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
bar_characters++;
|
bar_characters++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*for(i = 0; i < bar_characters; i++) {
|
||||||
|
printf("[%d] ", values[i]);
|
||||||
|
}
|
||||||
|
printf("\n");*/
|
||||||
|
|
||||||
/* check digit calculation */
|
/* check digit calculation */
|
||||||
total_sum = 0;
|
total_sum = 0;
|
||||||
for(i = 0; i < bar_characters; i++)
|
for(i = 0; i < bar_characters; i++)
|
||||||
@ -807,9 +825,13 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
total_sum += values[i];
|
total_sum += values[i];
|
||||||
}
|
}
|
||||||
concat(dest, C128Table[total_sum%103]);
|
concat(dest, C128Table[total_sum%103]);
|
||||||
|
values[bar_characters] = total_sum % 103;
|
||||||
|
bar_characters++;
|
||||||
|
|
||||||
/* Stop character */
|
/* Stop character */
|
||||||
concat(dest, C128Table[106]);
|
concat(dest, C128Table[106]);
|
||||||
|
values[bar_characters] = 106;
|
||||||
|
bar_characters++;
|
||||||
expand(symbol, dest);
|
expand(symbol, dest);
|
||||||
|
|
||||||
/* Add the separator pattern for composite symbols */
|
/* Add the separator pattern for composite symbols */
|
||||||
|
Loading…
Reference in New Issue
Block a user