From 69038e62e0f0139889c8e6621f13ff08227be56c Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 19 May 2024 19:10:32 -0400 Subject: [PATCH] * src/warning.h: Put warnings into alphabetical order. * src/warning.c: Ditto. * tests/scripts/options/warn: Fix tests for the new order. --- src/warning.c | 16 ++++++++-------- src/warning.h | 13 +++++++------ tests/scripts/options/warn | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/warning.c b/src/warning.c index 26584e92..ffb3ff38 100644 --- a/src/warning.c +++ b/src/warning.c @@ -32,10 +32,10 @@ static struct warning_data warn_flag; static const char *w_action_map[w_error+1] = {NULL, "ignore", "warn", "error"}; static const char *w_name_map[wt_max] = { - "invalid-var", + "circular-dep", "invalid-ref", - "undefined-var", - "circular-dep" + "invalid-var", + "undefined-var" }; #define encode_warn_action(_b,_s) \ @@ -64,10 +64,10 @@ warn_init () /* All warnings must have a default. */ warn_default.global = w_warn; - warn_default.actions[wt_invalid_var] = w_warn; - warn_default.actions[wt_invalid_ref] = w_warn; - warn_default.actions[wt_undefined_var] = w_ignore; warn_default.actions[wt_circular_dep] = w_warn; + warn_default.actions[wt_invalid_ref] = w_warn; + warn_default.actions[wt_invalid_var] = w_warn; + warn_default.actions[wt_undefined_var] = w_ignore; set_warnings (); } @@ -76,7 +76,7 @@ static void init_data (struct warning_data *data) { data->global = w_unset; - for (enum warning_type wt = wt_invalid_var; wt < wt_max; ++wt) + for (enum warning_type wt = 0; wt < wt_max; ++wt) data->actions[wt] = w_unset; } @@ -96,7 +96,7 @@ decode_warn_action (const char *action, size_t length) static enum warning_type decode_warn_name (const char *name, size_t length) { - for (enum warning_type wt = wt_invalid_var; wt < wt_max; ++wt) + for (enum warning_type wt = 0; wt < wt_max; ++wt) { size_t len = strlen (w_name_map[wt]); if (length == len && strncasecmp (name, w_name_map[wt], length) == 0) diff --git a/src/warning.h b/src/warning.h index fabbe01a..b5fe9feb 100644 --- a/src/warning.h +++ b/src/warning.h @@ -14,17 +14,18 @@ A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Types of warnings we can show. */ +/* Types of warnings we can show. + These can be rearranged but the first value must be 0. */ enum warning_type { - wt_invalid_var = 0, /* Assign to an invalid variable name. */ - wt_invalid_ref, /* Reference an invalid variable name. */ - wt_undefined_var, /* Reference an undefined variable name. */ - wt_circular_dep, /* A target depends on itself. */ + wt_circular_dep = 0, /* A target depends on itself. */ + wt_invalid_ref, /* Reference an invalid variable name. */ + wt_invalid_var, /* Assign to an invalid variable name. */ + wt_undefined_var, /* Reference an undefined variable name. */ wt_max }; -/* Action taken for a given warning. */ +/* Action taken for a given warning. Unset must be 0. */ enum warning_action { w_unset = 0, diff --git a/tests/scripts/options/warn b/tests/scripts/options/warn index 5285d873..7d79d3eb 100644 --- a/tests/scripts/options/warn +++ b/tests/scripts/options/warn @@ -5,8 +5,8 @@ $description = "Test the --warn option."; my %warn_test = ( '--warn' => '', '--warn=warn' => '', '--warn=error --warn=warn' => '', '--warn --warn=error' => '=error', - '--warn=ignore --warn=error --warn=ignore --warn=invalid-var,invalid-ref,undefined-var' => '=ignore,invalid-var,invalid-ref,undefined-var', - '--warn=invalid-ref:ignore --warn=error --warn=invalid-var:warn,,,,,undefined-var:error,,,,,' => '=error,invalid-var,invalid-ref:ignore,undefined-var:error' + '--warn=ignore --warn=error --warn=ignore --warn=invalid-ref,invalid-var,undefined-var' => '=ignore,invalid-ref,invalid-var,undefined-var', + '--warn=invalid-ref:ignore --warn=error --warn=invalid-var:warn,,,,,undefined-var:error,,,,,' => '=error,invalid-ref:ignore,invalid-var,undefined-var:error' ); # Verify the deprecated --warn-undefined-variables option