From 1aae8ade6e4cfbf178b8b842afbf68e60eb4d455 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 7 Sep 2012 14:28:31 +0000 Subject: [PATCH] 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 --- eeprom/decode-dimms | 16 ++++++++++++---- 1 file 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) {