From dceb7a3c4d083f6d9f93efa8f193f18adfb00c28 Mon Sep 17 00:00:00 2001 From: Mus Date: Sun, 25 Mar 2018 15:16:56 -0400 Subject: [PATCH] more fixes --- src/HDF5.jl | 6 +++--- src/datafile.jl | 2 +- test/gc.jl | 11 ++++++----- test/readremote.jl | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/HDF5.jl b/src/HDF5.jl index 8ef183c80..7a1626dc4 100644 --- a/src/HDF5.jl +++ b/src/HDF5.jl @@ -1386,9 +1386,9 @@ function read(obj::DatasetOrAttribute, ::Type{Array{S}}) where {S<:String} readarray(obj, memtype_id, buf) src = 1 for i = 1:len - slen = findnext(buf, 0x00, src) - src # find null terminator + slen = coalesce(findnext(isequal(0x00), buf, src), 0) - src # find null terminator sv = StringVector(slen) - copy!(sv, 1, buf, src, slen) + copyto!(sv, 1, buf, src, slen) ret[i] = String(sv) src += ilen end @@ -1804,7 +1804,7 @@ d_create_external(parent::Union{HDF5File, HDF5Group}, name::String, filepath::St function do_write_chunk(dataset::HDF5Dataset, offset, chunk_bytes::Vector{UInt8}, filter_mask=0) checkvalid(dataset) - offs = collect(Hsize, reverse(offset))-1 + offs = collect(Hsize, reverse(offset)) .- 1 h5do_write_chunk(dataset, H5P_DEFAULT, UInt32(filter_mask), offs, length(chunk_bytes), chunk_bytes) end diff --git a/src/datafile.jl b/src/datafile.jl index f69b62657..69c6f18cc 100644 --- a/src/datafile.jl +++ b/src/datafile.jl @@ -40,7 +40,7 @@ read(f::Base.Callable, parent::DataFile, name::String...) = # Read every variable in the file function read(f::DataFile) vars = names(f) - vals = Vector{Any}(length(vars)) + vals = Vector{Any}(undef,length(vars)) for i = 1:length(vars) vals[i] = read(f, vars[i]) end diff --git a/test/gc.jl b/test/gc.jl index bf8e5cea0..48ddb5ebc 100644 --- a/test/gc.jl +++ b/test/gc.jl @@ -1,11 +1,12 @@ using HDF5 using Compat.Test +import Compat.GC macro gcvalid(args...) Expr(:block, quote - gc_enable(true) - gc() - gc_enable(false) + GC.enable(true) + GC.gc() + GC.enable(false) end, [:(@test HDF5.isvalid($(esc(x)))) for x in args]...) end @@ -23,7 +24,7 @@ end @testset "gc" begin -gc_enable(false) +GC.enable(false) fn = tempname() for i = 1:10 file = h5open(fn, "w") @@ -62,7 +63,7 @@ for i = 1:10 @gcvalid dt ds d g a close(file) end -gc_enable(true) +GC.enable(true) rm(fn) end # testset gc diff --git a/test/readremote.jl b/test/readremote.jl index ab21562fa..700f50a3c 100644 --- a/test/readremote.jl +++ b/test/readremote.jl @@ -1,5 +1,6 @@ using HDF5 using Compat.Test +using Compat.LinearAlgebra: norm @testset "readremote" begin