aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/encoding.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/encoding.rb')
-rw-r--r--lib/rdoc/encoding.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb
index 0b1ec6728e..9fe3539412 100644
--- a/lib/rdoc/encoding.rb
+++ b/lib/rdoc/encoding.rb
@@ -75,7 +75,9 @@ module RDoc::Encoding
# Sets the encoding of +string+ based on the magic comment
def self.set_encoding string
- first_line = string[/\A(?:#!.*\n)?.*\n/]
+ string =~ /\A(?:#!.*\n)?(.*\n)/
+
+ first_line = $1
name = case first_line
when /^<\?xml[^?]*encoding=(["'])(.*?)\1/ then $2