diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-02 02:23:12 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-02 02:23:12 +0000 |
commit | aed0db8bd35af72f15514c747d8a64737192c6b8 (patch) | |
tree | d3609b5b6a7d0b36a037707aefc0e1d09b20059a /lib/csv.rb | |
parent | 4a7dedf7f0b92f327fbc9f1042ed9eb4c9ebef66 (diff) |
* lib/csv.rb: enable frozen_string_literal.
[fix GH-1116] Patch by @marshall-lee
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/csv.rb')
-rw-r--r-- | lib/csv.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 410622682e..a723a44430 100644 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # encoding: US-ASCII # = csv.rb -- CSV Reading and Writing # @@ -207,7 +208,7 @@ require "stringio" # class CSV # The version of the installed library. - VERSION = "2.4.8".freeze + VERSION = "2.4.8" # # A CSV::Row is part Array and part Hash. It retains an order for the fields @@ -1153,7 +1154,7 @@ class CSV args.unshift(io) else encoding = args[-1][:encoding] if args.last.is_a?(Hash) - str = "" + str = String.new str.force_encoding(encoding) if encoding args.unshift(str) end @@ -1178,7 +1179,7 @@ class CSV def self.generate_line(row, options = Hash.new) options = {row_sep: $INPUT_RECORD_SEPARATOR}.merge(options) encoding = options.delete(:encoding) - str = "" + str = String.new if encoding str.force_encoding(encoding) elsif field = row.find { |f| not f.nil? } @@ -1527,7 +1528,7 @@ class CSV # prepare for building safe regular expressions in the target encoding, # if we can transcode the needed characters # - @re_esc = "\\".encode(@encoding) rescue "" + @re_esc = "\\".encode(@encoding).freeze rescue "" @re_chars = /#{%"[-\\]\\[\\.^$?*+{}()|# \r\n\t\f\v]".encode(@encoding)}/ init_separators(options) |