aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2015-03-19 12:32:42 -0700
committerPaul Eggert2015-03-19 12:33:44 -0700
commitccf00107f7aa8897cde017bec3717ecc350515f7 (patch)
treef92f5f4c4a8f61f8f1f73a3ebb61304b409471ec
parent8aa13d07fe72b8a00ded10602f5c5ce773181b40 (diff)
downloademacs-ccf00107f7aa8897cde017bec3717ecc350515f7.tar.gz
emacs-ccf00107f7aa8897cde017bec3717ecc350515f7.zip
Merge from gnulib
This incorporates: 2015-03-19 fdopendir: port better to MinGW 2015-03-18 fdopendir: fix typo in comment 2015-02-24 glob, etc.: port to MSVC v18 on MS-Windows 8.1 * lib/dirent.in.h, lib/fdopendir.c: Update from gnulib. * lib/dirfd.c, m4/dirfd.m4: New files from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
-rw-r--r--ChangeLog11
-rw-r--r--lib/dirent.in.h2
-rw-r--r--lib/dirfd.c32
-rw-r--r--lib/fdopendir.c13
-rw-r--r--lib/gnulib.mk11
-rw-r--r--m4/dirfd.m483
-rw-r--r--m4/gnulib-comp.m420
7 files changed, 170 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f6523ea812..9d7ba9309ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
12015-03-19 Paul Eggert <eggert@cs.ucla.edu>
2
3 Merge from gnulib
4 This incorporates:
5 2015-03-19 fdopendir: port better to MinGW
6 2015-03-18 fdopendir: fix typo in comment
7 2015-02-24 glob, etc.: port to MSVC v18 on MS-Windows 8.1
8 * lib/dirent.in.h, lib/fdopendir.c: Update from gnulib.
9 * lib/dirfd.c, m4/dirfd.m4: New files from gnulib.
10 * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
11
12015-03-02 Robert Pluim <rpluim@gmail.com> (tiny change) 122015-03-02 Robert Pluim <rpluim@gmail.com> (tiny change)
2 13
3 * configure.ac: Error out if with-file-notification=w32 is 14 * configure.ac: Error out if with-file-notification=w32 is
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index ddd3b84fbb2..154d2689e3d 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -77,6 +77,7 @@ typedef struct gl_directory DIR;
77# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 77# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
78# undef opendir 78# undef opendir
79# define opendir rpl_opendir 79# define opendir rpl_opendir
80# define GNULIB_defined_opendir 1
80# endif 81# endif
81_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1))); 82_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
82_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name)); 83_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
@@ -128,6 +129,7 @@ _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
128# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 129# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
129# undef closedir 130# undef closedir
130# define closedir rpl_closedir 131# define closedir rpl_closedir
132# define GNULIB_defined_closedir 1
131# endif 133# endif
132_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1))); 134_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
133_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp)); 135_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
diff --git a/lib/dirfd.c b/lib/dirfd.c
new file mode 100644
index 00000000000..c91f8e55872
--- /dev/null
+++ b/lib/dirfd.c
@@ -0,0 +1,32 @@
1/* dirfd.c -- return the file descriptor associated with an open DIR*
2
3 Copyright (C) 2001, 2006, 2008-2015 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Jim Meyering. */
19
20#include <config.h>
21
22#include <dirent.h>
23#include <errno.h>
24
25int
26dirfd (DIR *dir_p)
27{
28 int fd = DIR_TO_FD (dir_p);
29 if (fd == -1)
30 errno = ENOTSUP;
31 return fd;
32}
diff --git a/lib/fdopendir.c b/lib/fdopendir.c
index 9dc1e7b26dc..837a8219b33 100644
--- a/lib/fdopendir.c
+++ b/lib/fdopendir.c
@@ -93,7 +93,7 @@ fdopendir (int fd)
93 That way, barring race conditions, fd_clone_opendir returns a 93 That way, barring race conditions, fd_clone_opendir returns a
94 stream whose file descriptor is FD. 94 stream whose file descriptor is FD.
95 95
96 If REPLACE_CHDIR or CWD is null, use opendir ("/proc/self/fd/...", 96 If REPLACE_FCHDIR or CWD is null, use opendir ("/proc/self/fd/...",
97 falling back on fchdir metadata. Otherwise, CWD is a saved version 97 falling back on fchdir metadata. Otherwise, CWD is a saved version
98 of the working directory; use fchdir/opendir(".")/restore_cwd(CWD). */ 98 of the working directory; use fchdir/opendir(".")/restore_cwd(CWD). */
99static DIR * 99static DIR *
@@ -156,7 +156,16 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd)
156 if (! dir && EXPECTED_ERRNO (saved_errno)) 156 if (! dir && EXPECTED_ERRNO (saved_errno))
157 { 157 {
158 char const *name = _gl_directory_name (fd); 158 char const *name = _gl_directory_name (fd);
159 return (name ? opendir (name) : NULL); 159 DIR *dp = name ? opendir (name) : NULL;
160
161 /* The caller has done an elaborate dance to arrange for opendir to
162 consume just the right file descriptor. If dirfd returns -1,
163 though, we're on a system like mingw where opendir does not
164 consume a file descriptor. Consume it via 'dup' instead. */
165 if (dp && dirfd (dp) < 0)
166 dup (fd);
167
168 return dp;
160 } 169 }
161# endif 170# endif
162 errno = saved_errno; 171 errno = saved_errno;
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 1b671e7f6de..7703cbfe283 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -237,6 +237,17 @@ EXTRA_DIST += dirent.in.h
237 237
238## end gnulib module dirent 238## end gnulib module dirent
239 239
240## begin gnulib module dirfd
241
242if gl_GNULIB_ENABLED_dirfd
243
244endif
245EXTRA_DIST += dirfd.c
246
247EXTRA_libgnu_a_SOURCES += dirfd.c
248
249## end gnulib module dirfd
250
240## begin gnulib module dosname 251## begin gnulib module dosname
241 252
242if gl_GNULIB_ENABLED_dosname 253if gl_GNULIB_ENABLED_dosname
diff --git a/m4/dirfd.m4 b/m4/dirfd.m4
new file mode 100644
index 00000000000..ce56cff6912
--- /dev/null
+++ b/m4/dirfd.m4
@@ -0,0 +1,83 @@
1# serial 22 -*- Autoconf -*-
2
3dnl Find out how to get the file descriptor associated with an open DIR*.
4
5# Copyright (C) 2001-2006, 2008-2015 Free Software Foundation, Inc.
6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it,
8# with or without modifications, as long as this notice is preserved.
9
10dnl From Jim Meyering
11
12AC_DEFUN([gl_FUNC_DIRFD],
13[
14 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
15
16 dnl Persuade glibc <dirent.h> to declare dirfd().
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
18
19 AC_CHECK_FUNCS([dirfd])
20 AC_CHECK_DECLS([dirfd], , ,
21 [[#include <sys/types.h>
22 #include <dirent.h>]])
23 if test $ac_cv_have_decl_dirfd = no; then
24 HAVE_DECL_DIRFD=0
25 fi
26
27 AC_CACHE_CHECK([whether dirfd is a macro],
28 gl_cv_func_dirfd_macro,
29 [AC_EGREP_CPP([dirent_header_defines_dirfd], [
30#include <sys/types.h>
31#include <dirent.h>
32#ifdef dirfd
33 dirent_header_defines_dirfd
34#endif],
35 gl_cv_func_dirfd_macro=yes,
36 gl_cv_func_dirfd_macro=no)])
37
38 # Use the replacement only if we have no function or macro with that name.
39 if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then
40 if test $ac_cv_have_decl_dirfd = yes; then
41 # If the system declares dirfd already, let's declare rpl_dirfd instead.
42 REPLACE_DIRFD=1
43 fi
44 fi
45])
46
47dnl Prerequisites of lib/dirfd.c.
48AC_DEFUN([gl_PREREQ_DIRFD],
49[
50 AC_CACHE_CHECK([how to get the file descriptor associated with an open DIR*],
51 [gl_cv_sys_dir_fd_member_name],
52 [
53 dirfd_save_CFLAGS=$CFLAGS
54 for ac_expr in d_fd dd_fd; do
55
56 CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
58 #include <sys/types.h>
59 #include <dirent.h>]],
60 [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
61 [dir_fd_found=yes]
62 )
63 CFLAGS=$dirfd_save_CFLAGS
64 test "$dir_fd_found" = yes && break
65 done
66 test "$dir_fd_found" = yes || ac_expr=no_such_member
67
68 gl_cv_sys_dir_fd_member_name=$ac_expr
69 ]
70 )
71 if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
72 AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME],
73 [$gl_cv_sys_dir_fd_member_name],
74 [the name of the file descriptor member of DIR])
75 fi
76 AH_VERBATIM([DIR_TO_FD],
77 [#ifdef DIR_FD_MEMBER_NAME
78# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
79#else
80# define DIR_TO_FD(Dir_p) -1
81#endif
82])
83])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index 5763fae12f3..949dd0e12f1 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -56,6 +56,7 @@ AC_DEFUN([gl_EARLY],
56 # Code from module crypto/sha256: 56 # Code from module crypto/sha256:
57 # Code from module crypto/sha512: 57 # Code from module crypto/sha512:
58 # Code from module dirent: 58 # Code from module dirent:
59 # Code from module dirfd:
59 # Code from module dosname: 60 # Code from module dosname:
60 # Code from module dtoastr: 61 # Code from module dtoastr:
61 # Code from module dtotimespec: 62 # Code from module dtotimespec:
@@ -394,6 +395,7 @@ AC_DEFUN([gl_INIT],
394 gl_UTIMENS 395 gl_UTIMENS
395 AC_C_VARARRAYS 396 AC_C_VARARRAYS
396 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false 397 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
398 gl_gnulib_enabled_dirfd=false
397 gl_gnulib_enabled_dosname=false 399 gl_gnulib_enabled_dosname=false
398 gl_gnulib_enabled_euidaccess=false 400 gl_gnulib_enabled_euidaccess=false
399 gl_gnulib_enabled_getdtablesize=false 401 gl_gnulib_enabled_getdtablesize=false
@@ -416,6 +418,18 @@ AC_DEFUN([gl_INIT],
416 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=true 418 gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=true
417 fi 419 fi
418 } 420 }
421 func_gl_gnulib_m4code_dirfd ()
422 {
423 if ! $gl_gnulib_enabled_dirfd; then
424 gl_FUNC_DIRFD
425 if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then
426 AC_LIBOBJ([dirfd])
427 gl_PREREQ_DIRFD
428 fi
429 gl_DIRENT_MODULE_INDICATOR([dirfd])
430 gl_gnulib_enabled_dirfd=true
431 fi
432 }
419 func_gl_gnulib_m4code_dosname () 433 func_gl_gnulib_m4code_dosname ()
420 { 434 {
421 if ! $gl_gnulib_enabled_dosname; then 435 if ! $gl_gnulib_enabled_dosname; then
@@ -595,6 +609,9 @@ AC_DEFUN([gl_INIT],
595 if test $HAVE_FDOPENDIR = 0; then 609 if test $HAVE_FDOPENDIR = 0; then
596 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 610 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
597 fi 611 fi
612 if test $HAVE_FDOPENDIR = 0; then
613 func_gl_gnulib_m4code_dirfd
614 fi
598 if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then 615 if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
599 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b 616 func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
600 fi 617 fi
@@ -636,6 +653,7 @@ AC_DEFUN([gl_INIT],
636 fi 653 fi
637 m4_pattern_allow([^gl_GNULIB_ENABLED_]) 654 m4_pattern_allow([^gl_GNULIB_ENABLED_])
638 AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b]) 655 AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b])
656 AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd])
639 AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) 657 AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname])
640 AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess]) 658 AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess])
641 AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize]) 659 AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize])
@@ -822,6 +840,7 @@ AC_DEFUN([gl_FILE_LIST], [
822 lib/count-trailing-zeros.c 840 lib/count-trailing-zeros.c
823 lib/count-trailing-zeros.h 841 lib/count-trailing-zeros.h
824 lib/dirent.in.h 842 lib/dirent.in.h
843 lib/dirfd.c
825 lib/dosname.h 844 lib/dosname.h
826 lib/dtoastr.c 845 lib/dtoastr.c
827 lib/dtotimespec.c 846 lib/dtotimespec.c
@@ -940,6 +959,7 @@ AC_DEFUN([gl_FILE_LIST], [
940 m4/count-one-bits.m4 959 m4/count-one-bits.m4
941 m4/count-trailing-zeros.m4 960 m4/count-trailing-zeros.m4
942 m4/dirent_h.m4 961 m4/dirent_h.m4
962 m4/dirfd.m4
943 m4/dup2.m4 963 m4/dup2.m4
944 m4/environ.m4 964 m4/environ.m4
945 m4/errno_h.m4 965 m4/errno_h.m4