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.

131 lines
3.5 KiB

  1. #
  2. # dirclass_maketable.pl
  3. #
  4. # [email protected]
  5. # 10 Aug 1998
  6. #
  7. # Generates a file mapping Unicode partition IDs to directional classes. This
  8. # process takes three input files: A 64K line file mapping each character to a
  9. # Unicode partition ID, a 64K line file mapping each character to a directional
  10. # class, and http://ie/specs/secure/trident/text/unicode_partitions.htm
  11. # which describes the partition ID definition and is used to order the
  12. # partition IDs.
  13. #
  14. $i = 0;
  15. $PARTDATA = "PartitionData.txt";
  16. print "Processing partition data\n";
  17. open PARTDATA or die("Can't open PartitionData.txt");
  18. while (<PARTDATA>)
  19. {
  20. ($char, $part) = /^([0-9a-fA-F]{4}) (....)$/;
  21. $partlist{$part} = ".";
  22. $$part[$#$part + 1] = hex($char);
  23. if (($i++ & 255) == 0)
  24. {
  25. print ".";
  26. }
  27. }
  28. close $PARTDATA;
  29. print "\n";
  30. @dirlist[65536] = ();
  31. $i = 0;
  32. $DIRDATA = "DirectionData.txt";
  33. print "Processing direction data\n";
  34. open DIRDATA or die("Can't open DirectionData.txt");
  35. while (<DIRDATA>)
  36. {
  37. ($char, $dir) = /^([0-9a-fA-F]{4}) (...)$/;
  38. @dirlist[hex($char)] = $dir;
  39. if (($i++ & 255) == 0)
  40. {
  41. print ".";
  42. }
  43. }
  44. close $DIRDATA;
  45. print "\n";
  46. print "Creating unidir.cxx\n";
  47. open(OUTFILE, ">unidir.cxx");
  48. printf OUTFILE "//\n";
  49. printf OUTFILE "// This is a generated file. Do not modify by hand.\n";
  50. printf OUTFILE "//\n";
  51. printf OUTFILE "// Generating script: %s\n", __FILE__;
  52. printf OUTFILE "// Generated on %s\n", scalar localtime;
  53. printf OUTFILE "//\n\n";
  54. print OUTFILE "#include \"headers.hxx\"\n\n";
  55. print OUTFILE "#ifndef X_INTLCORE_HXX_\n";
  56. print OUTFILE "#define X_INTLCORE_HXX_\n";
  57. print OUTFILE "#include \"intlcore.hxx\"\n";
  58. print OUTFILE "#endif\n\n";
  59. print OUTFILE "#ifndef X__UNIDIR_H\n";
  60. print OUTFILE "#define X__UNIDIR_H\n";
  61. print OUTFILE "#include \"unidir.h\"\n";
  62. print OUTFILE "#endif\n\n";
  63. print OUTFILE "#pragma MARK_DATA(__FILE__)\n";
  64. print OUTFILE "#pragma MARK_CODE(__FILE__)\n";
  65. print OUTFILE "#pragma MARK_CONST(__FILE__)\n";
  66. print OUTFILE "\n";
  67. print OUTFILE "const DIRCLS s_aDirClassFromCharClass[CHAR_CLASS_MAX] =\n{\n";
  68. while (<>)
  69. {
  70. next unless /^<h3>\d+./;
  71. ($catnum,$parts,$description) = /<h3>(\d+). +(.*) - ([^<]*)/;
  72. for $part (split /, +/, $parts)
  73. {
  74. %dirpart = ();
  75. for ($i = 0; $i <= $#$part; $i++)
  76. {
  77. $char = $$part[$i];
  78. $dirpart{$dirlist[$char]}++;
  79. }
  80. $dir = "UNK";
  81. $cch = 0;
  82. $fMultiple = 0;
  83. while (($dirT, $cchT) = each(%dirpart))
  84. {
  85. if ($dirT !~ /^UNK$/)
  86. {
  87. if ($dir !~ /^UNK$/)
  88. {
  89. $fMultiple = 1;
  90. }
  91. if ($dir !~ /^CBN$/ && ($cchT > $cch || $dirT =~ /^CBN$/))
  92. {
  93. $dir = $dirT;
  94. $cch = $cchT;
  95. }
  96. }
  97. }
  98. if ($fMultiple)
  99. {
  100. printf("Multiple directions in partition %s (%s); partition direction is %s\n", $part, $description, $dir);
  101. for ($i = 0; $i <= $#$part; $i++)
  102. {
  103. $char = $$part[$i];
  104. if ($dirlist[$char] !~ /^(UNK|($dir))$/)
  105. {
  106. printf(" U+%04X == %s\n", $char, $dirlist[$char]);
  107. }
  108. }
  109. }
  110. printf OUTFILE (" %s, // %s\n", $dir, $part);
  111. }
  112. }
  113. print OUTFILE "};\n\n";
  114. close OUTFILE;
  115. print "\n";