@@ -130,6 +130,12 @@ Base.findlast(a::Str, b::AbstractString) = nothing_sentinel(find(Last, a, b))
130130Base. findnext (a:: Str , b:: AbstractString , i) = nothing_sentinel (find (Fwd, a, b, i))
131131Base. findprev (a:: Str , b:: AbstractString , i) = nothing_sentinel (find (Rev, a, b, i))
132132
133+ # 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))
138+
133139function find (:: Type{D} , fun:: Function , str:: AbstractString , pos:: Integer ) where {D<: Direction }
134140 pos < Int (D=== Fwd) && (@boundscheck boundserr (str, pos); return 0 )
135141 if pos > (len = ncodeunits (str))
@@ -189,7 +195,7 @@ function find(::Type{D}, needle::AbstractString, str::AbstractString,
189195 @inbounds is_valid (str, pos) || index_error (str, pos)
190196 (tlen = ncodeunits (needle)) == 0 && return pos: pos- 1
191197 (cmp = CanContain (str, needle)) === NoCompare () && return _not_found
192- @inbounds ch, nxt = str_next (needle, 1 )
198+ @inbounds ch, nxt = iterate (needle, 1 )
193199 is_valid (eltype (str), ch) || return _not_found
194200 # Check if single character
195201 if nxt > tlen
@@ -205,7 +211,7 @@ function find(::Type{T}, needle::AbstractString, str::AbstractString) where {T<:
205211 pos = T === First ? 1 : thisind (str, slen)
206212 (tlen = ncodeunits (needle)) == 0 && return pos: (pos- 1 )
207213 (cmp = CanContain (str, needle)) === NoCompare () && return _not_found
208- @inbounds ch, nxt = str_next (needle, 1 )
214+ @inbounds ch, nxt = iterate (needle, 1 )
209215 is_valid (eltype (str), ch) || return _not_found
210216 # Check if single character
211217 if nxt > tlen
298304""" Compare two strings, starting at nxtstr and nxtsub"""
299305@inline function _cmp_str (str, strpos, endpos, sub, subpos, endsub)
300306 while strpos <= endpos
301- c, strnxt = str_next (str, strpos)
302- d, subpos = str_next (sub, subpos)
307+ c, strnxt = iterate (str, strpos)
308+ d, subpos = iterate (sub, subpos)
303309 c == d || break
304310 subpos > endsub && return strpos
305311 strpos = strnxt
0 commit comments