Used to ensure that an AI component conforms to a PPTT format, where PP and TT have equal width.
56{
57
58
59#define P(i) data[i]
60#define T(i) data[data_len / 2 + i]
61
62
63 size_t pos, i;
64 int pieceiszero, totaliszero, compare;
65
66 assert(data);
67
68
69
70
71
72 for (pos = 0; pos < data_len; pos++)
76 pos,
77 1
78 );
79
80
81
82
83
87 0,
88 data_len
89 );
90
91
92
93
94
95
96 pieceiszero = totaliszero = 1;
97 compare = 0;
98 for (i = 0; i < data_len / 2; i++) {
99 if (pieceiszero && P(i) != '0') pieceiszero = 0;
100 if (totaliszero && T(i) != '0') totaliszero = 0;
101 if (!compare && P(i) != T(i)) compare = P(i) < T(i) ? -1 : 1;
102 }
103
104
105
106
107
111 pieceiszero ? 0 : data_len / 2,
112 data_len / 2
113 );
114
115
116
117
118
122 0,
123 data_len
124 );
125
127
128}
#define GS1_LINTER_UNLIKELY(x)
Implementation may provide hint to the compiler that the expression is likely to be false.
Definition gs1syntaxdictionary-utils.h:76
#define GS1_LINTER_RETURN_ERROR(error, position, length)
Return from a linter indicating that a problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:103
#define GS1_LINTER_RETURN_OK
Return from a linter indicating that no problem was detected with the given data.
Definition gs1syntaxdictionary-utils.h:88
@ GS1_LINTER_PIECE_NUMBER_EXCEEDS_TOTAL
The piece number must not exceed the piece total.
Definition gs1syntaxdictionary.h:121
@ GS1_LINTER_ZERO_PIECE_NUMBER
The piece number must not have a value of zero.
Definition gs1syntaxdictionary.h:119
@ GS1_LINTER_INVALID_LENGTH_FOR_PIECE_OF_TOTAL
The piece with total must have an even length, having equal-length components.
Definition gs1syntaxdictionary.h:118
@ GS1_LINTER_ZERO_TOTAL_PIECES
The piece total must not have a value of zero.
Definition gs1syntaxdictionary.h:120
@ GS1_LINTER_NON_DIGIT_CHARACTER
A non-digit character was found where a digit is expected.
Definition gs1syntaxdictionary.h:78