#!/usr/bin/perl # OV [rows [prefix]] # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Kludge to massage the O*: entries in the misc and V Makefiles. This eats # # the O*: dependency lines, extracts the file names, sorts them, and otuputs # # another set of lines that should be all approximately the same length. The # # default number of rows is 32, but may be given on the command line. This # # script is called "OV" in honor of the names of the 16 entries (O0: thru # # OV:) that are generated by default. Note the limit of 62 entries. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # @let = (0 .. 9 , 'A' .. 'Z' , 'a' .. 'z'); # Second char for 62 entries. $0 =~ s'^.*/''; $cnt = shift(@ARGV) || ($0 eq 'OV' ? 32 : $0 eq 'OF' ? 16 : 8); # Number of rows to produce. $pfx = shift(@ARGV) || 'O'; # First character of entries' names. $fmt = "%s%s:"; for (<>) { s/^\s*\w+://; s/^\s+//; s/\s+$//; for (split) { if (++$x{$_} == 1) { $n ++; # Number of items found. $b += length; # Total of their sizes. } } } $npr = int($n / $cnt); # Number of items per row. $bpr = int($b / $cnt); # Mean bytes per rows. $bpr *= 1.1; # Might be useful in some cases. for ($r=0; $r<$cnt; $r++) { $row[$r] = sprintf($fmt, $pfx, $let[$r]); } for (sort keys %x) { $m = length($row[$r = 0]); for ($i=1; $i<$cnt; $i++) { $l = length($row[$i]); if ($l < $m) { $m = $l; $r = $i; } } $row[$r] = "$row[$r] $_"; } for ($r=0; $r<$cnt; $r++) { printf "$row[$r]\n"; }