return the combining class of character c (between 0 and 255) */
| 825 | |
| 826 | /* return the combining class of character c (between 0 and 255) */ |
| 827 | static int unicode_get_cc(uint32_t c) |
| 828 | { |
| 829 | uint32_t code, n, type, cc, c1, b; |
| 830 | int pos; |
| 831 | const uint8_t *p; |
| 832 | |
| 833 | pos = get_index_pos(&code, c, |
| 834 | unicode_cc_index, sizeof(unicode_cc_index) / 3); |
| 835 | if (pos < 0) |
| 836 | return 0; |
| 837 | p = unicode_cc_table + pos; |
| 838 | for(;;) { |
| 839 | b = *p++; |
| 840 | type = b >> 6; |
| 841 | n = b & 0x3f; |
| 842 | if (n < 48) { |
| 843 | } else if (n < 56) { |
| 844 | n = (n - 48) << 8; |
| 845 | n |= *p++; |
| 846 | n += 48; |
| 847 | } else { |
| 848 | n = (n - 56) << 8; |
| 849 | n |= *p++ << 8; |
| 850 | n |= *p++; |
| 851 | n += 48 + (1 << 11); |
| 852 | } |
| 853 | if (type <= 1) |
| 854 | p++; |
| 855 | c1 = code + n + 1; |
| 856 | if (c < c1) { |
| 857 | switch(type) { |
| 858 | case 0: |
| 859 | cc = p[-1]; |
| 860 | break; |
| 861 | case 1: |
| 862 | cc = p[-1] + c - code; |
| 863 | break; |
| 864 | case 2: |
| 865 | cc = 0; |
| 866 | break; |
| 867 | default: |
| 868 | case 3: |
| 869 | cc = 230; |
| 870 | break; |
| 871 | } |
| 872 | return cc; |
| 873 | } |
| 874 | code = c1; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | static void sort_cc(int *buf, int len) |
| 879 | { |
no test coverage detected