From 4d753671b2172d82d7d2dfb6929c30374a7a9996 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 4 Oct 2015 15:53:53 +0000 Subject: [PATCH] dir.c: make ASCII-8BIT * dir.c (rb_dir_getwd): make ASCII-8BIT if filesystem encoding is US-ASCII, like as Dir.glob. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ dir.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b6bb4db562..3311c3dfae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Oct 5 00:53:51 2015 Nobuyoshi Nakada + + * dir.c (rb_dir_getwd): make ASCII-8BIT if filesystem encoding is + US-ASCII, like as Dir.glob. + Sun Oct 4 23:39:09 2015 Tanaka Akira * enum.c (nmin_filter): Fix limit value. diff --git a/dir.c b/dir.c index d3f6530663..36cdadc0e9 100644 --- a/dir.c +++ b/dir.c @@ -1010,7 +1010,9 @@ rb_dir_getwd(void) { char *path; VALUE cwd; + int fsenc = rb_enc_to_index(rb_filesystem_encoding()); + if (fsenc == ENCINDEX_US_ASCII) fsenc = ENCINDEX_ASCII; path = my_getcwd(); #ifdef __APPLE__ cwd = rb_str_normalize_ospath(path, strlen(path)); @@ -1018,7 +1020,7 @@ rb_dir_getwd(void) #else cwd = rb_tainted_str_new2(path); #endif - rb_enc_associate(cwd, rb_filesystem_encoding()); + rb_enc_associate_index(cwd, fsenc); xfree(path); return cwd;