diff options
| author | Eli Zaretskii | 2016-11-14 21:25:44 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-11-14 21:25:44 +0200 |
| commit | 4b8703097225c85d90d80f7704371f490a559da1 (patch) | |
| tree | fac11087f19da5d5888856bc0ab1ad7029d0ac04 /src | |
| parent | eda171a924a888db9b705ba7146fcdc13d9a84d3 (diff) | |
| download | emacs-4b8703097225c85d90d80f7704371f490a559da1.tar.gz emacs-4b8703097225c85d90d80f7704371f490a559da1.zip | |
Revert "Improve case-insensitive checks (Bug#24441)"
This reverts commit 2f5e0b1bf7b0ac4f450847db34d599a072020600.
I see no reason for removing code, documentation, and comments
in the original commit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 93 |
1 files changed, 32 insertions, 61 deletions
diff --git a/src/fileio.c b/src/fileio.c index eec3591ff6e..f3f8f421618 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2236,10 +2236,13 @@ internal_delete_file (Lisp_Object filename) | |||
| 2236 | return NILP (tem); | 2236 | return NILP (tem); |
| 2237 | } | 2237 | } |
| 2238 | 2238 | ||
| 2239 | /* Return true if FILENAME is on a case-insensitive file system. | 2239 | /* Filesystems are case-sensitive on all supported systems except |
| 2240 | Use a runtime test if available. Otherwise, assume the file system | 2240 | MS-Windows, MS-DOS, Cygwin, and Mac OS X. They are always |
| 2241 | is case-insensitive on Microsoft-based platforms and case-sensitive | 2241 | case-insensitive on the first two, but they may or may not be |
| 2242 | elsewhere. | 2242 | case-insensitive on Cygwin and OS X. The following function |
| 2243 | attempts to provide a runtime test on those two systems. If the | ||
| 2244 | test is not conclusive, we assume case-insensitivity on Cygwin and | ||
| 2245 | case-sensitivity on Mac OS X. | ||
| 2243 | 2246 | ||
| 2244 | FIXME: Mounted filesystems on Posix hosts, like Samba shares or | 2247 | FIXME: Mounted filesystems on Posix hosts, like Samba shares or |
| 2245 | NFS-mounted Windows volumes, might be case-insensitive. Can we | 2248 | NFS-mounted Windows volumes, might be case-insensitive. Can we |
| @@ -2248,65 +2251,33 @@ internal_delete_file (Lisp_Object filename) | |||
| 2248 | static bool | 2251 | static bool |
| 2249 | file_name_case_insensitive_p (const char *filename) | 2252 | file_name_case_insensitive_p (const char *filename) |
| 2250 | { | 2253 | { |
| 2251 | #ifdef _PC_CASE_INSENSITIVE | 2254 | #ifdef DOS_NT |
| 2255 | return 1; | ||
| 2256 | #elif defined CYGWIN | ||
| 2257 | /* As of Cygwin-2.6.1, pathconf supports _PC_CASE_INSENSITIVE. */ | ||
| 2258 | # ifdef _PC_CASE_INSENSITIVE | ||
| 2252 | int res = pathconf (filename, _PC_CASE_INSENSITIVE); | 2259 | int res = pathconf (filename, _PC_CASE_INSENSITIVE); |
| 2253 | if (0 < res) | 2260 | if (res < 0) |
| 2254 | return true; | 2261 | return 1; |
| 2255 | if (res == 0 || errno != EINVAL) | 2262 | return res > 0; |
| 2256 | return false; | 2263 | # else |
| 2257 | #elif defined _PC_CASE_SENSITIVE | 2264 | return 1; |
| 2258 | int res = pathconf (filename, _PC_CASE_SENSITIVE); | ||
| 2259 | if (res == 0) | ||
| 2260 | return true; | ||
| 2261 | if (0 < res || errno != EINVAL) | ||
| 2262 | return false; | ||
| 2263 | #endif | ||
| 2264 | |||
| 2265 | #ifdef DARWIN_OS | ||
| 2266 | /* It is not clear whether this section is needed. For now, rely on | ||
| 2267 | pathconf and skip this section. If pathconf does not work, | ||
| 2268 | please recompile Emacs with -DDARWIN_OS_CASE_SENSITIVE_FIXME=1 or | ||
| 2269 | -DDARWIN_OS_CASE_SENSITIVE_FIXME=2, and file a bug report saying | ||
| 2270 | whether this fixed your problem. */ | ||
| 2271 | # ifndef DARWIN_OS_CASE_SENSITIVE_FIXME | ||
| 2272 | int DARWIN_OS_CASE_SENSITIVE_FIXME = 0; | ||
| 2273 | # endif | 2265 | # endif |
| 2274 | 2266 | #elif defined DARWIN_OS | |
| 2275 | if (DARWIN_OS_CASE_SENSITIVE_FIXME == 1) | 2267 | /* The following is based on |
| 2276 | { | 2268 | http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ |
| 2277 | /* This is based on developer.apple.com's getattrlist man page. */ | 2269 | struct attrlist alist; |
| 2278 | struct attrlist alist = {.volattr = ATTR_VOL_CAPABILITIES}; | 2270 | unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; |
| 2279 | struct vol_capabilities_attr_t vcaps; | 2271 | |
| 2280 | if (getattrlist (filename, &alist, &vcaps, sizeof vcaps, 0) == 0) | 2272 | memset (&alist, 0, sizeof (alist)); |
| 2281 | { | 2273 | alist.volattr = ATTR_VOL_CAPABILITIES; |
| 2282 | if (vcaps.valid[VOL_CAPABILITIES_FORMAT] & VOL_CAP_FMT_CASE_SENSITIVE) | 2274 | if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) |
| 2283 | return ! (vcaps.capabilities[VOL_CAPABILITIES_FORMAT] | 2275 | || !(alist.volattr & ATTR_VOL_CAPABILITIES)) |
| 2284 | & VOL_CAP_FMT_CASE_SENSITIVE); | 2276 | return 0; |
| 2285 | } | 2277 | vol_capabilities_attr_t *vcaps = buffer; |
| 2286 | else if (errno != EINVAL) | 2278 | return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); |
| 2287 | return false; | ||
| 2288 | } | ||
| 2289 | else if (DARWIN_OS_CASE_SENSITIVE_FIXME == 2) | ||
| 2290 | { | ||
| 2291 | /* The following is based on | ||
| 2292 | http://lists.apple.com/archives/darwin-dev/2007/Apr/msg00010.html. */ | ||
| 2293 | struct attrlist alist; | ||
| 2294 | unsigned char buffer[sizeof (vol_capabilities_attr_t) + sizeof (size_t)]; | ||
| 2295 | |||
| 2296 | memset (&alist, 0, sizeof (alist)); | ||
| 2297 | alist.volattr = ATTR_VOL_CAPABILITIES; | ||
| 2298 | if (getattrlist (filename, &alist, buffer, sizeof (buffer), 0) | ||
| 2299 | || !(alist.volattr & ATTR_VOL_CAPABILITIES)) | ||
| 2300 | return 0; | ||
| 2301 | vol_capabilities_attr_t *vcaps = buffer; | ||
| 2302 | return !(vcaps->capabilities[0] & VOL_CAP_FMT_CASE_SENSITIVE); | ||
| 2303 | } | ||
| 2304 | #endif | ||
| 2305 | |||
| 2306 | #if defined CYGWIN || defined DOS_NT | ||
| 2307 | return true; | ||
| 2308 | #else | 2279 | #else |
| 2309 | return false; | 2280 | return 0; |
| 2310 | #endif | 2281 | #endif |
| 2311 | } | 2282 | } |
| 2312 | 2283 | ||
| @@ -2378,7 +2349,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2378 | /* If the filesystem is case-insensitive and the file names are | 2349 | /* If the filesystem is case-insensitive and the file names are |
| 2379 | identical but for the case, don't ask for confirmation: they | 2350 | identical but for the case, don't ask for confirmation: they |
| 2380 | simply want to change the letter-case of the file name. */ | 2351 | simply want to change the letter-case of the file name. */ |
| 2381 | if ((! file_name_case_insensitive_p (SSDATA (encoded_file)) | 2352 | if ((!(file_name_case_insensitive_p (SSDATA (encoded_file))) |
| 2382 | || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) | 2353 | || NILP (Fstring_equal (Fdowncase (file), Fdowncase (newname)))) |
| 2383 | && ((NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists)))) | 2354 | && ((NILP (ok_if_already_exists) || INTEGERP (ok_if_already_exists)))) |
| 2384 | barf_or_query_if_file_exists (newname, false, "rename to it", | 2355 | barf_or_query_if_file_exists (newname, false, "rename to it", |