Skip to content

Commit a5e738b

Browse files
committed
Revert "parser: simplify :skip_lines implementation"
This reverts commit c2cc984. This may cause invalid parse result.
1 parent b9a8f36 commit a5e738b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/csv/parser.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -901,15 +901,18 @@ def build_scanner
901901
def skip_needless_lines
902902
return unless @skip_lines
903903

904-
@scanner.keep_start
905-
@scanner.each_line(@row_separator) do |line|
906-
line << @row_separator if parse_row_end
907-
break unless skip_line?(line)
908-
@lineno += 1
909-
@scanner.keep_drop
904+
until @scanner.eos?
910905
@scanner.keep_start
906+
line = @scanner.scan_all(@not_line_end) || "".encode(@encoding)
907+
line << @row_separator if parse_row_end
908+
if skip_line?(line)
909+
@lineno += 1
910+
@scanner.keep_drop
911+
else
912+
@scanner.keep_back
913+
return
914+
end
911915
end
912-
@scanner.keep_back
913916
end
914917

915918
def skip_line?(line)

0 commit comments

Comments
 (0)