diff options
| author | Paul Eggert | 2011-02-22 11:30:07 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-02-22 11:30:07 -0800 |
| commit | ae0d725005539d9259efac6a81ff8fdd45eb69a6 (patch) | |
| tree | c721b530409b355281537abc7b058bdb2697ee01 /src | |
| parent | 8d40723d1e9661840a67ca7be9c5b073526ab421 (diff) | |
| download | emacs-ae0d725005539d9259efac6a81ff8fdd45eb69a6.tar.gz emacs-ae0d725005539d9259efac6a81ff8fdd45eb69a6.zip | |
[ChangeLog]
Work around some portability problems with symlinks.
* Makefile.in (GNULIB_MODULES): Add lstat, readlink, symlink.
* configure.in (lstat, HAVE_LSTAT): Remove special hack.
* lib/lstat.c, lib/readlink.c, lib/stat.c, lib/symlink.c:
* m4/dos.m4, m4/lstat.m4, m4/readlink.m4, m4/stat.m4, m4/symlink.m4:
New files, automatically generated from gnulib.
* aclocal.m4, configure, lib/Makefile.in, lib/gnulib.mk:
* lib/stdlib.in.h, m4/gl-comp.m4, m4/stdlib_h.m4: Regenerate.
2011-02-22 Paul Eggert <eggert@cs.ucla.edu>
[src/ChangeLog]
Work around some portability problems with symlinks.
* fileio.c (Frename_file, Fmake_symbolic_link, Ffile_symlink_p):
Simplify the code by assuming that the readlink and symlink calls
exist, even if they always fail on this host.
(Ffile_readable_p): Likewise, for fifos.
* config.in: Regenerate.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/config.in | 40 | ||||
| -rw-r--r-- | src/fileio.c | 35 |
3 files changed, 54 insertions, 28 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 8befb78f91f..6673a25f74f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | 2011-02-22 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-02-22 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Work around some portability problems with symlinks. | ||
| 4 | * fileio.c (Frename_file, Fmake_symbolic_link, Ffile_symlink_p): | ||
| 5 | Simplify the code by assuming that the readlink and symlink calls | ||
| 6 | exist, even if they always fail on this host. | ||
| 7 | (Ffile_readable_p): Likewise, for fifos. | ||
| 8 | * config.in: Regenerate. | ||
| 9 | |||
| 3 | * dired.c (Ffile_attributes): Simplify and avoid #ifdef. | 10 | * dired.c (Ffile_attributes): Simplify and avoid #ifdef. |
| 4 | 11 | ||
| 5 | 2011-02-22 Wolfgang Jenkner <wjenkner@inode.at> (tiny change) | 12 | 2011-02-22 Wolfgang Jenkner <wjenkner@inode.at> (tiny change) |
diff --git a/src/config.in b/src/config.in index ded8c6b292a..2a2a71659f5 100644 --- a/src/config.in +++ b/src/config.in | |||
| @@ -72,6 +72,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 72 | /* Enable expensive run-time checking of data types? */ | 72 | /* Enable expensive run-time checking of data types? */ |
| 73 | #undef ENABLE_CHECKING | 73 | #undef ENABLE_CHECKING |
| 74 | 74 | ||
| 75 | /* Define on systems for which file names may have a so-called `drive letter' | ||
| 76 | prefix, define this to compute the length of that prefix, including the | ||
| 77 | colon. */ | ||
| 78 | #undef FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX | ||
| 79 | |||
| 80 | /* Define if the backslash character may also serve as a file name component | ||
| 81 | separator. */ | ||
| 82 | #undef FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR | ||
| 83 | |||
| 84 | /* Define if a drive letter prefix denotes a relative path if it is not | ||
| 85 | followed by a file name component separator. */ | ||
| 86 | #undef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE | ||
| 87 | |||
| 75 | /* Define this to check for errors in cons list. */ | 88 | /* Define this to check for errors in cons list. */ |
| 76 | #undef GC_CHECK_CONS_LIST | 89 | #undef GC_CHECK_CONS_LIST |
| 77 | 90 | ||
| @@ -576,6 +589,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 576 | /* Define to 1 if you have the `random' function. */ | 589 | /* Define to 1 if you have the `random' function. */ |
| 577 | #undef HAVE_RANDOM | 590 | #undef HAVE_RANDOM |
| 578 | 591 | ||
| 592 | /* Define to 1 if you have the `readlink' function. */ | ||
| 593 | #undef HAVE_READLINK | ||
| 594 | |||
| 579 | /* Define to 1 if you have the `recvfrom' function. */ | 595 | /* Define to 1 if you have the `recvfrom' function. */ |
| 580 | #undef HAVE_RECVFROM | 596 | #undef HAVE_RECVFROM |
| 581 | 597 | ||
| @@ -696,6 +712,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 696 | /* Define if struct stat has an st_dm_mode member. */ | 712 | /* Define if struct stat has an st_dm_mode member. */ |
| 697 | #undef HAVE_ST_DM_MODE | 713 | #undef HAVE_ST_DM_MODE |
| 698 | 714 | ||
| 715 | /* Define to 1 if you have the `symlink' function. */ | ||
| 716 | #undef HAVE_SYMLINK | ||
| 717 | |||
| 699 | /* Define to 1 if you have the `sync' function. */ | 718 | /* Define to 1 if you have the `sync' function. */ |
| 700 | #undef HAVE_SYNC | 719 | #undef HAVE_SYNC |
| 701 | 720 | ||
| @@ -888,6 +907,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 888 | /* Define to support using a Hesiod database to find the POP server. */ | 907 | /* Define to support using a Hesiod database to find the POP server. */ |
| 889 | #undef HESIOD | 908 | #undef HESIOD |
| 890 | 909 | ||
| 910 | #if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR | ||
| 911 | # define ISSLASH(C) ((C) == '/' || (C) == '\\') | ||
| 912 | #else | ||
| 913 | # define ISSLASH(C) ((C) == '/') | ||
| 914 | #endif | ||
| 915 | |||
| 891 | /* Define to support Kerberos-authenticated POP mail retrieval. */ | 916 | /* Define to support Kerberos-authenticated POP mail retrieval. */ |
| 892 | #undef KERBEROS | 917 | #undef KERBEROS |
| 893 | 918 | ||
| @@ -897,6 +922,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 897 | /* Define to 1 if localtime caches TZ. */ | 922 | /* Define to 1 if localtime caches TZ. */ |
| 898 | #undef LOCALTIME_CACHE | 923 | #undef LOCALTIME_CACHE |
| 899 | 924 | ||
| 925 | /* Define to 1 if `lstat' dereferences a symlink specified with a trailing | ||
| 926 | slash. */ | ||
| 927 | #undef LSTAT_FOLLOWS_SLASHED_SYMLINK | ||
| 928 | |||
| 900 | /* String giving fallback POP mail host. */ | 929 | /* String giving fallback POP mail host. */ |
| 901 | #undef MAILHOST | 930 | #undef MAILHOST |
| 902 | 931 | ||
| @@ -968,10 +997,21 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 968 | 'ptrdiff_t'. */ | 997 | 'ptrdiff_t'. */ |
| 969 | #undef PTRDIFF_T_SUFFIX | 998 | #undef PTRDIFF_T_SUFFIX |
| 970 | 999 | ||
| 1000 | /* Define to 1 if readlink fails to recognize a trailing slash. */ | ||
| 1001 | #undef READLINK_TRAILING_SLASH_BUG | ||
| 1002 | |||
| 971 | /* Define REL_ALLOC if you want to use the relocating allocator for buffer | 1003 | /* Define REL_ALLOC if you want to use the relocating allocator for buffer |
| 972 | space. */ | 1004 | space. */ |
| 973 | #undef REL_ALLOC | 1005 | #undef REL_ALLOC |
| 974 | 1006 | ||
| 1007 | /* Define to 1 if stat needs help when passed a directory name with a trailing | ||
| 1008 | slash */ | ||
| 1009 | #undef REPLACE_FUNC_STAT_DIR | ||
| 1010 | |||
| 1011 | /* Define to 1 if stat needs help when passed a file name with a trailing | ||
| 1012 | slash */ | ||
| 1013 | #undef REPLACE_FUNC_STAT_FILE | ||
| 1014 | |||
| 975 | /* Define as the return type of signal handlers (`int' or `void'). */ | 1015 | /* Define as the return type of signal handlers (`int' or `void'). */ |
| 976 | #undef RETSIGTYPE | 1016 | #undef RETSIGTYPE |
| 977 | 1017 | ||
diff --git a/src/fileio.c b/src/fileio.c index 0225e0bf3a9..26006d63052 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 | ||
| @@ -2338,12 +2330,6 @@ This happens for interactive use with M-x. */) | |||
| 2338 | } | 2330 | } |
| 2339 | UNGCPRO; | 2331 | UNGCPRO; |
| 2340 | return Qnil; | 2332 | return Qnil; |
| 2341 | |||
| 2342 | #else | ||
| 2343 | UNGCPRO; | ||
| 2344 | xsignal1 (Qfile_error, build_string ("Symbolic links are not supported")); | ||
| 2345 | |||
| 2346 | #endif /* S_IFLNK */ | ||
| 2347 | } | 2333 | } |
| 2348 | 2334 | ||
| 2349 | 2335 | ||
| @@ -2482,7 +2468,7 @@ See also `file-exists-p' and `file-attributes'. */) | |||
| 2482 | return Qnil; | 2468 | return Qnil; |
| 2483 | #else /* not DOS_NT and not macintosh */ | 2469 | #else /* not DOS_NT and not macintosh */ |
| 2484 | flags = O_RDONLY; | 2470 | flags = O_RDONLY; |
| 2485 | #if defined (S_IFIFO) && defined (O_NONBLOCK) | 2471 | #ifdef O_NONBLOCK |
| 2486 | /* Opening a fifo without O_NONBLOCK can wait. | 2472 | /* 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 | 2473 | 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. */ | 2474 | except in the case of a fifo, on a system which handles it. */ |
| @@ -2584,6 +2570,10 @@ points to a nonexistent file. */) | |||
| 2584 | (Lisp_Object filename) | 2570 | (Lisp_Object filename) |
| 2585 | { | 2571 | { |
| 2586 | Lisp_Object handler; | 2572 | Lisp_Object handler; |
| 2573 | char *buf; | ||
| 2574 | int bufsize; | ||
| 2575 | int valsize; | ||
| 2576 | Lisp_Object val; | ||
| 2587 | 2577 | ||
| 2588 | CHECK_STRING (filename); | 2578 | CHECK_STRING (filename); |
| 2589 | filename = Fexpand_file_name (filename, Qnil); | 2579 | filename = Fexpand_file_name (filename, Qnil); |
| @@ -2594,13 +2584,6 @@ points to a nonexistent file. */) | |||
| 2594 | if (!NILP (handler)) | 2584 | if (!NILP (handler)) |
| 2595 | return call2 (handler, Qfile_symlink_p, filename); | 2585 | return call2 (handler, Qfile_symlink_p, filename); |
| 2596 | 2586 | ||
| 2597 | #ifdef S_IFLNK | ||
| 2598 | { | ||
| 2599 | char *buf; | ||
| 2600 | int bufsize; | ||
| 2601 | int valsize; | ||
| 2602 | Lisp_Object val; | ||
| 2603 | |||
| 2604 | filename = ENCODE_FILE (filename); | 2587 | filename = ENCODE_FILE (filename); |
| 2605 | 2588 | ||
| 2606 | bufsize = 50; | 2589 | bufsize = 50; |
| @@ -2635,10 +2618,6 @@ points to a nonexistent file. */) | |||
| 2635 | xfree (buf); | 2618 | xfree (buf); |
| 2636 | val = DECODE_FILE (val); | 2619 | val = DECODE_FILE (val); |
| 2637 | return val; | 2620 | return val; |
| 2638 | } | ||
| 2639 | #else /* not S_IFLNK */ | ||
| 2640 | return Qnil; | ||
| 2641 | #endif /* not S_IFLNK */ | ||
| 2642 | } | 2621 | } |
| 2643 | 2622 | ||
| 2644 | DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, | 2623 | DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0, |