Commit ccf00107 authored by Paul Eggert's avatar Paul Eggert

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.
parent 8aa13d07
2015-03-19 Paul Eggert <eggert@cs.ucla.edu>
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.
2015-03-02 Robert Pluim <rpluim@gmail.com> (tiny change)
* configure.ac: Error out if with-file-notification=w32 is
......
......@@ -77,6 +77,7 @@ typedef struct gl_directory DIR;
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef opendir
# define opendir rpl_opendir
# define GNULIB_defined_opendir 1
# endif
_GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
......@@ -128,6 +129,7 @@ _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef closedir
# define closedir rpl_closedir
# define GNULIB_defined_closedir 1
# endif
_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
......
/* dirfd.c -- return the file descriptor associated with an open DIR*
Copyright (C) 2001, 2006, 2008-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Jim Meyering. */
#include <config.h>
#include <dirent.h>
#include <errno.h>
int
dirfd (DIR *dir_p)
{
int fd = DIR_TO_FD (dir_p);
if (fd == -1)
errno = ENOTSUP;
return fd;
}
......@@ -93,7 +93,7 @@ fdopendir (int fd)
That way, barring race conditions, fd_clone_opendir returns a
stream whose file descriptor is FD.
If REPLACE_CHDIR or CWD is null, use opendir ("/proc/self/fd/...",
If REPLACE_FCHDIR or CWD is null, use opendir ("/proc/self/fd/...",
falling back on fchdir metadata. Otherwise, CWD is a saved version
of the working directory; use fchdir/opendir(".")/restore_cwd(CWD). */
static DIR *
......@@ -156,7 +156,16 @@ fd_clone_opendir (int fd, struct saved_cwd const *cwd)
if (! dir && EXPECTED_ERRNO (saved_errno))
{
char const *name = _gl_directory_name (fd);
return (name ? opendir (name) : NULL);
DIR *dp = name ? opendir (name) : NULL;
/* The caller has done an elaborate dance to arrange for opendir to
consume just the right file descriptor. If dirfd returns -1,
though, we're on a system like mingw where opendir does not
consume a file descriptor. Consume it via 'dup' instead. */
if (dp && dirfd (dp) < 0)
dup (fd);
return dp;
}
# endif
errno = saved_errno;
......
......@@ -237,6 +237,17 @@ EXTRA_DIST += dirent.in.h
## end gnulib module dirent
## begin gnulib module dirfd
if gl_GNULIB_ENABLED_dirfd
endif
EXTRA_DIST += dirfd.c
EXTRA_libgnu_a_SOURCES += dirfd.c
## end gnulib module dirfd
## begin gnulib module dosname
if gl_GNULIB_ENABLED_dosname
......
# serial 22 -*- Autoconf -*-
dnl Find out how to get the file descriptor associated with an open DIR*.
# Copyright (C) 2001-2006, 2008-2015 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
dnl From Jim Meyering
AC_DEFUN([gl_FUNC_DIRFD],
[
AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
dnl Persuade glibc <dirent.h> to declare dirfd().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
AC_CHECK_FUNCS([dirfd])
AC_CHECK_DECLS([dirfd], , ,
[[#include <sys/types.h>
#include <dirent.h>]])
if test $ac_cv_have_decl_dirfd = no; then
HAVE_DECL_DIRFD=0
fi
AC_CACHE_CHECK([whether dirfd is a macro],
gl_cv_func_dirfd_macro,
[AC_EGREP_CPP([dirent_header_defines_dirfd], [
#include <sys/types.h>
#include <dirent.h>
#ifdef dirfd
dirent_header_defines_dirfd
#endif],
gl_cv_func_dirfd_macro=yes,
gl_cv_func_dirfd_macro=no)])
# Use the replacement only if we have no function or macro with that name.
if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then
if test $ac_cv_have_decl_dirfd = yes; then
# If the system declares dirfd already, let's declare rpl_dirfd instead.
REPLACE_DIRFD=1
fi
fi
])
dnl Prerequisites of lib/dirfd.c.
AC_DEFUN([gl_PREREQ_DIRFD],
[
AC_CACHE_CHECK([how to get the file descriptor associated with an open DIR*],
[gl_cv_sys_dir_fd_member_name],
[
dirfd_save_CFLAGS=$CFLAGS
for ac_expr in d_fd dd_fd; do
CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <dirent.h>]],
[[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
[dir_fd_found=yes]
)
CFLAGS=$dirfd_save_CFLAGS
test "$dir_fd_found" = yes && break
done
test "$dir_fd_found" = yes || ac_expr=no_such_member
gl_cv_sys_dir_fd_member_name=$ac_expr
]
)
if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME],
[$gl_cv_sys_dir_fd_member_name],
[the name of the file descriptor member of DIR])
fi
AH_VERBATIM([DIR_TO_FD],
[#ifdef DIR_FD_MEMBER_NAME
# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
#else
# define DIR_TO_FD(Dir_p) -1
#endif
])
])
......@@ -56,6 +56,7 @@ AC_DEFUN([gl_EARLY],
# Code from module crypto/sha256:
# Code from module crypto/sha512:
# Code from module dirent:
# Code from module dirfd:
# Code from module dosname:
# Code from module dtoastr:
# Code from module dtotimespec:
......@@ -394,6 +395,7 @@ AC_DEFUN([gl_INIT],
gl_UTIMENS
AC_C_VARARRAYS
gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
gl_gnulib_enabled_dirfd=false
gl_gnulib_enabled_dosname=false
gl_gnulib_enabled_euidaccess=false
gl_gnulib_enabled_getdtablesize=false
......@@ -416,6 +418,18 @@ AC_DEFUN([gl_INIT],
gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=true
fi
}
func_gl_gnulib_m4code_dirfd ()
{
if ! $gl_gnulib_enabled_dirfd; then
gl_FUNC_DIRFD
if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then
AC_LIBOBJ([dirfd])
gl_PREREQ_DIRFD
fi
gl_DIRENT_MODULE_INDICATOR([dirfd])
gl_gnulib_enabled_dirfd=true
fi
}
func_gl_gnulib_m4code_dosname ()
{
if ! $gl_gnulib_enabled_dosname; then
......@@ -595,6 +609,9 @@ AC_DEFUN([gl_INIT],
if test $HAVE_FDOPENDIR = 0; then
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
fi
if test $HAVE_FDOPENDIR = 0; then
func_gl_gnulib_m4code_dirfd
fi
if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then
func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b
fi
......@@ -636,6 +653,7 @@ AC_DEFUN([gl_INIT],
fi
m4_pattern_allow([^gl_GNULIB_ENABLED_])
AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd])
AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname])
AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess])
AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize])
......@@ -822,6 +840,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/count-trailing-zeros.c
lib/count-trailing-zeros.h
lib/dirent.in.h
lib/dirfd.c
lib/dosname.h
lib/dtoastr.c
lib/dtotimespec.c
......@@ -940,6 +959,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/count-one-bits.m4
m4/count-trailing-zeros.m4
m4/dirent_h.m4
m4/dirfd.m4
m4/dup2.m4
m4/environ.m4
m4/errno_h.m4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment