From 6a415a724007675a1b31a8858674d55fd9e7d798 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Fri, 11 Jun 2021 21:43:08 +0200 Subject: [PATCH 1/2] reverse search fix --- base/strings/search.jl | 2 +- test/strings/search.jl | 1 + test/strings/util.jl | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/strings/search.jl b/base/strings/search.jl index 338222ac5e1c1..c1fd3fd6fedd1 100644 --- a/base/strings/search.jl +++ b/base/strings/search.jl @@ -459,7 +459,7 @@ function _rsearchindex(s::AbstractVector{<:Union{Int8,UInt8}}, t::AbstractVector n = length(t) m = length(s) k = Int(_k) - sentinel - k < 1 && throw(BoundsError(s, _k)) + k < 0 && throw(BoundsError(s, _k)) if n == 0 return 0 <= k <= m ? max(k, 1) : sentinel diff --git a/test/strings/search.jl b/test/strings/search.jl index 5f52f8024cdd1..a7d2625cfac9e 100644 --- a/test/strings/search.jl +++ b/test/strings/search.jl @@ -97,6 +97,7 @@ for str in [astr] @test findprev('l', str, 2) == nothing @test findlast(',', str) == 6 @test findprev(',', str, 5) == nothing + @test findlast(str, "") == nothing @test findlast('\n', str) == 14 end diff --git a/test/strings/util.jl b/test/strings/util.jl index 3cf434feab113..2b08e2819e33b 100644 --- a/test/strings/util.jl +++ b/test/strings/util.jl @@ -163,6 +163,7 @@ end @test split("", "") == rsplit("", "") == [""] @test split("abc", "") == rsplit("abc", "") == ["a","b","c"] @test rsplit("abc", "", limit=2) == ["ab","c"] + @test rsplit("", "//") == [""] @test split("abc", "", limit=2) == ["a","bc"] @test split("", r"") == [""] From 75ce0bf714a492354e0261da5357f0563f3f8b59 Mon Sep 17 00:00:00 2001 From: Jerry Ling Date: Mon, 14 Jun 2021 21:00:03 +0200 Subject: [PATCH 2/2] Update search.jl --- test/strings/search.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/strings/search.jl b/test/strings/search.jl index a7d2625cfac9e..491987af06888 100644 --- a/test/strings/search.jl +++ b/test/strings/search.jl @@ -98,6 +98,7 @@ for str in [astr] @test findlast(',', str) == 6 @test findprev(',', str, 5) == nothing @test findlast(str, "") == nothing + @test findlast(str^2, str) == nothing @test findlast('\n', str) == 14 end