diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-27 14:51:20 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-27 14:51:20 +0000 |
commit | d760018fd972d4fe553c93e324a70d4ad7a0af16 (patch) | |
tree | 9f03c97bd57d68846531a294f276dd16a937ccec /file.c | |
parent | 1f3a98202ff02eddb7b553851c003854a1d29ee1 (diff) |
merge revision(s) 28037:28040:
* file.c (rb_home_dir): set filesystem encoding.
* file.c (file_expand_path): set encoding as the same of fname
when _result_ is not filesystem encoding. [ruby-dev:41429]
* file.c (file_expand_path): use rb_enc_associate_index and
rb_filesystem_encindex. Strings related FileSystem should
have filesystem_encoding.
* file.c (SET_EXTERNAL_ENCODING): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -2788,10 +2788,6 @@ ntfs_tail(const char *path) buflen = RSTRING_LEN(result),\ pend = p + buflen) -#define SET_EXTERNAL_ENCODING() (\ - (void)(extenc || (extenc = rb_default_external_encoding())),\ - rb_enc_associate(result, extenc)) - VALUE rb_home_dir(const char *user, VALUE result) { @@ -2832,6 +2828,7 @@ rb_home_dir(const char *user, VALUE result) } } #endif + rb_enc_associate_index(result, rb_filesystem_encindex()); return result; } @@ -2842,7 +2839,6 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) char *buf, *p, *pend, *root; size_t buflen, dirlen, bdiff; int tainted; - rb_encoding *extenc = 0; s = StringValuePtr(fname); BUFINIT(); @@ -2898,8 +2894,9 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) BUFCHECK(dirlen > buflen); strcpy(buf, dir); xfree(dir); - SET_EXTERNAL_ENCODING(); + rb_enc_associate_index(result, rb_filesystem_encindex()); } + else rb_enc_copy(result, fname); p = chompdirsep(skiproot(buf)); s += 2; } @@ -2909,6 +2906,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) if (!NIL_P(dname)) { file_expand_path(dname, Qnil, abs_mode, result); BUFINIT(); + rb_enc_copy(result, fname); } else { char *dir = my_getcwd(); @@ -2918,7 +2916,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) BUFCHECK(dirlen > buflen); strcpy(buf, dir); xfree(dir); - SET_EXTERNAL_ENCODING(); + rb_enc_associate_index(result, rb_filesystem_encindex()); } #if defined DOSISH || defined __CYGWIN__ if (isdirsep(*s)) { |