diff options
| author | Paul Eggert | 2011-03-01 21:25:09 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-03-01 21:25:09 -0800 |
| commit | 6c0dea8a89bdfbdad454a9609f0bed8db4c9fccf (patch) | |
| tree | fbde0220480ce4d37903e98c74c5103a0f320f16 /src | |
| parent | 8889f4e2c332b0ecedc9e6088252f4cbae301236 (diff) | |
| parent | 4a8b879b87962d5f37c05d3650f43cc571b22bc7 (diff) | |
| download | emacs-6c0dea8a89bdfbdad454a9609f0bed8db4c9fccf.tar.gz emacs-6c0dea8a89bdfbdad454a9609f0bed8db4c9fccf.zip | |
Merge: Work around some portability problems with symlinks.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/config.in | 21 | ||||
| -rw-r--r-- | src/fileio.c | 41 |
3 files changed, 47 insertions, 28 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0e5e295a622..34e28866144 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2011-03-02 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Work around some portability problems with symlinks. | ||
| 4 | |||
| 5 | * fileio.c (Fmake_symbolic_link): Treat ENOSYS specially, and | ||
| 6 | generate a special message for it. Suggested by Eli Zaretskii in | ||
| 7 | <http://lists.gnu.org/archive/html/emacs-devel/2011-02/msg00995.html>. | ||
| 8 | (Frename_file, Fmake_symbolic_link, Ffile_symlink_p): | ||
| 9 | Simplify the code by assuming that the readlink and symlink calls | ||
| 10 | exist, even if they always fail on this host. | ||
| 11 | (Ffile_readable_p): Likewise, for fifos. | ||
| 12 | * config.in: Regenerate. | ||
| 13 | |||
| 1 | 2011-02-27 Chong Yidong <cyd@stupidchicken.com> | 14 | 2011-02-27 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 15 | ||
| 3 | * frame.c (store_frame_param): Don't store value directly in | 16 | * frame.c (store_frame_param): Don't store value directly in |
diff --git a/src/config.in b/src/config.in index ded8c6b292a..4e49b4df170 100644 --- a/src/config.in +++ b/src/config.in | |||
| @@ -576,6 +576,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 576 | /* Define to 1 if you have the `random' function. */ | 576 | /* Define to 1 if you have the `random' function. */ |
| 577 | #undef HAVE_RANDOM | 577 | #undef HAVE_RANDOM |
| 578 | 578 | ||
| 579 | /* Define to 1 if you have the `readlink' function. */ | ||
| 580 | #undef HAVE_READLINK | ||
| 581 | |||
| 579 | /* Define to 1 if you have the `recvfrom' function. */ | 582 | /* Define to 1 if you have the `recvfrom' function. */ |
| 580 | #undef HAVE_RECVFROM | 583 | #undef HAVE_RECVFROM |
| 581 | 584 | ||
| @@ -696,6 +699,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 696 | /* Define if struct stat has an st_dm_mode member. */ | 699 | /* Define if struct stat has an st_dm_mode member. */ |
| 697 | #undef HAVE_ST_DM_MODE | 700 | #undef HAVE_ST_DM_MODE |
| 698 | 701 | ||
| 702 | /* Define to 1 if you have the `symlink' function. */ | ||
| 703 | #undef HAVE_SYMLINK | ||
| 704 | |||
| 699 | /* Define to 1 if you have the `sync' function. */ | 705 | /* Define to 1 if you have the `sync' function. */ |
| 700 | #undef HAVE_SYNC | 706 | #undef HAVE_SYNC |
| 701 | 707 | ||
| @@ -897,6 +903,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 897 | /* Define to 1 if localtime caches TZ. */ | 903 | /* Define to 1 if localtime caches TZ. */ |
| 898 | #undef LOCALTIME_CACHE | 904 | #undef LOCALTIME_CACHE |
| 899 | 905 | ||
| 906 | /* Define to 1 if `lstat' dereferences a symlink specified with a trailing | ||
| 907 | slash. */ | ||
| 908 | #undef LSTAT_FOLLOWS_SLASHED_SYMLINK | ||
| 909 | |||
| 900 | /* String giving fallback POP mail host. */ | 910 | /* String giving fallback POP mail host. */ |
| 901 | #undef MAILHOST | 911 | #undef MAILHOST |
| 902 | 912 | ||
| @@ -968,10 +978,21 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 968 | 'ptrdiff_t'. */ | 978 | 'ptrdiff_t'. */ |
| 969 | #undef PTRDIFF_T_SUFFIX | 979 | #undef PTRDIFF_T_SUFFIX |
| 970 | 980 | ||
| 981 | /* Define to 1 if readlink fails to recognize a trailing slash. */ | ||
| 982 | #undef READLINK_TRAILING_SLASH_BUG | ||
| 983 | |||
| 971 | /* Define REL_ALLOC if you want to use the relocating allocator for buffer | 984 | /* Define REL_ALLOC if you want to use the relocating allocator for buffer |
| 972 | space. */ | 985 | space. */ |
| 973 | #undef REL_ALLOC | 986 | #undef REL_ALLOC |
| 974 | 987 | ||
| 988 | /* Define to 1 if stat needs help when passed a directory name with a trailing | ||
| 989 | slash */ | ||
| 990 | #undef REPLACE_FUNC_STAT_DIR | ||
| 991 | |||
| 992 | /* Define to 1 if stat needs help when passed a file name with a trailing | ||
| 993 | slash */ | ||
| 994 | #undef REPLACE_FUNC_STAT_FILE | ||
| 995 | |||
| 975 | /* Define as the return type of signal handlers (`int' or `void'). */ | 996 | /* Define as the return type of signal handlers (`int' or `void'). */ |
| 976 | #undef RETSIGTYPE | 997 | #undef RETSIGTYPE |
| 977 | 998 | ||
diff --git a/src/fileio.c b/src/fileio.c index 0225e0bf3a9..18e9dbe9680 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2178,14 +2178,11 @@ This is what happens in interactive use with M-x. */) | |||
| 2178 | if (errno == EXDEV) | 2178 | if (errno == EXDEV) |
| 2179 | { | 2179 | { |
| 2180 | int count; | 2180 | int count; |
| 2181 | #ifdef S_IFLNK | ||
| 2182 | symlink_target = Ffile_symlink_p (file); | 2181 | symlink_target = Ffile_symlink_p (file); |
| 2183 | if (! NILP (symlink_target)) | 2182 | if (! NILP (symlink_target)) |
| 2184 | Fmake_symbolic_link (symlink_target, newname, | 2183 | Fmake_symbolic_link (symlink_target, newname, |
| 2185 | NILP (ok_if_already_exists) ? Qnil : Qt); | 2184 | NILP (ok_if_already_exists) ? Qnil : Qt); |
| 2186 | else | 2185 | else if (!NILP (Ffile_directory_p (file))) |
| 2187 | #endif | ||
| 2188 | if (!NILP (Ffile_directory_p (file))) | ||
| 2189 | call4 (Qcopy_directory, file, newname, Qt, Qnil); | 2186 | call4 (Qcopy_directory, file, newname, Qt, Qnil); |
| 2190 | else | 2187 | else |
| 2191 | /* We have already prompted if it was an integer, so don't | 2188 | /* We have already prompted if it was an integer, so don't |
| @@ -2197,11 +2194,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2197 | count = SPECPDL_INDEX (); | 2194 | count = SPECPDL_INDEX (); |
| 2198 | specbind (Qdelete_by_moving_to_trash, Qnil); | 2195 | specbind (Qdelete_by_moving_to_trash, Qnil); |
| 2199 | 2196 | ||
| 2200 | if (!NILP (Ffile_directory_p (file)) | 2197 | if (!NILP (Ffile_directory_p (file)) && NILP (symlink_target)) |
| 2201 | #ifdef S_IFLNK | ||
| 2202 | && NILP (symlink_target) | ||
| 2203 | #endif | ||
| 2204 | ) | ||
| 2205 | call2 (Qdelete_directory, file, Qt); | 2198 | call2 (Qdelete_directory, file, Qt); |
| 2206 | else | 2199 | else |
| 2207 | Fdelete_file (file, Qnil); | 2200 | Fdelete_file (file, Qnil); |
| @@ -2311,7 +2304,6 @@ This happens for interactive use with M-x. */) | |||
| 2311 | RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename, | 2304 | RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename, |
| 2312 | linkname, ok_if_already_exists)); | 2305 | linkname, ok_if_already_exists)); |
| 2313 | 2306 | ||
| 2314 | #ifdef S_IFLNK | ||
| 2315 | encoded_filename = ENCODE_FILE (filename); | 2307 | encoded_filename = ENCODE_FILE (filename); |
| 2316 | encoded_linkname = ENCODE_FILE (linkname); | 2308 | encoded_linkname = ENCODE_FILE (linkname); |
| 2317 | 2309 | ||
| @@ -2333,17 +2325,17 @@ This happens for interactive use with M-x. */) | |||
| 2333 | return Qnil; | 2325 | return Qnil; |
| 2334 | } | 2326 | } |
| 2335 | } | 2327 | } |
| 2328 | if (errno == ENOSYS) | ||
| 2329 | { | ||
| 2330 | UNGCPRO; | ||
| 2331 | xsignal1 (Qfile_error, | ||
| 2332 | build_string ("Symbolic links are not supported")); | ||
| 2333 | } | ||
| 2336 | 2334 | ||
| 2337 | report_file_error ("Making symbolic link", list2 (filename, linkname)); | 2335 | report_file_error ("Making symbolic link", list2 (filename, linkname)); |
| 2338 | } | 2336 | } |
| 2339 | UNGCPRO; | 2337 | UNGCPRO; |
| 2340 | return Qnil; | 2338 | return Qnil; |
| 2341 | |||
| 2342 | #else | ||
| 2343 | UNGCPRO; | ||
| 2344 | xsignal1 (Qfile_error, build_string ("Symbolic links are not supported")); | ||
| 2345 | |||
| 2346 | #endif /* S_IFLNK */ | ||
| 2347 | } | 2339 | } |
| 2348 | 2340 | ||
| 2349 | 2341 | ||
| @@ -2482,7 +2474,7 @@ See also `file-exists-p' and `file-attributes'. */) | |||
| 2482 | return Qnil; | 2474 | return Qnil; |
| 2483 | #else /* not DOS_NT and not macintosh */ | 2475 | #else /* not DOS_NT and not macintosh */ |
| 2484 | flags = O_RDONLY; | 2476 | flags = O_RDONLY; |
| 2485 | #if defined (S_IFIFO) && defined (O_NONBLOCK) | 2477 | #ifdef O_NONBLOCK |
| 2486 | /* Opening a fifo without O_NONBLOCK can wait. | 2478 | /* Opening a fifo without O_NONBLOCK can wait. |
| 2487 | We don't want to wait. But we don't want to mess wth O_NONBLOCK | 2479 | We don't want to wait. But we don't want to mess wth O_NONBLOCK |
| 2488 | except in the case of a fifo, on a system which handles it. */ | 2480 | except in the case of a fifo, on a system which handles it. */ |
| @@ -2584,6 +2576,10 @@ points to a nonexistent file. */) | |||
| 2584 | (Lisp_Object filename) | 2576 | (Lisp_Object filename) |
| 2585 | { | 2577 | { |
| 2586 | Lisp_Object handler; | 2578 | Lisp_Object handler; |
| 2579 | char *buf; | ||
| 2580 | int bufsize; | ||
| 2581 | int valsize; | ||
| 2582 | Lisp_Object val; | ||
| 2587 | 2583 | ||
| 2588 | CHECK_STRING (filename); | 2584 | CHECK_STRING (filename); |
| 2589 | filename = Fexpand_file_name (filename, Qnil); | 2585 | filename = Fexpand_file_name (filename, Qnil); |
| @@ -2594,13 +2590,6 @@ points to a nonexistent file. */) | |||
| 2594 | if (!NILP (handler)) | 2590 | if (!NILP (handler)) |
| 2595 | return call2 (handler, Qfile_symlink_p, filename); | 2591 | return call2 (handler, Qfile_symlink_p, filename); |
| 2596 | 2592 | ||
| 2597 | #ifdef S_IFLNK | ||
| 2598 | { | ||
| 2599 | char *buf; | ||
| 2600 | int bufsize; | ||
| 2601 | int valsize; | ||
| 2602 | Lisp_Object val; | ||
| 2603 | |||
| 2604 | filename = ENCODE_FILE (filename); | 2593 | filename = ENCODE_FILE (filename); |
| 2605 | 2594 | ||
| 2606 | bufsize = 50; | 2595 | bufsize = 50; |
| @@ -2635,10 +2624,6 @@ points to a nonexistent file. */) | |||
| 2635 | xfree (buf); | 2624 | xfree (buf); |
| 2636 | val = DECODE_FILE (val); | 2625 | val = DECODE_FILE (val); |
| 2637 | return val; | 2626 | return val; |
| 2638 | } | ||
| 2639 | #else /* not S_IFLNK */ | ||
| 2640 | return Qnil; | ||
| 2641 | #endif /* not S_IFLNK */ | ||
| 2642 | } | 2627 | } |
| 2643 | 2628 | ||
| 2644 | DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, | 2629 | DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, |