diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-11 18:13:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-11 18:13:40 +0000 |
commit | 0ae6c7f816cbc3ba0cdd97f609b9ffcbf49bf9bb (patch) | |
tree | f6edf414d88a0038fc62c09428007a3104a36a51 | |
parent | 23bb4d7898bcafad7b2b46339994b650aef60a42 (diff) | |
download | ruby-0ae6c7f816cbc3ba0cdd97f609b9ffcbf49bf9bb.tar.gz |
* file.c (file_expand_path): set external encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | file.c | 12 |
2 files changed, 14 insertions, 2 deletions
@@ -1,4 +1,6 @@ -Sat Apr 12 03:12:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> +Sat Apr 12 03:13:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (file_expand_path): set external encoding. * file.c (rb_file_s_basename, rb_file_s_dirname, rb_file_s_extname): copy encoding. @@ -2551,6 +2551,11 @@ rb_path_end(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),\ + rb_enc_check(fname, result)) + static int is_absolute_path(const char*); static VALUE @@ -2559,6 +2564,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) char *s, *buf, *b, *p, *pend, *root; long buflen, dirlen; int tainted; + rb_encoding *extenc = 0; FilePathValue(fname); s = StringValuePtr(fname); @@ -2586,6 +2592,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) #endif s++; tainted = 1; + SET_EXTERNAL_ENCODING(); } else { #ifdef HAVE_PWD_H @@ -2641,6 +2648,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) BUFCHECK(dirlen > buflen); strcpy(buf, dir); free(dir); + SET_EXTERNAL_ENCODING(); } p = chompdirsep(skiproot(buf)); s += 2; @@ -2660,6 +2668,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) BUFCHECK(dirlen > buflen); strcpy(buf, dir); free(dir); + SET_EXTERNAL_ENCODING(); } #if defined DOSISH || defined __CYGWIN__ if (isdirsep(*s)) { @@ -2749,13 +2758,14 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) if (tainted) OBJ_TAINT(result); rb_str_set_len(result, p - buf); + rb_enc_check(fname, result); return result; } VALUE rb_file_expand_path(VALUE fname, VALUE dname) { - return file_expand_path(fname, dname, rb_str_new(0, MAXPATHLEN + 2)); + return file_expand_path(fname, dname, rb_usascii_str_new(0, MAXPATHLEN + 2)); } /* |