summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
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++;