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.

196 lines
4.3 KiB

  1. #-----------------------------------------------------------------//
  2. # Script: cklang.pm
  3. #
  4. # (c) 2000 Microsoft Corporation. All rights reserved.
  5. #
  6. # Purpose: This script validate the language/class from
  7. # the Command Argument/Parameter.
  8. #
  9. # Version: <1.00> 06/16/2000 : Suemiao Rossognol
  10. #-----------------------------------------------------------------//
  11. ###-----Set current script Name/Version.----------------//
  12. package cklang;
  13. $VERSION = '1.00';
  14. ###-----Require section and extern modual.---------------//
  15. require 5.003;
  16. use strict;
  17. use lib $ENV{ "RazzleToolPath" };
  18. use lib $ENV{ "RazzleToolPath" }. "\\PostBuildScripts";
  19. no strict 'vars';
  20. no strict 'subs';
  21. use GetParams;
  22. use ParseTable;
  23. ###-----CkLang function.----------------------------------//
  24. sub CkLang
  25. {
  26. my ( $pLang, $pClass ) = @_;
  27. $pClass = uc( $pClass );
  28. $pLang = uc( $pLang );
  29. ###(1)Validate Language by Codes.txt file.-----------//
  30. my %hashCodes=();
  31. parse_table_file($ENV{"RazzleToolPath"}."\\Codes.txt", \%hashCodes );
  32. if ( !exists( $hashCodes{ $pLang } ) ){ return(0); }
  33. ###(2)Stop here if calss is not defined.------------//
  34. if( !$pClass ){ return (1);}
  35. ###(3)Sort ( @fe; jpn; ~cht )->( ~cht; @fe; jpn )
  36. @theClasses = ();
  37. &ReOrder( $pClass, \@theClasses );
  38. ###(4)Validate class.------------------------------//
  39. foreach $curClass( @theClasses )
  40. {
  41. ###Case: ~jpn.---------------------------------//
  42. if( $curClass =~ /^\~.*$/ )
  43. {
  44. if( $pLang ne substr( $curClass, 1, length($curClass)-1 ) )
  45. {
  46. next;
  47. }
  48. return(0);
  49. }
  50. ###Case: jpn.----------------------------------//
  51. if( $curClass !~ /^\@.*/ )
  52. {
  53. if( $pLang ne $curClass )
  54. {
  55. next;
  56. }
  57. return(1);
  58. }
  59. ###-----(3)Case: @FE.--------------------------//
  60. if ( $curClass ne $hashCodes{ $pLang }->{ "Class" })
  61. {
  62. next;
  63. }
  64. return(1);
  65. }
  66. return(0);
  67. }
  68. #-------------------------------------------------------------//
  69. #Function ReOrder: ( @fe; jpn; ~cht )->( ~cht; @fe; jpn )
  70. #-------------------------------------------------------------//
  71. sub ReOrder
  72. {
  73. my( $pStr, $rClass ) = @_;
  74. my @theClasses = split( /\;/,$pStr );
  75. $cnt = 0;
  76. $flag=0;
  77. $k=0;
  78. foreach ( @theClasses )
  79. {
  80. if( $_ =~ /^\~/ )
  81. {
  82. $rClass->[$k++]= $_;
  83. $flag |= ( 1 << $cnt );
  84. }
  85. ++$cnt;
  86. }
  87. $cnt =0;
  88. foreach ( @theClasses )
  89. {
  90. if( ( $flag >> $cnt++) & 1){ next; }
  91. $rClass->[$k++]= $_;
  92. }
  93. }
  94. #--------------------------------------------------------------//
  95. #Function Usage
  96. #--------------------------------------------------------------//
  97. sub Usage
  98. {
  99. print <<USAGE;
  100. Validates the given language and class by checking aganist
  101. the listed inforamtion in tools\codes.txt.
  102. Usage: $0 -l lang [ -c class ]
  103. -l Language.
  104. -c Class, with the following combination format, seperated by ;
  105. XXX considered as language
  106. \@XX considered as class of languages
  107. ~XXX considered as excluded language.
  108. /? Displays usage
  109. Examples:
  110. $0 -l:jpn -c:jpn ->>>> returns 0 (valid)
  111. $0 -l:jpn -c:\@fe;\@eu ->>>> returns 0 (valid)
  112. $0 -l:jpn -c:~chs;jpn;\@eu ->>>> returns 0 (valid)
  113. $0 -l:jpn -c:~jpn;\@fe ->>>> returns 1 (invalid)
  114. USAGE
  115. exit(1);
  116. }
  117. ###-----Cmd entry point for script.-------------------------------//
  118. if (eval("\$0 =~ /" . __PACKAGE__ . "\\.pm\$/i"))
  119. {
  120. # <run perl.exe GetParams.pm /? to get the complete usage for GetParams.pm>
  121. &GetParams ('-n', 'l:','-o', 'c:', '-p', 'lang class', @ARGV);
  122. $rtno = &cklang::CkLang( uc($lang), uc($class) );
  123. exit( !$rtno );
  124. }
  125. sub GetParams
  126. {
  127. #Call pm getparams with specified arguments
  128. &GetParams::getparams(@_);
  129. #Call the usage if specified by /?
  130. if ($HELP) {
  131. &Usage();
  132. }
  133. }
  134. #-------------------------------------------------------------//
  135. =head1 NAME
  136. B<cklang> - Check Language
  137. =head1 SYNOPSIS
  138. perl cklang.pm -l jpn [-c jpn]
  139. =head1 DESCRIPTION
  140. Check language jpn with class jpn
  141. =head1 INSTANCES
  142. =head2 <myinstances>
  143. <Description of myinstances>
  144. =head1 METHODS
  145. =head2 <mymathods>
  146. <Description of mymathods>
  147. =head1 SEE ALSO
  148. package ParseTable;
  149. =head1 AUTHOR
  150. <Suemiao Rossignol <[email protected]>>
  151. =cut
  152. 1;