summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-08 01:26:27 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-08 01:26:27 (GMT)
commit354028abe18bc5862a1b45e2f45060bf85c1ae35 (patch)
treee6da4f79a700852d9550e08adea365f93a5aba15 /dir.c
parent885147037b37d8fc5424b95d82972c45c1151073 (diff)
file.c: rb_str_normalize_ospath
* file.c (rb_str_normalize_ospath): extract and move from dir.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/dir.c b/dir.c
index e2400e5..7e9c659 100644
--- a/dir.c
+++ b/dir.c
@@ -84,11 +84,7 @@ char *strchr(char*,char);
#include <sys/param.h>
#include <sys/mount.h>
-rb_encoding *
-rb_utf8mac_encoding(void)
-{
- return rb_enc_from_index(ENCINDEX_UTF8_MAC);
-}
+VALUE rb_str_normalize_ospath(const char *ptr, long len);
static inline int
is_hfs(DIR *dirp)
@@ -634,10 +630,8 @@ dir_each(VALUE dir)
VALUE path;
#if HAVE_HFS
VALUE utf8str = Qnil;
- rb_encoding *utf8mac = 0;
- if (hfs_p && has_nonascii(name, namlen) && (utf8mac = rb_utf8mac_encoding()) != 0) {
- utf8str = rb_str_conv_enc(rb_tainted_str_new(name, namlen),
- utf8mac, rb_utf8_encoding());
+ if (hfs_p && has_nonascii(name, namlen) &&
+ !NIL_P(utf8str = rb_str_normalize_ospath(name, namlen))) {
RSTRING_GETMEM(utf8str, name, namlen);
}
#endif
@@ -1427,10 +1421,7 @@ glob_helper(
namlen = NAMLEN(dp);
# if HAVE_HFS
if (hfs_p && has_nonascii(name, namlen)) {
- rb_encoding *utf8mac = rb_utf8mac_encoding();
- if (utf8mac) {
- utf8str = rb_str_conv_enc(rb_str_new(name, namlen),
- utf8mac, rb_utf8_encoding());
+ if (!NIL_P(utf8str = rb_str_normalize_ospath(name, namlen))) {
RSTRING_GETMEM(utf8str, name, namlen);
}
}