Skip to content

Commit

Permalink
Fix the EOL auto-discovery logic
Browse files Browse the repository at this point in the history
so that it could work inside pipes, like

  $ ./some_faster_csv_script.rb < file.csv
  • Loading branch information
alexis committed May 30, 2011
1 parent cd9c813 commit 77a8940
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/faster_csv.rb
Expand Up @@ -1318,9 +1318,7 @@ def self.table(path, options = Hash.new)
# even if it occurs in a quoted field, # even if it occurs in a quoted field,
# assuming that you would have the same # assuming that you would have the same
# line endings there. If none of those # line endings there. If none of those
# sequences is found, +data+ is # sequences is found,
# <tt>ARGF</tt>, <tt>STDIN</tt>,
# <tt>STDOUT</tt>, or <tt>STDERR</tt>,
# or the stream is only available for # or the stream is only available for
# output, the default # output, the default
# <tt>$INPUT_RECORD_SEPARATOR</tt> # <tt>$INPUT_RECORD_SEPARATOR</tt>
Expand Down Expand Up @@ -1745,8 +1743,7 @@ def init_separators(options)


# automatically discover row separator when requested # automatically discover row separator when requested
if @row_sep == :auto if @row_sep == :auto
if [ARGF, STDIN, STDOUT, STDERR].include?(@io) or if !@io.respond_to?(:eof?) or (@io.eof? rescue true) # we can't auto-discover for STDOUT, STDERR, Zlib::GzipWriter streems, etc
(defined?(Zlib) and @io.class == Zlib::GzipWriter)
@row_sep = $INPUT_RECORD_SEPARATOR @row_sep = $INPUT_RECORD_SEPARATOR
else else
begin begin
Expand Down

0 comments on commit 77a8940

Please sign in to comment.