aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-05-20 22:51:32 -0700
committerPaul Eggert2017-05-20 22:56:36 -0700
commit075bd64609446e741a6efbcd6cd6e232db8d1df6 (patch)
treea67097df27736dd6b67712bb8eede15939da3d6a
parent2963861f3d4070420eeee0791008f3e1c02a0450 (diff)
downloademacs-075bd64609446e741a6efbcd6cd6e232db8d1df6.tar.gz
emacs-075bd64609446e741a6efbcd6cd6e232db8d1df6.zip
Narrow DARWIN_OS_CASE_SENSITIVE_FIXME to 1 choice
* etc/PROBLEMS: Document this (Bug#24441). * src/fileio.c (file_name_case_insensitive_p): Prefer pathconf with _PC_CASE_SENSITIVE, if it works, to DARWIN_OS_CASE_SENSITIVE_FIXME code. Support just one method for DARWIN_OS_CASE_SENSITIVE_FIXME, which matches the Apple documentation more precisely.
-rw-r--r--etc/PROBLEMS5
-rw-r--r--src/fileio.c68
2 files changed, 24 insertions, 49 deletions
diff --git a/etc/PROBLEMS b/etc/PROBLEMS
index e415887a4d8..ff88aa367f2 100644
--- a/etc/PROBLEMS
+++ b/etc/PROBLEMS
@@ -2486,9 +2486,8 @@ If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here.
2486The implementation of that function on Mac OS X uses pathconf with the 2486The implementation of that function on Mac OS X uses pathconf with the
2487_PC_CASE_SENSITIVE flag. There have been reports that this use of 2487_PC_CASE_SENSITIVE flag. There have been reports that this use of
2488pathconf does not work reliably. If you have a problem, please 2488pathconf does not work reliably. If you have a problem, please
2489recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or 2489recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME, and file a bug
2490-D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying 2490report saying whether this fixed your problem.
2491whether this fixed your problem.
2492 2491
2493* Build-time problems 2492* Build-time problems
2494 2493
diff --git a/src/fileio.c b/src/fileio.c
index e5e350542f9..17659b692ec 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2256,65 +2256,41 @@ static bool
2256file_name_case_insensitive_p (const char *filename) 2256file_name_case_insensitive_p (const char *filename)
2257{ 2257{
2258 /* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if 2258 /* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if
2259 those flags are available. As of this writing (2016-11-14), 2259 those flags are available. As of this writing (2017-05-20),
2260 Cygwin is the only platform known to support the former (starting 2260 Cygwin is the only platform known to support the former (starting
2261 with Cygwin-2.6.1), and Mac OS X is the only platform known to 2261 with Cygwin-2.6.1), and macOS is the only platform known to
2262 support the latter. 2262 support the latter. */
2263
2264 There have been reports that pathconf with _PC_CASE_SENSITIVE
2265 does not work reliably on Mac OS X. If you have a problem,
2266 please recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or
2267 -D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying
2268 whether this fixed your problem. */
2269 2263
2270#ifdef _PC_CASE_INSENSITIVE 2264#ifdef _PC_CASE_INSENSITIVE
2271 int res = pathconf (filename, _PC_CASE_INSENSITIVE); 2265 int res = pathconf (filename, _PC_CASE_INSENSITIVE);
2272 if (res >= 0) 2266 if (res >= 0)
2273 return res > 0; 2267 return res > 0;
2274#elif defined _PC_CASE_SENSITIVE && !defined DARWIN_OS_CASE_SENSITIVE_FIXME 2268#elif defined _PC_CASE_SENSITIVE
2275 int res = pathconf (filename, _PC_CASE_SENSITIVE); 2269 int res = pathconf (filename, _PC_CASE_SENSITIVE);
2276 if (res >= 0) 2270 if (res >= 0)
2277 return res == 0; 2271 return res == 0;
2278#endif 2272#endif
2279 2273
2280#ifdef DARWIN_OS 2274 /* There have been reports that pathconf with _PC_CASE_SENSITIVE
2281# ifndef DARWIN_OS_CASE_SENSITIVE_FIXME 2275 does not work reliably on Mac OS X. If you have a problem,
2282 int DARWIN_OS_CASE_SENSITIVE_FIXME = 0; 2276 please recompile Emacs with -D DARWIN_OS_CASE_SENSITIVE_FIXME=1 or
2283# endif 2277 -D DARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying
2278 whether this fixed your problem. */
2284 2279
2285 if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1) 2280#ifdef DARWIN_OS_CASE_SENSITIVE_FIXME
2286 { 2281# ifdef VOL_CAP_FMT_CASE_SENSITIVE
2287 /* This is based on developer.apple.com's getattrlist man page. */ 2282 {
2288 struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; 2283 struct attrlist alist = {.bitmapcount = ATTR_BIT_MAP_COUNT,
2289 vol_capabilities_attr_t vcaps; 2284 .volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES};
2290 if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) 2285 struct { uint32_t len; vol_capabilities_attr_t caps; } vcaps
2291 { 2286 __attribute__ ((aligned (4), packed));
2292 if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) 2287 int i = VOL_CAPABILITIES_FORMAT;
2293 return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT] 2288 if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0
2294 & VOL_CAP_FMT_CASE_SENSITIVE); 2289 && (vcaps.caps.valid[i] & VOL_CAP_FMT_CASE_SENSITIVE))
2295 } 2290 return ! (vcaps.caps.capabilities[i] & VOL_CAP_FMT_CASE_SENSITIVE);
2296 } 2291 }
2297# if DARWIN_OS_CASE_SENSITIVE_FIXME == 2
2298 {
2299 /* The following is based on
2300 http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html.
2301 It is normally not even compiled, since it runs afoul of
2302 static checking. See:
2303 http://lists.gnu.org/archive/html/emacs-devel/2017-05/msg00495.html
2304 */
2305 struct attrlist alist;
2306 unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)];
2307
2308 memset (&alist, 0, sizeof (alist));
2309 alist.volattr = ATTR_VOL_CAPABILITIES;
2310 if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0)
2311 || !(alist.volattr & ATTR_VOL_CAPABILITIES))
2312 return 0;
2313 vol_capabilities_attr_t *vcaps = buffer;
2314 return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE);
2315 }
2316# endif 2292# endif
2317#endif /* DARWIN_OS */ 2293#endif
2318 2294
2319#if defined CYGWIN || defined DOS_NT 2295#if defined CYGWIN || defined DOS_NT
2320 return true; 2296 return true;