Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
2.3 KiB

  1. @rem = '
  2. @perl.exe -w %~f0 %*
  3. @goto :EOF
  4. '; undef @rem;
  5. # List all files having a particular author.
  6. @args=@ARGV;
  7. undef @ARGV;
  8. $syntax = "junk [-?x] [<author>]";
  9. for ($i=0;$i<=$#args;$i++) {
  10. $_ = $args[$i];
  11. if (/^[-\/]x$/) {
  12. $alternate = 1;
  13. } elsif (/^[-\/]\?$/) {
  14. print <<EOT;
  15. $syntax
  16. Lists source files by author
  17. <author> - Lists just the files written by the given person
  18. x - Alternative output format
  19. EOT
  20. exit 0;
  21. } else {
  22. push (@ARGV,$_);
  23. }
  24. }
  25. sub printfiles {
  26. undef $lastname;
  27. foreach $file (sort @_) {
  28. if ($alternate) {
  29. $thisname = $file;
  30. $thisname =~ s/^(.*)\..*$/$1/;
  31. if ($lastname) {
  32. if ($thisname eq $lastname) {
  33. print " ";
  34. } else {
  35. print "\n";
  36. }
  37. }
  38. print $file;
  39. $lastname=$thisname;
  40. } else {
  41. print " $file\n";
  42. }
  43. }
  44. if ($alternate) { print "\n\n"; }
  45. }
  46. if ($#ARGV>=0) {
  47. $findauthor = shift;
  48. }
  49. ($#ARGV < 0) || die "$syntax\n";
  50. if ($#exts<0) {
  51. @exts = ("cpp", "cxx", "c", "h", "hxx", "hpp", "inc");
  52. }
  53. $findstr = "dir /b " . join(" ", map("*.$_", @exts))." 2>nul";
  54. open(FIND, "$findstr|");
  55. $files=0;
  56. while (<FIND>) {
  57. /^\s*$/ && next;
  58. $foundfiles=1;
  59. chop;
  60. $filename=$_;
  61. open(FILE, "$filename");
  62. $filename =~ s/.*\\([^\\]*)/$1/;
  63. push(@files, $filename);
  64. $found=0;
  65. while (<FILE>) {
  66. if ((/Author:.*\[(.*)]/i) ||
  67. (m[ +[0-9]+/[0-9]+/[0-9]+ -?([a-zA-Z-]+)])
  68. ){
  69. $a = $1;
  70. $a =~ tr/A-Z/a-z/;
  71. push (@{$fn{$a}}, $filename);
  72. if (!grep($_ eq $a, @authors)) { push(@authors, $a); }
  73. $found=1;
  74. last;
  75. }
  76. }
  77. if (!$found) {
  78. push (@fn_none, $filename);
  79. }
  80. close(FILE);
  81. }
  82. close(FIND);
  83. $foundfiles || die "No files found (".join(", ", map(".$_", @exts)).").\n";
  84. if ($findauthor) {
  85. @whichauthors = ($findauthor);
  86. } else {
  87. @whichauthors = sort @authors;
  88. }
  89. foreach $author (@whichauthors) {
  90. print "$author:\n";
  91. &printfiles(@{$fn{$author}});
  92. }
  93. if (!$findauthor && ($#fn_none >= 0)) {
  94. print "NONE:\n";
  95. &printfiles(@fn_none);
  96. }