From ba3617fa631bcc1c6bd4ceb4c17341f4d977186b Mon Sep 17 00:00:00 2001 From: Terry Burton Date: Sun, 13 Oct 2024 19:21:49 +0100 Subject: [PATCH] Annotate stubs as deprecated --- src/gs1syntaxdictionary-utils.h | 15 +++++ src/gs1syntaxdictionary.c | 108 +++++++++++++++++++------------- src/gs1syntaxdictionary.h | 9 +-- src/lint__stubs.c | 7 --- 4 files changed, 86 insertions(+), 53 deletions(-) diff --git a/src/gs1syntaxdictionary-utils.h b/src/gs1syntaxdictionary-utils.h index e68f0e9..8cd98bb 100644 --- a/src/gs1syntaxdictionary-utils.h +++ b/src/gs1syntaxdictionary-utils.h @@ -36,6 +36,21 @@ #include +#if defined(__clang__) +# define DIAG_PUSH _Pragma("clang diagnostic push") +# define DIAG_POP _Pragma("clang diagnostic pop") +# define DIAG_DISABLE_DEPRECATED_DECLARATIONS _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#elif defined(__GNUC__) +# define DIAG_PUSH _Pragma("GCC diagnostic push") +# define DIAG_POP _Pragma("GCC diagnostic pop") +# define DIAG_DISABLE_DEPRECATED_DECLARATIONS _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#elif defined(_MSC_VER) +# define DIAG_PUSH __pragma(warning(push)) +# define DIAG_POP __pragma(warning(pop)) +# define DIAG_DISABLE_DEPRECATED_DECLARATIONS __pragma(warning(disable: 4996)) +#endif + + /** * @brief Return from a linter indicating that no problem was detected with the * given data. diff --git a/src/gs1syntaxdictionary.c b/src/gs1syntaxdictionary.c index fca60d4..18342fb 100644 --- a/src/gs1syntaxdictionary.c +++ b/src/gs1syntaxdictionary.c @@ -19,6 +19,7 @@ #include #include "gs1syntaxdictionary.h" +#include "gs1syntaxdictionary-utils.h" struct name_function_s { @@ -26,51 +27,74 @@ struct name_function_s { gs1_linter_t fn; }; + +#define ENT(x) { .name = #x, .fn = gs1_lint_##x } +#define DEP(x) \ +DIAG_PUSH \ +DIAG_DISABLE_DEPRECATED_DECLARATIONS \ +ENT(x) \ +DIAG_POP + +/* GCC has flaky support for pragmas within expressions */ +#if defined(__GNUC__) && !defined(__clang__) + #undef DEP + #define DEP(x) ENT(x) + DIAG_PUSH + DIAG_DISABLE_DEPRECATED_DECLARATIONS +#endif + const struct name_function_s name_function_map[] = { - { .name = "couponcode", .fn = gs1_lint_couponcode }, - { .name = "couponposoffer", .fn = gs1_lint_couponposoffer }, - { .name = "cset39", .fn = gs1_lint_cset39 }, - { .name = "cset64", .fn = gs1_lint_cset64 }, - { .name = "cset82", .fn = gs1_lint_cset82 }, - { .name = "csetnumeric", .fn = gs1_lint_csetnumeric }, - { .name = "csum", .fn = gs1_lint_csum }, - { .name = "csumalpha", .fn = gs1_lint_csumalpha }, - { .name = "hasnondigit", .fn = gs1_lint_hasnondigit }, - { .name = "hh", .fn = gs1_lint_hh }, - { .name = "hhmi", .fn = gs1_lint_hhmi }, - { .name = "hhmm", .fn = gs1_lint_hhmm }, // Stub - { .name = "hyphen", .fn = gs1_lint_hyphen }, - { .name = "iban", .fn = gs1_lint_iban }, - { .name = "importeridx", .fn = gs1_lint_importeridx }, - { .name = "iso3166", .fn = gs1_lint_iso3166 }, - { .name = "iso3166999", .fn = gs1_lint_iso3166999 }, - { .name = "iso3166alpha2", .fn = gs1_lint_iso3166alpha2 }, - { .name = "iso3166list", .fn = gs1_lint_iso3166list }, // Stub - { .name = "iso4217", .fn = gs1_lint_iso4217 }, - { .name = "iso5218", .fn = gs1_lint_iso5218 }, - { .name = "key", .fn = gs1_lint_key }, - { .name = "latitude", .fn = gs1_lint_latitude }, - { .name = "longitude", .fn = gs1_lint_longitude }, - { .name = "mediatype", .fn = gs1_lint_mediatype }, - { .name = "mi", .fn = gs1_lint_mi }, - { .name = "mmoptss", .fn = gs1_lint_mmoptss }, // Stub - { .name = "nonzero", .fn = gs1_lint_nonzero }, - { .name = "nozeroprefix", .fn = gs1_lint_nozeroprefix }, - { .name = "packagetype", .fn = gs1_lint_packagetype }, - { .name = "pcenc", .fn = gs1_lint_pcenc }, - { .name = "pieceoftotal", .fn = gs1_lint_pieceoftotal }, - { .name = "posinseqslash", .fn = gs1_lint_posinseqslash }, - { .name = "ss", .fn = gs1_lint_ss }, - { .name = "winding", .fn = gs1_lint_winding }, - { .name = "yesno", .fn = gs1_lint_yesno }, - { .name = "yymmd0", .fn = gs1_lint_yymmd0 }, - { .name = "yymmdd", .fn = gs1_lint_yymmdd }, - { .name = "yymmddhh", .fn = gs1_lint_yymmddhh }, // Stub - { .name = "yyyymmd0", .fn = gs1_lint_yyyymmd0 }, - { .name = "yyyymmdd", .fn = gs1_lint_yyyymmdd }, - { .name = "zero", .fn = gs1_lint_zero }, + ENT(couponcode), + ENT(couponposoffer), + ENT(cset39), + ENT(cset64), + ENT(cset82), + ENT(csetnumeric), + ENT(csum), + ENT(csumalpha), + ENT(hasnondigit), + ENT(hh), + ENT(hhmi), + DEP(hhmm), + ENT(hyphen), + ENT(iban), + ENT(importeridx), + ENT(iso3166), + ENT(iso3166999), + ENT(iso3166alpha2), + DEP(iso3166list), + ENT(iso4217), + ENT(iso5218), + ENT(key), + ENT(latitude), + ENT(longitude), + ENT(mediatype), + ENT(mi), + DEP(mmoptss), + ENT(nonzero), + ENT(nozeroprefix), + ENT(packagetype), + ENT(pcenc), + ENT(pieceoftotal), + ENT(posinseqslash), + ENT(ss), + ENT(winding), + ENT(yesno), + ENT(yymmd0), + ENT(yymmdd), + DEP(yymmddhh), + ENT(yyyymmd0), + ENT(yyyymmdd), + ENT(zero), }; +/* Flaky GCC */ +#if defined(__GNUC__) && !defined(__clang__) + DIAG_POP +#endif + +#undef ENT +#undef DEP /* diff --git a/src/gs1syntaxdictionary.h b/src/gs1syntaxdictionary.h index cdb1a2d..1cb433a 100644 --- a/src/gs1syntaxdictionary.h +++ b/src/gs1syntaxdictionary.h @@ -234,14 +234,12 @@ GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_csumalpha(const char *data, si GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hasnondigit(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hh(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hhmi(const char *data, size_t *err_pos, size_t *err_len); -GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hhmm(const char *data, size_t *err_pos, size_t *err_len); // Stub GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_hyphen(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iban(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_importeridx(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166999(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166alpha2(const char *data, size_t *err_pos, size_t *err_len); -GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso3166list(const char *data, size_t *err_pos, size_t *err_len); // Stub GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso4217(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_iso5218(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_key(const char *data, size_t *err_pos, size_t *err_len); @@ -249,7 +247,6 @@ GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_latitude(const char *data, siz GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_longitude(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_mediatype(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_mi(const char *data, size_t *err_pos, size_t *err_len); -GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_mmoptss(const char *data, size_t *err_pos, size_t *err_len); // Stub GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_nonzero(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_nozeroprefix(const char *data, size_t *err_pos, size_t *err_len); 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 GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yesno(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmd0(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmdd(const char *data, size_t *err_pos, size_t *err_len); -GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yymmddhh(const char *data, size_t *err_pos, size_t *err_len); // Stub GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yyyymmd0(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_yyyymmdd(const char *data, size_t *err_pos, size_t *err_len); GS1_SYNTAX_DICTIONARY_API gs1_lint_err_t gs1_lint_zero(const char *data, size_t *err_pos, size_t *err_len); +GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_hhmm(const char *data, size_t *err_pos, size_t *err_len); +GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_iso3166list(const char *data, size_t *err_pos, size_t *err_len); +GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_mmoptss(const char *data, size_t *err_pos, size_t *err_len); +GS1_SYNTAX_DICTIONARY_API DEPRECATED gs1_lint_err_t gs1_lint_yymmddhh(const char *data, size_t *err_pos, size_t *err_len); + GS1_SYNTAX_DICTIONARY_API gs1_linter_t gs1_linter_from_name(const char *name); #ifdef __cplusplus diff --git a/src/lint__stubs.c b/src/lint__stubs.c index a4241a9..9229db2 100644 --- a/src/lint__stubs.c +++ b/src/lint__stubs.c @@ -16,13 +16,6 @@ * */ -/** - * @file lint__stubs.c - * - * @brief Unused linter stub functions. - * - */ - #include #include "gs1syntaxdictionary.h"