Changes in directory llvm/utils:
userloc.pl updated: 1.4 -> 1.5 --- Log message: Drop the -details option, it was broken. If you want to know about a particular directory, just pass that directory to the script. Also, clean up the HTML output, put list of skipped dirs at the end, and make a few other minor improvements. --- Diffs of the changes: (+42 -54) userloc.pl | 96 ++++++++++++++++++++++++++----------------------------------- 1 files changed, 42 insertions(+), 54 deletions(-) Index: llvm/utils/userloc.pl diff -u llvm/utils/userloc.pl:1.4 llvm/utils/userloc.pl:1.5 --- llvm/utils/userloc.pl:1.4 Thu Apr 20 13:47:13 2006 +++ llvm/utils/userloc.pl Fri Aug 11 13:36:55 2006 @@ -8,11 +8,9 @@ # then the cwd is used. The directory must be an LLVM tree checked out # from cvs. # -# Syntax: userloc.pl [-details|-recurse|-tag=tag|-html... <directory>... +# Syntax: userloc.pl [-recurse|-tag=tag|-html... <directory>... # # Options: -# -details -# Print detailed per-directory information. # -recurse # Recurse through sub directories. Without this, only the # specified directory is examined @@ -21,40 +19,31 @@ # -html # Generate HTML output instead of text output -die "Usage userloc.pl [-details|-recurse|-tag=tag|-html] <directories>..." +die "Usage userloc.pl [-recurse|-tag=tag|-html] <directories>..." if ($#ARGV < 0); my $tag = ""; -my $details = 0; my $recurse = 0; my $html = 0; +my $debug = 0; while ( substr($ARGV[0],0,1) eq '-' ) { - if ($ARGV[0] eq "-details") - { - $details = 1 ; - } - elsif ($ARGV[0] eq "-recurse") - { + if ($ARGV[0] eq "-recurse") { $recurse = 1; - } - elsif ($ARGV[0] =~ /-tag=.*/) - { + } elsif ($ARGV[0] =~ /-tag=.*/) { $tag = $ARGV[0]; $tag =~ s#-tag=(.*)#$1#; - } - elsif ($ARGV[0] eq "-html") - { + } elsif ($ARGV[0] eq "-html") { $html = 1; - } - else - { + } elsif ($ARGV[0] eq "-debug") { + $debug = 1; + } else { die "Invalid option: $ARGV[0]"; } shift; } -die "Usage userloc.pl [-details|-recurse|-tag=tag|-html] <directories>..." +die "Usage userloc.pl [-recurse|-tag=tag|-html] <directories>..." if ($#ARGV < 0); my %Stats; @@ -65,14 +54,15 @@ my $f = $_[0]; my $d = $_[1]; - return 0 if ( "$f" eq "configure"); if ( $d =~ ".*autoconf.*") { return 1 if ($f eq "configure.ac"); return 1 if ($f eq "AutoRegen.sh"); return 0; } - + return 0 if ( "$f" eq "configure"); + return 0 if ( "$f" eq 'PPCPerfectShuffle.h' ); + return 0 if ( $f =~ /.*\.cvs/); return 1; } @@ -95,13 +85,13 @@ return $files; } -my $annotate = "cvs annotate -lf "; +my $annotate = "cvs -z6 annotate -lf "; if (length($tag) > 0) { - $annotate = $annotate . " -r " . $tag; + $annotate = $annotate . " -r" . $tag; } -sub ScanDir +sub ScanDir { my $Dir = $_[0]; my $files = GetCVSFiles($Dir); @@ -109,26 +99,23 @@ open (DATA,"$annotate $files 2>/dev/null |") || die "Can't read cvs annotation data"; - my %st; while ( defined($line = <DATA>) ) { - if ($line =~ /^[0-9.]*[ \t]*\(/) + if ($line =~ /^[0-9.]*[ \t]*\([^)]*\):/) { - $line =~ s#^[0-9.]*[ \t]*\(([a-zA-Z0-9_.-]*).*#$1#; chomp($line); - $st{$line}++; + $line =~ s#^[0-9.]*[ \t]*\(([a-zA-Z0-9_.-]*) [^)]*\):.*#$1#; $Stats{$line}++; } } - $StatsDetails{$Dir} = { %st }; - close DATA; } sub ValidateDirectory { my $d = $_[0]; + return 0 if (! -d "$d" || ! -d "$d/CVS"); return 0 if ($d =~ /.*CVS.*/); return 0 if ($d =~ /.*Debug.*/); return 0 if ($d =~ /.*Release.*/); @@ -144,6 +131,7 @@ return 1 if ($d =~ /.*projects\/sample.*/); return 0 if ($d =~ /.*projects\/llvm-.*/); return 0 if ($d =~ /.*win32.*/); + return 0 if ($d =~ /.*\/.libs\/.*/); return 1; } @@ -157,12 +145,14 @@ if ($RowCount % 10 == 0) { - print " <tr><th style=\"text-align:left\">Directory</th>\n"; - foreach $user (sort keys %Stats) - { - print "<th style=\"text-align:right\">",$user,"</th>\n"; + if ($html) { + print " <tr><th style=\"text-align:left\">Directory</th>\n"; + foreach $user (sort keys %Stats) + { + print "<th style=\"text-align:right\">",$user,"</th>\n"; + } + print "</tr>\n"; } - print "</tr>\n"; } $RowCount++; @@ -217,41 +207,39 @@ print "<p>This document shows the total lines of code per user in each\n"; print "LLVM directory. Lines of code are attributed by the user that last\n"; print "committed the line. This does not necessarily reflect authorship.</p>\n"; -print "<p>The following directories were skipped:</p>\n"; -print "<ol>\n"; } +my @ignored_dirs; + for $Dir (@ALLDIRS) { - if ( -d "$Dir" && -d "$Dir/CVS" && ValidateDirectory($Dir) ) + if ( ValidateDirectory($Dir) ) { ScanDir($Dir); } elsif ($html) { - print "<li>$Dir</li>\n"; + push @ignored_dirs, $Dir; } } if ($html) { - print "</ol>\n"; print "<table>\n"; } -if ($details) -{ - foreach $dir (sort keys %StatsDetails) - { - printStats($dir,$StatsDetails{$dir}); - } -} - printStats("Total",\%Stats); - -if ($html) +if ($html) { - print "</table></body></html>\n"; + print "</table>"; + if (scalar @ignored_dirs > 0) { + print "<p>The following directories were skipped:</p>\n"; + print "<ol>\n"; + foreach $index (0 .. $#ignored_dirs) { + print " <li>", $ignored_dirs[$index], "</li>\n"; + } + print "</ol>\n"; + } + print "</body></html>\n"; } - _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits