aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-04 15:53:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-04 15:53:53 +0000
commit4d753671b2172d82d7d2dfb6929c30374a7a9996 (patch)
treeef8ef58f235b80d4524463a20002eef6921026a8 /dir.c
parent3c534a09e904a59f52e76fff334bae211d8f10e0 (diff)
downloadruby-4d753671b2172d82d7d2dfb6929c30374a7a9996.tar.gz
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
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c4
1 files changed, 3 insertions, 1 deletions
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;