From 2728842080a204a282ebbefce38ed8fc1c399a4e Mon Sep 17 00:00:00 2001 From: Frames White Date: Fri, 5 Jan 2024 12:52:40 +0800 Subject: [PATCH 1/2] Deprecate copy for deepcopy --- src/MD5.jl | 1 + src/deprecated.jl | 3 +++ src/types.jl | 1 - test/deprecated.jl | 1 + test/runtests.jl | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/deprecated.jl create mode 100644 test/deprecated.jl diff --git a/src/MD5.jl b/src/MD5.jl index ae5d35d..39eea5f 100644 --- a/src/MD5.jl +++ b/src/MD5.jl @@ -10,6 +10,7 @@ export md5 include("constants.jl") include("types.jl") include("core.jl") +include("deprecated.jl") # Our basic function is to process arrays of bytes diff --git a/src/deprecated.jl b/src/deprecated.jl new file mode 100644 index 0000000..8b9d1fb --- /dev/null +++ b/src/deprecated.jl @@ -0,0 +1,3 @@ +using Base: @deprecate +import Base: copy +@deprecate copy(ctx::MD5_CTX) deepcopy(ctx) diff --git a/src/types.jl b/src/types.jl index 76e86f8..df250c9 100644 --- a/src/types.jl +++ b/src/types.jl @@ -11,5 +11,4 @@ state_type(::Type{MD5_CTX}) = UInt32 blocklen(::Type{MD5_CTX}) = UInt64(64) MD5_CTX() = MD5_CTX(copy(MD5_initial_hash_value), 0, zeros(UInt8, blocklen(MD5_CTX)), false) -Base.copy(ctx::T) where {T<:MD5_CTX} = T(copy(ctx.state), ctx.bytecount, copy(ctx.buffer)) Base.show(io::IO, ::MD5_CTX) = write(io, "MD5 hash state") diff --git a/test/deprecated.jl b/test/deprecated.jl new file mode 100644 index 0000000..ce04632 --- /dev/null +++ b/test/deprecated.jl @@ -0,0 +1 @@ +@test (@test_deprecated copy(MD5.MD5_CTX())) isa MD5.MD5_CTX \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index db577b8..44d279c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,3 +30,4 @@ end include("nettle.jl") include("perf.jl") +include("deprecated.jl") \ No newline at end of file From b503cd49ce6edd990b8b7123a89c25d1d71cfbb8 Mon Sep 17 00:00:00 2001 From: Frames White Date: Fri, 5 Jan 2024 12:55:25 +0800 Subject: [PATCH 2/2] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 30df31d..ddc25fc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MD5" uuid = "6ac74813-4b46-53a4-afec-0b5dc9d7885c" -version = "0.2.2" +version = "0.2.3" [deps] Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"