exe/gloc in gloc-0.3.0 vs exe/gloc in gloc-0.3.1

- old
+ new

@@ -29,18 +29,19 @@ # note: git itself uses the first # 8,000 characters of a file, but # looking at the first 16 is fine # for our purposes... for now :-) # see buffer_is_binary() function +# in the "git" source repository! source_files.delete_if { |file| ( File.extname(file) == '.pdf' || # skip bl**dy PDF documents File.basename(file) =~ /\A\..*\z/ || # skip hidden ".*" files !File.exist?(file) || # skip non-existent paths !File.file?(file) || # skip directories !File.size?(file) || # skip empty files - !File.read(file, 16)["\0"].nil? # skip binary files + !File.read(file, 16)["\0"].nil? # skip binary files ) && ( $verbose && warn("SKIPPING #{file}...") ; true ) } BLANKS = %r{\A\s*\Z}.freeze @@ -63,11 +64,14 @@ line_count: 0, blank_count: 0, comment_count: 0, }) end - file_content = File.read(file, :encoding => 'UTF-8') # FIXME what about other encodings? - file_content = File.read(file, :encoding => 'ISO-8859-1') unless content.valid_encoding? + file_content = File.read(file, :encoding => 'UTF-8') + unless file_content.valid_encoding? + file_content = File.read(file, :encoding => 'ISO-8859-1') + # FIXME what about file encodings other than these two??? + end source_lines = file_content.each_line stats_for_ext.file_count += 1 stats_for_ext.line_count += source_lines.count stats_for_ext.blank_count += source_lines.grep(BLANKS).count next unless COMMENTS[file_ext] # only scan for comments if a regex exists!