[ChangeLog]

Assume S_ISLNK etc. work, since gnulib supports this.
* Makefile.in (GNULIB_MODULES): Add sys_stat.
* configure.in: Check for lstat and set HAVE_LSTAT=0 if not.
Pretend to be using the gnulib lstat module for benefit of sys/stat.h.
* configure, lib/Makefile.in, lib/gnulib.mk: Regenerate.
[lib-src/ChangeLog]
Assume S_ISLNK etc. work, since gnulib supports this.
* etags.c (S_ISREG): Remove.
[src/ChangeLog]
Assume S_ISLNK etc. work, since gnulib supports this.
* config.in: Regenerate.
* dired.c (lstat): Remove.
(file_name_completion): Assume S_ISDIR works.
(file_name_completion_stat): Assume S_ISLNK works.
Do not bother calling stat unless lstat says it's a symlink.
* fileio.c (S_ISLNK, S_ISFIFO, S_ISREG, lstat): Remove.
(Fcopy_file): Assume S_ISREG and S_ISLNK work.
(check_writable, Ffile_writable_p, Fset_file_times):
Assume S_ISDIR works.
(Ffile_readable_p): Use S_IFIFO, not S_ISFIFO, to guess whether
fifos exist.
(Ffile_regular_p, Finsert_file_contents): Assumes S_ISREG works.
* filelock.c (S_ISLNK): Remove.
* lread.c (openp): Assume S_ISDIR works.
* xrdb.c (S_ISDIR): Remove.
This commit is contained in:
Paul Eggert 2011-02-21 17:55:20 -08:00
parent 5ecec6a7f4
commit f68c809d7e
15 changed files with 79 additions and 63 deletions

View file

@ -1,3 +1,11 @@
2011-02-22 Paul Eggert <eggert@cs.ucla.edu>
Assume S_ISLNK etc. work, since gnulib supports this.
* Makefile.in (GNULIB_MODULES): Add sys_stat.
* configure.in: Check for lstat and set HAVE_LSTAT=0 if not.
Pretend to be using the gnulib lstat module for benefit of sys/stat.h.
* configure, lib/Makefile.in, lib/gnulib.mk: Regenerate.
2011-02-21 Paul Eggert <eggert@cs.ucla.edu> 2011-02-21 Paul Eggert <eggert@cs.ucla.edu>
* lib/min-max.h: New file, for "min" and "max". * lib/min-max.h: New file, for "min" and "max".

View file

@ -332,7 +332,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4
# as per $(gnulib_srcdir)/DEPENDENCIES. # as per $(gnulib_srcdir)/DEPENDENCIES.
GNULIB_MODULES = \ GNULIB_MODULES = \
crypto/md5 dtoastr filemode getloadavg getopt-gnu \ crypto/md5 dtoastr filemode getloadavg getopt-gnu \
ignore-value mktime strftime ignore-value mktime strftime sys_stat
GNULIB_TOOL_FLAGS = \ GNULIB_TOOL_FLAGS = \
--import --no-changelog --no-vc-files --makefile-name=gnulib.mk --import --no-changelog --no-vc-files --makefile-name=gnulib.mk
sync-from-gnulib: $(gnulib_srcdir) sync-from-gnulib: $(gnulib_srcdir)

18
configure vendored
View file

@ -2963,6 +2963,7 @@ as_fn_append ac_func_list " tzset"
as_fn_append ac_header_list " sys/stat.h" as_fn_append ac_header_list " sys/stat.h"
as_fn_append ac_header_list " sys/time.h" as_fn_append ac_header_list " sys/time.h"
as_fn_append ac_func_list " localtime_r" as_fn_append ac_func_list " localtime_r"
as_fn_append ac_func_list " lstat"
# Check that the precious variables saved in the cache have kept the same # Check that the precious variables saved in the cache have kept the same
# value. # value.
ac_cache_corrupted=false ac_cache_corrupted=false
@ -17211,6 +17212,23 @@ $as_echo "$gl_cv_next_unistd_h" >&6; }
# Emacs does not care about lstat's behavior on files whose names end in
# trailing slashes, so it does not use the gnulib lstat module.
# However, Emacs does want the "#define lstat stat" in sys/stat.h
# when lstat does not exist, so it pretends to use the lstat module
# even though it implements only the lstat-checking part of that module.
test $ac_cv_func_lstat = yes || HAVE_LSTAT=0
GNULIB_LSTAT=1
# UNIX98 PTYs. # UNIX98 PTYs.
for ac_func in grantpt for ac_func in grantpt
do : do :

View file

@ -2661,6 +2661,15 @@ gl_ASSERT_NO_GNULIB_POSIXCHECK
gl_ASSERT_NO_GNULIB_TESTS gl_ASSERT_NO_GNULIB_TESTS
gl_INIT gl_INIT
# Emacs does not care about lstat's behavior on files whose names end in
# trailing slashes, so it does not use the gnulib lstat module.
# However, Emacs does want the "#define lstat stat" in sys/stat.h
# when lstat does not exist, so it pretends to use the lstat module
# even though it implements only the lstat-checking part of that module.
AC_CHECK_FUNCS_ONCE([lstat])
test $ac_cv_func_lstat = yes || HAVE_LSTAT=0
gl_SYS_STAT_MODULE_INDICATOR([lstat])
# UNIX98 PTYs. # UNIX98 PTYs.
AC_CHECK_FUNCS(grantpt) AC_CHECK_FUNCS(grantpt)

View file

@ -1,3 +1,8 @@
2011-02-22 Paul Eggert <eggert@cs.ucla.edu>
Assume S_ISLNK etc. work, since gnulib supports this.
* etags.c (S_ISREG): Remove.
2011-02-21 Paul Eggert <eggert@cs.ucla.edu> 2011-02-21 Paul Eggert <eggert@cs.ucla.edu>
New file "lib/min-max.h". New file "lib/min-max.h".

View file

@ -190,10 +190,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
# define assert(x) ((void) 0) # define assert(x) ((void) 0)
#endif #endif
#if !defined (S_ISREG) && defined (S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ #ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */
# define NO_LONG_OPTIONS TRUE # define NO_LONG_OPTIONS TRUE
# define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
@ -5327,7 +5323,7 @@ prolog_skip_comment (linebuffer *plb, FILE *inf)
*/ */
static int static int
prolog_pr (char *s, char *last) prolog_pr (char *s, char *last)
/* Name of last clause. */ /* Name of last clause. */
{ {
int pos; int pos;
@ -5484,7 +5480,7 @@ Erlang_functions (FILE *inf)
*/ */
static int static int
erlang_func (char *s, char *last) erlang_func (char *s, char *last)
/* Name of last clause. */ /* Name of last clause. */
{ {
int pos; int pos;

View file

@ -24,7 +24,7 @@
# the same distribution terms as the rest of that program. # the same distribution terms as the rest of that program.
# #
# Generated by gnulib-tool. # Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value mktime strftime # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value mktime strftime sys_stat
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@

View file

@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program. # the same distribution terms as the rest of that program.
# #
# Generated by gnulib-tool. # Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value mktime strftime # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value mktime strftime sys_stat
MOSTLYCLEANFILES += core *.stackdump MOSTLYCLEANFILES += core *.stackdump

View file

@ -1,3 +1,22 @@
2011-02-22 Paul Eggert <eggert@cs.ucla.edu>
Assume S_ISLNK etc. work, since gnulib supports this.
* config.in: Regenerate.
* dired.c (lstat): Remove.
(file_name_completion): Assume S_ISDIR works.
(file_name_completion_stat): Assume S_ISLNK works.
Do not bother calling stat unless lstat says it's a symlink.
* fileio.c (S_ISLNK, S_ISFIFO, S_ISREG, lstat): Remove.
(Fcopy_file): Assume S_ISREG and S_ISLNK work.
(check_writable, Ffile_writable_p, Fset_file_times):
Assume S_ISDIR works.
(Ffile_readable_p): Use S_IFIFO, not S_ISFIFO, to guess whether
fifos exist.
(Ffile_regular_p, Finsert_file_contents): Assumes S_ISREG works.
* filelock.c (S_ISLNK): Remove.
* lread.c (openp): Assume S_ISDIR works.
* xrdb.c (S_ISDIR): Remove.
2011-02-21 Eli Zaretskii <eliz@gnu.org> 2011-02-21 Eli Zaretskii <eliz@gnu.org>
* makefile.w32-in ($(BLD)/filemode.$(O)): Move recipe to * makefile.w32-in ($(BLD)/filemode.$(O)): Move recipe to

View file

@ -465,6 +465,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
/* Define to 1 if you have the `lrand48' function. */ /* Define to 1 if you have the `lrand48' function. */
#undef HAVE_LRAND48 #undef HAVE_LRAND48
/* Define to 1 if you have the `lstat' function. */
#undef HAVE_LSTAT
/* Define to 1 if using libm17n-flt. */ /* Define to 1 if using libm17n-flt. */
#undef HAVE_M17N_FLT #undef HAVE_M17N_FLT

View file

@ -84,13 +84,6 @@ extern struct re_pattern_buffer *compile_pattern (Lisp_Object,
struct re_registers *, struct re_registers *,
Lisp_Object, int, int); Lisp_Object, int, int);
/* if system does not have symbolic links, it does not have lstat.
In that case, use ordinary stat instead. */
#ifndef S_IFLNK
#define lstat stat
#endif
Lisp_Object Qdirectory_files; Lisp_Object Qdirectory_files;
Lisp_Object Qdirectory_files_and_attributes; Lisp_Object Qdirectory_files_and_attributes;
Lisp_Object Qfile_name_completion; Lisp_Object Qfile_name_completion;
@ -539,7 +532,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, int all_flag, int v
if (file_name_completion_stat (encoded_dir, dp, &st) < 0) if (file_name_completion_stat (encoded_dir, dp, &st) < 0)
continue; continue;
directoryp = ((st.st_mode & S_IFMT) == S_IFDIR); directoryp = S_ISDIR (st.st_mode);
tem = Qnil; tem = Qnil;
/* If all_flag is set, always include all. /* If all_flag is set, always include all.
It would not actually be helpful to the user to ignore any possible It would not actually be helpful to the user to ignore any possible
@ -843,20 +836,16 @@ file_name_completion_stat (Lisp_Object dirname, DIRENTRY *dp, struct stat *st_ad
memcpy (fullname + pos, dp->d_name, len); memcpy (fullname + pos, dp->d_name, len);
fullname[pos + len] = 0; fullname[pos + len] = 0;
#ifdef S_IFLNK
/* We want to return success if a link points to a nonexistent file, /* We want to return success if a link points to a nonexistent file,
but we want to return the status for what the link points to, but we want to return the status for what the link points to,
in case it is a directory. */ in case it is a directory. */
value = lstat (fullname, st_addr); value = lstat (fullname, st_addr);
stat (fullname, st_addr); if (value == 0 && S_ISLNK (st_addr->st_mode))
return value; stat (fullname, st_addr);
#else
value = stat (fullname, st_addr);
#ifdef MSDOS #ifdef MSDOS
_djstat_flags = save_djstat_flags; _djstat_flags = save_djstat_flags;
#endif /* MSDOS */ #endif /* MSDOS */
return value; return value;
#endif /* S_IFLNK */
} }
Lisp_Object Lisp_Object

View file

@ -26,18 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <setjmp.h> #include <setjmp.h>
#include <unistd.h> #include <unistd.h>
#if !defined (S_ISLNK) && defined (S_IFLNK)
# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif
#if !defined (S_ISFIFO) && defined (S_IFIFO)
# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
#endif
#if !defined (S_ISREG) && defined (S_IFREG)
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#ifdef HAVE_PWD_H #ifdef HAVE_PWD_H
#include <pwd.h> #include <pwd.h>
#endif #endif
@ -95,10 +83,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "commands.h" #include "commands.h"
#ifndef S_ISLNK
# define lstat stat
#endif
#ifndef FILE_SYSTEM_CASE #ifndef FILE_SYSTEM_CASE
#define FILE_SYSTEM_CASE(filename) (filename) #define FILE_SYSTEM_CASE(filename) (filename)
#endif #endif
@ -1922,7 +1906,6 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
Fcons (file, Fcons (newname, Qnil))); Fcons (file, Fcons (newname, Qnil)));
} }
#if defined (S_ISREG) && defined (S_ISLNK)
if (input_file_statable_p) if (input_file_statable_p)
{ {
if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode))) if (!(S_ISREG (st.st_mode)) && !(S_ISLNK (st.st_mode)))
@ -1934,7 +1917,6 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
report_file_error ("Non-regular file", Fcons (file, Qnil)); report_file_error ("Non-regular file", Fcons (file, Qnil));
} }
} }
#endif /* S_ISREG && S_ISLNK */
#ifdef MSDOS #ifdef MSDOS
/* System's default file type was set to binary by _fmode in emacs.c. */ /* System's default file type was set to binary by _fmode in emacs.c. */
@ -2408,7 +2390,7 @@ check_writable (const char *filename)
struct stat st; struct stat st;
if (stat (filename, &st) < 0) if (stat (filename, &st) < 0)
return 0; return 0;
return (st.st_mode & S_IWRITE || (st.st_mode & S_IFMT) == S_IFDIR); return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
#else /* not MSDOS */ #else /* not MSDOS */
#ifdef HAVE_EUIDACCESS #ifdef HAVE_EUIDACCESS
return (euidaccess (filename, 2) >= 0); return (euidaccess (filename, 2) >= 0);
@ -2500,7 +2482,7 @@ See also `file-exists-p' and `file-attributes'. */)
return Qnil; return Qnil;
#else /* not DOS_NT and not macintosh */ #else /* not DOS_NT and not macintosh */
flags = O_RDONLY; flags = O_RDONLY;
#if defined (S_ISFIFO) && defined (O_NONBLOCK) #if defined (S_IFIFO) && defined (O_NONBLOCK)
/* Opening a fifo without O_NONBLOCK can wait. /* Opening a fifo without O_NONBLOCK can wait.
We don't want to wait. But we don't want to mess wth O_NONBLOCK We don't want to wait. But we don't want to mess wth O_NONBLOCK
except in the case of a fifo, on a system which handles it. */ except in the case of a fifo, on a system which handles it. */
@ -2555,7 +2537,7 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0,
should check ACLs though, which do affect this. */ should check ACLs though, which do affect this. */
if (stat (SDATA (dir), &statbuf) < 0) if (stat (SDATA (dir), &statbuf) < 0)
return Qnil; return Qnil;
return (statbuf.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil; return S_ISDIR (statbuf.st_mode) ? Qt : Qnil;
#else #else
return (check_writable (!NILP (dir) ? SSDATA (dir) : "") return (check_writable (!NILP (dir) ? SSDATA (dir) : "")
? Qt : Qnil); ? Qt : Qnil);
@ -2681,7 +2663,7 @@ See `file-symlink-p' to distinguish symlinks. */)
if (stat (SSDATA (absname), &st) < 0) if (stat (SSDATA (absname), &st) < 0)
return Qnil; return Qnil;
return (st.st_mode & S_IFMT) == S_IFDIR ? Qt : Qnil; return S_ISDIR (st.st_mode) ? Qt : Qnil;
} }
DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, Sfile_accessible_directory_p, 1, 1, 0, DEFUN ("file-accessible-directory-p", Ffile_accessible_directory_p, Sfile_accessible_directory_p, 1, 1, 0,
@ -2744,12 +2726,12 @@ See `file-symlink-p' to distinguish symlinks. */)
if (result < 0) if (result < 0)
return Qnil; return Qnil;
return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; return S_ISREG (st.st_mode) ? Qt : Qnil;
} }
#else #else
if (stat (SSDATA (absname), &st) < 0) if (stat (SSDATA (absname), &st) < 0)
return Qnil; return Qnil;
return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; return S_ISREG (st.st_mode) ? Qt : Qnil;
#endif #endif
} }
@ -3007,8 +2989,7 @@ Use the current time if TIME is nil. TIME is in the format of
struct stat st; struct stat st;
/* Setting times on a directory always fails. */ /* Setting times on a directory always fails. */
if (stat (SDATA (encoded_absname), &st) == 0 if (stat (SSDATA (encoded_absname), &st) == 0 && S_ISDIR (st.st_mode))
&& (st.st_mode & S_IFMT) == S_IFDIR)
return Qnil; return Qnil;
#endif #endif
report_file_error ("Setting file times", Fcons (absname, Qnil)); report_file_error ("Setting file times", Fcons (absname, Qnil));
@ -3267,7 +3248,6 @@ variable `last-coding-system-used' to the coding system actually used. */)
goto notfound; goto notfound;
} }
#ifdef S_IFREG
/* This code will need to be changed in order to work on named /* This code will need to be changed in order to work on named
pipes, and it's probably just not worth it. So we should at pipes, and it's probably just not worth it. So we should at
least signal an error. */ least signal an error. */
@ -3282,7 +3262,6 @@ variable `last-coding-system-used' to the coding system actually used. */)
xsignal2 (Qfile_error, xsignal2 (Qfile_error,
build_string ("not a regular file"), orig_filename); build_string ("not a regular file"), orig_filename);
} }
#endif
if (fd < 0) if (fd < 0)
if ((fd = emacs_open (SSDATA (filename), O_RDONLY, 0)) < 0) if ((fd = emacs_open (SSDATA (filename), O_RDONLY, 0)) < 0)

View file

@ -51,10 +51,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <utmp.h> #include <utmp.h>
#endif #endif
#if !defined (S_ISLNK) && defined (S_IFLNK)
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
#endif
/* A file whose last-modified time is just after the most recent boot. /* A file whose last-modified time is just after the most recent boot.
Define this to be NULL to disable checking for this file. */ Define this to be NULL to disable checking for this file. */
#ifndef BOOT_TIME_FILE #ifndef BOOT_TIME_FILE

View file

@ -1402,8 +1402,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto
encoded_fn = ENCODE_FILE (string); encoded_fn = ENCODE_FILE (string);
pfn = SSDATA (encoded_fn); pfn = SSDATA (encoded_fn);
exists = (stat (pfn, &st) >= 0 exists = (stat (pfn, &st) == 0 && ! S_ISDIR (st.st_mode));
&& (st.st_mode & S_IFMT) != S_IFDIR);
if (exists) if (exists)
{ {
/* Check that we can access or open it. */ /* Check that we can access or open it. */
@ -4385,7 +4384,7 @@ to load. See also `load-dangerous-libraries'. */);
Qdir_ok = intern_c_string ("dir-ok"); Qdir_ok = intern_c_string ("dir-ok");
staticpro (&Qdir_ok); staticpro (&Qdir_ok);
Qdo_after_load_evaluation = intern_c_string ("do-after-load-evaluation"); Qdo_after_load_evaluation = intern_c_string ("do-after-load-evaluation");
staticpro (&Qdo_after_load_evaluation) ; staticpro (&Qdo_after_load_evaluation) ;

View file

@ -38,10 +38,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
#if !defined(S_ISDIR) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#include "lisp.h" #include "lisp.h"
#ifdef USE_MOTIF #ifdef USE_MOTIF
@ -764,4 +760,3 @@ main (argc, argv)
XCloseDisplay (display); XCloseDisplay (display);
} }
#endif /* TESTRM */ #endif /* TESTRM */