diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-19 19:06:36 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-05-19 19:06:36 +0000 |
commit | ddf1f59df5fbff6c659177bc36e161b2ae285d5f (patch) | |
tree | 94bdeb974cbe8e1a9a1ef97eda915a66d9b6a910 /dir.c | |
parent | 9eb78a21387b6a90f5f9558de79b59f6348156fc (diff) |
merge revision(s) 50218: [Backport #11054] [Backport #11069]
* dir.c (need_normalization): use getattrlist() if fgetattrlist()
is unavailable, on OSX 10.5. [ruby-core:68829] [Bug #11054]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -103,13 +103,23 @@ char *strchr(char*,char); #include <sys/mount.h> #include <sys/vnode.h> +# if defined HAVE_FGETATTRLIST || !defined HAVE_GETATTRLIST +# define need_normalization(dirp, path) need_normalization(dirp) +# else +# define need_normalization(dirp, path) need_normalization(path) +# endif static inline int -need_normalization(DIR *dirp) +need_normalization(DIR *dirp, const char *path) { -# ifdef HAVE_GETATTRLIST +# if defined HAVE_FGETATTRLIST || defined HAVE_GETATTRLIST u_int32_t attrbuf[SIZEUP32(fsobj_tag_t)]; struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, ATTR_CMN_OBJTAG,}; - if (!fgetattrlist(dirfd(dirp), &al, attrbuf, sizeof(attrbuf), 0)) { +# if defined HAVE_FGETATTRLIST + int ret = fgetattrlist(dirfd(dirp), &al, attrbuf, sizeof(attrbuf), 0); +# else + int ret = getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0); +# endif + if (!ret) { const fsobj_tag_t *tag = (void *)(attrbuf+1); switch (*tag) { case VT_HFS: @@ -694,7 +704,7 @@ dir_each(VALUE dir) RETURN_ENUMERATOR(dir, 0, 0); GetDIR(dir, dirp); rewinddir(dirp->dir); - IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp->dir)); + IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp->dir, RSTRING_PTR(dirp->path))); while ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) { const char *name = dp->d_name; size_t namlen = NAMLEN(dp); @@ -1661,7 +1671,7 @@ glob_helper( # endif return 0; } - IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp)); + IF_NORMALIZE_UTF8PATH(norm_p = need_normalization(dirp, *path ? path : ".")); # if NORMALIZE_UTF8PATH if (!(norm_p || magical || recursive)) { |