Skip to content

Commit 9ccf94c

Browse files
committed
Remove old v0.6 compatibility code
1 parent bc04e93 commit 9ccf94c

File tree

16 files changed

+139
-371
lines changed

16 files changed

+139
-371
lines changed

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.2.0"
7+
version = "0.3.0"
88

99
[deps]
1010
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

src/StrBase.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ const SCU = SingleCU()
4545
const MCU = MultiCU()
4646

4747
include("types.jl")
48-
@static V6_COMPAT && include("compat.jl")
49-
@static NEW_ITERATE && include("fixparse.jl")
48+
include("fixparse.jl")
5049
include("chars.jl")
5150
include("access.jl")
5251
include("traits.jl")

src/compat.jl

Lines changed: 0 additions & 118 deletions
This file was deleted.

src/core.jl

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,16 @@ end
130130
@propagate_inbounds nextind(str::MaybeSub{T}, i::Int, nchar::Int) where {T<:Str} =
131131
(@_inline_meta(); _nextind(EncodingStyle(T), str, i, nchar))
132132

133-
@static if NEW_ITERATE
134-
@propagate_inbounds function _iterate(::SingleCU, T, str, pos)
135-
@_inline_meta()
136-
T(get_codeunit(str, pos)), pos + 1
137-
end
138-
@propagate_inbounds function iterate(str::MaybeSub{T}, pos::Integer=firstindex(str)
139-
)::Union{Nothing,Tuple{eltype(T),Int}} where {T<:Str}
140-
@_inline_meta()
141-
pos > ncodeunits(str) && return nothing
142-
@boundscheck pos <= 0 && boundserr(str, pos)
143-
_iterate(EncodingStyle(T), eltype(T), str, pos)
144-
end
133+
@propagate_inbounds function _iterate(::SingleCU, T, str, pos)
134+
@_inline_meta()
135+
T(get_codeunit(str, pos)), pos + 1
136+
end
137+
@propagate_inbounds function iterate(str::MaybeSub{T}, pos::Integer=firstindex(str)
138+
)::Union{Nothing,Tuple{eltype(T),Int}} where {T<:Str}
139+
@_inline_meta()
140+
pos > ncodeunits(str) && return nothing
141+
@boundscheck pos <= 0 && boundserr(str, pos)
142+
_iterate(EncodingStyle(T), eltype(T), str, pos)
145143
end
146144

147145
@propagate_inbounds index(str::MaybeSub{T}, i::Integer) where {T<:Str} =
@@ -155,11 +153,6 @@ end
155153
@propagate_inbounds reverseind(str::MaybeSub{T}, i::Integer) where {T<:Str} =
156154
(@_inline_meta(); _index(EncodingStyle(T), str, Int(ncodeunits(str) - i + 1)))
157155

158-
@static if V6_COMPAT
159-
@propagate_inbounds ind2chr(str::MaybeSub{T}, i::Int) where {T<:Str} = length(str, 1, i)
160-
@propagate_inbounds chr2ind(str::MaybeSub{T}, i::Int) where {T<:Str} = nextind(str, 0, i)
161-
end
162-
163156
@propagate_inbounds function is_valid(str::MaybeSub{T}, i::Integer) where {T<:Str}
164157
@_inline_meta()
165158
@boundscheck 1 <= i <= ncodeunits(str) || return false

src/search.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ const _not_found = 0:-1
120120
found(::Type{<:AbstractString}, v) = v != 0
121121
find_result(::Type{<:AbstractString}, v) = v
122122

123-
@static if !V6_COMPAT
124-
125123
nothing_sentinel(i) = first(i) == 0 ? nothing : i
126124
Base.findfirst(a, b::Str) = nothing_sentinel(find(First, a, b))
127125
Base.findlast(a, b::Str) = nothing_sentinel(find(Last, a, b))
@@ -132,8 +130,6 @@ Base.findlast(a::Str, b::AbstractString) = nothing_sentinel(find(Last, a, b))
132130
Base.findnext(a::Str, b::AbstractString, i) = nothing_sentinel(find(Fwd, a, b, i))
133131
Base.findprev(a::Str, b::AbstractString, i) = nothing_sentinel(find(Rev, a, b, i))
134132

135-
end
136-
137133
function find(::Type{D}, fun::Function, str::AbstractString, pos::Integer) where {D<:Direction}
138134
pos < Int(D===Fwd) && (@boundscheck boundserr(str, pos); return 0)
139135
if pos > (len = ncodeunits(str))

src/support.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -696,11 +696,9 @@ end
696696
first(str::Str, n::Integer) = str[1:min(end, nextind(str, 0, n))]
697697
last(str::Str, n::Integer) = str[max(1, prevind(str, ncodeunits(str)+1, n)):end]
698698

699-
const Chrs = @static V6_COMPAT ? Union{Char,AbstractChar} : Chr
700-
701699
# low level mem support functions
702700

703-
const HAS_WMEM = !(@static V6_COMPAT ? is_windows() : Sys.iswindows())
701+
const HAS_WMEM = !Sys.iswindows()
704702

705703
@static if HAS_WMEM
706704

@@ -900,15 +898,15 @@ end
900898

901899
(^)(str::T, cnt::Integer) where {T<:Str} = repeat(str, cnt)
902900

903-
function repeat(ch::CP, cnt::Integer) where {CP <: Chrs}
901+
function repeat(ch::CP, cnt::Integer) where {CP <: Chr}
904902
C = codepoint_cse(CP)
905903
cnt > 1 && return Str(C, _repeat(EncodingStyle(C), C, codepoint(ch), cnt))
906904
cnt == 1 && return _convert(C, codepoint(ch))
907905
cnt == 0 && return empty_str(C)
908906
repeaterr(cnt)
909907
end
910908

911-
(^)(ch::CP, cnt::Integer) where {CP <: Chrs} = repeat(ch, cnt)
909+
(^)(ch::CP, cnt::Integer) where {CP <: Chr} = repeat(ch, cnt)
912910

913911
function repeat(ch::C, cnt::Integer) where {C<:Union{ASCIIChr,LatinChr}}
914912
if cnt > 0

src/types.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ sizeof(s::Str) = sizeof(s.data) + 1 - STR_KEEP_NUL
120120
"""Codeunits of string as a Vector"""
121121
_data(s::Vector{UInt8}) = s
122122
_data(s::String) = s
123-
_data(s::Str{<:Byte_CSEs}) =
124-
@static V6_COMPAT ? Vector{UInt8}(s.data) : unsafe_wrap(Vector{UInt8}, s.data)
123+
_data(s::Str{<:Byte_CSEs}) = unsafe_wrap(Vector{UInt8}, s.data)
125124

126125
"""Pointer to codeunits of string"""
127126
pointer(s::Str{<:Byte_CSEs}) = pointer(s.data)

src/unicode.jl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,8 @@ Licensed under MIT License, see LICENSE.md
66
=#
77

88
# Recommended by deprecate
9-
@static if V6_COMPAT
10-
text_width(str::AbstractString) = strwidth(str)
11-
text_width(str::Str) = mapreduce(text_width, +, 0, str)
12-
13-
import Base: normalize_string
14-
Base.normalize_string(str::Str, opt::Symbol) = normalize(str, opt)
15-
Base.strwidth(str::Str) = text_width(str)
16-
else
17-
text_width(str::Str) = mapreduce(text_width, +, str; init=0)
18-
Base.Unicode.normalize(str::Str, opt::Symbol) = normalize(str, opt)
19-
end
9+
text_width(str::Str) = mapreduce(text_width, +, str; init=0)
10+
Base.Unicode.normalize(str::Str, opt::Symbol) = normalize(str, opt)
2011

2112
############################################################################
2213

src/utf8case.jl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ Copyright 2018 Gandalf Software, Inc., Scott P. Jones
33
Licensed under MIT License, see LICENSE.md
44
=#
55

6-
@static if V6_COMPAT
7-
Base.hex(chr::C) where {C<:Chr} = hex(codepoint(chr))
8-
Base.hex(chr::C, pad) where {C<:Chr} = hex(codepoint(chr), pad)
9-
end
10-
116
const CT = ChrBase.CaseTables
127

138
function _check_char(ch, tab)
@@ -115,11 +110,9 @@ function _upper_utf8(beg, off, len)
115110
out += 1
116111
elseif ch < 0xc4
117112
ch = (ch << 6) | (get_codeunit(pnt += 1) & 0x3f)
118-
if !V6_COMPAT && ch == 0xdf
119-
out = output_utf8_3byte!(out, 0x1e9e)
120-
else
121-
out = output_utf8_2byte!(out, _upper_bmp(ch))
122-
end
113+
out = (ch == 0xdf
114+
? output_utf8_3byte!(out, 0x1e9e)
115+
: output_utf8_2byte!(out, _upper_bmp(ch)))
123116
elseif ch < 0xe0
124117
# 2 byte
125118
c16 = get_utf8_2byte(pnt += 1, ch)
@@ -223,7 +216,7 @@ end
223216
@inline function _check_uppercase(ch, pnt)
224217
# ch < 0xc2 && return false (not needed, validated UTF-8 string)
225218
cont = get_codeunit(pnt)
226-
ch == 0xc3 ? ((cont > (V6_COMPAT ? 0x9f : 0x9e)) & (cont != 0xb7)) : (cont == 0xb5)
219+
ch == 0xc3 ? ((cont > 0x9e) & (cont != 0xb7)) : (cont == 0xb5)
227220
end
228221

229222
function uppercase(str::MaybeSub{S}) where {C<:UTF8CSE,S<:Str{C}}

src/util.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ end
100100

101101
function checkkeep(keepempty, keep, fun)
102102
keep === nothing && return keepempty
103-
@static V6_COMPAT ||
104-
Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", fun)
105-
keep
103+
Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", fun)
106104
end
107105

108106
splitarr(::Type{C}) where {C<:CSE} = SubString{Str{basecse(C),Nothing,Nothing,Nothing}}[]

0 commit comments

Comments
 (0)