ruby-changes:46872
From: nobu <ko1@a...>
Date: Thu, 1 Jun 2017 22:05:58 +0900 (JST)
Subject: [ruby-changes:46872] nobu:r58987 (trunk): load.c: convert by rb_get_path_check
nobu 2017-06-01 22:05:54 +0900 (Thu, 01 Jun 2017) New Revision: 58987 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58987 Log: load.c: convert by rb_get_path_check * load.c (rb_require_internal): convert to path name with the given safe level, without setting global safe level. Modified files: trunk/file.c trunk/internal.h trunk/load.c Index: load.c =================================================================== --- load.c (revision 58986) +++ load.c (revision 58987) @@ -969,6 +969,8 @@ rb_require_internal(VALUE fname, int saf https://github.com/ruby/ruby/blob/trunk/load.c#L969 RUBY_DTRACE_HOOK(REQUIRE_ENTRY, StringValuePtr(fname)); + fname = rb_get_path_check(fname, safe); + TH_PUSH_TAG(th); saved.safe = rb_safe_level(); if ((state = EXEC_TAG()) == 0) { @@ -976,16 +978,13 @@ rb_require_internal(VALUE fname, int saf https://github.com/ruby/ruby/blob/trunk/load.c#L978 long handle; int found; - rb_set_safe_level_force(safe); - FilePathValue(fname); rb_set_safe_level_force(0); RUBY_DTRACE_HOOK(FIND_REQUIRE_ENTRY, StringValuePtr(fname)); - path = rb_str_encode_ospath(fname); found = search_required(path, &path, safe); - RUBY_DTRACE_HOOK(FIND_REQUIRE_RETURN, StringValuePtr(fname)); + if (found) { if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) { result = 0; @@ -1018,6 +1017,7 @@ rb_require_internal(VALUE fname, int saf https://github.com/ruby/ruby/blob/trunk/load.c#L1017 rb_set_safe_level_force(saved.safe); if (state) { + RB_GC_GUARD(fname); /* never TAG_RETURN */ return state; } Index: internal.h =================================================================== --- internal.h (revision 58986) +++ internal.h (revision 58987) @@ -1168,6 +1168,7 @@ VALUE rb_file_expand_path_fast(VALUE, VA https://github.com/ruby/ruby/blob/trunk/internal.h#L1168 VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE); VALUE rb_get_path_check_to_string(VALUE, int); VALUE rb_get_path_check_convert(VALUE, VALUE, int); +VALUE rb_get_path_check(VALUE, int); void Init_File(void); int ruby_is_fd_loadable(int fd); Index: file.c =================================================================== --- file.c (revision 58986) +++ file.c (revision 58987) @@ -200,7 +200,7 @@ rb_get_path_check_convert(VALUE obj, VAL https://github.com/ruby/ruby/blob/trunk/file.c#L200 return rb_str_new4(tmp); } -static VALUE +VALUE rb_get_path_check(VALUE obj, int level) { VALUE tmp = rb_get_path_check_to_string(obj, level); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/