diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-25 22:55:35 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-11-25 22:55:35 -0800 |
commit | d20161b25e9cd184d841ba9e36ee5141c01fd75f (patch) | |
tree | 6026fea9d48e641bf63b23209970efd1f8024e2c /lib | |
parent | e27004c5fe3c227476ea210ff5bee2efb783ae17 (diff) | |
parent | a89f0b6f33f9eb8910a1fceda9028d76ef50b05d (diff) | |
download | emacs-d20161b25e9cd184d841ba9e36ee5141c01fd75f.tar.gz |
Merge from origin/emacs-26
a89f0b6f33 maint: shorten https://lists.gnu.org/archive/html/... links
8be3aee281 Merge from Gnulib
265cee553f Work around GCC bug 80776 on Fedora 27 x86
dc7a97fb84 Tweak copy-file, rename-file doc
cfa2a944d4 Change font-lock-extend-region-multiline handling in mhtml...
a8664cc998 Minor cleanup in tramp-gvfs-handle-file-local-copy
55c5b12fa0 Add test for Bug#29423 in Tramp.
3198a1646e Avoid jumbled order in HTML rendered by shr.el
23bfc2d2db Make sure 'dired-filename' property is always put by ls-lisp
f7fdaea4c0 A better solution for bug#29347
86e6ed8521 ; * src/thread.c (acquire_global_lock): Fix thinko in last...
f300852037 Avoid a hang after C-g while sit-for on a Unix TTY
d7fc719ff1 Improve the doc string of 'list-packages'
b4f67ebb92 Improve discoverability of 'defvar' for suppressing warnings
8a2b204e64 Improve discoverability of 'read-buffer-completion-ignore-...
eea4e9194c Improve documentation of self-insert-uses-region-functions
e6e41dac87 Reflect changes in copy-file and rename-file in doc strings
0ec534070f * lisp/progmodes/cc-vars.el (c-offsets-alist): Doc fix. (...
1d0dbdff6c Reorder type predicates in ELisp manual
b081ec9dd7 Fix backward scrolling in buffers with header-line
8e40429c96 ; Fix some doc typos
ed2c542920 * lisp/bindings.el (buffer-file-coding-system): Add explic...
d82474e452 * src/fns.c (syms_of_fns) <overriding-plist-environment>: ...
292c09ff6d Fix incorrect interaction of drag/drop and double click (b...
d6fadb1d26 * lisp/menu-bar.el (menu-bar-options-save): Add display-li...
daa959efbc * lisp/menu-bar.el (menu-bar-options-save): Add global-dis...
17fc74d1b9 * lisp/follow.el (follow-mode): Restore mode line lighter....
f20c2e2f3d ; Compare process status against 127 exactly
2d203ffb7e Extract the common part of ruby-flymake-simple and ruby-fl...
09944d499a Add Rubocop Flymake backend
c65a0ae7c4 ; Fix a typo
7ab7603125 Update nt/INSTALL.W64 (Bug#28601)
11db253c08 Remove incorrect NEWS item about VC state indicator (Bug#2...
2fdc01c036 * lisp/emacs-lisp/byte-run.el (defsubst): Doc fix.
735c8b516e Make c-defun-name analyze more thoroughly a function type ...
92f0c4cd56 Avoid bogus abbreviated file names if HOME changes
8d450453fa * lisp/emacs-lisp/byte-run.el (inline): Give it a doc.
37a3b4ea40 Fix erc keep-place module with new defaults (Bug#29111)
6c312605bf Add window divider faces to NS (bug#29353)
# Conflicts:
# etc/NEWS
# lisp/ruler-mode.el
Diffstat (limited to 'lib')
-rw-r--r-- | lib/allocator.h | 2 | ||||
-rw-r--r-- | lib/fstatat.c | 12 | ||||
-rw-r--r-- | lib/intprops.h | 6 | ||||
-rw-r--r-- | lib/lstat.c | 39 | ||||
-rw-r--r-- | lib/signal.in.h | 2 | ||||
-rw-r--r-- | lib/stat-time.h | 45 | ||||
-rw-r--r-- | lib/stdio-impl.h | 4 | ||||
-rw-r--r-- | lib/stdio.in.h | 2 | ||||
-rw-r--r-- | lib/timespec.h | 2 |
9 files changed, 85 insertions, 29 deletions
diff --git a/lib/allocator.h b/lib/allocator.h index 8f79d7435c3..fc3d646aa54 100644 --- a/lib/allocator.h +++ b/lib/allocator.h @@ -29,7 +29,7 @@ struct allocator /* Do not use GCC attributes such as __attribute__ ((malloc)) with the function types pointed at by these members, because these attributes do not work with pointers to functions. See - <https://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2011-04/msg00007.html>. */ /* Call ALLOCATE to allocate memory, like 'malloc'. On failure ALLOCATE should return NULL, though not necessarily set errno. When given diff --git a/lib/fstatat.c b/lib/fstatat.c index 294861f51b1..237e68c5da7 100644 --- a/lib/fstatat.c +++ b/lib/fstatat.c @@ -41,6 +41,8 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) above. */ #include "sys/stat.h" +#include "stat-time.h" + #include <errno.h> #include <fcntl.h> #include <string.h> @@ -51,6 +53,12 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) # define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 # endif +static int +normal_fstatat (int fd, char const *file, struct stat *st, int flag) +{ + return stat_time_normalize (orig_fstatat (fd, file, st, flag), st); +} + /* fstatat should always follow symbolic links that end in /, but on Solaris 9 it doesn't if AT_SYMLINK_NOFOLLOW is specified. Likewise, trailing slash on a non-directory should be an error. @@ -63,7 +71,7 @@ orig_fstatat (int fd, char const *filename, struct stat *buf, int flags) int rpl_fstatat (int fd, char const *file, struct stat *st, int flag) { - int result = orig_fstatat (fd, file, st, flag); + int result = normal_fstatat (fd, file, st, flag); size_t len; if (LSTAT_FOLLOWS_SLASHED_SYMLINK || result != 0) @@ -79,7 +87,7 @@ rpl_fstatat (int fd, char const *file, struct stat *st, int flag) errno = ENOTDIR; return -1; } - result = orig_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); + result = normal_fstatat (fd, file, st, flag & ~AT_SYMLINK_NOFOLLOW); } /* Fix stat behavior. */ if (result == 0 && !S_ISDIR (st->st_mode) && file[len - 1] == '/') diff --git a/lib/intprops.h b/lib/intprops.h index a34e81c7b5e..2df7b1f9f69 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -26,7 +26,7 @@ #define _GL_INT_CONVERT(e, v) (0 * (e) + (v)) /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see - <https://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>. */ #define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v)) /* The extra casts in the following macros work around compiler bugs, @@ -179,7 +179,7 @@ /* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Avoid && and || as they tickle bugs in Sun C 5.11 2010/08/13 and other compilers; see - <https://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>. */ #define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ ((b) < 0 \ ? ((a) < 0 \ @@ -443,7 +443,7 @@ implementation-defined result or signal for values outside T's range. However, code that works around this theoretical problem runs afoul of a compiler bug in Oracle Studio 12.3 x86. See: - https://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00049.html + https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html As the compiler bug is real, don't try to work around the theoretical problem. */ diff --git a/lib/lstat.c b/lib/lstat.c index c721a4e641c..f3c61779540 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -47,6 +47,8 @@ orig_lstat (const char *filename, struct stat *buf) above. */ # include "sys/stat.h" +# include "stat-time.h" + # include <string.h> # include <errno.h> @@ -66,32 +68,33 @@ orig_lstat (const char *filename, struct stat *buf) int rpl_lstat (const char *file, struct stat *sbuf) { - size_t len; - int lstat_result = orig_lstat (file, sbuf); - - if (lstat_result != 0) - return lstat_result; + int result = orig_lstat (file, sbuf); /* This replacement file can blindly check against '/' rather than using the ISSLASH macro, because all platforms with '\\' either lack symlinks (mingw) or have working lstat (cygwin) and thus do not compile this file. 0 len should have already been filtered out above, with a failure return of ENOENT. */ - len = strlen (file); - if (file[len - 1] != '/' || S_ISDIR (sbuf->st_mode)) - return 0; - - /* At this point, a trailing slash is only permitted on - symlink-to-dir; but it should have found information on the - directory, not the symlink. Call stat() to get info about the - link's referent. Our replacement stat guarantees valid results, - even if the symlink is not pointing to a directory. */ - if (!S_ISLNK (sbuf->st_mode)) + if (result == 0) { - errno = ENOTDIR; - return -1; + if (S_ISDIR (sbuf->st_mode) || file[strlen (file) - 1] != '/') + result = stat_time_normalize (result, sbuf); + else + { + /* At this point, a trailing slash is permitted only on + symlink-to-dir; but it should have found information on the + directory, not the symlink. Call 'stat' to get info about the + link's referent. Our replacement stat guarantees valid results, + even if the symlink is not pointing to a directory. */ + if (!S_ISLNK (sbuf->st_mode)) + { + errno = ENOTDIR; + return -1; + } + result = stat (file, sbuf); + } } - return stat (file, sbuf); + return result; } #endif /* HAVE_LSTAT */ diff --git a/lib/signal.in.h b/lib/signal.in.h index 9c32b14962f..e8107c37bf5 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h @@ -200,7 +200,7 @@ typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; /* When also using extern inline, suppress the use of static inline in standard headers of problematic Apple configurations, as Libc at least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., - <https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. + <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>. Perhaps Apple will fix this some day. */ #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ && (defined __i386__ || defined __x86_64__)) diff --git a/lib/stat-time.h b/lib/stat-time.h index 47a3bf8f21e..1cf821992ed 100644 --- a/lib/stat-time.h +++ b/lib/stat-time.h @@ -20,6 +20,10 @@ #ifndef STAT_TIME_H #define STAT_TIME_H 1 +#include "intprops.h" + +#include <errno.h> +#include <stddef.h> #include <sys/stat.h> #include <time.h> @@ -202,6 +206,47 @@ get_stat_birthtime (struct stat const *st) return t; } +/* If a stat-like function returned RESULT, normalize the timestamps + in *ST, in case this platform suffers from the Solaris 11 bug where + tv_nsec might be negative. Return the adjusted RESULT, setting + errno to EOVERFLOW if normalization overflowed. This function + is intended to be private to this .h file. */ +_GL_STAT_TIME_INLINE int +stat_time_normalize (int result, struct stat *st) +{ +#if defined __sun && defined STAT_TIMESPEC + if (result == 0) + { + long int timespec_resolution = 1000000000; + short int const ts_off[] = { offsetof (struct stat, st_atim), + offsetof (struct stat, st_mtim), + offsetof (struct stat, st_ctim) }; + int i; + for (i = 0; i < sizeof ts_off / sizeof *ts_off; i++) + { + struct timespec *ts = (struct timespec *) ((char *) st + ts_off[i]); + long int q = ts->tv_nsec / timespec_resolution; + long int r = ts->tv_nsec % timespec_resolution; + if (r < 0) + { + r += timespec_resolution; + q--; + } + ts->tv_nsec = r; + /* Overflow is possible, as Solaris 11 stat can yield + tv_sec == TYPE_MINIMUM (time_t) && tv_nsec == -1000000000. + INT_ADD_WRAPV is OK, since time_t is signed on Solaris. */ + if (INT_ADD_WRAPV (q, ts->tv_sec, &ts->tv_sec)) + { + errno = EOVERFLOW; + return -1; + } + } + } +#endif + return result; +} + #ifdef __cplusplus } #endif diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h index 8960333687e..329801ad23b 100644 --- a/lib/stdio-impl.h +++ b/lib/stdio-impl.h @@ -81,7 +81,7 @@ #ifdef __TANDEM /* NonStop Kernel */ # ifndef _IOERR /* These values were determined by the program 'stdioext-flags' at - <https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */ # define _IOERR 0x40 # define _IOREAD 0x80 # define _IOWRT 0x4 @@ -132,7 +132,7 @@ struct _gl_real_FILE # define fp_ ((struct _gl_real_FILE *) fp) /* These values were determined by a program similar to the one at - <https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00165.html>. */ + <https://lists.gnu.org/r/bug-gnulib/2010-12/msg00165.html>. */ # define _IOREAD 0x1 # define _IOWRT 0x2 # define _IORW 0x4 diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 066e08eba9a..505f3f49f4e 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -152,7 +152,7 @@ /* When also using extern inline, suppress the use of static inline in standard headers of problematic Apple configurations, as Libc at least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., - <https://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>. + <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>. Perhaps Apple will fix this some day. */ #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ && defined __GNUC__ && defined __STDC__) diff --git a/lib/timespec.h b/lib/timespec.h index cc34067374f..84c8146a3ea 100644 --- a/lib/timespec.h +++ b/lib/timespec.h @@ -87,7 +87,7 @@ timespec_cmp (struct timespec a, struct timespec b) return 1; /* Pacify gcc -Wstrict-overflow (bleeding-edge circa 2017-10-02). See: - http://lists.gnu.org/archive/html/bug-gnulib/2017-10/msg00006.html */ + http://lists.gnu.org/r/bug-gnulib/2017-10/msg00006.html */ assume (-1 <= a.tv_nsec && a.tv_nsec <= 2 * TIMESPEC_RESOLUTION); assume (-1 <= b.tv_nsec && b.tv_nsec <= 2 * TIMESPEC_RESOLUTION); |