summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-17 07:16:37 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-17 07:16:37 +0000
commit7405ea0c0f8841270c5f6d77d529cb926c66b958 (patch)
tree71f82f961449b121febdf7a87db128ef44931f65
parentcec9163e7bf3bcc77ba6a6ad612df95e1733c0d6 (diff)
merge revision(s) 49178: [Backport #10700]
* 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/branches/ruby_2_2@49296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--dir.c23
-rw-r--r--version.h2
3 files changed, 29 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1c16eb4278..dfd53f6645 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Jan 17 16:16:14 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]
+
Sat Jan 17 02:04:01 2015 Eric Wong <e@80x24.org>
* lib/resolv.rb: consider ENETUNREACH as ResolvTimeout
diff --git a/dir.c b/dir.c
index 5386ff03f2..a4ee52ca49 100644
--- a/dir.c
+++ b/dir.c
@@ -1327,6 +1327,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 hfs_p)
{
@@ -1518,7 +1536,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;
diff --git a/version.h b/version.h
index c0530ef0f8..f853235037 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.0"
#define RUBY_RELEASE_DATE "2015-01-17"
-#define RUBY_PATCHLEVEL 18
+#define RUBY_PATCHLEVEL 19
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 1