From 963974c5b5704d50a698abac6a0e0d43475fe038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Mon, 8 Apr 2024 23:50:48 -0400 Subject: [PATCH 1/2] fix breakage caused by JuliaLang/julia/pull/53896 --- src/utils.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index d12eb023..ca28ed59 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -245,10 +245,11 @@ end # one-liner suggested from ScottPJones consumeBOM(buf, pos) = (length(buf) >= 3 && buf[pos] == 0xef && buf[pos + 1] == 0xbb && buf[pos + 2] == 0xbf) ? pos + 3 : pos -if isdefined(Base,:wrap) - __wrap(x,pos) = Base.wrap(Array,x,pos) +if isdefined(Base, :Memory) + __wrap(x) = view(x,Base.OneTo(length(x))) + __wrap(x::Array) = x else - __wrap(x,pos) = x + __wrap(x) = x end # whatever input is given, turn it into an AbstractVector{UInt8} we can parse with @@ -267,7 +268,7 @@ end x = x.data return parent(x), first(x.indices), last(x.indices), tfile else #support from IOBuffer containing Memory - y = __wrap(x.data,length(x.data)) #generates a Vector{UInt8} from Memory{UInt8} + y = __wrap(x.data) #generates a Vector{UInt8} from Memory{UInt8} return y, x.ptr, x.size, tfile end elseif x isa Cmd || x isa IO From eafb38b4a3d283dfbb27de4fb4b9ab23eaf2b8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Riedemann?= <38795484+longemen3000@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:48:26 -0400 Subject: [PATCH 2/2] make __wrap compatible with 1.11 RC --- src/utils.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index ca28ed59..d1efe22e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -246,8 +246,13 @@ end consumeBOM(buf, pos) = (length(buf) >= 3 && buf[pos] == 0xef && buf[pos + 1] == 0xbb && buf[pos + 2] == 0xbf) ? pos + 3 : pos if isdefined(Base, :Memory) - __wrap(x) = view(x,Base.OneTo(length(x))) - __wrap(x::Array) = x + if isdefined(Base,:wrap) + __wrap(x) = Base.wrap(Array,x,length(x)) + __wrap(x::Array) = x + else + __wrap(x) = view(x,Base.OneTo(length(x))) + __wrap(x::Array) = x + end else __wrap(x) = x end @@ -268,7 +273,7 @@ end x = x.data return parent(x), first(x.indices), last(x.indices), tfile else #support from IOBuffer containing Memory - y = __wrap(x.data) #generates a Vector{UInt8} from Memory{UInt8} + y = __wrap(x.data) #generates a Vector{UInt8} from Memory{UInt8}, if available. return y, x.ptr, x.size, tfile end elseif x isa Cmd || x isa IO