From: "h.shirosaki (Hiroshi Shirosaki)" Date: 2013-03-28T00:49:18+09:00 Subject: [ruby-core:53772] [ruby-trunk - Bug #8165] Problems with require Issue #8165 has been updated by h.shirosaki (Hiroshi Shirosaki). It seems `short_feature` is not proper if the path contains non-ascii characters. rb_str_substr() would look up string position per character, not per byte. rb_str_subseq() seems to work for non-ascii. diff --git a/load.c b/load.c index 7c69461..dab493d 100644 --- a/load.c +++ b/load.c @@ -247,16 +247,16 @@ features_index_add(VALUE feature, VALUE offset) if (p < feature_str) break; /* Now *p == '/'. We reach this point for every '/' in `feature`. */ - short_feature = rb_str_substr(feature, p + 1 - feature_str, feature_end - p - 1); + short_feature = rb_str_subseq(feature, p + 1 - feature_str, feature_end - p - 1); features_index_add_single(short_feature, offset); if (ext) { - short_feature = rb_str_substr(feature, p + 1 - feature_str, ext - p - 1); + short_feature = rb_str_subseq(feature, p + 1 - feature_str, ext - p - 1); features_index_add_single(short_feature, offset); } } features_index_add_single(feature, offset); if (ext) { - short_feature = rb_str_substr(feature, 0, ext - feature_str); + short_feature = rb_str_subseq(feature, 0, ext - feature_str); features_index_add_single(short_feature, offset); } } ---------------------------------------- Bug #8165: Problems with require https://bugs.ruby-lang.org/issues/8165#change-37969 Author: Krugloff (Alexandr Kruglov) Status: Assigned Priority: Normal Assignee: tarui (Masaya Tarui) Category: Target version: current: 2.1.0 ruby -v: ruby 2.0.0-p0 Require doesn't work correctly if path contains cyrillic. require '/home/mak/test.rb' #-> true require '/home/mak/test.rb' #-> false require '/home/mak/��������������/test.rb' #-> true require '/home/mak/��������������/test.rb' #-> true -- http://bugs.ruby-lang.org/