Skip to content

Commit

Permalink
Fix breakage caused by JuliaLang/julia/pull/53896 (#1133)
Browse files Browse the repository at this point in the history
* fix breakage caused by JuliaLang/julia/pull/53896

* make __wrap compatible with 1.11 RC
  • Loading branch information
longemen3000 committed Apr 9, 2024
1 parent acd36a6 commit 67424ce
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/utils.jl
Expand Up @@ -245,10 +245,16 @@ 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)
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,pos) = x
__wrap(x) = x
end

# whatever input is given, turn it into an AbstractVector{UInt8} we can parse with
Expand All @@ -267,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,length(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
Expand Down

0 comments on commit 67424ce

Please sign in to comment.