1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

dir.c: OSX case-folding

* dir.c (glob_helper): match in case-folding only if the directory
  resides on a case-insensitve file system, on OSX.
  [ruby-core:67364] [Bug #10700]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-08 03:53:45 +00:00
parent e247d9e145
commit d6aa766ad5
2 changed files with 28 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Thu Jan 8 12:53:44 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* dir.c (glob_helper): match in case-folding only if the directory
resides on a case-insensitve file system, on OSX.
[ruby-core:67364] [Bug #10700]
Thu Jan 8 11:39:18 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* .travis.yml: Remove redundant configuration option.

23
dir.c
View file

@ -1351,6 +1351,24 @@ join_path(const char *path, long len, int dirsep, const char *name, size_t namle
}
#ifdef HAVE_GETATTRLIST
static int
is_case_sensitive(DIR *dirp)
{
u_int32_t attrbuf[SIZEUP32(vol_capabilities_attr_t) + 1];
struct attrlist al = {ATTR_BIT_MAP_COUNT, 0, 0, ATTR_VOL_INFO|ATTR_VOL_CAPABILITIES};
const vol_capabilities_attr_t *cap = (void *)(attrbuf+1);
const int idx = VOL_CAPABILITIES_FORMAT;
const uint32_t mask = VOL_CAP_FMT_CASE_SENSITIVE;
struct statfs sf;
if (fstatfs(dirfd(dirp), &sf)) return -1;
if (getattrlist(sf.f_mntonname, &al, attrbuf, sizeof(attrbuf), FSOPT_NOFOLLOW))
return -1;
if (!(cap->valid[idx] & mask))
return -1;
return (cap->capabilities[idx] & mask) != 0;
}
static char *
replace_real_basename(char *path, long base, int norm_p)
{
@ -1542,7 +1560,10 @@ glob_helper(
closedir(dirp);
goto literally;
}
flags |= FNM_CASEFOLD;
# endif
# ifdef HAVE_GETATTRLIST
if (is_case_sensitive(dirp) == 0)
flags |= FNM_CASEFOLD;
# endif
while ((dp = READDIR(dirp, enc)) != NULL) {
char *buf;