Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle eachrsplit change #22

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
version:
- '1.6'
- '1.7'
- '1.9'
- 'nightly'
os:
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["ScottPJones <scottjones@alum.mit.edu>"]
keywords = ["Strings"]
license = "MIT"
uuid = "e79e7a6a-7bb1-5a4d-9d64-da657b06f53a"
version = "1.1.4"
version = "1.1.5"

[deps]
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
Expand Down
3 changes: 3 additions & 0 deletions src/encode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ function convert(::Type{T},
Str(C, _str_cpy(UInt8, vec, length(vec)))
end

convert(::Type{UniStr}, vec::AbstractArray{UInt8}) = _str(vec)

convert(::Type{<:Str{C}}, vec::AbstractArray{UInt8}) where {C<:Union{BinaryCSE,Text1CSE}} =
Str(C, _str_cpy(UInt8, vec, length(vec)))
convert(::Type{<:Str{Text2CSE}}, vec::AbstractArray{UInt16}) =
Expand All @@ -210,6 +212,7 @@ convert(::Type{<:Str{Text4CSE}}, vec::AbstractArray{UInt32}) =
(::Type{UniStr})(str::String) = _str(str)
(::Type{UniStr})(str::Str{<:Union{ASCIICSE,SubSet_CSEs}}) = str

# need to fix this, should only allow already validated strings
function convert(::Type{UniStr}, str::T) where {T<:Str}
# handle zero length string quickly
is_empty(str) && return empty_ascii
Expand Down
13 changes: 9 additions & 4 deletions src/util.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#=
Utility functions for Str strings

Copyright 2018-2021 Gandalf Software, Inc., Scott P. Jones,
Copyright 2018-2023 Gandalf Software, Inc., Scott P. Jones,
and other contributors to the Julia language
Licensed under MIT License, see LICENSE.md
Based initially on julia/test/strings/util.jl
Expand Down Expand Up @@ -131,16 +131,21 @@ split(str::_SplitTypes, splitter::SetOfChars;
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =
__split(str, in(splitter), limit, checkkeep(keepempty, keep, :split), splitarr(str))

@static if isdefined(Base, :eachrsplit)
const _RSplitTypes = MaybeSub{<:Str{<:Union{_LatinCSE,_UCS2CSE,_UTF32CSE}}}
else
const _RSplitTypes = MaybeSub{<:Str}
Base._rsplit(str::MaybeSub{<:Str}, splitter, limit, keepempty, vec) =
__rsplit(str, splitter, limit, keepempty, vec)
end

rsplit(str::MaybeSub{<:Str}, splitter;
rsplit(str::_RSplitTypes, splitter;
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =
__rsplit(str, splitter, limit, checkkeep(keepempty, keep, :rsplit), splitarr(str))
rsplit(str::MaybeSub{<:Str}, splitter::AbstractChar;
rsplit(str::_RSplitTypes, splitter::AbstractChar;
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =
__rsplit(str, isequal(splitter), limit, checkkeep(keepempty, keep, :rsplit), splitarr(str))
rsplit(str::MaybeSub{<:Str}, splitter::SetOfChars;
rsplit(str::_RSplitTypes, splitter::SetOfChars;
limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) =
__rsplit(str, in(splitter), limit, checkkeep(keepempty, keep, :rsplit), splitarr(str))

Expand Down