UPC/EAN, ITF14: quiet zones, addongap; raster/vector: sync code, use double

This commit is contained in:
gitlost 2020-07-15 19:00:12 +01:00
parent e90c273165
commit 2a19b883a5
55 changed files with 2917 additions and 1351 deletions

View file

@ -305,13 +305,15 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], char dest[])
}
/* EAN-2 and EAN-5 add-on codes */
static void add_on(unsigned char source[], char dest[], int mode) {
static void add_on(unsigned char source[], char dest[], int addon_gap) {
char parity[6];
unsigned int i, code_type;
/* If an add-on then append with space */
if (mode != 0) {
strcat(dest, "9");
if (addon_gap != 0) {
i = strlen(dest);
dest[i] = itoc(addon_gap);
dest[i + 1] = '\0';
}
/* Start character */
@ -704,6 +706,7 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
unsigned char local_source[20] = {0};
unsigned int latch, reader, writer, with_addon;
int error_number, i, plus_count;
int addon_gap = 0;
with_addon = FALSE;
latch = FALSE;
@ -714,7 +717,7 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
return ZINT_ERROR_TOO_LONG;
}
if (symbol->symbology != BARCODE_ISBNX) {
/* ISBN has it's own checking routine */
/* ISBN has its own checking routine */
error_number = is_sane("0123456789+", source, src_len);
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "284: Invalid characters in data");
@ -741,11 +744,6 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
}
/* Add leading zeroes */
ustrcpy(local_source, (unsigned char *) "");
if (symbol->symbology == BARCODE_ISBNX) {
to_upper(local_source);
}
ean_leading_zeroes(symbol, source, local_source);
for (reader = 0; reader < ustrlen(local_source); reader++) {
@ -774,6 +772,12 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
writer++;
}
} while (reader <= ustrlen(local_source));
if (symbol->symbology == BARCODE_UPCA || symbol->symbology == BARCODE_UPCA_CHK || symbol->symbology == BARCODE_UPCA_CC) {
addon_gap = symbol->option_2 >= 9 && symbol->option_2 <= 12 ? symbol->option_2 : 9;
} else {
addon_gap = symbol->option_2 >= 7 && symbol->option_2 <= 12 ? symbol->option_2 : 7;
}
} else {
strcpy((char*) first_part, (char*) local_source);
}
@ -894,12 +898,12 @@ INTERNAL int eanx(struct zint_symbol *symbol, unsigned char source[], int src_le
switch (ustrlen(second_part)) {
case 0: break;
case 2:
add_on(second_part, (char*) dest, 1);
add_on(second_part, (char*) dest, addon_gap);
strcat((char*) symbol->text, "+");
strcat((char*) symbol->text, (char*) second_part);
break;
case 5:
add_on(second_part, (char*) dest, 1);
add_on(second_part, (char*) dest, addon_gap);
strcat((char*) symbol->text, "+");
strcat((char*) symbol->text, (char*) second_part);
break;