aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2012-09-07 14:28:31 +0000
committerJean Delvare <jdelvare@suse.de>2012-09-07 14:28:31 +0000
commit1aae8ade6e4cfbf178b8b842afbf68e60eb4d455 (patch)
tree17e8144f409811330206efb197a37d7e28f73d6e
parentd4da05d116751a9e564cede71b4a962c04bc85f7 (diff)
downloadi2c-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-xeeprom/decode-dimms16
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) {