@@ -5,12 +5,15 @@ Copyright 2017-2018 Gandalf Software, Inc., Scott P. Jones
55Licensed under MIT License, see LICENSE.md
66=#
77
8+ const _wide_upper = ChrBase. _wide_upper
9+ const _wide_lower_latin = ChrBase. _wide_lower_latin
10+
811function uppercase_first (str:: MaybeSub{S} ) where {C<: ASCIICSE ,S<: Str{C} }
912 (len = ncodeunits (str)) == 0 && return str
1013 @preserve str begin
1114 pnt = pointer (str)
1215 ch = get_codeunit (pnt)
13- _islower_a (ch) || return str
16+ _is_lower_a (ch) || return str
1417 buf, out = _allocate (UInt8, len)
1518 unsafe_copyto! (out, pnt, len)
1619 set_codeunit! (out, ch - 0x20 )
@@ -23,7 +26,7 @@ function lowercase_first(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
2326 @preserve str begin
2427 pnt = pointer (str)
2528 ch = get_codeunit (pnt)
26- _isupper_a (ch) || return str
29+ _is_upper_a (ch) || return str
2730 buf, out = _allocate (UInt8, len)
2831 unsafe_copyto! (out, pnt, len)
2932 set_codeunit! (out, ch + 0x20 )
@@ -38,7 +41,7 @@ function _upper(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:ASCIICSE}
3841 out += off
3942 while out < fin
4043 ch = get_codeunit (out)
41- _islower_a (ch) && set_codeunit! (out, ch - 0x20 )
44+ _is_lower_a (ch) && set_codeunit! (out, ch - 0x20 )
4245 out += 1
4346 end
4447 Str (C, buf)
@@ -51,7 +54,7 @@ function _lower(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:ASCIICSE}
5154 out += off
5255 while out < fin
5356 ch = get_codeunit (out)
54- _isupper_a (ch) && set_codeunit! (out, ch + 0x20 )
57+ _is_upper_a (ch) && set_codeunit! (out, ch + 0x20 )
5558 out += 1
5659 end
5760 Str (C, buf)
@@ -64,7 +67,7 @@ function _upper(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:LatinCSE}
6467 out += off
6568 while out < fin
6669 ch = get_codeunit (out)
67- _can_upper (ch) && set_codeunit! (out, ch - 0x20 )
70+ _can_upper_al (ch) && set_codeunit! (out, ch - 0x20 )
6871 out += 1
6972 end
7073 Str (C, buf)
@@ -76,7 +79,7 @@ function uppercase(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
7679 pnt = beg = pointer (str)
7780 fin = beg + len
7881 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)
8083 pnt += 1
8184 end
8285 end
@@ -89,7 +92,7 @@ function lowercase(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
8992 pnt = beg = pointer (str)
9093 fin = beg + len
9194 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)
9396 pnt += 1
9497 end
9598 end
@@ -101,7 +104,7 @@ function uppercase_first(str::MaybeSub{S}) where {C<:LatinCSE,S<:Str{C}}
101104 @preserve str begin
102105 pnt = pointer (str)
103106 ch = get_codeunit (pnt)
104- _can_upper (ch) || return str
107+ _can_upper_al (ch) || return str
105108 buf, out = _allocate (UInt8, len)
106109 set_codeunit! (out, ch - 0x20 )
107110 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}}
118121 if _wide_lower_latin (ch)
119122 buf, out = _allocate (UInt16, len)
120123 _widen! (out, pnt, pnt + len)
121- set_codeunit! (out, _wide_out_upper (ch))
124+ set_codeunit! (out, _wide_upper (ch))
122125 Str (_UCS2CSE, buf)
123- elseif _can_upper (ch)
126+ elseif _can_upper_al (ch)
124127 buf8, out8 = _allocate (UInt8, len)
125128 len > 1 && unsafe_copyto! (out8, pnt, len)
126129 set_codeunit! (out8, ch - 0x20 )
@@ -136,7 +139,7 @@ function lowercase_first(str::MaybeSub{S}) where {C<:Latin_CSEs,S<:Str{C}}
136139 @preserve str begin
137140 pnt = pointer (str)
138141 ch = get_codeunit (pnt)
139- _isupper_al (ch) || return str
142+ _is_upper_al (ch) || return str
140143 buf, out = _allocate (UInt8, len)
141144 set_codeunit! (out, ch + 0x20 )
142145 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}
158161 out += off
159162 while out < fin
160163 ch = get_codeunit (out)
161- _can_upper (ch) && set_codeunit! (out, ch - 0x20 )
164+ _can_upper_al (ch) && set_codeunit! (out, ch - 0x20 )
162165 out += 1
163166 end
164167 Str (C, buf)
@@ -182,7 +185,7 @@ function _widenupper(beg::Ptr{UInt8}, off, len)
182185 out = bytoff (out, off)
183186 while out < fin
184187 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))
186189 cur += 1
187190 out += 2
188191 end
@@ -195,7 +198,7 @@ function uppercase(str::MaybeSub{S}) where {C<:LatinCSE,S<:Str{C}}
195198 pnt = beg = pointer (str)
196199 fin = beg + len
197200 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)
199202 pnt += 1
200203 end
201204 end
@@ -210,7 +213,7 @@ function uppercase(str::MaybeSub{S}) where {C<:_LatinCSE,S<:Str{C}}
210213 while pnt < fin
211214 ch = get_codeunit (pnt)
212215 _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)
214217 pnt += 1
215218 end
216219 end
@@ -224,7 +227,7 @@ function _lower(::Type{C}, beg::Ptr{UInt8}, off, len) where {C<:Latin_CSEs}
224227 out += off
225228 while out < fin
226229 ch = get_codeunit (out)
227- _isupper_al (ch) && set_codeunit! (out, ch + 0x20 )
230+ _is_upper_al (ch) && set_codeunit! (out, ch + 0x20 )
228231 out += 1
229232 end
230233 Str (C, buf)
@@ -236,7 +239,7 @@ function lowercase(str::MaybeSub{S}) where {C<:Latin_CSEs,S<:Str{C}}
236239 pnt = beg = pointer (str)
237240 fin = beg + len
238241 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)
240243 pnt += 1
241244 end
242245 end
@@ -259,9 +262,9 @@ function _lower(::Type{C}, beg, off, len) where {C<:_UCS2CSE}
259262 while out < fin
260263 ch = get_codeunit (out)
261264 if ch <= 0x7f
262- _isupper_a (ch) && set_codeunit! (out, ch += 0x20 )
265+ _is_upper_a (ch) && set_codeunit! (out, ch += 0x20 )
263266 elseif ch <= 0xff
264- _isupper_l (ch) && set_codeunit! (out, ch += 0x20 )
267+ _is_upper_l (ch) && set_codeunit! (out, ch += 0x20 )
265268 elseif ch <= 0xffff
266269 if _can_lower_bmp (ch)
267270 ch = _lower_bmp (ch)
@@ -289,7 +292,7 @@ function _lower(::Type{C}, beg, off, len) where {C<:Union{UCS2CSE,UTF32_CSEs}}
289292 while out < fin
290293 ch = get_codeunit (out)
291294 if ch <= 0xff
292- _isupper_al (ch) && set_codeunit! (out, ch += 0x20 )
295+ _is_upper_al (ch) && set_codeunit! (out, ch += 0x20 )
293296 elseif ch <= 0xffff
294297 _can_lower_bmp (ch) && set_codeunit! (out, _lower_bmp (ch))
295298 elseif ch <= 0x1ffff
@@ -305,10 +308,10 @@ function lowercase_first(str::MaybeSub{S}) where {C<:_UCS2CSE,S<:Str{C}}
305308 @preserve str begin
306309 pnt = pointer (str)
307310 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) )) ||
310313 return str
311- cl = _lower_ch (ch)
314+ cl = _lowercase (ch)
312315 if ch > 0xff && cl <= 0xff && _check_mask_ul (pnt+ 1 , len- 1 , _latin_mask (UInt16))
313316 buf8, out8 = _allocate (UInt8, len)
314317 len > 1 && _narrow! (out8, pnt, pnt + len)
@@ -328,7 +331,7 @@ function uppercase_first(str::MaybeSub{S}) where {C<:Union{UCS2_CSEs,UTF32_CSEs}
328331 @preserve str begin
329332 pnt = pointer (str)
330333 ch = get_codeunit (pnt)
331- cp = _title_ch (ch)
334+ cp = _titlecase (ch)
332335 ch == cp && return str
333336 buf, out = _allocate (codeunit (C), len)
334337 len > 1 && unsafe_copyto! (out, pnt, len)
@@ -345,7 +348,7 @@ function lowercase_first(str::MaybeSub{S}) where {C<:Union{UCS2CSE,UTF32_CSEs},S
345348 _can_lower_ch (ch) || return str
346349 buf, out = _allocate (codeunit (C), len)
347350 len > 1 && unsafe_copyto! (out, pnt, len)
348- set_codeunit! (out, _lower_ch (ch))
351+ set_codeunit! (out, _lowercase (ch))
349352 Str (C, buf)
350353 end
351354end
@@ -372,7 +375,7 @@ function _upper(::Type{C}, beg, off, len) where {C<:Union{UCS2_CSEs,UTF32_CSEs}}
372375 while out < fin
373376 ch = get_codeunit (out)
374377 if ch <= 0x7f
375- _islower_a (ch) && set_codeunit! (out, ch -= 0x20 )
378+ _is_lower_a (ch) && set_codeunit! (out, ch -= 0x20 )
376379 elseif ch <= 0xff
377380 set_codeunit! (out, _uppercase_l (ch))
378381 elseif ch <= 0xffff
0 commit comments