Source code of Windows XP (NT5)
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.

59 lines
1.3 KiB

  1. my ($input_file, $output_file, $sp_map) = @ARGV;
  2. my $sp_file = "$ENV{RAZZLETOOLPATH}\\spfiles.txt";
  3. my %spmap;
  4. open SPMAP, $sp_map;
  5. while (<SPMAP>) {
  6. chomp;
  7. $_ = lc $_;
  8. my ($src, $dst) = /(\S+)\s*(\S+)/;
  9. $src =~ s/^(...inf|lang)\\//i;
  10. $dst =~ s/^([im].|lang|new)\\//i;
  11. if ($dst =~ /\\/) {
  12. $spmap{$src} = "" if !exists $spmap{$src};
  13. next;
  14. }
  15. if ($dst =~ /\_$/) {
  16. $dst =~ s/\_$/substr $src, -1/e;
  17. }
  18. $spmap{$src} = $dst;
  19. }
  20. close SPMAP;
  21. my %sp;
  22. open SPFILE, $sp_file or die $!;
  23. while (<SPFILE>) {
  24. chomp;
  25. $_ = lc $_;
  26. my ($tag, $path, $file) = /^([^\;\s]*\s+)?([^\;\s]*\\)?([^\\\;\s]*)/;
  27. next if $file eq "" or $tag =~ /[cd]/i;
  28. my $name;
  29. my $temp = $path.$file;
  30. if (exists $spmap{$temp} or $tag =~ /[sm]/i) {
  31. $name = $spmap{$temp};
  32. } else {
  33. $name = $file;
  34. }
  35. next if !defined $name or $name eq "";
  36. $sp{$name}++;
  37. }
  38. close SPFILE;
  39. open IN, $input_file or die $!;
  40. my @lines = <IN>;
  41. close IN;
  42. open OUT, ">$output_file" or die $!;
  43. my $read = 0;
  44. for (@lines) {
  45. chomp;
  46. if (/^\[/) { $read = 0 }
  47. if ($read and $sp{lc $_}) { push @sp, $_; next }
  48. if (/^\[driver\]$/i) { $read = 1 }
  49. print OUT "$_\n";
  50. if (/^\[sp/i) { print OUT map {"$_\n"} @sp }
  51. }
  52. close OUT;