mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* sample/test.rb (valid_syntax?): skips BOM. [ruby-dev:38666]
* test/ruby/test_system.rb (TestSystem#valid_syntax?): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d121a3fb79
commit
53ecede90b
3 changed files with 13 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Wed Jun 17 14:37:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* sample/test.rb (valid_syntax?): skips BOM. [ruby-dev:38666]
|
||||||
|
|
||||||
|
* test/ruby/test_system.rb (TestSystem#valid_syntax?): ditto.
|
||||||
|
|
||||||
Wed Jun 17 13:54:18 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Jun 17 13:54:18 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* ext/strscan/strscan.c (Init_strscan): remove obsolete
|
* ext/strscan/strscan.c (Init_strscan): remove obsolete
|
||||||
|
|
|
@ -1930,10 +1930,11 @@ end
|
||||||
|
|
||||||
def valid_syntax?(code, fname)
|
def valid_syntax?(code, fname)
|
||||||
p fname
|
p fname
|
||||||
code.force_encoding("ascii-8bit")
|
code = code.dup.force_encoding("ascii-8bit")
|
||||||
code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) {
|
code.sub!(/\A(\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
|
||||||
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
||||||
}.force_encoding("us-ascii")
|
}
|
||||||
|
code.force_encoding("us-ascii")
|
||||||
catch {|tag| eval(code, binding, fname, 0)}
|
catch {|tag| eval(code, binding, fname, 0)}
|
||||||
rescue Exception
|
rescue Exception
|
||||||
STDERR.puts $!.message
|
STDERR.puts $!.message
|
||||||
|
|
|
@ -4,10 +4,11 @@ require_relative 'envutil'
|
||||||
|
|
||||||
class TestSystem < Test::Unit::TestCase
|
class TestSystem < Test::Unit::TestCase
|
||||||
def valid_syntax?(code, fname)
|
def valid_syntax?(code, fname)
|
||||||
code.force_encoding("ascii-8bit")
|
code = code.dup.force_encoding("ascii-8bit")
|
||||||
code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) {
|
code.sub!(/\A(\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
|
||||||
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
|
||||||
}
|
}
|
||||||
|
code.force_encoding("us-ascii")
|
||||||
catch {|tag| eval(code, binding, fname, 0)}
|
catch {|tag| eval(code, binding, fname, 0)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue