Skip to content

Commit ace2e64

Browse files
committed
Make sure we ignore opening/closing quotes when considering missing values. Fixes JuliaData/CSV.jl#454
1 parent 57f9f33 commit ace2e64

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/Parsers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ end
233233
if eof(source, pos, len)
234234
code |= EOF
235235
end
236-
elseif sentinel === missing && pos == startpos
236+
elseif sentinel === missing && pos == vstartpos
237237
code &= ~(OK | INVALID)
238238
code |= SENTINEL
239239
end

src/strings.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
if sentinel !== nothing && sentinel !== missing && sentstart == vstartpos && sentinelpos == vpos
244244
# if we matched a sentinel value that was as long or longer than our type value
245245
code |= SENTINEL
246-
elseif sentinel === missing && startpos == vpos
246+
elseif sentinel === missing && vstartpos == vpos
247247
code |= SENTINEL
248248
else
249249
code |= OK

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,13 @@ showerror(io, e2)
378378
@test Parsers.quotednotescaped(QUOTED)
379379
@test !Parsers.quotednotescaped(QUOTED | ESCAPED_STRING)
380380

381+
# https://github.com/JuliaData/CSV.jl/issues/454
382+
x, code, vpos, vlen, tlen = Parsers.xparse(Float64, "\"\"", 1, 2)
383+
@test Parsers.sentinel(code)
384+
385+
x, code, vpos, vlen, tlen = Parsers.xparse(String, "\"\"", 1, 2)
386+
@test Parsers.sentinel(code)
387+
381388
end # @testset "misc"
382389

383390
include("floats.jl")

0 commit comments

Comments
 (0)