diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-09 07:16:31 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-09 07:16:31 +0000 |
commit | 4def2274b2685eab2c2a3bc4cd831faf1382e5e9 (patch) | |
tree | a1032822a5601832494371e659331a27d2b1065e | |
parent | 0d1f4fb57deeeb88f55751bf71ad7c2e90ac47b1 (diff) |
merge revision(s) 50515: [Backport #11155]
* load.c (loaded_feature_path): stop returning false negatives for
filenames which are trailing substrings of file extensions. For
example, 'b', which a trailing substring of ".rb" should not return
false. [Bug #11155][ruby-core:69206]
* test/ruby/test_autoload.rb: test for fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@50805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | load.c | 2 | ||||
-rw-r--r-- | test/ruby/test_autoload.rb | 26 | ||||
-rw-r--r-- | version.h | 8 |
4 files changed, 40 insertions, 5 deletions
@@ -1,3 +1,12 @@ +Tue Jun 9 16:15:31 2015 Aaron Patterson <tenderlove@ruby-lang.org> + + * load.c (loaded_feature_path): stop returning false negatives for + filenames which are trailing substrings of file extensions. For + example, 'b', which a trailing substring of ".rb" should not return + false. [Bug #11155][ruby-core:69206] + + * test/ruby/test_autoload.rb: test for fix + Fri May 29 14:03:33 2015 Matt Hoyle <matt@deployable.co> * ext/bigdecimal/bigdecimal.c (VpSetPTR): fix a typo, 'expoennt' @@ -319,7 +319,7 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len, const char *e; if (vlen < len+1) return 0; - if (!strncmp(name+(vlen-len), feature, len)) { + if (strchr(feature, '.') && !strncmp(name+(vlen-len), feature, len)) { plen = vlen - len; } else { diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 1931df45c5..f88bcac579 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -56,6 +56,32 @@ p Foo::Bar } end + def test_autoload_with_unqualified_file_name # [ruby-core:69206] + lp = $LOAD_PATH.dup + lf = $LOADED_FEATURES.dup + + Dir.mktmpdir('autoload') { |tmpdir| + $LOAD_PATH << tmpdir + + Dir.chdir(tmpdir) do + eval <<-END + class ::Object + module A + autoload :C, 'b' + end + end + END + + File.open('b.rb', 'w') {|file| file.puts 'module A; class C; end; end'} + assert_kind_of Class, ::A::C + end + } + ensure + $LOAD_PATH.replace lp + $LOADED_FEATURES.replace lf + Object.send(:remove_const, :A) if Object.const_defined?(:A) + end + def test_require_explicit Tempfile.create(['autoload', '.rb']) {|file| file.puts 'class Object; AutoloadTest = 1; end' @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.7" -#define RUBY_RELEASE_DATE "2015-05-29" -#define RUBY_PATCHLEVEL 362 +#define RUBY_RELEASE_DATE "2015-06-09" +#define RUBY_PATCHLEVEL 363 #define RUBY_RELEASE_YEAR 2015 -#define RUBY_RELEASE_MONTH 5 -#define RUBY_RELEASE_DAY 29 +#define RUBY_RELEASE_MONTH 6 +#define RUBY_RELEASE_DAY 9 #include "ruby/version.h" |