diff options
| author | Ken Brown | 2016-11-14 17:26:12 -0500 |
|---|---|---|
| committer | Ken Brown | 2016-11-15 17:53:22 -0500 |
| commit | 8b48e937af801e11e2d1844d60b6e585ce09dcea (patch) | |
| tree | d15e90273e2cea2f6a2961cf0e71085adb99d0cb | |
| parent | 9ed2502878d16ed7f20e8b4817e1eed963468de7 (diff) | |
| download | emacs-8b48e937af801e11e2d1844d60b6e585ce09dcea.tar.gz emacs-8b48e937af801e11e2d1844d60b6e585ce09dcea.zip | |
Simplify case-insensitivity checks on Mac OS X
* src/fileio.c (file_name_case_insensitive_p): Try skipping the
Darwin code and instead using pathconf with _PC_CASE_SENSITIVE.
Leave in two alternatives conditionally compiled based on
DARWIN_OS_CASE_SENSITIVE_FIXME in case pathconf doesn't work.
* etc/PROBLEMS: Mention the possible problem with pathconf on
Mac OS X.
| -rw-r--r-- | etc/PROBLEMS | 12 | ||||
| -rw-r--r-- | src/fileio.c | 81 |
2 files changed, 69 insertions, 24 deletions
diff --git a/etc/PROBLEMS b/etc/PROBLEMS index 62d2bd1d26d..bbf865cf3f8 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS | |||
| @@ -2415,6 +2415,18 @@ If this does not work, please inform bug-gnu-emacs@gnu.org. Then | |||
| 2415 | please call support for your X-server and see if you can get a fix. | 2415 | please call support for your X-server and see if you can get a fix. |
| 2416 | If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here. | 2416 | If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here. |
| 2417 | 2417 | ||
| 2418 | |||
| 2419 | * Runtime problems specific to Mac OS X | ||
| 2420 | |||
| 2421 | ** On Mac OS X, file-name-case-insensitive-p may be unreliable | ||
| 2422 | |||
| 2423 | The implementation of that function on Mac OS X uses pathconf with the | ||
| 2424 | _PC_CASE_SENSITIVE flag. There have been reports that this use of | ||
| 2425 | pathconf does not work reliably. If you have a problem, please | ||
| 2426 | recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or | ||
| 2427 | -DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying | ||
| 2428 | whether this fixed your problem. | ||
| 2429 | |||
| 2418 | * Build-time problems | 2430 | * Build-time problems |
| 2419 | 2431 | ||
| 2420 | ** Configuration | 2432 | ** Configuration |
diff --git a/src/fileio.c b/src/fileio.c index f3f8f421618..70799eb2cd1 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2251,33 +2251,66 @@ internal_delete_file (Lisp_Object filename) | |||
| 2251 | static bool | 2251 | static bool |
| 2252 | file_name_case_insensitive_p (const char *filename) | 2252 | file_name_case_insensitive_p (const char *filename) |
| 2253 | { | 2253 | { |
| 2254 | #ifdef DOS_NT | 2254 | /* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if |
| 2255 | return 1; | 2255 | those flags are available. As of this writing (2016-11-14), |
| 2256 | #elif defined CYGWIN | 2256 | Cygwin is the only platform known to support the former (starting |
| 2257 | /* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ | 2257 | with Cygwin-2.6.1), and Mac OS X is the only platform known to |
| 2258 | # ifdef _PC_CASE_INSENSITIVE | 2258 | support the latter. |
| 2259 | |||
| 2260 | There have been reports that pathconf with _PC_CASE_SENSITIVE | ||
| 2261 | does not work reliably on Mac OS X. If you have a problem, | ||
| 2262 | please recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or | ||
| 2263 | -DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying | ||
| 2264 | whether this fixed your problem. */ | ||
| 2265 | |||
| 2266 | #ifdef _PC_CASE_INSENSITIVE | ||
| 2259 | int res = pathconf (filename, _PC_CASE_INSENSITIVE); | 2267 | int res = pathconf (filename, _PC_CASE_INSENSITIVE); |
| 2260 | if (res < 0) | 2268 | if (res >= 0) |
| 2261 | return 1; | 2269 | return res > 0; |
| 2262 | return res > 0; | 2270 | #elif defined _PC_CASE_SENSITIVE && !defined DARWIN_OS_CASE_SENSITIVE_FIXME |
| 2263 | # else | 2271 | int res = pathconf (filename, _PC_CASE_SENSITIVE); |
| 2264 | return 1; | 2272 | if (res >= 0) |
| 2273 | return res == 0; | ||
| 2274 | #endif | ||
| 2275 | |||
| 2276 | #ifdef DARWIN_OS | ||
| 2277 | # ifndef DARWIN_OS_CASE_SENSITIVE_FIXME | ||
| 2278 | int DARWIN_OS_CASE_SENSITIVE_FIXME = 0; | ||
| 2265 | # endif | 2279 | # endif |
| 2266 | #elif defined DARWIN_OS | 2280 | |
| 2267 | /* The following is based on | 2281 | if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1) |
| 2268 | http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ | 2282 | { |
| 2269 | struct attrlist alist; | 2283 | /* This is based on developer.apple.com's getattrlist man page. */ |
| 2270 | unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; | 2284 | struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; |
| 2271 | 2285 | struct vol_capabilities_attr_t vcaps; | |
| 2272 | memset (&alist, 0, sizeof (alist)); | 2286 | if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) |
| 2273 | alist.volattr = ATTR_VOL_CAPABILITIES; | 2287 | { |
| 2274 | if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) | 2288 | if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) |
| 2275 | || !(alist.volattr & ATTR_VOL_CAPABILITIES)) | 2289 | return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT] |
| 2276 | return 0; | 2290 | & VOL_CAP_FMT_CASE_SENSITIVE); |
| 2277 | vol_capabilities_attr_t *vcaps = buffer; | 2291 | } |
| 2278 | return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); | 2292 | } |
| 2293 | else if (DARWIN_OS_CASE_SENSITIVE_FIXME == 2) | ||
| 2294 | { | ||
| 2295 | /* The following is based on | ||
| 2296 | http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ | ||
| 2297 | struct attrlist alist; | ||
| 2298 | unsigned char buffer[sizeof (vol_capabilities_attr_t) sizeof (size_t)]; | ||
| 2299 | |||
| 2300 | memset (&alist, 0, sizeof (alist)); | ||
| 2301 | alist.volattr = ATTR_VOL_CAPABILITIES; | ||
| 2302 | if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) | ||
| 2303 | || !(alist.volattr & ATTR_VOL_CAPABILITIES)) | ||
| 2304 | return 0; | ||
| 2305 | vol_capabilities_attr_t *vcaps = buffer; | ||
| 2306 | return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); | ||
| 2307 | } | ||
| 2308 | #endif /* DARWIN_OS */ | ||
| 2309 | |||
| 2310 | #if defined CYGWIN || defined DOS_NT | ||
| 2311 | return true; | ||
| 2279 | #else | 2312 | #else |
| 2280 | return 0; | 2313 | return false; |
| 2281 | #endif | 2314 | #endif |
| 2282 | } | 2315 | } |
| 2283 | 2316 | ||