Skip to content
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
19 changes: 3 additions & 16 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,17 @@ steps:
image: julia:1.5
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"
---
kind: pipeline
name: linux - arm64 - Julia 1.0

platform:
os: linux
arch: arm64

steps:
- name: build
image: julia:1.0
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"

---
kind: pipeline
name: linux - arm - Julia 1.0
name: linux - arm64 - Julia 1.6

platform:
os: linux
arch: arm
arch: arm64

steps:
- name: build
image: julia:1.0
image: julia:1.6
commands:
- "julia --project=. --check-bounds=yes --color=yes -e 'using InteractiveUtils; versioninfo(verbose=true); using Pkg; Pkg.build(); Pkg.test(coverage=true)'"
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.5'
- '1.6'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions 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.0.4"
version = "1.0.5"

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

[compat]
julia = "^1.0.0"
ModuleInterfaceTools = "^1.0.0"
MurmurHash3 = "^1.0.3"
StrAPI = "^1.0.0"
ChrBase = "^1.0.1"
CharSetEncodings = "^1.0.0"
julia = "1"
ModuleInterfaceTools = "1"
MurmurHash3 = "^1.2"
StrAPI = "^1.1"
ChrBase = "^1.0.3"
CharSetEncodings = "1"
4 changes: 2 additions & 2 deletions src/compare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ end
while pnt < fin
str_done(b, pos) && return 1
c1, pnt = _nextcp(C, pnt)
ch, pos = str_next(b, pos)
ch, pos = iterate(b, pos)
c2 = ch%UInt32
c1 == c2 || return ifelse(c1 < c2, -1, 1)
end
Expand Down Expand Up @@ -93,7 +93,7 @@ function _cpeq(a::MaybeSub{T}, b) where {C<:CSE, T<:Str{C}}
while pnt < fin
str_done(b, pos) && return false
c1, pnt = _nextcp(C, pnt)
ch, pos = str_next(b, pos)
ch, pos = iterate(b, pos)
c1 == codepoint(ch) || return false
end
true
Expand Down
14 changes: 10 additions & 4 deletions src/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ Base.findlast(a::Str, b::AbstractString) = nothing_sentinel(find(Last, a, b))
Base.findnext(a::Str, b::AbstractString, i) = nothing_sentinel(find(Fwd, a, b, i))
Base.findprev(a::Str, b::AbstractString, i) = nothing_sentinel(find(Rev, a, b, i))

# Fix ambiguities caused by addition of new findfirst definition to base
Base.findfirst(a::AbstractChar, b::Str) = nothing_sentinel(find(First, a, b))
Base.findlast(a::AbstractChar, b::Str) = nothing_sentinel(find(Last, a, b))
Base.findnext(a::AbstractChar, b::Str, i) = nothing_sentinel(find(Fwd, a, b, i))
Base.findprev(a::AbstractChar, b::Str, i) = nothing_sentinel(find(Rev, a, b, i))

function find(::Type{D}, fun::Function, str::AbstractString, pos::Integer) where {D<:Direction}
pos < Int(D===Fwd) && (@boundscheck boundserr(str, pos); return 0)
if pos > (len = ncodeunits(str))
Expand Down Expand Up @@ -189,7 +195,7 @@ function find(::Type{D}, needle::AbstractString, str::AbstractString,
@inbounds is_valid(str, pos) || index_error(str, pos)
(tlen = ncodeunits(needle)) == 0 && return pos:pos-1
(cmp = CanContain(str, needle)) === NoCompare() && return _not_found
@inbounds ch, nxt = str_next(needle, 1)
@inbounds ch, nxt = iterate(needle, 1)
is_valid(eltype(str), ch) || return _not_found
# Check if single character
if nxt > tlen
Expand All @@ -205,7 +211,7 @@ function find(::Type{T}, needle::AbstractString, str::AbstractString) where {T<:
pos = T === First ? 1 : thisind(str, slen)
(tlen = ncodeunits(needle)) == 0 && return pos:(pos-1)
(cmp = CanContain(str, needle)) === NoCompare() && return _not_found
@inbounds ch, nxt = str_next(needle, 1)
@inbounds ch, nxt = iterate(needle, 1)
is_valid(eltype(str), ch) || return _not_found
# Check if single character
if nxt > tlen
Expand Down Expand Up @@ -298,8 +304,8 @@ end
"""Compare two strings, starting at nxtstr and nxtsub"""
@inline function _cmp_str(str, strpos, endpos, sub, subpos, endsub)
while strpos <= endpos
c, strnxt = str_next(str, strpos)
d, subpos = str_next(sub, subpos)
c, strnxt = iterate(str, strpos)
d, subpos = iterate(sub, subpos)
c == d || break
subpos > endsub && return strpos
strpos = strnxt
Expand Down
4 changes: 2 additions & 2 deletions src/support.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function unsafe_check_string(str::T;
totalchar = latin1byte = num2byte = num3byte = num4byte = invalids = 0
pos = 1
@inbounds while !str_done(str, pos)
chr, nxt = str_next(str, pos)
chr, nxt = iterate(str, pos)
ch = chr%UInt32
totalchar += 1
if ch > 0x7f
Expand All @@ -288,7 +288,7 @@ function unsafe_check_string(str::T;
break
end
# next character *must* be a trailing surrogate character
chr, nxt = str_next(str, nxt)
chr, nxt = iterate(str, nxt)
if !is_surrogate_trail(chr)
accept_invalids || strerror(StrErrors.NOT_TRAIL, pos, chr)
invalids += 1
Expand Down
4 changes: 2 additions & 2 deletions src/utf8.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,9 @@ _iterate(::MultiCU, ::Type{T}, str::SubString{<:Str{RawUTF8CSE}}, pos::Int) wher
end

_next(::MultiCU, ::Type{T}, str::Str{RawUTF8CSE}, pos::Int) where {T} =
str_next(str.data, pos)
iterate(str.data, pos)
_next(::MultiCU, ::Type{T}, str::SubString{<:Str{RawUTF8CSE}}, pos::Int) where {T} =
str_next(SubString(str.string.data, str.offset + pos, str.offset + ncodeunits(str)), 1)
iterate(SubString(str.string.data, str.offset + pos, str.offset + ncodeunits(str)), 1)

## overload methods for efficiency ##

Expand Down
14 changes: 7 additions & 7 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ let

@test lastindex(srep) == 7

@test str_next(srep, 3) == ('β',5)
@test str_next(srep, 7) == ('β',9)
@test iterate(srep, 3) == ('β',5)
@test iterate(srep, 7) == ('β',9)

@test srep[7] == 'β'
@test_throws StringIndexError srep[8]
Expand Down Expand Up @@ -340,8 +340,8 @@ end
@test_throws MethodError codeunit(tstr, true)
@test_throws MethodError isvalid(tstr, 1)
@test_throws MethodError isvalid(tstr, true)
@test_throws MethodError str_next(tstr, 1)
@test_throws MethodError str_next(tstr, true)
@test_throws MethodError iterate(tstr, 1)
@test_throws MethodError iterate(tstr, true)
@test_throws MethodError lastindex(tstr)

gstr = GenericString("12")
Expand Down Expand Up @@ -611,7 +611,7 @@ end
for st in ("Hello", "Σ", "こんにちは", "😊😁")
local s
s = ST(st)
@test str_next(s, lastindex(s))[2] > sizeof(s)
@test iterate(s, lastindex(s))[2] > sizeof(s)
@test nextind(s, lastindex(s)) > sizeof(s)
end
end
Expand Down Expand Up @@ -915,7 +915,7 @@ function testbin(::Type{ST}) where {ST}
b"\xf8\x9f\x98\x84", b"\xf8\x9f\x98\x84z")),
s in lst
st = ST(s)
@test str_next(st, 1)[2] == 2
@test iterate(st, 1)[2] == 2
@test nextind(st, 1) == 2
end

Expand All @@ -930,7 +930,7 @@ function testbin(::Type{ST}) where {ST}
(s, r) in lst
st = ST(s)
(ST === BinaryStr || ST === Text1Str) && (r = 2)
@test str_next(st, 1)[2] == r
@test iterate(st, 1)[2] == r
@test nextind(st, 1) == r
end
end
Expand Down