summaryrefslogtreecommitdiff
path: root/lib/rdoc/encoding.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-18 08:24:57 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-18 08:24:57 +0000
commitdff59f6c5df7d995d02e8173a8ce42ff9c552e88 (patch)
tree9f5e5cec85b40b986b3405b913a5c59cb82e53e9 /lib/rdoc/encoding.rb
parentaa233d3f3331c266baabfefc68d9bc2cc2f4fd0b (diff)
* lib/rdoc/encoding.rb: Do not remove #! line from document when
setting encoding. This allows ruby executables to be parsed as ruby files. * test/rdoc/test_rdoc_encoding.rb: Test for above. * lib/rdoc/parser.rb: Set the parser file name of ruby executables correctly. * test/rdoc/test_rdoc_parser.rb: Test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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