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.

115 lines
3.8 KiB

  1. #!/usr/bin/perl
  2. #
  3. # unicodepartition_makeheader.pl
  4. #
  5. # [email protected]
  6. # June 16, 1998
  7. #
  8. # Make a header file for the Unicode partition table mapping. This table
  9. # provides mapping for wchar_t to partition ID.
  10. #
  11. while (<>)
  12. {
  13. ($index,$value) = /(....) (....)/;
  14. @table[hex($index)] = $value;
  15. }
  16. open( OUTFILE, ">unipart.cxx" );
  17. printf OUTFILE "//+---------------------------------------------------------------------------\n";
  18. printf OUTFILE "//\n";
  19. printf OUTFILE "// Microsoft Trident\n";
  20. printf OUTFILE "// Copyright (C) Microsoft Corporation, 1998 - 2000.\n";
  21. printf OUTFILE "//\n";
  22. printf OUTFILE "// File: unipart.cxx\n";
  23. printf OUTFILE "//\n";
  24. printf OUTFILE "// This is a generated file. Do not modify by hand.\n";
  25. printf OUTFILE "//\n";
  26. printf OUTFILE "// Generating script: %s\n", __FILE__;
  27. printf OUTFILE "// Generated on %s\n", scalar localtime;
  28. printf OUTFILE "//\n";
  29. printf OUTFILE "//----------------------------------------------------------------------------\n";
  30. printf OUTFILE "\n";
  31. print OUTFILE "#ifndef X_INTLCORE_HXX_\n";
  32. print OUTFILE "#define X_INTLCORE_HXX_\n";
  33. print OUTFILE "#include \"intlcore.hxx\"\n";
  34. print OUTFILE "#endif\n\n";
  35. print OUTFILE "#pragma MARK_DATA(__FILE__)\n";
  36. print OUTFILE "#pragma MARK_CODE(__FILE__)\n";
  37. print OUTFILE "#pragma MARK_CONST(__FILE__)\n";
  38. print OUTFILE "\n";
  39. for ($page=0; $page<65536; $page+=256)
  40. {
  41. $value = @table[$page];
  42. for ($offset=1; $offset<256 && ($value eq @table[$page+$offset]); $offset++)
  43. {
  44. }
  45. $p = $page / 256;
  46. if ($offset==256)
  47. {
  48. @itable[$p] = "__$value";
  49. }
  50. else
  51. {
  52. $class = sprintf("acc_%02X", $p);
  53. @itable[$p] = $class;
  54. printf OUTFILE ("const CHAR_CLASS %s[256] = // U+%02Xxx\n{\n ", $class, $p);
  55. for ($o1=0;$o1<256;$o1+=16)
  56. {
  57. for ($o2=0;$o2<16;$o2+=1)
  58. {
  59. printf OUTFILE ("%s%s", @table[$page+$o1+$o2], ($o1+$o2==255)?" ":",");
  60. }
  61. printf OUTFILE (" // %02X - %02X\n", $o1, $o1+15);
  62. printf OUTFILE (" ") if $o1 != 240;
  63. }
  64. print OUTFILE "};\n\n";
  65. }
  66. }
  67. print OUTFILE "const CHAR_CLASS * const pccUnicodeClass[256] =\n{\n ";
  68. for ($p=0;$p<255;$p++)
  69. {
  70. print OUTFILE "@itable[$p], ";
  71. printf OUTFILE (" // %02X - %02X\n ", $p - 7, $p) if (($p & 7) == 7);
  72. }
  73. printf OUTFILE ("%s // F8 - FF\n", @itable[255]);
  74. print OUTFILE "};\n\n";
  75. print OUTFILE "//+----------------------------------------------------------------------------\n";
  76. print OUTFILE "//\n";
  77. print OUTFILE "// Function: CharClassFromChSlow\n";
  78. print OUTFILE "//\n";
  79. print OUTFILE "// Synopsis: Given a character return a Unicode character class. This\n";
  80. print OUTFILE "// character class implies other properties, such as script id,\n";
  81. print OUTFILE "// breaking class, etc.\n";
  82. print OUTFILE "//\n";
  83. print OUTFILE "// Note: pccUnicodeClass is a hack table. For every Unicode page for\n";
  84. print OUTFILE "// which every codepoint is the same value, the table entry is\n";
  85. print OUTFILE "// the charclass itself. Otherwise we have a pointer to a table\n";
  86. print OUTFILE "// of charclass.\n";
  87. print OUTFILE "//\n";
  88. print OUTFILE "//-----------------------------------------------------------------------------\n";
  89. print OUTFILE "\n";
  90. print OUTFILE "CHAR_CLASS CharClassFromChSlow(\n";
  91. print OUTFILE " wchar_t wch) // [in]\n";
  92. print OUTFILE "{\n";
  93. print OUTFILE " const CHAR_CLASS * const pcc = pccUnicodeClass[wch>>8];\n";
  94. print OUTFILE " const UINT_PTR icc = UINT_PTR(pcc);\n";
  95. print OUTFILE "\n";
  96. print OUTFILE " return (CHAR_CLASS)(icc < 256 ? icc : pcc[wch & 0xff]);\n";
  97. print OUTFILE "}\n";