Skip to content
Browse files

Minor documentation cleanup.

  • Loading branch information...
1 parent 0182b3f commit 189abcef5f5b7e8ded7e2d1ba5c1ab21f83eec72 @JEG2 committed Jun 2, 2011
Showing with 22 additions and 8 deletions.
  1. +1 −0 CHANGELOG
  2. +21 −8 lib/faster_csv.rb
View
1 CHANGELOG
@@ -6,6 +6,7 @@ Below is a complete listing of changes for each revision of FasterCSV.
* Removed setup.rb due to licensing concerns.
* Improved stray quoting error message (patch by Edvard Majakari).
+* Improved line ending detection algorithm (patch by Alexey).
== 1.5.4
View
29 lib/faster_csv.rb
@@ -1744,9 +1744,17 @@ def init_separators(options)
# automatically discover row separator when requested
if @row_sep == :auto
begin
- saved_pos = @io.pos # remember where we were (@io.pos will raise an axception if @io is pipe or not opened for reading)
+ #
+ # remember where we were (pos() will raise an axception if @io is pipe
+ # or not opened for reading)
+ #
+ saved_pos = @io.pos
while @row_sep == :auto
- break if @io.eof? # if we run out of data, it's probably a single line - ensure block will set default value
+ #
+ # if we run out of data, it's probably a single line
+ # (ensure will set default value)
+ #
+ break if @io.eof?
# read ahead a bit
sample = @io.read(1024)
@@ -1767,13 +1775,18 @@ def init_separators(options)
saved_pos -= 1024
end
@io.read(saved_pos) if saved_pos.nonzero?
-
- rescue IOError # not opened for reading
- rescue NoMethodError # Zlib::GzipWriter streem doesn't have eof? method
+ rescue IOError # not opened for reading
+ # do nothing: ensure will set default
+ rescue NoMethodError # Zlib::GzipWriter doesn't have eof?
+ # do nothing: ensure will set default
rescue SystemCallError # pipe
-
- ensure # stream not opened for reading, or pipe, or single-line data
- @row_sep = $INPUT_RECORD_SEPARATOR if @row_sep == :auto
+ # do nothing: ensure will set default
+ ensure
+ #
+ # set default if we failed to detect
+ # (stream not opened for reading, a pipe, or a single line of data)
+ #
+ @row_sep = $INPUT_RECORD_SEPARATOR if @row_sep == :auto
end
end

0 comments on commit 189abce

Please sign in to comment.
Something went wrong with that request. Please try again.