From: Alan T. DeKok Date: Fri, 19 Nov 2021 20:20:52 +0000 (-0500) Subject: update use of T_TOKEN_LAST X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bf6693938f49d477a928f7ee452164e4139ac4e;p=thirdparty%2Ffreeradius-server.git update use of T_TOKEN_LAST it's not part of the enum, it's the number of elements in the enum --- diff --git a/src/lib/util/token.c b/src/lib/util/token.c index abc5da795d8..8b4a3693ebb 100644 --- a/src/lib/util/token.c +++ b/src/lib/util/token.c @@ -69,7 +69,7 @@ size_t fr_token_quotes_table_len = NUM_ELEMENTS(fr_token_quotes_table); /* * This is a hack, and has to be kept in sync with tokens.h */ -char const *fr_tokens[T_TOKEN_LAST + 1] = { +char const *fr_tokens[T_TOKEN_LAST] = { [T_INVALID] = "?", [T_EOL] = "EOL", @@ -108,8 +108,6 @@ char const *fr_tokens[T_TOKEN_LAST + 1] = { [T_SINGLE_QUOTED_STRING] = "<'STRING'>", [T_BACK_QUOTED_STRING] = "<`STRING`>", [T_SOLIDUS_QUOTED_STRING] = "", - - [T_TOKEN_LAST] = "", }; @@ -117,7 +115,7 @@ char const *fr_tokens[T_TOKEN_LAST + 1] = { * * Non-string types convert to '?' to screw ups can be identified easily */ -const char fr_token_quote[T_TOKEN_LAST + 1] = { +const char fr_token_quote[T_TOKEN_LAST] = { [ 0 ... T_HASH ] = '?', /* GCC extension for range initialization, also allowed by clang */ [T_BARE_WORD] = '\0', @@ -125,13 +123,11 @@ const char fr_token_quote[T_TOKEN_LAST + 1] = { [T_SINGLE_QUOTED_STRING] = '\'', [T_BACK_QUOTED_STRING] = '`', [T_SOLIDUS_QUOTED_STRING] = '/', - - [T_TOKEN_LAST] = '?', }; #define T(_x) [T_OP_ ## _x] = true -const bool fr_assignment_op[T_TOKEN_LAST + 1] = { +const bool fr_assignment_op[T_TOKEN_LAST] = { T(INCRM), T(ADD_EQ), T(SUB_EQ), @@ -140,7 +136,7 @@ const bool fr_assignment_op[T_TOKEN_LAST + 1] = { T(PREPEND), }; -const bool fr_equality_op[T_TOKEN_LAST + 1] = { +const bool fr_equality_op[T_TOKEN_LAST] = { T(NE), T(GE), T(GT), @@ -155,7 +151,7 @@ const bool fr_equality_op[T_TOKEN_LAST + 1] = { #undef T #define T(_x) [T_## _x] = true -const bool fr_str_tok[T_TOKEN_LAST + 1] = { +const bool fr_str_tok[T_TOKEN_LAST] = { T(BARE_WORD), T(DOUBLE_QUOTED_STRING), T(SINGLE_QUOTED_STRING), diff --git a/src/lib/util/token.h b/src/lib/util/token.h index aede4e96488..ec7cf3be785 100644 --- a/src/lib/util/token.h +++ b/src/lib/util/token.h @@ -67,8 +67,11 @@ typedef enum fr_token { T_SINGLE_QUOTED_STRING, /* 'foo' */ T_BACK_QUOTED_STRING, /* `foo` */ T_SOLIDUS_QUOTED_STRING, /* /foo/ */ - T_TOKEN_LAST } fr_token_t; +/* + * This must be manually updated, and is never part of the ENUM. + */ +#define T_TOKEN_LAST (T_SOLIDUS_QUOTED_STRING + 1) #define T_EQSTART T_OP_ADD_EQ #define T_EQEND (T_HASH) @@ -82,11 +85,11 @@ extern fr_table_num_ordered_t const fr_tokens_table[]; extern size_t fr_tokens_table_len; extern fr_table_num_sorted_t const fr_token_quotes_table[]; extern size_t fr_token_quotes_table_len; -extern const char *fr_tokens[T_TOKEN_LAST + 1]; -extern const char fr_token_quote[T_TOKEN_LAST + 1]; -extern const bool fr_assignment_op[T_TOKEN_LAST + 1]; -extern const bool fr_equality_op[T_TOKEN_LAST + 1]; -extern const bool fr_str_tok[T_TOKEN_LAST + 1]; +extern const char *fr_tokens[T_TOKEN_LAST]; +extern const char fr_token_quote[T_TOKEN_LAST]; +extern const bool fr_assignment_op[T_TOKEN_LAST]; +extern const bool fr_equality_op[T_TOKEN_LAST]; +extern const bool fr_str_tok[T_TOKEN_LAST]; int getword (char const **ptr, char *buf, int buflen, bool unescape); fr_token_t gettoken(char const **ptr, char *buf, int buflen, bool unescape);