diff --git a/README.md b/README.md index 764ba8108..e05004e1b 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `fieldoffsets` has been deprecated in favor of `fieldoffset`[#14777](https://github.com/JuliaLang/julia/pull/14777). +* `print_escaped` is now another method of `escape_string`, `print_unescaped` a method of `unescape_string`, and `print_joined` a method of `join`. [#16603](https://github.com/JuliaLang/julia/pull/16603) + ## New macros * `@static` has been added [#16219](https://github.com/JuliaLang/julia/pull/16219). diff --git a/src/Compat.jl b/src/Compat.jl index f150a1a34..d32fb5648 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1425,4 +1425,17 @@ else import Base.promote_eltype_op end +if VERSION < v"0.5.0-dev+4351" + Base.join(io::IO, items) = + print_joined(io, items) + Base.join(io::IO, items, delim) = + print_joined(io, items, delim) + Base.join(io::IO, items, delim, last) = + print_joined(io, items, delim, last) + Base.unescape_string(io, s::AbstractString) = + print_unescaped(io, s) + Base.escape_string(io, str::AbstractString, esc::AbstractString) = + print_escaped(io, str, esc) +end + end # module diff --git a/test/runtests.jl b/test/runtests.jl index 249a27a08..68db06688 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1337,3 +1337,10 @@ let end @test norm(normalize!(v) - w, Inf) < eps() end + +# JuliaLang/julia#16603 +@test sprint(join, [1, 2, 3]) == "123" +@test sprint(join, [1, 2, 3], ',') == "1,2,3" +@test sprint(join, [1, 2, 3], ", ", ", and ") == "1, 2, and 3" +@test sprint(escape_string, "xyz\n", "z") == "xy\\z\\n" +@test sprint(unescape_string, "xyz\\n") == "xyz\n"