diff --git a/NEWS.md b/NEWS.md index 07ccb1881e301..c222644b90680 100644 --- a/NEWS.md +++ b/NEWS.md @@ -299,6 +299,9 @@ Deprecated or removed * Calling `union` with no arguments is deprecated; construct an empty set with an appropriate element type using `Set{T}()` instead ([#23144]). + * `Base.cpad` has been removed; use an appropriate combination of `rpad` and `lpad` + instead ([#23187]). + Julia v0.6.0 Release Notes ========================== diff --git a/base/deprecated.jl b/base/deprecated.jl index 196ca8270a25b..54f57c816bf34 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1642,6 +1642,9 @@ end end end +# PR #23187 +@deprecate cpad(s, n::Integer, p=" ") rpad(lpad(s, div(n+strwidth(s), 2), p), n, p) false + # END 0.7 deprecations # BEGIN 1.0 deprecations diff --git a/base/pkg/entry.jl b/base/pkg/entry.jl index 41f638102cfdb..58487eac71db1 100644 --- a/base/pkg/entry.jl +++ b/base/pkg/entry.jl @@ -572,7 +572,8 @@ end function warnbanner(msg...; label="[ WARNING ]", prefix="") cols = Base.displaysize(STDERR)[2] - warn(prefix="", Base.cpad(label,cols,"=")) + str = rpad(lpad(label, div(cols+strwidth(label), 2), "="), cols, "=") + warn(prefix="", str) println(STDERR) warn(prefix=prefix, msg...) println(STDERR) diff --git a/base/strings/util.jl b/base/strings/util.jl index d8f665a28b13e..f7297ae6810fc 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -256,7 +256,6 @@ julia> rpad("March",20) ``` """ rpad(s, n::Integer, p=" ") = rpad(string(s),n,string(p)) -cpad(s, n::Integer, p=" ") = rpad(lpad(s,div(n+strwidth(s),2),p),n,p) # splitter can be a Char, Vector{Char}, AbstractString, Regex, ... # any splitter that provides search(s::AbstractString, splitter)