From 2368dbdfa3c438b614a4727bde7cacac2d0a87a9 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 16 Mar 2018 17:34:44 +0000 Subject: merge revision(s) 58745,58780,59040,60743: [Backport #13863] rb_w32_ugetcwd: UTF-8 version getcwd * dir.c (rb_dir_getwd): convert from UTF-8. * win32/win32.c (w32_getcwd): codepage aware getcwd using GetCurrentDirectoryW. potential memory leak * dir.c (rb_dir_getwd): get rid of potential memory leak. * util.c (ruby_getcwd): ditto. file.c: realpath in OS path encoding * dir.c (rb_dir_getwd_ospath): return cwd path in the OS path encoding. * file.c (rb_realpath_internal): work in the OS path encoding load.c: cwd encoding * load.c (rb_get_expanded_load_path): save cwd cache in OS path encoding, to get rid of unnecessary conversion and infinite loading when it needs encoding conversion. [ruby-dev:50221] [Bug #13863] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- load.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'load.c') diff --git a/load.c b/load.c index bd0f8b8fdf..b8946ac91b 100644 --- a/load.c +++ b/load.c @@ -95,15 +95,6 @@ rb_construct_expanded_load_path(enum expand_type type, int *has_relative, int *h rb_ary_replace(vm->load_path_snapshot, vm->load_path); } -static VALUE -load_path_getcwd(void) -{ - char *cwd = my_getcwd(); - VALUE cwd_str = rb_filesystem_str_new_cstr(cwd); - xfree(cwd); - return cwd_str; -} - VALUE rb_get_expanded_load_path(void) { @@ -115,7 +106,7 @@ rb_get_expanded_load_path(void) int has_relative = 0, has_non_cache = 0; rb_construct_expanded_load_path(EXPAND_ALL, &has_relative, &has_non_cache); if (has_relative) { - vm->load_path_check_cache = load_path_getcwd(); + vm->load_path_check_cache = rb_dir_getwd_ospath(); } else if (has_non_cache) { /* Non string object. */ @@ -133,7 +124,7 @@ rb_get_expanded_load_path(void) } else if (vm->load_path_check_cache) { int has_relative = 1, has_non_cache = 1; - VALUE cwd = load_path_getcwd(); + VALUE cwd = rb_dir_getwd_ospath(); if (!rb_str_equal(vm->load_path_check_cache, cwd)) { /* Current working directory or filesystem encoding was changed. Expand relative load path and non-cacheable objects again. */ -- cgit v1.2.3