aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2017-04-30 00:38:28 -0700
committerPaul Eggert2017-04-30 00:40:33 -0700
commit7e4dae99d619315179a90461b42ae8d734c5bb45 (patch)
tree98a34f046bd50c1a38bf19cb96e5e0fb77ecf441 /lib
parenta3f3fea14abbc59a2b47cae5bec6252ec3a1f8cf (diff)
downloademacs-7e4dae99d619315179a90461b42ae8d734c5bb45.tar.gz
emacs-7e4dae99d619315179a90461b42ae8d734c5bb45.zip
Merge from gnulib
This avoids incorporating the following, which I suspect are more trouble for Emacs than they’re worth: 2017-04-29 stat, fstat: fix time_t etc. on native Windows platforms * admin/merge-gnulib (AVOIDED_MODULES): Avoid stat, too. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/pathmax.h, lib/stat.c, m4/pathmax.m4, m4/stat.m4: Remove.
Diffstat (limited to 'lib')
-rw-r--r--lib/gnulib.mk.in28
-rw-r--r--lib/pathmax.h83
-rw-r--r--lib/stat.c138
3 files changed, 1 insertions, 248 deletions
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index 4a76f0a5aed..af26648c0e0 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -21,7 +21,7 @@
21# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
22# 22#
23# Generated by gnulib-tool. 23# Generated by gnulib-tool.
24# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=unsetenv --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub update-copyright utimens vla warnings 24# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stat --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=unsetenv --gnu-make --makefile-name=gnulib.mk.in --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-leading-zeros count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub update-copyright utimens vla warnings
25 25
26 26
27MOSTLYCLEANFILES += core *.stackdump 27MOSTLYCLEANFILES += core *.stackdump
@@ -885,9 +885,7 @@ gl_GNULIB_ENABLED_dosname = @gl_GNULIB_ENABLED_dosname@
885gl_GNULIB_ENABLED_euidaccess = @gl_GNULIB_ENABLED_euidaccess@ 885gl_GNULIB_ENABLED_euidaccess = @gl_GNULIB_ENABLED_euidaccess@
886gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@ 886gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@
887gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@ 887gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@
888gl_GNULIB_ENABLED_pathmax = @gl_GNULIB_ENABLED_pathmax@
889gl_GNULIB_ENABLED_secure_getenv = @gl_GNULIB_ENABLED_secure_getenv@ 888gl_GNULIB_ENABLED_secure_getenv = @gl_GNULIB_ENABLED_secure_getenv@
890gl_GNULIB_ENABLED_stat = @gl_GNULIB_ENABLED_stat@
891gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@ 889gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@
892gl_GNULIB_ENABLED_strtoull = @gl_GNULIB_ENABLED_strtoull@ 890gl_GNULIB_ENABLED_strtoull = @gl_GNULIB_ENABLED_strtoull@
893gl_GNULIB_ENABLED_tempname = @gl_GNULIB_ENABLED_tempname@ 891gl_GNULIB_ENABLED_tempname = @gl_GNULIB_ENABLED_tempname@
@@ -1765,17 +1763,6 @@ EXTRA_DIST += openat.h
1765endif 1763endif
1766## end gnulib module openat-h 1764## end gnulib module openat-h
1767 1765
1768## begin gnulib module pathmax
1769ifeq (,$(OMIT_GNULIB_MODULE_pathmax))
1770
1771ifneq (,$(gl_GNULIB_ENABLED_pathmax))
1772
1773endif
1774EXTRA_DIST += pathmax.h
1775
1776endif
1777## end gnulib module pathmax
1778
1779## begin gnulib module pipe2 1766## begin gnulib module pipe2
1780ifeq (,$(OMIT_GNULIB_MODULE_pipe2)) 1767ifeq (,$(OMIT_GNULIB_MODULE_pipe2))
1781 1768
@@ -1982,19 +1969,6 @@ EXTRA_DIST += warn-on-use.h
1982endif 1969endif
1983## end gnulib module snippet/warn-on-use 1970## end gnulib module snippet/warn-on-use
1984 1971
1985## begin gnulib module stat
1986ifeq (,$(OMIT_GNULIB_MODULE_stat))
1987
1988ifneq (,$(gl_GNULIB_ENABLED_stat))
1989
1990endif
1991EXTRA_DIST += stat.c
1992
1993EXTRA_libgnu_a_SOURCES += stat.c
1994
1995endif
1996## end gnulib module stat
1997
1998## begin gnulib module stat-time 1972## begin gnulib module stat-time
1999ifeq (,$(OMIT_GNULIB_MODULE_stat-time)) 1973ifeq (,$(OMIT_GNULIB_MODULE_stat-time))
2000 1974
diff --git a/lib/pathmax.h b/lib/pathmax.h
deleted file mode 100644
index aa0730e27a8..00000000000
--- a/lib/pathmax.h
+++ /dev/null
@@ -1,83 +0,0 @@
1/* Define PATH_MAX somehow. Requires sys/types.h.
2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2017 Free Software
3 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, or (at your option)
8 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#ifndef _PATHMAX_H
19# define _PATHMAX_H
20
21/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
22 including the terminating NUL byte.
23 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
24 PATH_MAX is not defined on systems which have no limit on filename length,
25 such as GNU/Hurd.
26
27 This file does *not* define PATH_MAX always. Programs that use this file
28 can handle the GNU/Hurd case in several ways:
29 - Either with a package-wide handling, or with a per-file handling,
30 - Either through a
31 #ifdef PATH_MAX
32 or through a fallback like
33 #ifndef PATH_MAX
34 # define PATH_MAX 8192
35 #endif
36 or through a fallback like
37 #ifndef PATH_MAX
38 # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
39 #endif
40 */
41
42# include <unistd.h>
43
44# include <limits.h>
45
46# ifndef _POSIX_PATH_MAX
47# define _POSIX_PATH_MAX 256
48# endif
49
50/* Don't include sys/param.h if it already has been. */
51# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
52# include <sys/param.h>
53# endif
54
55# if !defined PATH_MAX && defined MAXPATHLEN
56# define PATH_MAX MAXPATHLEN
57# endif
58
59# ifdef __hpux
60/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
61 *not* including the terminating NUL byte, and is set to 1023.
62 Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
63 not defined at all any more. */
64# undef PATH_MAX
65# define PATH_MAX 1024
66# endif
67
68# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
69/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
70 section "Maximum Path Length Limitation",
71 <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
72 explains that the maximum size of a filename, including the terminating
73 NUL byte, is 260 = 3 + 256 + 1.
74 This is the same value as
75 - FILENAME_MAX in <stdio.h>,
76 - _MAX_PATH in <stdlib.h>,
77 - MAX_PATH in <windef.h>.
78 Undefine the original value, because mingw's <limits.h> gets it wrong. */
79# undef PATH_MAX
80# define PATH_MAX 260
81# endif
82
83#endif /* _PATHMAX_H */
diff --git a/lib/stat.c b/lib/stat.c
deleted file mode 100644
index 7e7c2f6f887..00000000000
--- a/lib/stat.c
+++ /dev/null
@@ -1,138 +0,0 @@
1/* Work around platform bugs in stat.
2 Copyright (C) 2009-2017 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* written by Eric Blake */
18
19/* If the user's config.h happens to include <sys/stat.h>, let it include only
20 the system's <sys/stat.h> here, so that orig_stat doesn't recurse to
21 rpl_stat. */
22#define __need_system_sys_stat_h
23#include <config.h>
24
25/* Get the original definition of stat. It might be defined as a macro. */
26#include <sys/types.h>
27#include <sys/stat.h>
28#undef __need_system_sys_stat_h
29
30#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
31# if _GL_WINDOWS_64_BIT_ST_SIZE
32# undef stat /* avoid warning on mingw64 with _FILE_OFFSET_BITS=64 */
33# define stat _stati64
34# define REPLACE_FUNC_STAT_DIR 1
35# undef REPLACE_FUNC_STAT_FILE
36# elif REPLACE_FUNC_STAT_FILE
37/* mingw64 has a broken stat() function, based on _stat(), in libmingwex.a.
38 Bypass it. */
39# define stat _stat
40# define REPLACE_FUNC_STAT_DIR 1
41# undef REPLACE_FUNC_STAT_FILE
42# endif
43#endif
44
45static int
46orig_stat (const char *filename, struct stat *buf)
47{
48 return stat (filename, buf);
49}
50
51/* Specification. */
52/* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
53 eliminates this include because of the preliminary #include <sys/stat.h>
54 above. */
55#include "sys/stat.h"
56
57#include <errno.h>
58#include <limits.h>
59#include <stdbool.h>
60#include <string.h>
61#include "dosname.h"
62#include "verify.h"
63
64#if REPLACE_FUNC_STAT_DIR
65# include "pathmax.h"
66 /* The only known systems where REPLACE_FUNC_STAT_DIR is needed also
67 have a constant PATH_MAX. */
68# ifndef PATH_MAX
69# error "Please port this replacement to your platform"
70# endif
71#endif
72
73/* Store information about NAME into ST. Work around bugs with
74 trailing slashes. Mingw has other bugs (such as st_ino always
75 being 0 on success) which this wrapper does not work around. But
76 at least this implementation provides the ability to emulate fchdir
77 correctly. */
78
79int
80rpl_stat (char const *name, struct stat *st)
81{
82 int result = orig_stat (name, st);
83#if REPLACE_FUNC_STAT_FILE
84 /* Solaris 9 mistakenly succeeds when given a non-directory with a
85 trailing slash. */
86 if (result == 0 && !S_ISDIR (st->st_mode))
87 {
88 size_t len = strlen (name);
89 if (ISSLASH (name[len - 1]))
90 {
91 errno = ENOTDIR;
92 return -1;
93 }
94 }
95#endif /* REPLACE_FUNC_STAT_FILE */
96#if REPLACE_FUNC_STAT_DIR
97
98 if (result == -1 && errno == ENOENT)
99 {
100 /* Due to mingw's oddities, there are some directories (like
101 c:\) where stat() only succeeds with a trailing slash, and
102 other directories (like c:\windows) where stat() only
103 succeeds without a trailing slash. But we want the two to be
104 synonymous, since chdir() manages either style. Likewise, Mingw also
105 reports ENOENT for names longer than PATH_MAX, when we want
106 ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
107 Fortunately, mingw PATH_MAX is small enough for stack
108 allocation. */
109 char fixed_name[PATH_MAX + 1] = {0};
110 size_t len = strlen (name);
111 bool check_dir = false;
112 verify (PATH_MAX <= 4096);
113 if (PATH_MAX <= len)
114 errno = ENAMETOOLONG;
115 else if (len)
116 {
117 strcpy (fixed_name, name);
118 if (ISSLASH (fixed_name[len - 1]))
119 {
120 check_dir = true;
121 while (len && ISSLASH (fixed_name[len - 1]))
122 fixed_name[--len] = '\0';
123 if (!len)
124 fixed_name[0] = '/';
125 }
126 else
127 fixed_name[len++] = '/';
128 result = orig_stat (fixed_name, st);
129 if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
130 {
131 result = -1;
132 errno = ENOTDIR;
133 }
134 }
135 }
136#endif /* REPLACE_FUNC_STAT_DIR */
137 return result;
138}