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.

160 lines
4.8 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. if ($lines[0] =~ /^\xff\xfe/)
  43. {
  44. ProcessUnicode();
  45. }
  46. else
  47. {
  48. ProcessANSI();
  49. }
  50. sub ProcessANSI
  51. {
  52. open OUT, ">$output_file" or die $!;
  53. for (@lines) {
  54. if (/^\[sourcedisksfiles.*\]$/i ... /^\[(?!sourcedisksfiles).*\]$/i) {
  55. my ($file) = /^([^\s=]+)/;
  56. if ($sp{lc $file}) {
  57. s/(=\s*)1,/${1}100,/;
  58. s/(=\s*)7,/${1}107,/;
  59. }
  60. }
  61. print OUT $_;
  62. }
  63. close OUT;
  64. # NOTE: In my testing, $flag doesn't behave as expected, instead EVERY line is
  65. # processed. Probably something like the if(...) in the above loop would be better.
  66. if ($ENV{_BuildArch} =~ /ia64/i){
  67. open OUT, ">$output_file" or die $!;
  68. my $flag=FALSE;
  69. for (@lines) {
  70. if (/^\[sourcedisksfiles\.ia64\]$/i || $flag==TRUE) {
  71. $flag=TRUE;
  72. if (/\[(.*)\]/) {$flag=FALSE;}
  73. my ($file) = /^([^\s=]+)/;
  74. if (/=\s*55,/) {
  75. $file =~ /.(.*)$/;
  76. if ($sp{lc $1}) {
  77. s/(=\s*)55,/${1}155,/;
  78. s/(=\s*)56,/${1}156,/;
  79. }
  80. }
  81. }
  82. print OUT $_;
  83. }
  84. close OUT;
  85. }
  86. }
  87. sub ProcessUnicode
  88. {
  89. # Need to reread our data
  90. open IN, $input_file or die $!;
  91. binmode(IN);
  92. @lines = <IN>;
  93. close IN;
  94. open OUT, ">${output_file}";# or die $!;
  95. binmode(OUT);
  96. for (@lines)
  97. {
  98. # if (/^\[sourcedisksfiles.*\]$/i ... /^\[(?!sourcedisksfiles).*\]$/i) Except in unicode...
  99. if (/^\0\[\0s\0o\0u\0r\0c\0e\0d\0i\0s\0k\0s\0f\0i\0l\0e\0s\0.*\]\0$\0/i ...
  100. /^\0\[\0(?!s\0o\0u\0r\0c\0e\0d\0i\0s\0k\0s\0f\0i\0l\0e\0s\0).*\]\0$\0/i)
  101. {
  102. my ($file) = /^([^\s=]+)/;
  103. $file =~ s/\0//g; # Get rid of extra \0s from unicode to compare file name
  104. if ($sp{lc $file})
  105. {
  106. # s/(=\s*)1,/${1}100,/; Except that its a unicode file, so we've gotta be nasty
  107. # = s* 1 , ${1}1 0 0 ,
  108. s/(=[\s\0]*)1\0,\0/${1}1\0\x30\0\x30\0,\0/;
  109. # s/(=\s*)7,/${1}107,/; Except that its a unicode file, so we've gotta be nasty
  110. # = s* 7 , ${1}1 0 7 ,
  111. s/(=[\s\0]*)7\0,\0/${1}1\0\x30\0\x37\0,\0/;
  112. }
  113. }
  114. print OUT $_;
  115. }
  116. close OUT;
  117. # Do we have any 55s for the ia64 build?
  118. if ($ENV{_BuildArch} =~ /ia64/i)
  119. {
  120. open OUT, ">$output_file" or die $!;
  121. binmode(OUT);
  122. for (@lines)
  123. {
  124. # if (/^\[sourcedisksfiles\.ia64]$/i ... /^\[(?!sourcedisksfiles\.ia64).*\]$/i) Except in unicode...
  125. if (/^\0\[\0s\0o\0u\0r\0c\0e\0d\0i\0s\0k\0s\0f\0i\0l\0e\0s\0\.\0i\0a\0\x36\0\x34\0\]\0$\0/i ...
  126. /^\0\[\0(?!s\0o\0u\0r\0c\0e\0d\0i\0s\0k\0s\0f\0i\0l\0e\0s\0\.\0i\0a\0\x36\0\x34\0).*\]\0$\0/i)
  127. {
  128. my ($file) = /^([^\s=]+)/;
  129. $file =~ s/\0//g; # Get rid of extra \0s from unicode to compare file name
  130. $file =~ /.(.*)$/; # Trim the 1st character
  131. if ($sp{lc $1})
  132. {
  133. # s/(=\s*)55,/${1}155,/; Except that its a unicode file, so we've gotta be nasty
  134. # = s* 5 5 , ${1}1 5 5 ,
  135. s/(=[\s\0]*)5\0\x35\0,\0/${1}1\0\x35\0\x35\0,\0/;
  136. # s/(=\s*)56,/${1}156,/; Except that its a unicode file, so we've gotta be nasty
  137. # = s* 5 6 , ${1}1 5 6 ,
  138. s/(=[\s\0]*)5\0\x36\0,\0/${1}1\0\x35\0\x36\0,\0/;
  139. }
  140. }
  141. print OUT $_;
  142. }
  143. close OUT;
  144. }
  145. }