ruby-changes:39931
From: nobu <ko1@a...>
Date: Sun, 4 Oct 2015 10:10:15 +0900 (JST)
Subject: [ruby-changes:39931] nobu:r52012 (trunk): dir.c: normalize cwd
nobu 2015-10-04 10:10:00 +0900 (Sun, 04 Oct 2015) New Revision: 52012 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52012 Log: dir.c: normalize cwd * dir.c (rb_dir_getwd): normalize OS path to UTF-8 on OS X. Modified files: trunk/ChangeLog trunk/dir.c trunk/test/ruby/test_dir_m17n.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 52011) +++ ChangeLog (revision 52012) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Oct 4 10:09:57 2015 Nobuyoshi Nakada <nobu@r...> + + * dir.c (rb_dir_getwd): normalize OS path to UTF-8 on OS X. + Sun Oct 4 00:09:45 2015 Nobuyoshi Nakada <nobu@r...> * template/ruby-runner.c.in: wrapper to set dynamic loading path Index: dir.c =================================================================== --- dir.c (revision 52011) +++ dir.c (revision 52012) @@ -1012,7 +1012,12 @@ rb_dir_getwd(void) https://github.com/ruby/ruby/blob/trunk/dir.c#L1012 VALUE cwd; path = my_getcwd(); +#ifdef __APPLE__ + cwd = rb_str_normalize_ospath(path, strlen(path)); + OBJ_TAINT(cwd); +#else cwd = rb_tainted_str_new2(path); +#endif rb_enc_associate(cwd, rb_filesystem_encoding()); xfree(path); Index: test/ruby/test_dir_m17n.rb =================================================================== --- test/ruby/test_dir_m17n.rb (revision 52011) +++ test/ruby/test_dir_m17n.rb (revision 52012) @@ -395,4 +395,14 @@ class TestDir_M17N < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir_m17n.rb#L395 pp.assert_equal(orig, ents, bug7267) } end + + def test_pwd + with_tmpdir {|d| + orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}" + orig.each do |n| + Dir.mkdir(n) + assert_equal(n, File.basename(Dir.chdir(n) {Dir.pwd})) + end + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/