diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-25 02:32:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-25 02:32:06 +0000 |
commit | ed469831e44f2b5a9384b18e660677b20a5ab664 (patch) | |
tree | 5bb8be2989daaec412e3b09b22034aab1007e9a4 /dir.c | |
parent | abd135d36bef0f340fd914405c8cfe0c0e579f86 (diff) | |
download | ruby-ed469831e44f2b5a9384b18e660677b20a5ab664.tar.gz |
* file.c (rb_enc_path_next, rb_enc_path_skip_prefix)
(rb_enc_path_last_separator, rb_enc_path_end)
(ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware
path handling functions.
* file.c (rb_home_dir, file_expand_path, rb_realpath_internal)
(rb_file_s_basename, rb_file_dirname, rb_file_s_extname)
(rb_file_join): should respect the encodings of arguments than
file system encoding. [ruby-dev:45145] [Bug #5919]
* dir.c (check_dirname, ruby_glob0): ditto.
* ext/pathname/pathname.c (path_sub_ext): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -897,11 +897,16 @@ check_dirname(volatile VALUE *dir) { VALUE d = *dir; char *path, *pend; + long len; + rb_encoding *enc; rb_secure(2); FilePathValue(d); - path = RSTRING_PTR(d); - if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) { + enc = rb_enc_get(d); + RSTRING_GETMEM(d, path, len); + pend = path + len; + pend = rb_enc_path_end(rb_enc_path_skip_prefix(path, pend, enc), pend, enc); + if (pend - path < len) { d = rb_str_subseq(d, 0, pend - path); } *dir = rb_str_encode_ospath(d); @@ -1481,7 +1486,7 @@ ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg, rb_enco start = root = path; flags |= FNM_SYSCASE; #if defined DOSISH - root = rb_path_skip_prefix(root); + root = rb_enc_path_skip_prefix(root, root + strlen(root), enc); #endif if (root && *root == '/') root++; |