1
1
#=
2
2
Search functions for Str strings
3
3
4
- Copyright 2018-2020 Gandalf Software, Inc., Scott P. Jones,
4
+ Copyright 2018-2023 Gandalf Software, Inc., Scott P. Jones,
5
5
and other contributors to the Julia language
6
6
Licensed under MIT License, see LICENSE.md
7
7
Based in part on julia/base/strings/search.jl
@@ -131,7 +131,11 @@ for (S,T) in ((:AbstractString, :Str), (:Str, :AbstractString), (:Str, :Str),
131
131
end
132
132
133
133
function find (:: Type{D} , fun:: Function , str:: AbstractString , pos:: Integer ) where {D<: Direction }
134
- pos < Int (D=== Fwd) && (@boundscheck boundserr (str, pos); return 0 )
134
+ if pos < 1
135
+ D === Fwd && @boundscheck boundserr (str, pos)
136
+ # Just return 0 if < 0 for Rev (match Base bug)
137
+ return 0
138
+ end
135
139
if pos > (len = ncodeunits (str))
136
140
@boundscheck pos > len+ 1 && boundserr (str, pos)
137
141
return 0
@@ -157,7 +161,11 @@ find(::Type{D}, pred::P, str::AbstractString,
157
161
find (D, pred. x, str, pos)
158
162
159
163
function find (:: Type{D} , ch:: AbstractChar , str:: AbstractString , pos:: Integer ) where {D<: Direction }
160
- pos < Int (D=== Fwd) && (@boundscheck boundserr (str, pos); return 0 )
164
+ if pos < 1
165
+ D === Fwd && @boundscheck boundserr (str, pos)
166
+ # Just return 0 if < 0 for Rev (match Base bug)
167
+ return 0
168
+ end
161
169
if pos > (len = ncodeunits (str))
162
170
@boundscheck pos > len+ 1 && boundserr (str, pos)
163
171
return 0
0 commit comments