| 361 | | sub real_printl($$) # print a line w/ label and value |
| | 362 | sub real_printl($$) # print a line w/ label and values |
| | 363 | { |
| | 364 | my ($label, @values) = @_; |
| | 365 | local $_; |
| | 366 | |
| | 367 | if ($opt_html) { |
| | 368 | $label = html_encode($label); |
| | 369 | @values = map { html_encode($_) } @values; |
| | 370 | print "<tr><td valign=top>$label</td>"; |
| | 371 | print "<td>$_</td>" foreach @values; |
| | 372 | print "</tr>\n"; |
| | 373 | } else { |
| | 374 | my $format = "%-47s".(" %-19s" x (scalar @values - 1))." %s\n"; |
| | 375 | my $maxl = 0; # Keep track of the max number of lines |
| | 376 | |
| | 377 | # It's a bit tricky because each value may span over more than |
| | 378 | # one line. We can easily extract the values per column, but |
| | 379 | # we need them per line at printing time. So we have to |
| | 380 | # prepare a 2D array with all the individual string fragments. |
| | 381 | my ($col, @lines); |
| | 382 | for ($col = 0; $col < @values; $col++) { |
| | 383 | my @cells = split /\n/, $values[$col]; |
| | 384 | $maxl = @cells if @cells > $maxl; |
| | 385 | for (my $l = 0; $l < @cells; $l++) { |
| | 386 | $lines[$l]->[$col] = $cells[$l]; |
| | 387 | } |
| | 388 | } |
| | 389 | |
| | 390 | # Also make sure there are no holes in the array |
| | 391 | for (my $l = 0; $l < $maxl; $l++) { |
| | 392 | for ($col = 0; $col < @values; $col++) { |
| | 393 | $lines[$l]->[$col] = "" |
| | 394 | if not defined $lines[$l]->[$col]; |
| | 395 | } |
| | 396 | } |
| | 397 | |
| | 398 | printf $format, $label, @{shift @lines}; |
| | 399 | printf $format, "", @{$_} foreach (@lines); |
| | 400 | } |
| | 401 | } |
| | 402 | |
| | 403 | sub printl2($$) # print a line w/ label and value (outside a table) |
| 367 | | print "<tr><td valign=top>$label</td><td>$value</td></tr>\n"; |
| 368 | | } else { |
| 369 | | my @values = split /\n/, $value; |
| 370 | | printf "%-47s %s\n", $label, shift @values; |
| 371 | | printf "%-47s %s\n", "", $_ foreach (@values); |
| 372 | | } |
| 373 | | } |
| 374 | | |
| 375 | | sub printl2($$) # print a line w/ label and value (outside a table) |
| 376 | | { |
| 377 | | my ($label, $value) = @_; |
| | 409 | } |
| | 410 | print "$label: $value\n"; |
| | 411 | } |
| | 412 | |
| | 413 | sub real_prints($) # print separator w/ given text |
| | 414 | { |
| | 415 | my ($label, $ncol) = @_; |
| | 416 | $ncol = 1 unless $ncol; |
| | 1812 | # Side-by-side output format is only possible if all DIMMs have a similar |
| | 1813 | # output structure |
| | 1814 | if ($opt_side_by_side) { |
| | 1815 | for $current (1 .. $#dimm) { |
| | 1816 | my @ref_output = @{$dimm[0]->{output}}; |
| | 1817 | my @test_output = @{$dimm[$current]->{output}}; |
| | 1818 | my $line; |
| | 1819 | |
| | 1820 | if (scalar @ref_output != scalar @test_output) { |
| | 1821 | $opt_side_by_side = 0; |
| | 1822 | last; |
| | 1823 | } |
| | 1824 | |
| | 1825 | for ($line = 0; $line < @ref_output; $line++) { |
| | 1826 | my ($ref_func, $ref_label, @ref_dummy) = @{$ref_output[$line]}; |
| | 1827 | my ($test_func, $test_label, @test_dummy) = @{$test_output[$line]}; |
| | 1828 | |
| | 1829 | if ($ref_func != $test_func || $ref_label ne $test_label) { |
| | 1830 | $opt_side_by_side = 0; |
| | 1831 | last; |
| | 1832 | } |
| | 1833 | } |
| | 1834 | } |
| | 1835 | |
| | 1836 | if (!$opt_side_by_side) { |
| | 1837 | printc("Side-by-side output only possible if all DIMMS are similar\n"); |
| | 1838 | |
| | 1839 | # Discard "Decoding EEPROM" entry from all outputs |
| | 1840 | for $current (0 .. $#dimm) { |
| | 1841 | shift(@{$dimm[$current]->{output}}); |
| | 1842 | } |
| | 1843 | } |
| | 1844 | } |
| | 1845 | |
| 1779 | | foreach (@{$dimm[$current]->{output}}) { |
| 1780 | | my ($func, @param) = @{$_}; |
| | 1857 | my @output = @{$dimm[$current]->{output}}; |
| | 1858 | for (my $line = 0; $line < @output; $line++) { |
| | 1859 | my ($func, @param) = @{$output[$line]}; |
| | 1860 | |
| | 1861 | if ($opt_side_by_side) { |
| | 1862 | foreach ($current+1 .. $#dimm) { |
| | 1863 | my @xoutput = @{$dimm[$_]->{output}}; |
| | 1864 | if (@{$xoutput[$line]} == 3) { |
| | 1865 | # Line with data, stack all values |
| | 1866 | push @param, @{$xoutput[$line]}[2]; |
| | 1867 | } else { |
| | 1868 | # Separator, make it span |
| | 1869 | push @param, scalar @dimm; |
| | 1870 | } |
| | 1871 | } |
| | 1872 | } |
| | 1873 | |