aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/encoding.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-05 10:35:30 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-05 10:35:30 +0000
commit8186c3994e0cf1f91070176af66846d8f1556ec4 (patch)
tree362b9fc870edb3820ef488a6618baf5669d3aa48 /lib/rdoc/encoding.rb
parent0de432c787ece6a2ad88a8694526da29ad663b62 (diff)
downloadruby-8186c3994e0cf1f91070176af66846d8f1556ec4.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.rb13
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