]> code.delx.au - gnu-emacs/blobdiff - lib/save-cwd.c
Update copyright year to 2016
[gnu-emacs] / lib / save-cwd.c
index fd746584fa8e9d940424b73b47b8ea7640658d53..1fa5d69e8575232beb87203217a744df90dfbf02 100644 (file)
@@ -1,6 +1,6 @@
 /* save-cwd.c -- Save and restore current working directory.
 
-   Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2014 Free Software
+   Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2016 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    you're still using an obsolete system with these problems, please
    send email to the maintainer of this code.  */
 
+#if !defined HAVE_FCHDIR && !defined fchdir
+# define fchdir(fd) (-1)
+#endif
+
 int
 save_cwd (struct saved_cwd *cwd)
 {
-#ifdef HAVE_FCHDIR
   cwd->desc = open (".", O_SEARCH | O_CLOEXEC);
-#else
-  cwd->desc = -1;
-#endif
   /* The 'name' member is present only to minimize differences from
      gnulib.  Initialize it to zero, if only to simplify debugging.  */
   cwd->name = 0;
@@ -71,16 +71,14 @@ save_cwd (struct saved_cwd *cwd)
 int
 restore_cwd (const struct saved_cwd *cwd)
 {
-#ifdef HAVE_FCHDIR
   /* Restore the previous directory if possible, to avoid tying down
-     the file system of the new directory (Bug#18232).  */
+     the file system of the new directory (Bug#18232).
+     Don't worry if fchdir fails, as Emacs doesn't care what the
+     working directory is.  The fchdir call is inside an 'if' merely to
+     pacify compilers that complain if fchdir's return value is ignored.  */
   if (fchdir (cwd->desc) == 0)
     return 0;
 
-  /* Don't worry if fchdir fails, as Emacs doesn't care what the
-     working directory is.  The fchdir call is inside an 'if' merely to
-     pacify compilers that complain if fchdir's return value is ignored.  */
-#endif
   return 0;
 }