diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-05 10:35:30 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-05 10:35:30 +0000 |
commit | 23863ff75d3ec9205d5f365b98b6608e38a93749 (patch) | |
tree | 362b9fc870edb3820ef488a6618baf5669d3aa48 /lib/rdoc/encoding.rb | |
parent | 0d715e1b7540e1c876a4c53862355d5c43dd8683 (diff) | |
download | ruby-23863ff75d3ec9205d5f365b98b6608e38a93749.tar.gz |
* lib/rdoc/*, test/rdoc/*: Update rdoc/rdoc master(f191513)
https://github.com/rdoc/rdoc/blob/master/History.rdoc#423--2016--
https://github.com/rdoc/rdoc/blob/master/History.rdoc#422--2016-02-09
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/encoding.rb')
-rw-r--r-- | lib/rdoc/encoding.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb index 5327f9a961..1056827937 100644 --- a/lib/rdoc/encoding.rb +++ b/lib/rdoc/encoding.rb @@ -74,10 +74,21 @@ module RDoc::Encoding nil end + def self.remove_frozen_string_literal string + string =~ /\A(?:#!.*\n)?(.*\n)/ + first_line = $1 + + if first_line =~ /\A# +frozen[-_]string[-_]literal[=:].+$/i + string.sub! first_line, '' + end + end + ## # Sets the encoding of +string+ based on the magic comment def self.set_encoding string + remove_frozen_string_literal string + string =~ /\A(?:#!.*\n)?(.*\n)/ first_line = $1 @@ -90,6 +101,8 @@ module RDoc::Encoding string.sub! first_line, '' + remove_frozen_string_literal string + return unless Object.const_defined? :Encoding enc = Encoding.find name |