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.

136 lines
2.7 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM SanityCheckUnicodeFiles.cmd
  5. REM Ensure that commonly messed up Unicode files have the proper
  6. REM FFFE "signature" on the front of the file.
  7. REM
  8. REM Copyright (c) Microsoft Corporation. All rights reserved.
  9. REM
  10. REM ------------------------------------------------------------------
  11. perl -x "%~f0" %*
  12. goto :EOF
  13. #!perl
  14. use strict;
  15. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  16. use lib $ENV{RAZZLETOOLPATH};
  17. use PbuildEnv;
  18. use ParseArgs;
  19. use Logmsg;
  20. use UnicodeCheck;
  21. sub Usage { print<<USAGE; exit(1) }
  22. SanityCheckUnicodeFiles.cmd
  23. Ensure that commonly messed up Unicode files have the proper "FFFE"
  24. Unicode signature on the front of the file.
  25. We read the list of files to sanity check from
  26. "$ENV{RAZZLETOOLPATH}\\PostBuildScripts\\SanityCheckList.txt".
  27. All paths we obtain are appended to "$ENV{_NTDRIVE}$ENV{_NTROOT}\\"
  28. to produce the final path to the file to be checked.
  29. USAGE
  30. parseargs('?' => \&Usage);
  31. my $BasePath = "$ENV{_NTDRIVE}$ENV{_NTROOT}";
  32. my $FileList = "$ENV{RAZZLETOOLPATH}\\PostBuildScripts\\SanityCheckList.txt";
  33. logmsg( "Reading file list to sanity check from '$FileList'..." );
  34. #
  35. # Read the file list in
  36. #
  37. # We assume things will be in the \NT tree and in the format of:
  38. #
  39. # \mergedcomponents\setupinfs\usa\intl.txt
  40. #
  41. my @FilesToSanityCheck;
  42. my $ThisLine;
  43. if ( open(FILELIST, $FileList ) )
  44. {
  45. while ( <FILELIST> )
  46. {
  47. # Save off the line so we can use it...
  48. $ThisLine = $_;
  49. # Chop off any trailing newline...
  50. $ThisLine =~ s/\n$//;
  51. # We only care about this if it's not a comment line...
  52. if ( $ThisLine =~ /^\;/ )
  53. {
  54. # printf( "Comment Line : $ThisLine\n" );
  55. }
  56. else
  57. {
  58. # printf( "Data Line : $ThisLine\n" );
  59. # Build the correct path...
  60. my $FilePath;
  61. $FilePath = $BasePath;
  62. if ( ! ($ThisLine =~ /^\\/) )
  63. {
  64. $FilePath .= "\\";
  65. }
  66. $FilePath .= $ThisLine;
  67. # Append this file path to the array...
  68. push( @FilesToSanityCheck, $FilePath );
  69. }
  70. }
  71. # Close the file...
  72. close( FILELIST );
  73. }
  74. my $NumFiles = @FilesToSanityCheck;
  75. if ( $NumFiles < 1 )
  76. {
  77. wrnmsg( "No files to sanity check!" );
  78. }
  79. logmsg( "Checking $NumFiles file(s) for valid Unicode signatures..." );
  80. #
  81. # Sanity check each file in the list
  82. #
  83. my $ThisFile;
  84. foreach $ThisFile (@FilesToSanityCheck)
  85. {
  86. IsFileUnicode( $ThisFile );
  87. }
  88. logmsg( "Done checking Unicode signatures." );