Skip to content

Commit 4b85eab

Browse files
committed
Fix for uppercase changes
1 parent 614db48 commit 4b85eab

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ git:
1717
## (tests will run but not make your overall status red)
1818
matrix:
1919
allow_failures:
20-
- julia: 1.0
20+
# - julia: 1.0
2121
- julia: nightly
2222

2323
## uncomment and modify the following lines to manually install system packages

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = ["ScottPJones <[email protected]>"]
44
keywords = ["Strings"]
55
license = "MIT"
66
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
7-
version = "0.1.9"
7+
version = "0.1.10"
88

99
[deps]
1010
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
julia 0.6 2-
22
MurmurHash3 0.1.5
33
ModuleInterfaceTools 0.1.6
4-
StrAPI 0.1.7
4+
StrAPI 0.1.8
55
CharSetEncodings 0.1.8
6-
ChrBase 0.1.5
6+
ChrBase 0.1.6

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ platform:
1313
## (tests will run but not make your overall status red)
1414
matrix:
1515
allow_failures:
16-
- julia_version: 1.0
16+
# - julia_version: 1.0
1717
- julia_version: latest
1818

1919
branches:

src/casefold.jl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ Copyright 2017-2018 Gandalf Software, Inc., Scott P. Jones
55
Licensed under MIT License, see LICENSE.md
66
=#
77

8+
_wide_lower_l(c) = ifelse(c > (V6_COMPAT ? 0xdf : 0xde), c != 0xf7, c == 0xb5)
9+
@inline _wide_lower_ch(ch) =
10+
ch <= 0x7f ? _islower_a(ch) : (ch > 0xff ? _islower_u(ch) : _wide_lower_l(ch))
11+
12+
@inline _isupper_ch(ch) =
13+
ch <= 0x7f ? _isupper_a(ch) : (ch <= 0xff ? _isupper_l(ch) : _isupper_u(ch))
14+
15+
_wide_lower_latin(ch) = (ch == 0xb5) | (ch == 0xff) | (!V6_COMPAT & (ch == 0xdf))
16+
17+
_wide_out_upper(ch) =
18+
ifelse(ch == 0xb5, 0x39c, ifelse(ch == 0xff, 0x178, ifelse(ch == 0xdf, 0x1e9e, ch%UInt16)))
19+
20+
821
function uppercase_first(str::MaybeSub{S}) where {C<:ASCIICSE,S<:Str{C}}
922
(len = ncodeunits(str)) == 0 && return str
1023
@preserve str begin
@@ -109,12 +122,6 @@ function uppercase_first(str::MaybeSub{S}) where {C<:LatinCSE,S<:Str{C}}
109122
end
110123
end
111124

112-
@static if V6_COMPAT
113-
_wide_lower_latin(ch) = (ch == 0xb5) | (ch == 0xff)
114-
else
115-
_wide_lower_latin(ch) = (ch == 0xb5) | (ch == 0xff) | (ch == 0xdf)
116-
end
117-
118125
# Special handling for characters that can't map into Latin1
119126
function uppercase_first(str::MaybeSub{S}) where {C<:_LatinCSE,S<:Str{C}}
120127
(len = ncodeunits(str)) == 0 && return str
@@ -128,7 +135,7 @@ function uppercase_first(str::MaybeSub{S}) where {C<:_LatinCSE,S<:Str{C}}
128135
Str(C, buf)
129136
elseif _wide_lower_latin(ch)
130137
buf, out = _allocate(UInt16, len)
131-
set_codeunit!(out, ifelse(ch == 0xb5, 0x39c, ifelse(ch == 0xff, 0x178, 0x1e9e)))
138+
set_codeunit!(out, _wide_out_upper(ch))
132139
# Perform the widen operation on the rest (should be done via SIMD)
133140
@inbounds for i = 2:len
134141
set_codeunit!(out += 2, get_codeunit(pnt += 2)%UInt16)
@@ -191,15 +198,7 @@ function _widenupper(beg::Ptr{UInt8}, off, len)
191198
out = bytoff(out, off)
192199
while out < fin
193200
ch = get_codeunit(cur)
194-
if ch == 0xb5
195-
set_codeunit!(out, 0x39c)
196-
elseif ch == 0xff
197-
set_codeunit!(out, 0x178)
198-
elseif !V6_COMPAT && (ch == 0xdf)
199-
set_codeunit!(out, 0x1e9e)
200-
else
201-
set_codeunit!(out, _can_upper(ch) ? ch - 0x20 : ch)
202-
end
201+
set_codeunit!(out, _can_upper(ch) ? ch - 0x20 : _wide_out_upper(ch))
203202
cur += 1
204203
out += 2
205204
end
@@ -319,7 +318,7 @@ function lowercase(str::MaybeSub{S}) where {C<:Union{UCS2_CSEs,UTF32_CSEs},S<:St
319318
pnt = beg = pointer(str)
320319
fin = beg + sizeof(str)
321320
while pnt < fin
322-
_can_lower_ch(get_codeunit(pnt)) && return _lower(C, beg, pnt-beg, ncodeunits(str))
321+
_isupper_ch(get_codeunit(pnt)) && return _lower(C, beg, pnt-beg, ncodeunits(str))
323322
pnt += sizeof(CU)
324323
end
325324
end

0 commit comments

Comments
 (0)