This source file includes following definitions.
- uc_is_grapheme_break
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <config.h>
27
28
29 #include "unigbrk.h"
30
31
32
33
34 #define UC_IS_GRAPHEME_BREAK(A, B) \
35 (
36 \
37 \
38 \
39 (A) == GBP_CR && (B) == GBP_LF ? false : \
40 \
41 \
42 (A) == GBP_CONTROL || (A) == GBP_CR || (A) == GBP_LF ? true : \
43 \
44 \
45 (B) == GBP_CONTROL || (B) == GBP_CR || (B) == GBP_LF ? true : \
46 \
47 \
48 (A) == GBP_L && ((B) == GBP_L || (B) == GBP_V \
49 || (B) == GBP_LV || (B) == GBP_LVT) ? false : \
50 \
51 \
52 ((A) == GBP_LV || (A) == GBP_V) \
53 && ((B) == GBP_V || (B) == GBP_T) ? false : \
54 \
55 \
56 ((A) == GBP_LVT || (A) == GBP_T) && (B) == GBP_T ? false : \
57 \
58 \
59 (B) == GBP_EXTEND || (B) == GBP_ZWJ ? false : \
60 \
61 \
62 (B) == GBP_SPACINGMARK ? false : \
63 \
64 \
65 (A) == GBP_PREPEND ? false : \
66 \
67 \
68 ((A) == GBP_EB || (A) == GBP_EBG) && (B) == GBP_EM ? false : \
69 \
70 \
71 (A) == GBP_ZWJ && ((B) == GBP_GAZ || (B) == GBP_EBG) ? false \
72 \
73 \
74 : true)
75
76 #define UC_GRAPHEME_BREAKS_FOR(A) \
77 ( (UC_IS_GRAPHEME_BREAK(A, GBP_OTHER) << GBP_OTHER) \
78 | (UC_IS_GRAPHEME_BREAK(A, GBP_CR) << GBP_CR) \
79 | (UC_IS_GRAPHEME_BREAK(A, GBP_LF) << GBP_LF) \
80 | (UC_IS_GRAPHEME_BREAK(A, GBP_CONTROL) << GBP_CONTROL) \
81 | (UC_IS_GRAPHEME_BREAK(A, GBP_EXTEND) << GBP_EXTEND) \
82 | (UC_IS_GRAPHEME_BREAK(A, GBP_PREPEND) << GBP_PREPEND) \
83 | (UC_IS_GRAPHEME_BREAK(A, GBP_SPACINGMARK) << GBP_SPACINGMARK) \
84 | (UC_IS_GRAPHEME_BREAK(A, GBP_L) << GBP_L) \
85 | (UC_IS_GRAPHEME_BREAK(A, GBP_V) << GBP_V) \
86 | (UC_IS_GRAPHEME_BREAK(A, GBP_T) << GBP_T) \
87 | (UC_IS_GRAPHEME_BREAK(A, GBP_LV) << GBP_LV) \
88 | (UC_IS_GRAPHEME_BREAK(A, GBP_LVT) << GBP_LVT) \
89 | (UC_IS_GRAPHEME_BREAK(A, GBP_RI) << GBP_RI) \
90 | (UC_IS_GRAPHEME_BREAK(A, GBP_ZWJ) << GBP_ZWJ) \
91 | (UC_IS_GRAPHEME_BREAK(A, GBP_EB) << GBP_EB) \
92 | (UC_IS_GRAPHEME_BREAK(A, GBP_EM) << GBP_EM) \
93 | (UC_IS_GRAPHEME_BREAK(A, GBP_GAZ) << GBP_GAZ) \
94 | (UC_IS_GRAPHEME_BREAK(A, GBP_EBG) << GBP_EBG))
95
96 static const unsigned long int gb_table[18] =
97 {
98 UC_GRAPHEME_BREAKS_FOR(0),
99 UC_GRAPHEME_BREAKS_FOR(1),
100 UC_GRAPHEME_BREAKS_FOR(2),
101 UC_GRAPHEME_BREAKS_FOR(3),
102 UC_GRAPHEME_BREAKS_FOR(4),
103 UC_GRAPHEME_BREAKS_FOR(5),
104 UC_GRAPHEME_BREAKS_FOR(6),
105 UC_GRAPHEME_BREAKS_FOR(7),
106 UC_GRAPHEME_BREAKS_FOR(8),
107 UC_GRAPHEME_BREAKS_FOR(9),
108 UC_GRAPHEME_BREAKS_FOR(10),
109 UC_GRAPHEME_BREAKS_FOR(11),
110 UC_GRAPHEME_BREAKS_FOR(12),
111 UC_GRAPHEME_BREAKS_FOR(13),
112 UC_GRAPHEME_BREAKS_FOR(14),
113 UC_GRAPHEME_BREAKS_FOR(15),
114 UC_GRAPHEME_BREAKS_FOR(16),
115 UC_GRAPHEME_BREAKS_FOR(17),
116 };
117
118 bool
119 uc_is_grapheme_break (ucs4_t a, ucs4_t b)
120 {
121 int a_gcp, b_gcp;
122
123 if ((a | b) < 0x300)
124 {
125
126 return a != '\r' || b != '\n';
127 }
128
129 a_gcp = uc_graphemeclusterbreak_property (a);
130 b_gcp = uc_graphemeclusterbreak_property (b);
131 return (gb_table[a_gcp] >> b_gcp) & 1;
132 }