Skip to content

Commit c6067f1

Browse files
committed
Sync with Syntax Dictionary
1 parent 62b9988 commit c6067f1

File tree

12 files changed

+125
-209
lines changed

12 files changed

+125
-209
lines changed

src/c-lib/gs1encoders-test.vcxproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,19 @@
184184
<ClCompile Include="syntax\lint_hasnondigit.c" />
185185
<ClCompile Include="syntax\lint_hh.c" />
186186
<ClCompile Include="syntax\lint_hhmi.c" />
187-
<ClCompile Include="syntax\lint_hhmm.c" />
188187
<ClCompile Include="syntax\lint_hyphen.c" />
189188
<ClCompile Include="syntax\lint_iban.c" />
190189
<ClCompile Include="syntax\lint_importeridx.c" />
191190
<ClCompile Include="syntax\lint_iso3166.c" />
192191
<ClCompile Include="syntax\lint_iso3166999.c" />
193192
<ClCompile Include="syntax\lint_iso3166alpha2.c" />
194-
<ClCompile Include="syntax\lint_iso3166list.c" />
195193
<ClCompile Include="syntax\lint_iso4217.c" />
196194
<ClCompile Include="syntax\lint_iso5218.c" />
197195
<ClCompile Include="syntax\lint_key.c" />
198196
<ClCompile Include="syntax\lint_latitude.c" />
199197
<ClCompile Include="syntax\lint_longitude.c" />
200198
<ClCompile Include="syntax\lint_mediatype.c" />
201199
<ClCompile Include="syntax\lint_mi.c" />
202-
<ClCompile Include="syntax\lint_mmoptss.c" />
203200
<ClCompile Include="syntax\lint_nonzero.c" />
204201
<ClCompile Include="syntax\lint_nozeroprefix.c" />
205202
<ClCompile Include="syntax\lint_packagetype.c" />
@@ -211,10 +208,10 @@
211208
<ClCompile Include="syntax\lint_yesno.c" />
212209
<ClCompile Include="syntax\lint_yymmd0.c" />
213210
<ClCompile Include="syntax\lint_yymmdd.c" />
214-
<ClCompile Include="syntax\lint_yymmddhh.c" />
215211
<ClCompile Include="syntax\lint_yyyymmdd.c" />
216212
<ClCompile Include="syntax\lint_yyyymmd0.c" />
217213
<ClCompile Include="syntax\lint_zero.c" />
214+
<ClCompile Include="syntax\lint__stubs.c" />
218215
</ItemGroup>
219216
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
220217
<ImportGroup Label="ExtensionTargets">

src/c-lib/gs1encoders-test.vcxproj.filters

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@
107107
<ClCompile Include="syntax\lint_hhmi.c">
108108
<Filter>Source Files</Filter>
109109
</ClCompile>
110-
<ClCompile Include="syntax\lint_hhmm.c">
111-
<Filter>Source Files</Filter>
112-
</ClCompile>
113110
<ClCompile Include="syntax\lint_hyphen.c">
114111
<Filter>Source Files</Filter>
115112
</ClCompile>
@@ -128,9 +125,6 @@
128125
<ClCompile Include="syntax\lint_iso3166alpha2.c">
129126
<Filter>Source Files</Filter>
130127
</ClCompile>
131-
<ClCompile Include="syntax\lint_iso3166list.c">
132-
<Filter>Source Files</Filter>
133-
</ClCompile>
134128
<ClCompile Include="syntax\lint_iso4217.c">
135129
<Filter>Source Files</Filter>
136130
</ClCompile>
@@ -152,9 +146,6 @@
152146
<ClCompile Include="syntax\lint_mi.c">
153147
<Filter>Source Files</Filter>
154148
</ClCompile>
155-
<ClCompile Include="syntax\lint_mmoptss.c">
156-
<Filter>Source Files</Filter>
157-
</ClCompile>
158149
<ClCompile Include="syntax\lint_nonzero.c">
159150
<Filter>Source Files</Filter>
160151
</ClCompile>
@@ -188,9 +179,6 @@
188179
<ClCompile Include="syntax\lint_yymmdd.c">
189180
<Filter>Source Files</Filter>
190181
</ClCompile>
191-
<ClCompile Include="syntax\lint_yymmddhh.c">
192-
<Filter>Source Files</Filter>
193-
</ClCompile>
194182
<ClCompile Include="syntax\lint_yyyymmd0.c">
195183
<Filter>Source Files</Filter>
196184
</ClCompile>
@@ -200,5 +188,8 @@
200188
<ClCompile Include="syntax\lint_zero.c">
201189
<Filter>Source Files</Filter>
202190
</ClCompile>
191+
<ClCompile Include="syntax\lint__stubs.c">
192+
<Filter>Source Files</Filter>
193+
</ClCompile>
203194
</ItemGroup>
204195
</Project>

src/c-lib/gs1encoders.vcxproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,22 +153,19 @@
153153
<ClCompile Include="syntax\lint_hasnondigit.c" />
154154
<ClCompile Include="syntax\lint_hh.c" />
155155
<ClCompile Include="syntax\lint_hhmi.c" />
156-
<ClCompile Include="syntax\lint_hhmm.c" />
157156
<ClCompile Include="syntax\lint_hyphen.c" />
158157
<ClCompile Include="syntax\lint_iban.c" />
159158
<ClCompile Include="syntax\lint_importeridx.c" />
160159
<ClCompile Include="syntax\lint_iso3166.c" />
161160
<ClCompile Include="syntax\lint_iso3166999.c" />
162161
<ClCompile Include="syntax\lint_iso3166alpha2.c" />
163-
<ClCompile Include="syntax\lint_iso3166list.c" />
164162
<ClCompile Include="syntax\lint_iso4217.c" />
165163
<ClCompile Include="syntax\lint_iso5218.c" />
166164
<ClCompile Include="syntax\lint_key.c" />
167165
<ClCompile Include="syntax\lint_latitude.c" />
168166
<ClCompile Include="syntax\lint_longitude.c" />
169167
<ClCompile Include="syntax\lint_mediatype.c" />
170168
<ClCompile Include="syntax\lint_mi.c" />
171-
<ClCompile Include="syntax\lint_mmoptss.c" />
172169
<ClCompile Include="syntax\lint_nonzero.c" />
173170
<ClCompile Include="syntax\lint_nozeroprefix.c" />
174171
<ClCompile Include="syntax\lint_packagetype.c" />
@@ -180,10 +177,10 @@
180177
<ClCompile Include="syntax\lint_yesno.c" />
181178
<ClCompile Include="syntax\lint_yymmd0.c" />
182179
<ClCompile Include="syntax\lint_yymmdd.c" />
183-
<ClCompile Include="syntax\lint_yymmddhh.c" />
184180
<ClCompile Include="syntax\lint_yyyymmd0.c" />
185181
<ClCompile Include="syntax\lint_yyyymmdd.c" />
186182
<ClCompile Include="syntax\lint_zero.c" />
183+
<ClCompile Include="syntax\lint__stubs.c" />
187184
</ItemGroup>
188185
<ItemGroup>
189186
<ClInclude Include="ai.h" />

src/c-lib/gs1encoders.vcxproj.filters

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@
6666
<ClCompile Include="syntax\lint_hhmi.c">
6767
<Filter>Source Files</Filter>
6868
</ClCompile>
69-
<ClCompile Include="syntax\lint_hhmm.c">
70-
<Filter>Source Files</Filter>
71-
</ClCompile>
7269
<ClCompile Include="syntax\lint_hyphen.c">
7370
<Filter>Source Files</Filter>
7471
</ClCompile>
@@ -87,9 +84,6 @@
8784
<ClCompile Include="syntax\lint_iso3166alpha2.c">
8885
<Filter>Source Files</Filter>
8986
</ClCompile>
90-
<ClCompile Include="syntax\lint_iso3166list.c">
91-
<Filter>Source Files</Filter>
92-
</ClCompile>
9387
<ClCompile Include="syntax\lint_iso4217.c">
9488
<Filter>Source Files</Filter>
9589
</ClCompile>
@@ -111,9 +105,6 @@
111105
<ClCompile Include="syntax\lint_mi.c">
112106
<Filter>Source Files</Filter>
113107
</ClCompile>
114-
<ClCompile Include="syntax\lint_mmoptss.c">
115-
<Filter>Source Files</Filter>
116-
</ClCompile>
117108
<ClCompile Include="syntax\lint_nonzero.c">
118109
<Filter>Source Files</Filter>
119110
</ClCompile>
@@ -147,9 +138,6 @@
147138
<ClCompile Include="syntax\lint_yymmdd.c">
148139
<Filter>Source Files</Filter>
149140
</ClCompile>
150-
<ClCompile Include="syntax\lint_yymmddhh.c">
151-
<Filter>Source Files</Filter>
152-
</ClCompile>
153141
<ClCompile Include="syntax\lint_yyyymmd0.c">
154142
<Filter>Source Files</Filter>
155143
</ClCompile>
@@ -159,6 +147,9 @@
159147
<ClCompile Include="syntax\lint_zero.c">
160148
<Filter>Source Files</Filter>
161149
</ClCompile>
150+
<ClCompile Include="syntax\lint__stubs.c">
151+
<Filter>Source Files</Filter>
152+
</ClCompile>
162153
</ItemGroup>
163154
<ItemGroup>
164155
<ClInclude Include="enc-private.h">

src/c-lib/syntax/gs1syntaxdictionary-utils.h

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@
3636
#include <string.h>
3737

3838

39+
#if defined(__clang__)
40+
# define DIAG_PUSH _Pragma("clang diagnostic push")
41+
# define DIAG_POP _Pragma("clang diagnostic pop")
42+
# define DIAG_DISABLE_DEPRECATED_DECLARATIONS _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
43+
#elif defined(__GNUC__)
44+
# define DIAG_PUSH _Pragma("GCC diagnostic push")
45+
# define DIAG_POP _Pragma("GCC diagnostic pop")
46+
# define DIAG_DISABLE_DEPRECATED_DECLARATIONS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
47+
#elif defined(_MSC_VER)
48+
# define DIAG_PUSH __pragma(warning(push))
49+
# define DIAG_POP __pragma(warning(pop))
50+
# define DIAG_DISABLE_DEPRECATED_DECLARATIONS __pragma(warning(disable: 4996))
51+
#endif
52+
53+
3954
/**
4055
* @brief Return from a linter indicating that no problem was detected with the
4156
* given data.
@@ -119,24 +134,4 @@ do { \
119134
} \
120135
} while (0)
121136

122-
123-
/**
124-
* @brief Generates a stub function to replace legacy linters.
125-
*
126-
* The generated stub function is retained for API compatibility purposes only
127-
* and is no longer referenced by the Syntax Dictionary.
128-
*
129-
*/
130-
#define GS1_LINTER_STUB(linter) \
131-
GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t linter( \
132-
const char* const data, \
133-
size_t* const err_pos, \
134-
size_t* const err_len) \
135-
{ \
136-
(void)data; \
137-
(void)err_pos; \
138-
(void)err_len; \
139-
GS1_LINTER_RETURN_OK; \
140-
}
141-
142137
#endif /* GS1_SYNTAXDICTIONARY_UTILS_H */

src/c-lib/syntax/gs1syntaxdictionary.c

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,82 @@
1919
#include <string.h>
2020

2121
#include "gs1syntaxdictionary.h"
22+
#include "gs1syntaxdictionary-utils.h"
2223

2324

2425
struct name_function_s {
2526
char *name;
2627
gs1_linter_t fn;
2728
};
2829

30+
31+
#define ENT(x) { .name = #x, .fn = gs1_lint_##x }
32+
#define DEP(x) \
33+
DIAG_PUSH \
34+
DIAG_DISABLE_DEPRECATED_DECLARATIONS \
35+
ENT(x) \
36+
DIAG_POP
37+
38+
/* GCC has flaky support for pragmas within expressions */
39+
#if defined(__GNUC__) && !defined(__clang__)
40+
#undef DEP
41+
#define DEP(x) ENT(x)
42+
DIAG_PUSH
43+
DIAG_DISABLE_DEPRECATED_DECLARATIONS
44+
#endif
45+
2946
const struct name_function_s name_function_map[] = {
30-
{ .name = "couponcode", .fn = gs1_lint_couponcode },
31-
{ .name = "couponposoffer", .fn = gs1_lint_couponposoffer },
32-
{ .name = "cset39", .fn = gs1_lint_cset39 },
33-
{ .name = "cset64", .fn = gs1_lint_cset64 },
34-
{ .name = "cset82", .fn = gs1_lint_cset82 },
35-
{ .name = "csetnumeric", .fn = gs1_lint_csetnumeric },
36-
{ .name = "csum", .fn = gs1_lint_csum },
37-
{ .name = "csumalpha", .fn = gs1_lint_csumalpha },
38-
{ .name = "hasnondigit", .fn = gs1_lint_hasnondigit },
39-
{ .name = "hh", .fn = gs1_lint_hh },
40-
{ .name = "hhmi", .fn = gs1_lint_hhmi },
41-
{ .name = "hhmm", .fn = gs1_lint_hhmm }, // Stub
42-
{ .name = "hyphen", .fn = gs1_lint_hyphen },
43-
{ .name = "iban", .fn = gs1_lint_iban },
44-
{ .name = "importeridx", .fn = gs1_lint_importeridx },
45-
{ .name = "iso3166", .fn = gs1_lint_iso3166 },
46-
{ .name = "iso3166999", .fn = gs1_lint_iso3166999 },
47-
{ .name = "iso3166alpha2", .fn = gs1_lint_iso3166alpha2 },
48-
{ .name = "iso3166list", .fn = gs1_lint_iso3166list }, // Stub
49-
{ .name = "iso4217", .fn = gs1_lint_iso4217 },
50-
{ .name = "iso5218", .fn = gs1_lint_iso5218 },
51-
{ .name = "key", .fn = gs1_lint_key },
52-
{ .name = "latitude", .fn = gs1_lint_latitude },
53-
{ .name = "longitude", .fn = gs1_lint_longitude },
54-
{ .name = "mediatype", .fn = gs1_lint_mediatype },
55-
{ .name = "mi", .fn = gs1_lint_mi },
56-
{ .name = "mmoptss", .fn = gs1_lint_mmoptss }, // Stub
57-
{ .name = "nonzero", .fn = gs1_lint_nonzero },
58-
{ .name = "nozeroprefix", .fn = gs1_lint_nozeroprefix },
59-
{ .name = "packagetype", .fn = gs1_lint_packagetype },
60-
{ .name = "pcenc", .fn = gs1_lint_pcenc },
61-
{ .name = "pieceoftotal", .fn = gs1_lint_pieceoftotal },
62-
{ .name = "posinseqslash", .fn = gs1_lint_posinseqslash },
63-
{ .name = "ss", .fn = gs1_lint_ss },
64-
{ .name = "winding", .fn = gs1_lint_winding },
65-
{ .name = "yesno", .fn = gs1_lint_yesno },
66-
{ .name = "yymmd0", .fn = gs1_lint_yymmd0 },
67-
{ .name = "yymmdd", .fn = gs1_lint_yymmdd },
68-
{ .name = "yymmddhh", .fn = gs1_lint_yymmddhh }, // Stub
69-
{ .name = "yyyymmd0", .fn = gs1_lint_yyyymmd0 },
70-
{ .name = "yyyymmdd", .fn = gs1_lint_yyyymmdd },
71-
{ .name = "zero", .fn = gs1_lint_zero },
47+
ENT(couponcode),
48+
ENT(couponposoffer),
49+
ENT(cset39),
50+
ENT(cset64),
51+
ENT(cset82),
52+
ENT(csetnumeric),
53+
ENT(csum),
54+
ENT(csumalpha),
55+
ENT(hasnondigit),
56+
ENT(hh),
57+
ENT(hhmi),
58+
DEP(hhmm),
59+
ENT(hyphen),
60+
ENT(iban),
61+
ENT(importeridx),
62+
ENT(iso3166),
63+
ENT(iso3166999),
64+
ENT(iso3166alpha2),
65+
DEP(iso3166list),
66+
ENT(iso4217),
67+
ENT(iso5218),
68+
ENT(key),
69+
ENT(latitude),
70+
ENT(longitude),
71+
ENT(mediatype),
72+
ENT(mi),
73+
DEP(mmoptss),
74+
ENT(nonzero),
75+
ENT(nozeroprefix),
76+
ENT(packagetype),
77+
ENT(pcenc),
78+
ENT(pieceoftotal),
79+
ENT(posinseqslash),
80+
ENT(ss),
81+
ENT(winding),
82+
ENT(yesno),
83+
ENT(yymmd0),
84+
ENT(yymmdd),
85+
DEP(yymmddhh),
86+
ENT(yyyymmd0),
87+
ENT(yyyymmdd),
88+
ENT(zero),
7289
};
7390

91+
/* Flaky GCC */
92+
#if defined(__GNUC__) && !defined(__clang__)
93+
DIAG_POP
94+
#endif
95+
96+
#undef ENT
97+
#undef DEP
7498

7599

76100
/*

src/c-lib/syntax/gs1syntaxdictionary.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,22 +234,19 @@ GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_csumalpha(const char *data, si
234234
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hasnondigit(const char *data, size_t *err_pos, size_t *err_len);
235235
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hh(const char *data, size_t *err_pos, size_t *err_len);
236236
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hhmi(const char *data, size_t *err_pos, size_t *err_len);
237-
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hhmm(const char *data, size_t *err_pos, size_t *err_len); // Stub
238237
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hyphen(const char *data, size_t *err_pos, size_t *err_len);
239238
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iban(const char *data, size_t *err_pos, size_t *err_len);
240239
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_importeridx(const char *data, size_t *err_pos, size_t *err_len);
241240
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166(const char *data, size_t *err_pos, size_t *err_len);
242241
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166999(const char *data, size_t *err_pos, size_t *err_len);
243242
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166alpha2(const char *data, size_t *err_pos, size_t *err_len);
244-
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166list(const char *data, size_t *err_pos, size_t *err_len); // Stub
245243
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso4217(const char *data, size_t *err_pos, size_t *err_len);
246244
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso5218(const char *data, size_t *err_pos, size_t *err_len);
247245
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_key(const char *data, size_t *err_pos, size_t *err_len);
248246
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_latitude(const char *data, size_t *err_pos, size_t *err_len);
249247
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_longitude(const char *data, size_t *err_pos, size_t *err_len);
250248
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_mediatype(const char *data, size_t *err_pos, size_t *err_len);
251249
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_mi(const char *data, size_t *err_pos, size_t *err_len);
252-
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_mmoptss(const char *data, size_t *err_pos, size_t *err_len); // Stub
253250
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_nonzero(const char *data, size_t *err_pos, size_t *err_len);
254251
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_nozeroprefix(const char *data, size_t *err_pos, size_t *err_len);
255252
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_packagetype(const char *data, size_t *err_pos, size_t *err_len);
@@ -261,11 +258,15 @@ GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_winding(const char *data, size
261258
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yesno(const char *data, size_t *err_pos, size_t *err_len);
262259
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmd0(const char *data, size_t *err_pos, size_t *err_len);
263260
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmdd(const char *data, size_t *err_pos, size_t *err_len);
264-
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmddhh(const char *data, size_t *err_pos, size_t *err_len); // Stub
265261
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yyyymmd0(const char *data, size_t *err_pos, size_t *err_len);
266262
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yyyymmdd(const char *data, size_t *err_pos, size_t *err_len);
267263
GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_zero(const char *data, size_t *err_pos, size_t *err_len);
268264

265+
GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_hhmm(const char *data, size_t *err_pos, size_t *err_len);
266+
GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_iso3166list(const char *data, size_t *err_pos, size_t *err_len);
267+
GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_mmoptss(const char *data, size_t *err_pos, size_t *err_len);
268+
GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_yymmddhh(const char *data, size_t *err_pos, size_t *err_len);
269+
269270
GS1_SYNTAX_DICTIONARY_API gs1_linter_t gs1_linter_from_name(const char *name);
270271

271272
#ifdef __cplusplus

0 commit comments

Comments
 (0)