DarkShadow44

Untitled

May 1st, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. static void sortkey_handle_japanese_character(sortkey_data* data, weight_main_info* weightmain, const character_info* info, const character_info* info_other, BOOL is_special)
  2. {
  3. const BYTE MASK_PW = 0x87;
  4. const BYTE BASELINE_EXTRA = 0xc4;
  5. const BYTE ISOLATE_KANA = 0x20 | BASELINE_EXTRA; /* if bit is set then hiragana, else katakana */
  6. const BYTE ISOLATE_SMALL = 0x2 | BASELINE_EXTRA; /* if bit is set then normal kana, else small kana */
  7. const BYTE ISOLATE_WIDTH = 0x1 | BASELINE_EXTRA; /* if bit is set then full width, else half width */
  8. int weight_case;
  9. weight_extra_info extra;
  10.  
  11. weightmain->script_member = 34;
  12. weightmain->weight_primary = info_other->weight_primary;
  13. if (info->weight_primary != 0 && is_special)
  14. weightmain->weight_primary = (char)(weightmain->weight_primary & MASK_PW); /* Special case found through testing, seems to work reliably */
  15.  
  16. if (!is_special)
  17. main_weights_add(data, weightmain);
  18.  
  19. weight_case = info_other->weight_case | BASELINE_EXTRA;
  20.  
  21. extra.flag_small = (BYTE)(weight_case & ISOLATE_SMALL);
  22. extra.flag_kana = (BYTE)(weight_case & ISOLATE_KANA);
  23. extra.flag_width = (BYTE)(weight_case & ISOLATE_WIDTH);
  24.  
  25. if (is_special && info->weight_primary == 1)
  26. extra.flag_width = (BYTE)((info->weight_case | BASELINE_EXTRA) & ISOLATE_WIDTH); // Special case found through testing, seems to work reliably
  27.  
  28. if (data->flags & NORM_IGNOREKANATYPE)
  29. extra.flag_kana = BASELINE_EXTRA;
  30. if (data->flags & NORM_IGNOREWIDTH)
  31. extra.flag_width = BASELINE_EXTRA;
  32. LIST_ADD(data->weights_extra, weight_extra_info, extra);
  33.  
  34. diacritic_weights_add(data, info, info->weight_diacritic);
  35. case_weights_add(data, MIN_WEIGHT);
  36. }
  37.  
  38. weightmain = create_weight_main(info.script_member, info.weight_primary);
  39.  
  40. if (weightmain.weight_primary <= 1)
  41. {
  42. int iprev;
  43.  
  44. weightmain.script_member = 0xff;
  45. weightmain.weight_primary = 0xff;
  46.  
  47. for (iprev = i - 1; iprev >= 0; iprev--)
  48. {
  49. WCHAR cprev = str[iprev];
  50. character_info prev_info;
  51. character_info_expansion dummy;
  52.  
  53. if (!get_char(data->locale , &prev_info, cprev))
  54. {
  55. if (!get_expansion(&dummy, cprev))
  56. continue;
  57. else
  58. break;
  59. }
  60.  
  61. if (prev_info.script_member < JAPANESE)
  62. {
  63. continue;
  64. }
  65. else if (prev_info.script_member == JAPANESE)
  66. {
  67. if (prev_info.weight_primary <= 1)
  68. continue;
  69.  
  70. sortkey_handle_japanese_character(data, &weightmain, &info, &prev_info, TRUE);
  71. break;
  72. }
  73. else
  74. {
  75. weightmain.script_member = prev_info.script_member;
  76. weightmain.weight_primary = prev_info.weight_primary;
  77.  
  78. diacritic_weights_add(data, &info, info.weight_diacritic);
  79.  
  80. case_weights_add(data, MIN_WEIGHT);
  81. break;
  82. }
  83. }
  84. main_weights_add(data, &weightmain);
  85. }
  86. else
  87. {
  88. sortkey_handle_japanese_character(data, &weightmain, &info, &info, FALSE);
  89. }
  90. break;
Advertisement
Add Comment
Please, Sign In to add comment