Skip to content

Commit

Permalink
Revert "parser: simplify :skip_lines implementation"
Browse files Browse the repository at this point in the history
This reverts commit c2cc984.

This may cause invalid parse result.
  • Loading branch information
kou committed Mar 22, 2024
1 parent b9a8f36 commit a5e738b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/csv/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -901,15 +901,18 @@ def build_scanner
def skip_needless_lines
return unless @skip_lines

@scanner.keep_start
@scanner.each_line(@row_separator) do |line|
line << @row_separator if parse_row_end
break unless skip_line?(line)
@lineno += 1
@scanner.keep_drop
until @scanner.eos?
@scanner.keep_start
line = @scanner.scan_all(@not_line_end) || "".encode(@encoding)
line << @row_separator if parse_row_end
if skip_line?(line)
@lineno += 1
@scanner.keep_drop
else
@scanner.keep_back
return
end
end
@scanner.keep_back
end

def skip_line?(line)
Expand Down

0 comments on commit a5e738b

Please sign in to comment.