1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* include/ruby/defines.h (CASEFOLD_FILESYSTEM): Revert r30508. See #4255.

Now __APPLE__ is not CASEFOLD_FILESYSTEM again.

* load.c (loaded_feature_path, rb_feature_p, load_lock): Revert r30508. 
  See #4255. Make $LOADED_FEATURES scanning case-sensitive again.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nahi 2011-05-22 12:52:18 +00:00
parent 75431b924c
commit 27ddbc5972
3 changed files with 16 additions and 33 deletions

View file

@ -1,3 +1,11 @@
Sun May 22 21:29:29 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
* include/ruby/defines.h (CASEFOLD_FILESYSTEM): Revert r30508. See #4255.
Now __APPLE__ is not CASEFOLD_FILESYSTEM again.
* load.c (loaded_feature_path, rb_feature_p, load_lock): Revert r30508.
See #4255. Make $LOADED_FEATURES scanning case-sensitive again.
Sun May 22 18:59:27 2011 Hiroshi Nakamura <nahi@ruby-lang.org> Sun May 22 18:59:27 2011 Hiroshi Nakamura <nahi@ruby-lang.org>
* ext/openssl/ossl_asn1.c(ossl_asn1_default_tag): avoid using RCLASS_SUPER * ext/openssl/ossl_asn1.c(ossl_asn1_default_tag): avoid using RCLASS_SUPER

25
load.c
View file

@ -9,20 +9,12 @@
VALUE ruby_dln_librefs; VALUE ruby_dln_librefs;
#if CASEFOLD_FILESYSTEM #define IS_RBEXT(e) (strcmp((e), ".rb") == 0)
#define fncomp strcasecmp #define IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
#define fnncomp strncasecmp
#else
#define fncomp strcmp
#define fnncomp strncmp
#endif
#define IS_RBEXT(e) (fncomp((e), ".rb") == 0)
#define IS_SOEXT(e) (fncomp((e), ".so") == 0 || fncomp((e), ".o") == 0)
#ifdef DLEXT2 #ifdef DLEXT2
#define IS_DLEXT(e) (fncomp((e), DLEXT) == 0 || fncomp((e), DLEXT2) == 0) #define IS_DLEXT(e) (strcmp((e), DLEXT) == 0 || strcmp((e), DLEXT2) == 0)
#else #else
#define IS_DLEXT(e) (fncomp((e), DLEXT) == 0) #define IS_DLEXT(e) (strcmp((e), DLEXT) == 0)
#endif #endif
@ -88,8 +80,8 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len,
long n = RSTRING_LEN(p); long n = RSTRING_LEN(p);
if (vlen < n + len + 1) continue; if (vlen < n + len + 1) continue;
if (n && (fnncomp(name, s, n) || name[n] != '/')) continue; if (n && (strncmp(name, s, n) || name[n] != '/')) continue;
if (fnncomp(name + n + 1, feature, len)) continue; if (strncmp(name + n + 1, feature, len)) continue;
if (name[n+len+1] && name[n+len+1] != '.') continue; if (name[n+len+1] && name[n+len+1] != '.') continue;
switch (type) { switch (type) {
case 's': case 's':
@ -151,7 +143,7 @@ rb_feature_p(const char *feature, const char *ext, int rb, int expanded, const c
v = RARRAY_PTR(features)[i]; v = RARRAY_PTR(features)[i];
f = StringValuePtr(v); f = StringValuePtr(v);
if ((n = RSTRING_LEN(v)) < len) continue; if ((n = RSTRING_LEN(v)) < len) continue;
if (fnncomp(f, feature, len) != 0) { if (strncmp(f, feature, len) != 0) {
if (expanded) continue; if (expanded) continue;
if (!load_path) load_path = rb_get_expanded_load_path(); if (!load_path) load_path = rb_get_expanded_load_path();
if (!(p = loaded_feature_path(f, n, feature, len, type, load_path))) if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
@ -390,8 +382,7 @@ load_lock(const char *ftptr)
if (!loading_tbl || !st_lookup(loading_tbl, (st_data_t)ftptr, &data)) { if (!loading_tbl || !st_lookup(loading_tbl, (st_data_t)ftptr, &data)) {
/* loading ruby library should be serialized. */ /* loading ruby library should be serialized. */
if (!loading_tbl) { if (!loading_tbl) {
GET_VM()->loading_table = loading_tbl = GET_VM()->loading_table = loading_tbl = st_init_strtable();
(CASEFOLD_FILESYSTEM ? st_init_strcasetable() : st_init_strtable());
} }
/* partial state */ /* partial state */
ftptr = ruby_strdup(ftptr); ftptr = ruby_strdup(ftptr);

View file

@ -339,20 +339,4 @@ class TestRequire < Test::Unit::TestCase
[], /\$LOADED_FEATURES is frozen; cannot append feature \(RuntimeError\)$/, [], /\$LOADED_FEATURES is frozen; cannot append feature \(RuntimeError\)$/,
bug3756) bug3756)
end end
def test_case_insensitive
load_path = $:.dup
loaded = $".dup
path = File.expand_path(__FILE__)
$:.unshift(File.dirname(path))
$".push(path) unless $".include?(path)
bug4255 = '[ruby-core:34297]'
assert_equal(false, $bug4255 ||= false, bug4255)
$bug4255 = true
f = File.basename(__FILE__, ".*").upcase
assert_equal(false, require(f))
ensure
$:.replace(load_path)
$".replace(loaded)
end if File.identical?(__FILE__, __FILE__.upcase)
end end