load.c: keep encoding of feature name

* file.c (rb_find_file_ext_safe, rb_find_file_safe): default to
  US-ASCII for encdb and transdb.
* load.c (search_required): keep encoding of feature name.  set
  loading path to filesystem encoding.  [Bug #6377][ruby-core:44750]
* ruby.c (add_modules, require_libraries): assume default external
  encoding as well as ARGV.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-08-23 07:46:12 +00:00
parent 2933909caf
commit c68d29960b
5 changed files with 43 additions and 6 deletions

2
file.c
View file

@ -5243,6 +5243,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level)
RBASIC(fname)->klass = 0;
fnlen = RSTRING_LEN(fname);
tmp = rb_str_tmp_new(MAXPATHLEN + 2);
rb_enc_associate_index(tmp, rb_usascii_encindex());
for (j=0; ext[j]; j++) {
rb_str_cat2(fname, ext[j]);
for (i = 0; i < RARRAY_LEN(load_path); i++) {
@ -5305,6 +5306,7 @@ rb_find_file_safe(VALUE path, int safe_level)
long i;
tmp = rb_str_tmp_new(MAXPATHLEN + 2);
rb_enc_associate_index(tmp, rb_usascii_encindex());
for (i = 0; i < RARRAY_LEN(load_path); i++) {
VALUE str = RARRAY_PTR(load_path)[i];
RB_GC_GUARD(str) = rb_get_path_check(str, safe_level);