Skip to content

Commit 2b2cc34

Browse files
cchderricknalimilan
authored andcommitted
fix v0.7.0 deprecations (#5)
1 parent d6a0f9f commit 2b2cc34

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910
matrix:
1011
allow_failures:
@@ -15,5 +16,5 @@ notifications:
1516
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
1617
# - julia -e 'Pkg.clone(pwd()); Pkg.build("DBFTables"); Pkg.test("DBFTables"; coverage=true)';
1718
after_success:
18-
- julia -e 'cd(Pkg.dir("DBFTables")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
19-
- julia -e 'cd(Pkg.dir("DBFTables")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())';
19+
- julia -e 'using Pkg, DBFTables; cd(joinpath(dirname(pathof(DBFTables)),"..")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())';
20+
- julia -e 'using Pkg, DBFTables; cd(joinpath(dirname(pathof(DBFTables)),"..")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())';

REQUIRE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
julia 0.6
2-
Missings
3-
DataFrames 0.11
1+
julia 0.7
2+
DataFrames 0.13

src/DBFTables.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module DBFTables
22

3-
using Missings, DataFrames
3+
using DataFrames, Printf
44

55
# Read DBF files in xBase format
66
# Files written in this format have the extension .dbf
@@ -27,7 +27,7 @@ struct DBFHeader
2727
end
2828

2929
function dbf_field_type(fld::Char, dec::UInt8)
30-
rt = Void
30+
rt = Nothing
3131
if fld == 'C'
3232
rt = String
3333
elseif fld == 'D'
@@ -51,29 +51,29 @@ function dbf_field_type(fld::Char, dec::UInt8)
5151
end
5252

5353
function read_dbf_field(io::IO)
54-
field_name = strip(replace((String(read!(io, Vector{UInt8}(11)))), '\0', ' ')) # 0x00
54+
field_name = strip(replace(String(read!(io, Vector{UInt8}(undef, 11))),'\0'=>' ')) # 0x00
5555
field_type = read(io, Char) # 0x0B
5656
read(io, Int32) # skip 0x0C
5757
field_len = read(io, UInt8) # 0x10
5858
field_dec = read(io, UInt8) # 0x11
59-
read!(io, Vector{UInt8}(14)) # reserved
59+
read!(io, Vector{UInt8}(undef, 14)) # reserved
6060
return DBFFieldDescriptor(field_name, dbf_field_type(field_type, field_dec), field_len, field_dec)
6161
end
6262

6363
function read_dbf_header(io::IO)
6464
ver = read(io, UInt8)
65-
date = read!(io, Vector{UInt8}(3)) # 0x01
65+
date = read!(io, Vector{UInt8}(undef, 3)) # 0x01
6666
last_update = @sprintf("%4d%02d%02d", date[1]+1900, date[2], date[3])
6767
records = read(io, Int32) # 0x04
6868
hsize = read(io, Int16) # 0x08
6969
rsize = read(io, Int16) # 0x0A
7070
read(io, Int16) # reserved # 0x0C
7171
incomplete = Bool(read(io, UInt8)) # 0x0E
7272
encrypted = Bool(read(io, UInt8)) # 0x0F
73-
read!(io, Vector{UInt8}(12)) # reserved
73+
read!(io, Vector{UInt8}(undef, 12)) # reserved
7474
mdx = Bool(read(io, UInt8)) # 0x1C
7575
langId = read(io, UInt8) # 0x1D
76-
read!(io, Vector{UInt8}(2)) # reserved # 0x1E
76+
read!(io, Vector{UInt8}(undef, 2)) # reserved # 0x1E
7777
fields = DBFFieldDescriptor[]
7878

7979
while !eof(io)
@@ -99,7 +99,7 @@ function read_dbf_records!(io::IO, df::DataFrame, header::DBFHeader; deleted=fal
9999
r = Any[]
100100
for i = 1:length(header.fields)
101101
#print("P: $(position(io)) ")
102-
fld_data = read!(io, Vector{UInt8}(header.fields[i].len))
102+
fld_data = read!(io, Vector{UInt8}(undef, header.fields[i].len))
103103
#println("D: $(ascii(fld_data))")
104104
if header.fields[i].typ == Bool
105105
logical = Char(fld_data[1])
@@ -112,13 +112,13 @@ function read_dbf_records!(io::IO, df::DataFrame, header::DBFHeader; deleted=fal
112112
end
113113
elseif header.fields[i].typ == Int
114114
tmp = tryparse(header.fields[i].typ, String(fld_data))
115-
push!(r, tmp.hasvalue ? tmp.value : missing)
115+
push!(r, tmp==nothing ? missing : tmp)
116116
elseif header.fields[i].typ == Float64
117117
tmp = tryparse(header.fields[i].typ, String(fld_data))
118-
push!(r, tmp.hasvalue ? tmp.value : missing)
118+
push!(r, tmp==nothing ? missing : tmp)
119119
elseif header.fields[i].typ == String
120120
push!(r, strip(String(fld_data)))
121-
elseif header.fields[i].typ == Void
121+
elseif header.fields[i].typ == Nothing
122122
push!(r, missing)
123123
else
124124
warn("Type $(header.fields[i].typ) is not supported")

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using DBFTables
2-
using Base.Test
2+
using Test
33
using Missings
44

55
dir = @__DIR__

0 commit comments

Comments
 (0)