From 8adb91d61f4b3d217529d5348ef97de7555ebe1e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 7 Sep 2012 14:22:56 +0000 Subject: [PATCH] In side-by-side merged cells mode, don't make columns larger than they need to be. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6066 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + eeprom/decode-dimms | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 075ef9d..8e30774 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ SVN HEAD decode-dimms: Decode module configuration type of DDR2 SDRAM Decode bus width extension of DDR3 SDRAM Don't choke when no EEPROM is found + don't make columns larger than they need to be i2cdetect: Do a best effort detection if functionality is missing i2c-dev.h: Minimize differences with kernel flavor Move SMBus helper functions to include/i2c/smbus.h diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index a969276..821df7d 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -393,7 +393,7 @@ sub real_printl($$) # print a line w/ label and values splice(@values, 1); } - my $format = "%-47s".((" %-".$sbs_col_width."s") x (scalar @values - 1))." %s\n"; + my $format = "%-47s".((" %-".$sbs_col_width."s") x (scalar @values - 1))." %s\n"; my $maxl = 0; # Keep track of the max number of lines # It's a bit tricky because each value may span over more than @@ -1938,9 +1938,23 @@ if ($opt_side_by_side) { } } +# Check if all dimms have the same value for a given line +sub line_has_same_values($) +{ + my $line = shift; + my $value = $dimm[0]->{output}->[$line]->[2]; + + # Skip lines with no values (headers) + return 1 unless defined $value; + + for my $other (1 .. $#dimm) { + return 0 unless $value eq $dimm[$other]->{output}->[$line]->[2]; + } + + return 1; +} + # Find out the longest value string to adjust the column width -# Note: this could be improved a bit by not taking into account strings -# which will end up being merged. $sbs_col_width = 15; if ($opt_side_by_side && !$opt_html) { for $current (0 .. $#dimm) { @@ -1949,6 +1963,7 @@ if ($opt_side_by_side && !$opt_html) { my @strings; for ($line = 0; $line < @output; $line++) { + next if $opt_merge && line_has_same_values($line); my ($func, $label, $value) = @{$output[$line]}; push @strings, split("\n", $value) if defined $value; }