From 90ec3fe5aa8aed2a1c42751f91ffaa438cf04867 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 10 May 2013 23:50:25 +0200 Subject: [PATCH] refactor: fix few "inverted boolean" usages In some subroutines, we used a return value of 0 to indicate success, and a return status of 1 to indicate failure. That was not very consistent with the perl interpretation of 0 as a false value and 1 as a true value. So we now invert the meaning of the exit statuses. * lib/Automake/Options.pm (_process_option_list): Here. (process_global_option_list, process_option_list): And by reflex, here as well. * bin/automake.in (handle_options): And here. (generate_makefile, scan_autoconf_traces): Adjust. Signed-off-by: Stefano Lattarini --- bin/automake.in | 10 +++++----- lib/Automake/Options.pm | 22 ++++++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bin/automake.in b/bin/automake.in index 3614b6b..0aef771 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -1148,7 +1148,7 @@ sub handle_silent () ################################################################ -# Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise. +# Handle AUTOMAKE_OPTIONS variable. Return 0 on error, 1 otherwise. sub handle_options () { my $var = var ('AUTOMAKE_OPTIONS'); @@ -1162,7 +1162,7 @@ sub handle_options () my @options = map { { option => $_->[1], where => $_->[0] } } $var->value_as_list_recursive (cond_filter => TRUE, location => 1); - return 1 if process_option_list (@options); + return 0 unless process_option_list (@options); } if ($strictness == GNITS) @@ -1172,7 +1172,7 @@ sub handle_options () set_option ('check-news', INTERNAL); } - return 0; + return 1; } # shadow_unconditionally ($varname, $where) @@ -5280,7 +5280,7 @@ EOF { my @opts = split (' ', $args[1]); @opts = map { { option => $_, where => $where } } @opts; - exit $exit_code if process_global_option_list (@opts); + exit $exit_code unless process_global_option_list (@opts); } } elsif ($macro eq 'AM_MAINTAINER_MODE') @@ -7731,7 +7731,7 @@ sub generate_makefile $relative_dir = dirname ($makefile); read_main_am_file ($makefile_am, $makefile_in); - if (handle_options) + if (not handle_options) { # Process buffered warnings. flush_messages; diff --git a/lib/Automake/Options.pm b/lib/Automake/Options.pm index e87fb05..f745d3a 100644 --- a/lib/Automake/Options.pm +++ b/lib/Automake/Options.pm @@ -241,7 +241,7 @@ These functions should be called at most once for each set of options having the same precedence; i.e., do not call it twice for two options from C. -Return 1 on error, 0 otherwise. +Return 0 on error, 1 otherwise. =cut @@ -323,20 +323,20 @@ sub _process_option_list (\%@) # Obsolete (and now removed) de-ANSI-fication support. error ($where, "automatic de-ANSI-fication support has been removed"); - return 1; + return 0; } # TODO: Remove this special check in Automake 3.0. elsif ($_ eq 'cygnus') { error $where, "support for Cygnus-style trees has been removed"; - return 1; + return 0; } # TODO: Remove this special check in Automake 3.0. elsif ($_ eq 'dist-lzma') { error ($where, "support for lzma-compressed distribution " . "archives has been removed"); - return 1; + return 0; } # TODO: Make this a fatal error in Automake 2.0. elsif ($_ eq 'dist-shar') @@ -360,15 +360,17 @@ sub _process_option_list (\%@) } elsif ($_ eq 'tar-v7' || $_ eq 'tar-ustar' || $_ eq 'tar-pax') { - return 1 - unless _option_is_from_configure ($_, $where); + if (not _option_is_from_configure ($_, $where)) + { + return 0; + } for my $opt ('tar-v7', 'tar-ustar', 'tar-pax') { next if $opt eq $_ or ! exists $options->{$opt}; error ($where, "options '$_' and '$opt' are mutually exclusive"); - return 1; + return 0; } } elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/) @@ -378,7 +380,7 @@ sub _process_option_list (\%@) { error ($where, "require Automake $_, but have $VERSION", uniq_scope => US_GLOBAL); - return 1; + return 0; } } elsif (/^(?:--warnings=|-W)(.*)$/) @@ -389,7 +391,7 @@ sub _process_option_list (\%@) elsif (! _is_valid_easy_option $_) { error ($where, "option '$_' not recognized"); - return 1; + return 0; } } # We process warnings here, so that any explicitly-given warning setting @@ -401,7 +403,7 @@ sub _process_option_list (\%@) "unknown warning category '$w->{'cat'}'" if switch_warning $w->{cat}; } - return 0; + return 1; } sub process_option_list (@) -- 2.7.4