Used to ensure that an AI component conforms to a "`<pos>/<end>`" format for variable width <pos>
and <end>
.
54{
55
56
57#define P(i) data[i]
58#define E(i) data[i + pos + 1]
59
60
61 size_t pos, len, slash_pos;
62
63 assert(data);
64
65
66
67
68
69 for (pos = 0; data[pos] >= '0' && data[pos] <= '9'; pos++);
70
71
72
73
74
76 while (data[pos]) pos++;
79 0,
80 pos
81 );
82 }
83
84 slash_pos = pos;
85
86
87
88
89
90 for (pos++; data[pos]; pos++)
92 while (data[pos]) pos++;
95 0,
96 pos
97 );
98 }
99
100 len = pos;
101
102
103
104
108 0,
109 len
110 );
111
112 pos = slash_pos;
113
114
115
116
117
121 0,
122 pos
123 );
124
125
126
127
128
132 pos + 1,
133 len - pos - 1
134 );
135
136
137
138
139
140 if (pos == len - pos - 1) {
141 size_t i;
142 int compare = 0;
143 for (i = 0; i < pos && !compare; i++)
144 if (P(i) != E(i))
145 compare = P(i) < E(i) ? -1 : 1;
149 0,
150 len
151 );
153
156 0,
157 len
158 );
159
161
162}
#define GS1_LINTER_UNLIKELY(x)
Implemention 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_ILLEGAL_ZERO_PREFIX
A zero prefix is not permitted.
Definition gs1syntaxdictionary.h:94
@ GS1_LINTER_POSITION_IN_SEQUENCE_MALFORMED
The data must have the format "<pos>/<end>".
Definition gs1syntaxdictionary.h:189
@ GS1_LINTER_POSITION_EXCEEDS_END
The position number must not exceed the end number.
Definition gs1syntaxdictionary.h:190