Reindent auxiliary functions.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5467 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2008-11-30 12:24:42 +00:00
1 parent 66fe01e8a8
commit bf809dca15
1 file changed
+47 -44
+47 -44
View File
@@ -1710,55 +1710,57 @@ use vars qw(@cpu_ids);
# $_[0] is the sought value # $_[0] is the sought value
# @_[1..] is the list to seek in # @_[1..] is the list to seek in
# Returns: 0 on failure, 1 if found. # Returns: 1 if found, 0 if not.
# Note: Every use of this sub probably indicates the use of the wrong
# datastructure
sub contains sub contains
{ {
my $sought = shift; my $sought = shift;
foreach (@_) { local $_;
return 1 if $sought eq $_;
} foreach (@_) {
return 0; return 1 if $sought eq $_;
}
return 0;
} }
# Address can be decimal or hexadecimal # Address can be decimal or hexadecimal
sub valid_address sub valid_address
{ {
my $value = shift; my $value = shift;
if ($value !~ m/^(0x[0-9a-f]+|[0-9]+)$/i) { if ($value !~ m/^(0x[0-9a-f]+|[0-9]+)$/i) {
print "$value is not a valid address, sorry.\n"; print "$value is not a valid address, sorry.\n";
exit -1; exit -1;
} }
$value = oct($value) if $value =~ /^0x/i; $value = oct($value) if $value =~ m/^0x/i;
return $value; return $value;
} }
sub parse_not_to_scan sub parse_not_to_scan
{ {
my ($min, $max, $to_parse) = @_; my ($min, $max, $to_parse) = @_;
my @ranges = split /\s*, \s*/, $to_parse; my @ranges = split /\s*, \s*/, $to_parse;
my @res; my @res;
my $range; my $range;
foreach $range (@ranges) {
my ($start, $end) = split /\s*-\s*/, $range; foreach $range (@ranges) {
$start = valid_address($start); my ($start, $end) = split /\s*-\s*/, $range;
if (defined $end) { $start = valid_address($start);
$end = valid_address($end); if (defined $end) {
if ($end <= $start) { $end = valid_address($end);
print "$start-$end is not a valid range, sorry.\n"; if ($end <= $start) {
exit -1; print "$start-$end is not a valid range, sorry.\n";
} exit -1;
$start = $min if $start < $min; }
$end = $max if $end > $max; $start = $min if $start < $min;
push @res, ($start..$end); $end = $max if $end > $max;
} else { push @res, ($start..$end);
push @res, $start if $start >= $min and $start <= $max; } else {
} push @res, $start if $start >= $min and $start <= $max;
} }
return sort { $a <=> $b } @res; }
return sort { $a <=> $b } @res;
} }
# @_[0]: Reference to list 1 # @_[0]: Reference to list 1
@@ -1767,14 +1769,15 @@ sub parse_not_to_scan
# Elements must be numeric. # Elements must be numeric.
sub any_list_match sub any_list_match
{ {
my ($list1, $list2) = @_; my ($list1, $list2) = @_;
my ($el1, $el2); my ($el1, $el2);
foreach $el1 (@$list1) {
foreach $el2 (@$list2) { foreach $el1 (@$list1) {
return 1 if $el1 == $el2; foreach $el2 (@$list2) {
} return 1 if $el1 == $el2;
} }
return 0; }
return 0;
} }
################### ###################