ruby-changes:40769
From: hsbt <ko1@a...>
Date: Wed, 2 Dec 2015 11:23:23 +0900 (JST)
Subject: [ruby-changes:40769] hsbt:r52848 (trunk): * lib/csv.rb: enable frozen_string_literal.
hsbt 2015-12-02 11:23:12 +0900 (Wed, 02 Dec 2015) New Revision: 52848 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52848 Log: * lib/csv.rb: enable frozen_string_literal. [fix GH-1116] Patch by @marshall-lee Modified files: trunk/ChangeLog trunk/lib/csv.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52847) +++ ChangeLog (revision 52848) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Dec 2 11:23:06 2015 SHIBATA Hiroshi <hsbt@r...> + + * lib/csv.rb: enable frozen_string_literal. + [fix GH-1116] Patch by @marshall-lee + Wed Dec 2 10:36:25 2015 SHIBATA Hiroshi <hsbt@r...> * ext/bigdecimal/bigdecimal.c: Fix double word typo. Index: lib/csv.rb =================================================================== --- lib/csv.rb (revision 52847) +++ lib/csv.rb (revision 52848) @@ -1,3 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1 +# frozen_string_literal: true # encoding: US-ASCII # = csv.rb -- CSV Reading and Writing # @@ -207,7 +208,7 @@ require "stringio" https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L208 # 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 https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1154 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 https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1179 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 https://github.com/ruby/ruby/blob/trunk/lib/csv.rb#L1528 # 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/