unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Paul Eggert <eggert@cs.ucla.edu>, Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 2f5e0b1: Improve case-insensitive checks (Bug#24441)
Date: Mon, 14 Nov 2016 17:33:18 -0500	[thread overview]
Message-ID: <c1f258ea-7da6-e20a-3f8d-dea8cb2ed404@cornell.edu> (raw)
In-Reply-To: <f302b594-7b1c-f989-045b-fa56f0be6fc4@cornell.edu>

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

On 11/14/2016 4:07 PM, Ken Brown wrote:
> On 11/14/2016 3:54 PM, Paul Eggert wrote:
>> On 11/14/2016 12:43 PM, Eli Zaretskii wrote:
>>> I'd be glad to see the solution improved, of course.
>>
>> I thought those changes were relatively minor technical improvements.
>> Evidently they were taken as intrusive and stepping on other peoples'
>> toes. Sorry about that; that was certainly not the intent. Please feel
>> free to ignore the changes.
>
> I don't want to ignore the changes.  I'll send a new patch that
> incorporates some of your changes.

Here it is.

Ken


[-- Attachment #2: 0001-Simplify-case-insensitivity-checks-on-Mac-OS-X.patch --]
[-- Type: text/plain, Size: 3932 bytes --]

From 93cd4ee1fc261bca5d9d54f6e1366e74668ccc29 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Mon, 14 Nov 2016 17:26:12 -0500
Subject: [PATCH] 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.
---
 src/fileio.c | 81 ++++++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 57 insertions(+), 24 deletions(-)

diff --git a/src/fileio.c b/src/fileio.c
index f3f8f42..70799eb 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -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
 }
 
-- 
2.8.3


  reply	other threads:[~2016-11-14 22:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 19:30 [Emacs-diffs] master 2f5e0b1: Improve case-insensitive checks (Bug#24441) Eli Zaretskii
2016-11-14 20:22 ` Ken Brown
2016-11-14 20:43   ` Eli Zaretskii
2016-11-14 20:54     ` Paul Eggert
2016-11-14 21:07       ` Ken Brown
2016-11-14 22:33         ` Ken Brown [this message]
2016-11-15 16:07           ` Eli Zaretskii
2016-11-15 19:15             ` Ken Brown
2016-11-15 20:26               ` Eli Zaretskii
2016-11-19 19:29                 ` Philipp Stephani
     [not found] <20161114170952.20595.32286@vcs.savannah.gnu.org>
     [not found] ` <20161114170952.6729A220179@vcs.savannah.gnu.org>
2016-11-14 21:03   ` Ken Brown
2016-11-14 21:53     ` John Wiegley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1f258ea-7da6-e20a-3f8d-dea8cb2ed404@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).