This source file includes following definitions.
- utf32le_mbc_enc_len
- utf32le_is_mbc_newline
- utf32le_mbc_to_code
- utf32le_code_to_mbclen
- utf32le_code_to_mbc
- utf32le_mbc_case_fold
- utf32le_is_mbc_ambiguous
- utf32le_left_adjust_char_head
- utf32le_get_case_fold_codes_by_str
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
27
28
29
30 #include "regenc.h"
31
32 static int
33 utf32le_mbc_enc_len(const UChar* p ARG_UNUSED)
34 {
35 return 4;
36 }
37
38 static int
39 utf32le_is_mbc_newline(const UChar* p, const UChar* end)
40 {
41 if (p + 3 < end) {
42 if (*p == 0x0a && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0)
43 return 1;
44 #ifdef USE_UNICODE_ALL_LINE_TERMINATORS
45 if ((
46 #ifndef USE_CRNL_AS_LINE_TERMINATOR
47 *p == 0x0d ||
48 #endif
49 *p == 0x85)
50 && *(p+1) == 0x00 && (p+2) == 0x00 && *(p+3) == 0x00)
51 return 1;
52 if (*(p+1) == 0x20 && (*p == 0x29 || *p == 0x28)
53 && *(p+2) == 0x00 && *(p+3) == 0x00)
54 return 1;
55 #endif
56 }
57 return 0;
58 }
59
60 static OnigCodePoint
61 utf32le_mbc_to_code(const UChar* p, const UChar* end ARG_UNUSED)
62 {
63 return (OnigCodePoint )(((p[3] * 256 + p[2]) * 256 + p[1]) * 256 + p[0]);
64 }
65
66 static int
67 utf32le_code_to_mbclen(OnigCodePoint code ARG_UNUSED)
68 {
69 return 4;
70 }
71
72 static int
73 utf32le_code_to_mbc(OnigCodePoint code, UChar *buf)
74 {
75 UChar* p = buf;
76
77 *p++ = (UChar ) (code & 0xff);
78 *p++ = (UChar )((code & 0xff00) >> 8);
79 *p++ = (UChar )((code & 0xff0000) >>16);
80 *p++ = (UChar )((code & 0xff000000) >>24);
81 return 4;
82 }
83
84 static int
85 utf32le_mbc_case_fold(OnigCaseFoldType flag,
86 const UChar** pp, const UChar* end, UChar* fold)
87 {
88 const UChar* p = *pp;
89
90 if (ONIGENC_IS_ASCII_CODE(*p) && *(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) {
91 #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
92 if ((flag & ONIGENC_CASE_FOLD_TURKISH_AZERI) != 0) {
93 if (*p == 0x49) {
94 *fold++ = 0x31;
95 *fold++ = 0x01;
96 }
97 }
98 else {
99 #endif
100 *fold++ = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
101 *fold++ = 0;
102 #ifdef USE_UNICODE_CASE_FOLD_TURKISH_AZERI
103 }
104 #endif
105
106 *fold++ = 0;
107 *fold = 0;
108 *pp += 4;
109 return 4;
110 }
111 else
112 return onigenc_unicode_mbc_case_fold(ONIG_ENCODING_UTF32_LE, flag, pp, end,
113 fold);
114 }
115
116 #if 0
117 static int
118 utf32le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
119 {
120 const UChar* p = *pp;
121
122 (*pp) += 4;
123
124 if (*(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) {
125 int c, v;
126
127 if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
128 return TRUE;
129 }
130
131 c = *p;
132 v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
133 (BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
134 if ((v | BIT_CTYPE_LOWER) != 0) {
135
136 if (c >= 0xaa && c <= 0xba)
137 return FALSE;
138 else
139 return TRUE;
140 }
141 return (v != 0 ? TRUE : FALSE);
142 }
143
144 return FALSE;
145 }
146 #endif
147
148 static UChar*
149 utf32le_left_adjust_char_head(const UChar* start, const UChar* s)
150 {
151 int rem;
152
153 if (s <= start) return (UChar* )s;
154
155 rem = (s - start) % 4;
156 return (UChar* )(s - rem);
157 }
158
159 static int
160 utf32le_get_case_fold_codes_by_str(OnigCaseFoldType flag,
161 const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])
162 {
163 return onigenc_unicode_get_case_fold_codes_by_str(ONIG_ENCODING_UTF32_LE,
164 flag, p, end, items);
165 }
166
167 OnigEncodingType OnigEncodingUTF32_LE = {
168 utf32le_mbc_enc_len,
169 "UTF-32LE",
170 4,
171 4,
172 utf32le_is_mbc_newline,
173 utf32le_mbc_to_code,
174 utf32le_code_to_mbclen,
175 utf32le_code_to_mbc,
176 utf32le_mbc_case_fold,
177 onigenc_unicode_apply_all_case_fold,
178 utf32le_get_case_fold_codes_by_str,
179 onigenc_unicode_property_name_to_ctype,
180 onigenc_unicode_is_code_ctype,
181 onigenc_utf16_32_get_ctype_code_range,
182 utf32le_left_adjust_char_head,
183 onigenc_always_false_is_allowed_reverse_match
184 };