diff options
author | Jean Delvare <jdelvare@suse.de> | 2012-09-07 14:28:31 +0000 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2012-09-07 14:28:31 +0000 |
commit | 1aae8ade6e4cfbf178b8b842afbf68e60eb4d455 (patch) | |
tree | 17e8144f409811330206efb197a37d7e28f73d6e | |
parent | d4da05d116751a9e564cede71b4a962c04bc85f7 (diff) | |
download | i2c-tools-1aae8ade6e4cfbf178b8b842afbf68e60eb4d455.tar.gz |
Move the code to a function, it's cleaner.
git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6068 7894878c-1315-0410-8ee3-d5d059ff63e0
-rwxr-xr-x | eeprom/decode-dimms | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index c23b211..9bd331e 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -1955,8 +1955,12 @@ sub line_has_same_values($) } # Find out the longest value string to adjust the column width -$sbs_col_width = 15; -if ($opt_side_by_side && !$opt_html) { +sub find_col_width($) +{ + my $width = shift; + + return $width unless $opt_side_by_side && !$opt_html; + my $line; my $line_nr = @{$dimm[0]->{output}}; @@ -1965,18 +1969,22 @@ if ($opt_side_by_side && !$opt_html) { my @strings; - for $current (0 .. $#dimm) { + for my $current (0 .. $#dimm) { my $value = $dimm[$current]->{output}->[$line]->[2]; push @strings, split("\n", $value) if defined $value; } foreach my $line2 (@strings) { my $len = length($line2); - $sbs_col_width = $len if $len > $sbs_col_width; + $width = $len if $len > $width; } } + + return $width; } +$sbs_col_width = find_col_width(15); + # Print the decoded information for all DIMMs for $current (0 .. $#dimm) { if ($opt_side_by_side) { |