summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-26 03:01:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-26 03:01:41 +0000
commit0e6dcc7ab24e6e5b8ee3b9a532c0318eb5155e2e (patch)
tree10e9d00b89f6bb5b0d275ee4dbd6e35fe886b2ef /dir.c
parentc5b7d11e59cf8953d18ed6aba2c4df2b1eb29fd4 (diff)
merge revision(s) 32826,34732: [Backport #6681]
* 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. * util.c, include/ruby/util.h (ruby_add_suffix): remove the function. [Bug #5153] [ruby-core:38736] * io.c (argf_next_argv): remove the call of above function. * ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test extension module because this is only for testsing ruby_add_suffix(). * LEGAL: remove the mention about a part of util.c, because now we removed the part. * io.c (argf_next_argv): now the new filename is not guranteed to use, so should check the return value of rename(2). * test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible): now we expect same result with other platforms on no_safe_rename platforms (=Windows). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/dir.c b/dir.c
index 2cc1226d4d..387a2490b6 100644
--- a/dir.c
+++ b/dir.c
@@ -910,11 +910,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);
@@ -1494,7 +1499,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++;