emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: windows build failure


From: Paul Eggert
Subject: Re: windows build failure
Date: Tue, 22 Feb 2011 13:44:48 -0800
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7

On 02/22/2011 02:49 AM, Eli Zaretskii wrote:
From: Paul Eggert<address@hidden>
No, the idea is that normal code should not use #ifdef S_IFLNK.

Well, "normal code" in Emacs does.  We have 5 such places at this
time, if I didn't miss any.

These #ifdef uses are problematic, and should be removed.  For example,
on a GNU system (make-symbolic-link A B) signals a file-already-exists
error if B already exists, but if I'm reading the code correctly this
does not happen on a system lacking symlinks.  It's better to remove
unnecessary discrepancies like this.

How can we use this idea, when the code in question calls functions
like `symlink' or `readlink", which don't exist on hosts that don't
support symlinks?

Use substitutes for symlink and readlink that always fail.
That's easy and works well in practice.

Once compilation and link work, we will also need to carefully review
the affected code,

The affected code is fairly small.  A complete patch for your review
is below; it removes the problematic #ifdefs and thereby
shrinks the main Emacs source code by about 25 lines.
(As usual, I'm attaching the full patch, which includes files
autogenerated from gnulib.)

The new symbols in config.in that you may have to look at for Windows
include FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX,
FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR,
FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE, HAVE_READLINK, HAVE_SYMLINK,
REPLACE_FUNC_STAT_DIR, and REPLACE_FUNC_STAT_FILE.

This patch also works around some other portability issues with
symlinks, with respect to file names that end with "/".  This
doesn't affect Windows, but we might as well fix those too,
since we get them for essentially zero programming cost here.

[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  <address@hidden>
[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.
=== modified file 'Makefile.in'
--- Makefile.in 2011-02-22 01:55:20 +0000
+++ Makefile.in 2011-02-22 18:48:53 +0000
@@ -332,7 +332,7 @@
 # as per $(gnulib_srcdir)/DEPENDENCIES.
 GNULIB_MODULES = \
   crypto/md5 dtoastr filemode getloadavg getopt-gnu \
-  ignore-value mktime strftime sys_stat
+  ignore-value lstat mktime readlink strftime symlink sys_stat
 GNULIB_TOOL_FLAGS = \
  --import --no-changelog --no-vc-files --makefile-name=gnulib.mk
 sync-from-gnulib: $(gnulib_srcdir)

=== modified file 'configure.in'
--- configure.in        2011-02-22 01:55:20 +0000
+++ configure.in        2011-02-22 18:48:14 +0000
@@ -2661,15 +2661,6 @@
 gl_ASSERT_NO_GNULIB_TESTS
 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.
 AC_CHECK_FUNCS(grantpt)


=== modified file 'src/fileio.c'
--- src/fileio.c        2011-02-22 01:55:20 +0000
+++ src/fileio.c        2011-02-22 18:39:29 +0000
@@ -2178,14 +2178,11 @@
       if (errno == EXDEV)
        {
           int count;
-#ifdef S_IFLNK
           symlink_target = Ffile_symlink_p (file);
           if (! NILP (symlink_target))
             Fmake_symbolic_link (symlink_target, newname,
                                  NILP (ok_if_already_exists) ? Qnil : Qt);
-          else
-#endif
-         if (!NILP (Ffile_directory_p (file)))
+         else if (!NILP (Ffile_directory_p (file)))
            call4 (Qcopy_directory, file, newname, Qt, Qnil);
          else
            /* We have already prompted if it was an integer, so don't
@@ -2197,11 +2194,7 @@
          count = SPECPDL_INDEX ();
          specbind (Qdelete_by_moving_to_trash, Qnil);

-         if (!NILP (Ffile_directory_p (file))
-#ifdef S_IFLNK
-             && NILP (symlink_target)
-#endif
-             )
+         if (!NILP (Ffile_directory_p (file)) && NILP (symlink_target))
            call2 (Qdelete_directory, file, Qt);
          else
            Fdelete_file (file, Qnil);
@@ -2311,7 +2304,6 @@
     RETURN_UNGCPRO (call4 (handler, Qmake_symbolic_link, filename,
                           linkname, ok_if_already_exists));

-#ifdef S_IFLNK
   encoded_filename = ENCODE_FILE (filename);
   encoded_linkname = ENCODE_FILE (linkname);

@@ -2338,12 +2330,6 @@
     }
   UNGCPRO;
   return Qnil;
-
-#else
-  UNGCPRO;
-  xsignal1 (Qfile_error, build_string ("Symbolic links are not supported"));
-
-#endif /* S_IFLNK */
 }

 
@@ -2482,7 +2468,7 @@
   return Qnil;
 #else /* not DOS_NT and not macintosh */
   flags = O_RDONLY;
-#if defined (S_IFIFO) && defined (O_NONBLOCK)
+#ifdef O_NONBLOCK
   /* Opening a fifo without O_NONBLOCK can wait.
      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.  */
@@ -2584,6 +2570,10 @@
   (Lisp_Object filename)
 {
   Lisp_Object handler;
+  char *buf;
+  int bufsize;
+  int valsize;
+  Lisp_Object val;

   CHECK_STRING (filename);
   filename = Fexpand_file_name (filename, Qnil);
@@ -2594,13 +2584,6 @@
   if (!NILP (handler))
     return call2 (handler, Qfile_symlink_p, filename);

-#ifdef S_IFLNK
-  {
-  char *buf;
-  int bufsize;
-  int valsize;
-  Lisp_Object val;
-
   filename = ENCODE_FILE (filename);

   bufsize = 50;
@@ -2635,10 +2618,6 @@
   xfree (buf);
   val = DECODE_FILE (val);
   return val;
-  }
-#else /* not S_IFLNK */
-  return Qnil;
-#endif /* not S_IFLNK */
 }

 DEFUN ("file-directory-p", Ffile_directory_p, Sfile_directory_p, 1, 1, 0,



Attachment: emacs-symlink-diff.txt.gz
Description: GNU Zip compressed data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]