Commit 8b48e937 authored by Ken Brown's avatar Ken Brown
Browse files

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.
parent 9ed25028
......@@ -2415,6 +2415,18 @@ If this does not work, please inform bug-gnu-emacs@gnu.org. Then
please call support for your X-server and see if you can get a fix.
If you do, please send it to bug-gnu-emacs@gnu.org so we can list it here.
* Runtime problems specific to Mac OS X
** On Mac OS X, file-name-case-insensitive-p may be unreliable
The implementation of that function on Mac OS X uses pathconf with the
_PC_CASE_SENSITIVE flag. There have been reports that this use of
pathconf does not work reliably. If you have a problem, please
recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or
-DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying
whether this fixed your problem.
* Build-time problems
** Configuration
......
......@@ -2251,33 +2251,66 @@ internal_delete_file (Lisp_Object filename)
static bool
file_name_case_insensitive_p (const char *filename)
{
#ifdef DOS_NT
return 1;
#elif defined CYGWIN
/* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */
# ifdef _PC_CASE_INSENSITIVE
/* Use pathconf with _PC_CASE_INSENSITIVE or _PC_CASE_SENSITIVE if
those flags are available. As of this writing (2016-11-14),
Cygwin is the only platform known to support the former (starting
with Cygwin-2.6.1), and Mac OS X is the only platform known to
support the latter.
There have been reports that pathconf with _PC_CASE_SENSITIVE
does not work reliably on Mac OS X. If you have a problem,
please recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or
-DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying
whether this fixed your problem. */
#ifdef _PC_CASE_INSENSITIVE
int res = pathconf (filename, _PC_CASE_INSENSITIVE);
if (res < 0)
return 1;
return res > 0;
# else
return 1;
if (res >= 0)
return res > 0;
#elif defined _PC_CASE_SENSITIVE && !defined DARWIN_OS_CASE_SENSITIVE_FIXME
int res = pathconf (filename, _PC_CASE_SENSITIVE);
if (res >= 0)
return res == 0;
#endif
#ifdef DARWIN_OS
# ifndef DARWIN_OS_CASE_SENSITIVE_FIXME
int DARWIN_OS_CASE_SENSITIVE_FIXME = 0;
# endif
#elif defined DARWIN_OS
/* The following is based on
http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */
struct attrlist alist;
unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)];
memset (&alist, 0, sizeof (alist));
alist.volattr = ATTR_VOL_CAPABILITIES;
if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0)
|| !(alist.volattr & ATTR_VOL_CAPABILITIES))
return 0;
vol_capabilities_attr_t *vcaps = buffer;
return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE);
if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1)
{
/* This is based on developer.apple.com's getattrlist man page. */
struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES};
struct vol_capabilities_attr_t vcaps;
if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0)
{
if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE)
return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT]
& VOL_CAP_FMT_CASE_SENSITIVE);
}
}
else if (DARWIN_OS_CASE_SENSITIVE_FIXME == 2)
{
/* The following is based on
http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */
struct attrlist alist;
unsigned char buffer[sizeof (vol_capabilities_attr_t) sizeof (size_t)];
memset (&alist, 0, sizeof (alist));
alist.volattr = ATTR_VOL_CAPABILITIES;
if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0)
|| !(alist.volattr & ATTR_VOL_CAPABILITIES))
return 0;
vol_capabilities_attr_t *vcaps = buffer;
return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE);
}
#endif /* DARWIN_OS */
#if defined CYGWIN || defined DOS_NT
return true;
#else
return 0;
return false;
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment