mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-09 13:41:59 -04:00
C25/DBAR: use new func gs1_check_digit() for common GS1 check digit calc
CODE11/CODE39/EXCODE39/CODE93/PZN/CHANNEL/VIN/DBAR/UPCEAN: fuller error messages DATAMATRIX: look_ahead_test debug counts DBAR: consolidate option_2 cols_per_row CMakeLists.txt: restore -fno-var-tracking-assignments for gcc no DEBUG overall: suppress various warnings on various configs testcommon.c: clean-up
This commit is contained in:
parent
33ebcea30c
commit
52c00e59ba
30 changed files with 739 additions and 715 deletions
|
@ -1386,3 +1386,17 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
|
|||
/* the character '[' in the reduced string refers to the FNC1 character */
|
||||
return error_value;
|
||||
}
|
||||
|
||||
/* Helper to return standard GS1 check digit (GS1 General Specifications 7.9.1) */
|
||||
INTERNAL char gs1_check_digit(const unsigned char source[], const int length) {
|
||||
int i;
|
||||
int count = 0;
|
||||
int factor = length & 1 ? 3 : 1;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
count += factor * ctoi(source[i]);
|
||||
factor = factor == 1 ? 3 : 1;
|
||||
}
|
||||
|
||||
return itoc((10 - (count % 10)) % 10);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue