unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: windows build failure
Date: Tue, 22 Feb 2011 13:44:48 -0800	[thread overview]
Message-ID: <4D642E50.7080006@cs.ucla.edu> (raw)
In-Reply-To: <E1PrpoL-0003V4-Gv@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 6337 bytes --]

On 02/22/2011 02:49 AM, Eli Zaretskii wrote:
>> From: Paul Eggert<eggert@cs.ucla.edu>
>> 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  <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.
=== 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 */
  }

  \f
@@ -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 #2: emacs-symlink-diff.txt.gz --]
[-- Type: application/x-gzip, Size: 15638 bytes --]

  reply	other threads:[~2011-02-22 21:44 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-21 19:37 windows build failure Sean Sieger
2011-02-21 19:40 ` Sean Sieger
2011-02-21 19:46 ` Christoph
2011-02-21 19:48 ` Paul Eggert
2011-02-21 20:21   ` Eli Zaretskii
2011-02-21 20:29     ` Lennart Borgman
2011-02-21 22:50     ` Sean Sieger
2011-02-21 20:37   ` Eli Zaretskii
2011-02-22  2:09     ` Paul Eggert
2011-02-22  8:57       ` Eli Zaretskii
2011-02-22  9:40         ` Paul Eggert
2011-02-22 10:49           ` Eli Zaretskii
2011-02-22 21:44             ` Paul Eggert [this message]
2011-02-23  9:47               ` Eli Zaretskii
2011-02-23 10:32                 ` Eli Zaretskii
2011-02-25 21:28                 ` Paul Eggert
2011-02-26 18:01                   ` Remove S_IFLNK (was: windows build failure) Eli Zaretskii
2011-02-26 20:01                     ` Remove S_IFLNK Stefan Monnier
2011-02-26 22:36                     ` Paul Eggert
2011-02-27 19:54                       ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2013-09-17 21:45 windows build failure Sean Sieger
2013-09-18  6:42 ` Eli Zaretskii
2013-09-18  6:56   ` Dani Moncayo
2013-09-18  7:23     ` Eli Zaretskii
2013-09-18 12:37       ` Sean Sieger
2013-09-18 12:44         ` Eli Zaretskii
     [not found]   ` <CADWZ7fL5iWhAWqrc8RqipO3Zgaz=AygHPUhhTNG97zTVaxpE3g@mail.gmail.com>
2013-09-18 12:46     ` Eli Zaretskii
2013-09-18 13:08       ` Sean Sieger
2013-09-18 13:18         ` Eli Zaretskii
2013-09-18 13:25           ` Sean Sieger
2013-09-18 14:48             ` Eli Zaretskii
2013-09-18 15:15               ` Sean Sieger
2013-09-18 15:28                 ` Eli Zaretskii
2013-09-18 15:38                   ` Sean Sieger
2013-09-19 14:14               ` Sean Sieger
2013-09-19 14:24                 ` Eli Zaretskii
2013-09-19 17:33                   ` Sean Sieger
2013-09-19 18:46                     ` Eli Zaretskii
2013-09-19 20:25                       ` Sean Sieger
2013-09-20  7:28                         ` Eli Zaretskii
2013-09-20 14:24                           ` Sean Sieger
2013-09-20 15:16                             ` Eli Zaretskii
2013-09-20 16:23                               ` Sean Sieger
2013-09-20 16:34                               ` Sean Sieger
2013-09-20 17:40                                 ` Eli Zaretskii
2013-10-12 13:31                                   ` Eli Zaretskii
2013-10-12 15:55                                     ` Paul Eggert
2013-10-12 16:49                                       ` Eli Zaretskii
2013-10-12 19:13                                         ` Paul Eggert
2013-10-12 20:03                                           ` Eli Zaretskii
2013-10-12 21:45                                             ` Paul Eggert
2013-10-12 19:31                                     ` Sean Sieger
2013-10-14 12:41                                     ` Sean Sieger
2013-10-14 16:25                                       ` Eli Zaretskii
2013-10-14 17:31                                         ` Sean Sieger
2013-10-14 18:02                                     ` Sean Sieger
2013-10-14 18:10                                       ` Eli Zaretskii
2013-10-14 19:06                                         ` Sean Sieger
2013-10-14 19:13                                           ` Eli Zaretskii
2013-10-14 19:24                                             ` Sean Sieger
2013-05-26 20:29 Sean Sieger
2013-05-27 16:36 ` Eli Zaretskii
2013-05-27 18:07   ` Óscar Fuentes
2013-05-27 19:10     ` Eli Zaretskii
2013-05-27 19:56       ` Óscar Fuentes
2013-05-28 18:19   ` Sean Sieger
2013-05-28 19:07     ` Eli Zaretskii
2013-05-29 13:15       ` rzl24ozi
2013-05-29 15:21         ` Eli Zaretskii
2013-05-29 15:50           ` Óscar Fuentes
2013-05-29 17:17             ` Eli Zaretskii
2013-05-29 17:02           ` Paul Eggert
2013-05-29 17:20             ` Eli Zaretskii
2013-05-29 18:55               ` Paul Eggert
2013-05-29 20:28                 ` Eli Zaretskii
2013-05-29 21:27                   ` Paul Eggert
2013-05-30  2:46                     ` Eli Zaretskii
2013-05-29 23:35           ` rzl24ozi
2013-05-30 18:03             ` Eli Zaretskii
2013-05-30 19:38               ` rzl24ozi
2013-05-31  8:50                 ` Eli Zaretskii
2013-05-29 16:06   ` cg
2013-05-29 17:21     ` Eli Zaretskii
2012-07-29 16:40 Windows " Dani Moncayo
2012-07-29 16:49 ` Dani Moncayo
2011-02-14 16:47 windows " Sean Sieger
2011-02-14 16:54 ` Tom Tromey
2011-02-14 17:17   ` Eli Zaretskii
2011-02-14 17:20     ` Sean Sieger
2011-02-14 17:49     ` Eli Zaretskii
2011-02-14 18:02       ` Tom Tromey
2011-02-14 20:43       ` Sean Sieger
2011-01-03 17:57 Sean Sieger
2011-01-03 19:37 ` Eli Zaretskii
2010-08-02 15:01 Sean Sieger
2010-08-02 15:05 ` Juanma Barranquero
2010-08-02 15:16   ` Sean Sieger
2010-07-19 14:42 Sean Sieger
2010-07-19 15:03 ` Óscar Fuentes
2010-07-19 15:30   ` Juanma Barranquero
2010-07-19 17:45     ` Eli Zaretskii
2010-07-20 18:33       ` Juanma Barranquero
2010-07-19 18:35   ` Sean Sieger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D642E50.7080006@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).