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

make replace with count=0 a no-op #22325

Merged
merged 13 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
improve TODO notes (StefanKarpinski)
  • Loading branch information
rfourquet committed Jul 4, 2017
commit 4405d63c300e3da0d41074e5ee278ac8493d6e5e
7 changes: 5 additions & 2 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,11 @@ function bkfact!(A::StridedMatrix, uplo::Symbol, symmetric::Bool = issymmetric(A
return bkfact!(symmetric ? Symmetric(A, uplo) : Hermitian(A, uplo), rook)
end

# NOTE: rename the function replace_new from strings/util.jl to replace
# when this replace is removed from deprecated.jl
# PR #22325
# TODO: when this replace is removed from deprecated.jl:
# 1) rename the function replace_new from strings/util.jl to replace
# 2) update the replace(s::AbstractString, pat, f) method, below replace_new
# (see instructions there)
function replace(s::AbstractString, pat, f, n::Integer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add a comment explaining that replace_new needs to be renamed to replace when removing this deprecation (and make sure tests will fail if that's not the case).

if n <= 0
depwarn(string("`replace(s, pat, r, count)` with `count <= 0` is deprecated, use ",
Expand Down
4 changes: 2 additions & 2 deletions base/strings/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ _replace(io, repl, str, r, pattern) = print(io, repl)
_replace(io, repl::Function, str, r, pattern) =
print(io, repl(SubString(str, first(r), last(r))))

# TODO: rename to `replace` when `replace` is removed from deprecated.jl
function replace_new(str::String, pattern, repl, count::Integer)
# rename to `replace` when `replace` is removed from deprecated.jl
count == 0 && return str
count < 0 && throw(DomainError())
n = 1
Expand Down Expand Up @@ -406,7 +406,7 @@ If `pat` is a regular expression and `r` is a `SubstitutionString`, then capture
references in `r` are replaced with the corresponding matched text.
"""
replace(s::AbstractString, pat, f) = replace_new(String(s), pat, f, typemax(Int))
# change this to the following when `replace` is removed from deprecated:
# TODO: change this to the following when `replace` is removed from deprecated.jl:
# replace(s::AbstractString, pat, f, count::Integer=typemax(Int)) =
# replace(String(s), pat, f, count)

Expand Down