Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts: get_feat.pl: reduce table width for all features output

Auto-adjust the table columns width to better fit under
terminals, by breaking the description on multiple lines
and auto-estimating the minimal size for the
per-architecture status.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/9d39ac3fd51f1360aecc328c01558be88a1d6930.1607095090.git.mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
f5889e70 4fa32f87

+59 -12
+59 -12
scripts/get_feat.pl
··· 19 19 20 20 my $prefix=$basename . "../Documentation/features"; 21 21 22 + # Used only at for full features output. The script will auto-adjust 23 + # such values for the minimal possible values 24 + my $status_size = 1; 25 + my $description_size = 1; 26 + 22 27 GetOptions( 23 28 "debug|d+" => \$debug, 24 29 "dir=s" => \$prefix, ··· 82 77 my $max_size_description = length($h_description); 83 78 my $max_size_subsys = length($h_subsys); 84 79 my $max_size_status = length($h_status); 85 - my $max_size_arch = length($h_arch); 80 + 81 + my $max_size_arch = 0; 82 + my $max_size_arch_with_header; 83 + my $max_description_word = 0; 86 84 87 85 sub parse_feat { 88 86 my $file = $File::Find::name; ··· 135 127 if (length($description) > $max_size_description) { 136 128 $max_size_description = length($description); 137 129 } 130 + 131 + foreach my $word (split /\s+/, $description) { 132 + if (length($word) > $max_description_word) { 133 + $max_description_word = length($word); 134 + } 135 + } 136 + 138 137 next; 139 138 } 140 139 next if (m/^\\s*$/); ··· 195 180 $data{$name}->{description} = $description; 196 181 $data{$name}->{comments} = $comments; 197 182 $data{$name}->{table} = \%arch_table; 183 + 184 + $max_size_arch_with_header = $max_size_arch + length($h_arch); 198 185 } 199 186 200 187 # ··· 313 296 print "$com\n\n"; 314 297 } 315 298 316 - print "=" x $max_size_arch; 299 + print "=" x $max_size_arch_with_header; 317 300 print " "; 318 301 print "=" x $max_size_status; 319 302 print "\n"; ··· 321 304 printf "%-${max_size_arch}s ", $h_arch; 322 305 printf "%-${max_size_status}s", $h_status . "\n"; 323 306 324 - print "=" x $max_size_arch; 307 + print "=" x $max_size_arch_with_header; 325 308 print " "; 326 309 print "=" x $max_size_status; 327 310 print "\n"; ··· 332 315 printf "%-${max_size_status}s\n", $arch_table{$arch}; 333 316 } 334 317 335 - print "=" x $max_size_arch; 318 + print "=" x $max_size_arch_with_header; 336 319 print " "; 337 320 print "=" x $max_size_status; 338 321 print "\n"; ··· 368 351 369 352 sub output_matrix { 370 353 my $title = "Feature status on all architectures"; 354 + my $notcompat = "Not compatible"; 371 355 372 356 print "=" x length($title) . "\n"; 373 357 print "$title\n"; ··· 377 359 my $desc_title = "$h_kconfig / $h_description"; 378 360 379 361 my $desc_size = $max_size_kconfig + 4; 380 - $desc_size = $max_size_description if ($max_size_description > $desc_size); 362 + if (!$description_size) { 363 + $desc_size = $max_size_description if ($max_size_description > $desc_size); 364 + } else { 365 + $desc_size = $description_size if ($description_size > $desc_size); 366 + } 367 + $desc_size = $max_description_word if ($max_description_word > $desc_size); 368 + 381 369 $desc_size = length($desc_title) if (length($desc_title) > $desc_size); 382 370 383 - my $status_size = 60; 371 + $max_size_status = length($notcompat) if (length($notcompat) > $max_size_status); 372 + 373 + # Ensure that the status will fit 374 + my $min_status_size = $max_size_status + $max_size_arch + 6; 375 + $status_size = $min_status_size if ($status_size < $min_status_size); 376 + 384 377 385 378 my $cur_subsys = ""; 386 379 foreach my $name (sort { ··· 423 394 my %arch_table = %{$data{$name}->{table}}; 424 395 my $cur_status = ""; 425 396 426 - my @lines; 397 + my (@lines, @descs); 427 398 my $line = ""; 428 399 foreach my $arch (sort { 429 400 ($arch_table{$b} cmp $arch_table{$a}) or ··· 433 404 my $status = $arch_table{$arch}; 434 405 435 406 if ($status eq "---") { 436 - $status = "Not compatible"; 407 + $status = $notcompat; 437 408 } 438 409 439 410 if ($status ne $cur_status) { ··· 452 423 } 453 424 push @lines, $line if ($line ne ""); 454 425 455 - # Ensure that description will be printed 456 - push @lines, "" while (scalar(@lines) < 2); 426 + my $description = $data{$name}->{description}; 427 + while (length($description) > $desc_size) { 428 + my $d = substr $description, 0, $desc_size; 429 + 430 + # Ensure that it will end on a space 431 + # if it can't, it means that the size is too small 432 + # Instead of aborting it, let's print what we have 433 + if (!($d =~ s/^(.*)\s+.*/$1/)) { 434 + $d = substr $d, 0, -1; 435 + push @descs, "$d\\"; 436 + $description =~ s/^\Q$d\E//; 437 + } else { 438 + push @descs, $d; 439 + $description =~ s/^\Q$d\E\s+//; 440 + } 441 + } 442 + push @descs, $description; 443 + 444 + # Ensure that the full description will be printed 445 + push @lines, "" while (scalar(@lines) < 2 + scalar(@descs)); 457 446 458 447 my $ln = 0; 459 448 for my $line(@lines) { 460 449 if (!$ln) { 461 450 printf "|%-${max_size_name}s", $name; 462 451 printf "|%-${desc_size}s", "``" . $data{$name}->{kconfig} . "``"; 463 - } elsif ($ln == 2) { 452 + } elsif ($ln >= 2 && scalar(@descs)) { 464 453 printf "|%-${max_size_name}s", ""; 465 - printf "|%-${desc_size}s", $data{$name}->{description}; 454 + printf "|%-${desc_size}s", shift @descs; 466 455 } else { 467 456 printf "|%-${max_size_name}s", ""; 468 457 printf "|%-${desc_size}s", "";