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
commit204232897e21bdf77a1f11c8e2e66d3b52a07399 (patch)
treeef8ef58f235b80d4524463a20002eef6921026a8 /dir.c
parentbcef5293c78e7f57f0198946c4a0d1ca8a3ad544 (diff)
downloadruby-204232897e21bdf77a1f11c8e2e66d3b52a07399.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;