]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
update use of T_TOKEN_LAST
authorAlan T. DeKok <aland@freeradius.org>
Fri, 19 Nov 2021 20:20:52 +0000 (15:20 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 19 Nov 2021 20:37:01 +0000 (15:37 -0500)
it's not part of the enum, it's the number of elements in the enum

src/lib/util/token.c
src/lib/util/token.h

index abc5da795d88b971c853fa2836f2d0d73266abb7..8b4a3693ebbedd8cd0f6c51bcfe80bb73fbd687f 100644 (file)
@@ -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] = "</STRING/>",
-
-       [T_TOKEN_LAST] = "<invalid>",
 };
 
 
@@ -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),
index aede4e96488a4ff6b8d6e79d32f6f2d3abcd762c..ec7cf3be785239141254f28a5206749225e4703d 100644 (file)
@@ -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);