mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Update PZN to new (as of 2013) PZN-8 standard
Bug fix by Milton Neil
This commit is contained in:
parent
726fb64c02
commit
b2123f78a3
@ -293,10 +293,10 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length
|
|||||||
|
|
||||||
int i, error_number, zeroes;
|
int i, error_number, zeroes;
|
||||||
unsigned int count, check_digit;
|
unsigned int count, check_digit;
|
||||||
char localstr[10];
|
char localstr[11];
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
if (length > 6) {
|
if (length > 7) {
|
||||||
strcpy(symbol->errtxt, "Input wrong length (C25)");
|
strcpy(symbol->errtxt, "Input wrong length (C25)");
|
||||||
return ZINT_ERROR_TOO_LONG;
|
return ZINT_ERROR_TOO_LONG;
|
||||||
}
|
}
|
||||||
@ -307,22 +307,22 @@ int pharmazentral(struct zint_symbol *symbol, unsigned char source[], int length
|
|||||||
}
|
}
|
||||||
|
|
||||||
localstr[0] = '-';
|
localstr[0] = '-';
|
||||||
zeroes = 6 - length + 1;
|
zeroes = 7 - length + 1;
|
||||||
for (i = 1; i < zeroes; i++)
|
for (i = 1; i < zeroes; i++)
|
||||||
localstr[i] = '0';
|
localstr[i] = '0';
|
||||||
strcpy(localstr + zeroes, (char *) source);
|
strcpy(localstr + zeroes, (char *) source);
|
||||||
|
|
||||||
for (i = 1; i < 7; i++) {
|
for (i = 1; i < 8; i++) {
|
||||||
count += (i + 1) * ctoi(localstr[i]);
|
count += i * ctoi(localstr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_digit = count % 11;
|
check_digit = count % 11;
|
||||||
if (check_digit == 11) {
|
if (check_digit == 11) {
|
||||||
check_digit = 0;
|
check_digit = 0;
|
||||||
}
|
}
|
||||||
localstr[7] = itoc(check_digit);
|
localstr[8] = itoc(check_digit);
|
||||||
localstr[8] = '\0';
|
localstr[9] = '\0';
|
||||||
if (localstr[7] == 'A') {
|
if (localstr[8] == 'A') {
|
||||||
strcpy(symbol->errtxt, "Invalid PZN Data (C27)");
|
strcpy(symbol->errtxt, "Invalid PZN Data (C27)");
|
||||||
return ZINT_ERROR_INVALID_DATA;
|
return ZINT_ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user