Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In CSV.jl#523, we have an interesting case of some rows having a rand… #39

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/Parsers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,20 @@ end
end
end
if matched
# if a newline is next, consume it as well
if b == UInt8('\n')
pos += 1
incr!(source)
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
elseif b == UInt8('\r')
pos += 1
incr!(source)
if !eof(source, pos, len) && peekbyte(source, pos) == UInt8('\n')
pos += 1
incr!(source)
end
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
end
code |= DELIMITED
@goto donedone
end
Expand All @@ -412,6 +426,21 @@ end
pos = checkdelim(source, pos, len, delim)
end
if matched
# if a newline is next, consume it as well
b = peekbyte(source, pos)
if b == UInt8('\n')
pos += 1
incr!(source)
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
elseif b == UInt8('\r')
pos += 1
incr!(source)
if !eof(source, pos, len) && peekbyte(source, pos) == UInt8('\n')
pos += 1
incr!(source)
end
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
end
code |= DELIMITED
@goto donedone
end
Expand Down
29 changes: 29 additions & 0 deletions src/strings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@
end
end
if matched
# if a newline is next, consume it as well
if b == UInt8('\n')
pos += 1
incr!(source)
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
elseif b == UInt8('\r')
pos += 1
incr!(source)
if !eof(source, pos, len) && peekbyte(source, pos) == UInt8('\n')
pos += 1
incr!(source)
end
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
end
code |= DELIMITED
@goto donedone
end
Expand All @@ -206,6 +220,21 @@
pos = checkdelim(source, pos, len, delim)
end
if matched
# if a newline is next, consume it as well
b = peekbyte(source, pos)
if b == UInt8('\n')
pos += 1
incr!(source)
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
elseif b == UInt8('\r')
pos += 1
incr!(source)
if !eof(source, pos, len) && peekbyte(source, pos) == UInt8('\n')
pos += 1
incr!(source)
end
code |= NEWLINE | ifelse(eof(source, pos, len), EOF, SUCCESS)
end
code |= DELIMITED
@goto donedone
end
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ testcases = [
# ignorerepeated
(str="1a,,", kwargs=(ignorerepeated=true,), x=1, code=(OK | DELIMITED | INVALID_DELIMITER), vpos=1, vlen=2, tlen=4),
(str="1a,,2", kwargs=(ignorerepeated=true,), x=1, code=(OK | DELIMITED | INVALID_DELIMITER), vpos=1, vlen=2, tlen=4),
(str="1,\n", kwargs=(ignorerepeated=true, delim=UInt8(',')), x=1, code=(OK | DELIMITED | NEWLINE | EOF), vpos=1, vlen=1, tlen=3),
];

for useio in (false, true)
Expand Down