@@ -5,12 +5,15 @@ Copyright 2017-2018 Gandalf Software, Inc., Scott P. Jones
5
5
Licensed under MIT License, see LICENSE.md
6
6
=#
7
7
8
+ const _wide_upper = ChrBase. _wide_upper
9
+ const _wide_lower_latin = ChrBase. _wide_lower_latin
10
+
8
11
function uppercase_first (str:: MaybeSub{S} ) where {C<: ASCIICSE ,S<: Str{C} }
9
12
(len = ncodeunits (str)) == 0 && return str
10
13
@preserve str begin
11
14
pnt = pointer (str)
12
15
ch = get_codeunit (pnt)
13
- _islower_a (ch) || return str
16
+ _is_lower_a (ch) || return str
14
17
buf, out = _allocate (UInt8, len)
15
18
unsafe_copyto! (out, pnt, len)
16
19
set_codeunit! (out, ch - 0x20 )
@@ -23,7 +26,7 @@ function lowercase_first(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
23
26
@preserve str begin
24
27
pnt = pointer (str)
25
28
ch = get_codeunit (pnt)
26
- _isupper_a (ch) || return str
29
+ _is_upper_a (ch) || return str
27
30
buf, out = _allocate (UInt8, len)
28
31
unsafe_copyto! (out, pnt, len)
29
32
set_codeunit! (out, ch + 0x20 )
@@ -38,7 +41,7 @@ function _upper(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:ASCIICSE}
38
41
out += off
39
42
while out < fin
40
43
ch = get_codeunit (out)
41
- _islower_a (ch) && set_codeunit! (out, ch - 0x20 )
44
+ _is_lower_a (ch) && set_codeunit! (out, ch - 0x20 )
42
45
out += 1
43
46
end
44
47
Str (C, buf)
@@ -51,7 +54,7 @@ function _lower(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:ASCIICSE}
51
54
out += off
52
55
while out < fin
53
56
ch = get_codeunit (out)
54
- _isupper_a (ch) && set_codeunit! (out, ch + 0x20 )
57
+ _is_upper_a (ch) && set_codeunit! (out, ch + 0x20 )
55
58
out += 1
56
59
end
57
60
Str (C, buf)
@@ -64,7 +67,7 @@ function _upper(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:LatinCSE}
64
67
out += off
65
68
while out < fin
66
69
ch = get_codeunit (out)
67
- _can_upper (ch) && set_codeunit! (out, ch - 0x20 )
70
+ _can_upper_al (ch) && set_codeunit! (out, ch - 0x20 )
68
71
out += 1
69
72
end
70
73
Str (C, buf)
@@ -76,7 +79,7 @@ function uppercase(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
76
79
pnt = beg = pointer (str)
77
80
fin = beg + len
78
81
while pnt < fin
79
- _islower_a (get_codeunit (pnt)) && return _upper (C, beg, pnt- beg, len)
82
+ _is_lower_a (get_codeunit (pnt)) && return _upper (C, beg, pnt- beg, len)
80
83
pnt += 1
81
84
end
82
85
end
@@ -89,7 +92,7 @@ function lowercase(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
89
92
pnt = beg = pointer (str)
90
93
fin = beg + len
91
94
while pnt < fin
92
- _isupper_a (get_codeunit (pnt)) && return _lower (C, beg, pnt- beg, len)
95
+ _is_upper_a (get_codeunit (pnt)) && return _lower (C, beg, pnt- beg, len)
93
96
pnt += 1
94
97
end
95
98
end
@@ -101,7 +104,7 @@ function uppercase_first(str::MaybeSub{S}) where {C<:LatinCSE,S<:Str{C}}
101
104
@preserve str begin
102
105
pnt = pointer (str)
103
106
ch = get_codeunit (pnt)
104
- _can_upper (ch) || return str
107
+ _can_upper_al (ch) || return str
105
108
buf, out = _allocate (UInt8, len)
106
109
set_codeunit! (out, ch - 0x20 )
107
110
len > 1 && unsafe_copyto! (out + 1 , pnt+ 1 , len- 1 )
@@ -118,9 +121,9 @@ function uppercase_first(str::MaybeSub{S}) where {C<:_LatinCSE,S<:Str{C}}
118
121
if _wide_lower_latin (ch)
119
122
buf, out = _allocate (UInt16, len)
120
123
_widen! (out, pnt, pnt + len)
121
- set_codeunit! (out, _wide_out_upper (ch))
124
+ set_codeunit! (out, _wide_upper (ch))
122
125
Str (_UCS2CSE, buf)
123
- elseif _can_upper (ch)
126
+ elseif _can_upper_al (ch)
124
127
buf8, out8 = _allocate (UInt8, len)
125
128
len > 1 && unsafe_copyto! (out8, pnt, len)
126
129
set_codeunit! (out8, ch - 0x20 )
@@ -136,7 +139,7 @@ function lowercase_first(str::MaybeSub{S}) where {C<:Latin_CSEs,S<:Str{C}}
136
139
@preserve str begin
137
140
pnt = pointer (str)
138
141
ch = get_codeunit (pnt)
139
- _isupper_al (ch) || return str
142
+ _is_upper_al (ch) || return str
140
143
buf, out = _allocate (UInt8, len)
141
144
set_codeunit! (out, ch + 0x20 )
142
145
len > 1 && unsafe_copyto! (out+ 1 , pnt+ 1 , len- 1 )
@@ -158,7 +161,7 @@ function _upper(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:_LatinCSE}
158
161
out += off
159
162
while out < fin
160
163
ch = get_codeunit (out)
161
- _can_upper (ch) && set_codeunit! (out, ch - 0x20 )
164
+ _can_upper_al (ch) && set_codeunit! (out, ch - 0x20 )
162
165
out += 1
163
166
end
164
167
Str (C, buf)
@@ -182,7 +185,7 @@ function _widenupper(beg::Ptr{UInt8}, off, len)
182
185
out = bytoff (out, off)
183
186
while out < fin
184
187
ch = get_codeunit (cur)
185
- set_codeunit! (out, _can_upper (ch) ? ch - 0x20 : _wide_out_upper (ch))
188
+ set_codeunit! (out, _can_upper_al (ch) ? ( ch - 0x20 ) : _wide_upper (ch))
186
189
cur += 1
187
190
out += 2
188
191
end
@@ -195,7 +198,7 @@ function uppercase(str::MaybeSub{S}) where {C<:LatinCSE,S<:Str{C}}
195
198
pnt = beg = pointer (str)
196
199
fin = beg + len
197
200
while pnt < fin
198
- _can_upper (get_codeunit (pnt)) && return _upper (C, beg, pnt- beg, len)
201
+ _can_upper_al (get_codeunit (pnt)) && return _upper (C, beg, pnt- beg, len)
199
202
pnt += 1
200
203
end
201
204
end
@@ -210,7 +213,7 @@ function uppercase(str::MaybeSub{S}) where {C<:_LatinCSE,S<:Str{C}}
210
213
while pnt < fin
211
214
ch = get_codeunit (pnt)
212
215
_wide_lower_latin (ch) && return _widenupper (beg, pnt- beg, len)
213
- _can_upper (ch) && return _upper (C, beg, pnt- beg, len)
216
+ _can_upper_al (ch) && return _upper (C, beg, pnt- beg, len)
214
217
pnt += 1
215
218
end
216
219
end
@@ -224,7 +227,7 @@ function _lower(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:Latin_CSEs}
224
227
out += off
225
228
while out < fin
226
229
ch = get_codeunit (out)
227
- _isupper_al (ch) && set_codeunit! (out, ch + 0x20 )
230
+ _is_upper_al (ch) && set_codeunit! (out, ch + 0x20 )
228
231
out += 1
229
232
end
230
233
Str (C, buf)
@@ -236,7 +239,7 @@ function lowercase(str::MaybeSub{S}) where {C<:Latin_CSEs,S<:Str{C}}
236
239
pnt = beg = pointer (str)
237
240
fin = beg + len
238
241
while pnt < fin
239
- _isupper_al (get_codeunit (pnt)) && return _lower (C, beg, pnt- beg, len)
242
+ _is_upper_al (get_codeunit (pnt)) && return _lower (C, beg, pnt- beg, len)
240
243
pnt += 1
241
244
end
242
245
end
@@ -259,9 +262,9 @@ function _lower(::Type{C}, beg, off, len) where {C<:_UCS2CSE}
259
262
while out < fin
260
263
ch = get_codeunit (out)
261
264
if ch <= 0x7f
262
- _isupper_a (ch) && set_codeunit! (out, ch += 0x20 )
265
+ _is_upper_a (ch) && set_codeunit! (out, ch += 0x20 )
263
266
elseif ch <= 0xff
264
- _isupper_l (ch) && set_codeunit! (out, ch += 0x20 )
267
+ _is_upper_l (ch) && set_codeunit! (out, ch += 0x20 )
265
268
elseif ch <= 0xffff
266
269
if _can_lower_bmp (ch)
267
270
ch = _lower_bmp (ch)
@@ -289,7 +292,7 @@ function _lower(::Type{C}, beg, off, len) where {C<:Union{UCS2CSE,UTF32_CSEs}}
289
292
while out < fin
290
293
ch = get_codeunit (out)
291
294
if ch <= 0xff
292
- _isupper_al (ch) && set_codeunit! (out, ch += 0x20 )
295
+ _is_upper_al (ch) && set_codeunit! (out, ch += 0x20 )
293
296
elseif ch <= 0xffff
294
297
_can_lower_bmp (ch) && set_codeunit! (out, _lower_bmp (ch))
295
298
elseif ch <= 0x1ffff
@@ -305,10 +308,10 @@ function lowercase_first(str::MaybeSub{S}) where {C<:_UCS2CSE,S<:Str{C}}
305
308
@preserve str begin
306
309
pnt = pointer (str)
307
310
ch = get_codeunit (pnt)
308
- (ch <= 0xff ? _isupper_al (ch) : ch <= 0xffff ? _can_lower_bmp (ch) :
309
- ch <= 0x1ffff && _can_lower_slp (ch)) ||
311
+ (ch <= 0xff ? _is_upper_al (ch) : ch <= 0xffff ? _can_lower_bmp (ch) :
312
+ ( ch <= 0x1ffff && _can_lower_slp (ch) )) ||
310
313
return str
311
- cl = _lower_ch (ch)
314
+ cl = _lowercase (ch)
312
315
if ch > 0xff && cl <= 0xff && _check_mask_ul (pnt+ 1 , len- 1 , _latin_mask (UInt16))
313
316
buf8, out8 = _allocate (UInt8, len)
314
317
len > 1 && _narrow! (out8, pnt, pnt + len)
@@ -328,7 +331,7 @@ function uppercase_first(str::MaybeSub{S}) where {C<:Union{UCS2_CSEs,UTF32_CSEs}
328
331
@preserve str begin
329
332
pnt = pointer (str)
330
333
ch = get_codeunit (pnt)
331
- cp = _title_ch (ch)
334
+ cp = _titlecase (ch)
332
335
ch == cp && return str
333
336
buf, out = _allocate (codeunit (C), len)
334
337
len > 1 && unsafe_copyto! (out, pnt, len)
@@ -345,7 +348,7 @@ function lowercase_first(str::MaybeSub{S}) where {C<:Union{UCS2CSE,UTF32_CSEs},S
345
348
_can_lower_ch (ch) || return str
346
349
buf, out = _allocate (codeunit (C), len)
347
350
len > 1 && unsafe_copyto! (out, pnt, len)
348
- set_codeunit! (out, _lower_ch (ch))
351
+ set_codeunit! (out, _lowercase (ch))
349
352
Str (C, buf)
350
353
end
351
354
end
@@ -372,7 +375,7 @@ function _upper(::Type{C}, beg, off, len) where {C<:Union{UCS2_CSEs,UTF32_CSEs}}
372
375
while out < fin
373
376
ch = get_codeunit (out)
374
377
if ch <= 0x7f
375
- _islower_a (ch) && set_codeunit! (out, ch -= 0x20 )
378
+ _is_lower_a (ch) && set_codeunit! (out, ch -= 0x20 )
376
379
elseif ch <= 0xff
377
380
set_codeunit! (out, _uppercase_l (ch))
378
381
elseif ch <= 0xffff
0 commit comments