Skip to content

Commit 266312c

Browse files
authored
Merge pull request #16 from JuliaString/spj/eachsplit
Update for change removing _split from Base/util.jl in 1.8
2 parents c187e38 + c0b7b44 commit 266312c

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

.drone.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
22
kind: pipeline
3-
name: linux - arm64 - Julia 1.5
3+
name: linux - arm64 - Julia 1.6
44

55
platform:
66
os: linux
77
arch: arm64
88

99
steps:
1010
- name: build
11-
image: julia:1.5
11+
image: julia:1.6
1212
commands:
1313
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"
1414

1515
---
1616
kind: pipeline
17-
name: linux - arm64 - Julia 1.6
17+
name: linux - arm64 - Julia 1.7
1818

1919
platform:
2020
os: linux
2121
arch: arm64
2222

2323
steps:
2424
- name: build
25-
image: julia:1.6
25+
image: julia:1.7
2626
commands:
2727
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.5'
1413
- '1.6'
14+
- '1.7'
1515
- 'nightly'
1616
os:
1717
- ubuntu-latest

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = ["ScottPJones <scottjones@alum.mit.edu>"]
44
keywords = ["Strings"]
55
license = "MIT"
66
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
7-
version = "1.0.6"
7+
version = "1.1.0"
88

99
[deps]
1010
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
@@ -24,7 +24,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2424
test = ["Test", "Random"]
2525

2626
[compat]
27-
julia = "1"
27+
julia = "^1.6"
2828
ModuleInterfaceTools = "1"
2929
MurmurHash3 = "^1.2"
3030
StrAPI = "^1.1"

src/StrBase.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ using ModuleInterfaceTools
3434
MS_UTF8, MS_UTF16, MS_UTF32, MS_SubUTF32, MS_Latin, MS_ByteStr, MS_RawUTF8,
3535
_wrap_substr, _empty_sub,
3636
AccessType, UInt16_U, UInt32_U, UInt16_S, UInt32_S, UInt16_US, UInt32_US,
37-
alignedtype, swappedtype, checkkeep, splitarr, __split, __rsplit, __replace
37+
alignedtype, swappedtype, checkkeep, splitarr, __rsplit, __replace
38+
39+
@static if !isdefined(Base, :eachsplit)
40+
@api develop __split
41+
end
3842

3943
using Base: @_inline_meta, @propagate_inbounds, @_propagate_inbounds_meta, RefValue
4044

src/search.jl

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,14 @@ found(::Type{<:AbstractString}, v) = v != 0
121121
find_result(::Type{<:AbstractString}, v) = v
122122

123123
nothing_sentinel(i) = first(i) == 0 ? nothing : i
124-
Base.findfirst(a, b::Str) = nothing_sentinel(find(First, a, b))
125-
Base.findlast(a, b::Str) = nothing_sentinel(find(Last, a, b))
126-
Base.findnext(a, b::Str, i) = nothing_sentinel(find(Fwd, a, b, i))
127-
Base.findprev(a, b::Str, i) = nothing_sentinel(find(Rev, a, b, i))
128-
Base.findfirst(a::Str, b::AbstractString) = nothing_sentinel(find(First, a, b))
129-
Base.findlast(a::Str, b::AbstractString) = nothing_sentinel(find(Last, a, b))
130-
Base.findnext(a::Str, b::AbstractString, i) = nothing_sentinel(find(Fwd, a, b, i))
131-
Base.findprev(a::Str, b::AbstractString, i) = nothing_sentinel(find(Rev, a, b, i))
132-
133124
# Fix ambiguities caused by addition of new findfirst definition to base
134-
Base.findfirst(a::AbstractChar, b::Str) = nothing_sentinel(find(First, a, b))
135-
Base.findlast(a::AbstractChar, b::Str) = nothing_sentinel(find(Last, a, b))
136-
Base.findnext(a::AbstractChar, b::Str, i) = nothing_sentinel(find(Fwd, a, b, i))
137-
Base.findprev(a::AbstractChar, b::Str, i) = nothing_sentinel(find(Rev, a, b, i))
125+
for (S,T) in ((:AbstractString, :Str), (:Str, :AbstractString), (:Str, :Str),
126+
(:Function, :Str), (:AbstractChar, :Str))
127+
@eval Base.findfirst(a::$S, b::$T) = nothing_sentinel(find(First, a, b))
128+
@eval Base.findlast(a::$S, b::$T) = nothing_sentinel(find(Last, a, b))
129+
@eval Base.findnext(a::$S, b::$T, i::Integer) = nothing_sentinel(find(Fwd, a, b, i))
130+
@eval Base.findprev(a::$S, b::$T, i::Integer) = nothing_sentinel(find(Rev, a, b, i))
131+
end
138132

139133
function find(::Type{D}, fun::Function, str::AbstractString, pos::Integer) where {D<:Direction}
140134
pos < Int(D===Fwd) && (@boundscheck boundserr(str, pos); return 0)

src/util.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#=
22
Utility functions for Str strings
33
4-
Copyright 2018-2020 Gandalf Software, Inc., Scott P. Jones,
4+
Copyright 2018-2021 Gandalf Software, Inc., Scott P. Jones,
55
and other contributors to the Julia language
66
Licensed under MIT License, see LICENSE.md
77
Based initially on julia/test/strings/util.jl
@@ -65,6 +65,7 @@ rpad(ch::Chr, cnt::Integer, pad::AbstractChar=' ') =
6565
const SetOfChars =
6666
Union{Tuple{Vararg{<:AbstractChar}},AbstractVector{<:AbstractChar},Set{<:AbstractChar}}
6767

68+
@static if !isdefined(Base, :eachsplit)
6869
function __split(str, splitter, limit::Integer, keep_empty::Bool, strs::Vector)
6970
pos = 1
7071
lst = lastindex(str)
@@ -85,6 +86,7 @@ function __split(str, splitter, limit::Integer, keep_empty::Bool, strs::Vector)
8586
end
8687
(keep_empty || pos <= lst) ? push!(strs, SubString(str, pos)) : strs
8788
end
89+
end
8890

8991
function __rsplit(str, splitter, limit::Integer, keep_empty::Bool, strs::Vector)
9092
res = find(Last, splitter, str)
@@ -111,10 +113,9 @@ splitarr(::MaybeSub{String}) = SubString{String}[]
111113
splitarr(::MaybeSub{T}) where {T<:Str} =
112114
SubString{Str{basecse(T),Nothing,Nothing,Nothing}}[]
113115

116+
@static if !isdefined(Base, :eachsplit)
114117
Base._split(str::MaybeSub{<:Str}, splitter, limit, keepempty, vec) =
115118
__split(str, splitter, limit, keepempty, vec)
116-
Base._rsplit(str::MaybeSub{<:Str}, splitter, limit, keepempty, vec) =
117-
__rsplit(str, splitter, limit, keepempty, vec)
118119

119120
split(str::MaybeSub{<:Str}, splitter;
120121
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =
@@ -127,6 +128,10 @@ split(str::MaybeSub{<:Str}, splitter::AbstractChar;
127128
split(str::MaybeSub{<:Str}, splitter::SetOfChars;
128129
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =
129130
__split(str, in(splitter), limit, checkkeep(keepempty, keep, :split), splitarr(str))
131+
end
132+
133+
Base._rsplit(str::MaybeSub{<:Str}, splitter, limit, keepempty, vec) =
134+
__rsplit(str, splitter, limit, keepempty, vec)
130135

131136
rsplit(str::MaybeSub{<:Str}, splitter;
132137
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =

0 commit comments

Comments
 (0)