commit 0c86f5592e79100c9f307e878cb41b3c02f1f85a (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Sun Aug 16 14:30:09 2020 -0700 Simplify format_time_string * src/timefns.c (emacs_nmemftime, format_time_string): Simplify on the basis of recent nstrftime changes. Propagate nstrftime errno. diff --git a/src/timefns.c b/src/timefns.c index 94cfddf0da..71d5e10872 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1312,11 +1312,12 @@ or (if you need time as a string) `format-time-string'. */) ((size_t) -1) for MAXSIZE. This function behaves like nstrftime, except it allows NUL - bytes in FORMAT and it does not support nanoseconds. */ + bytes in FORMAT. */ static size_t emacs_nmemftime (char *s, size_t maxsize, const char *format, size_t format_len, const struct tm *tp, timezone_t tz, int ns) { + int saved_errno = errno; size_t total = 0; /* Loop through all the NUL-terminated strings in the format @@ -1326,30 +1327,25 @@ emacs_nmemftime (char *s, size_t maxsize, const char *format, '\0' byte so we must invoke it separately for each such string. */ for (;;) { - size_t len; - size_t result; - + errno = 0; + size_t result = nstrftime (s, maxsize, format, tp, tz, ns); + if (result == 0 && errno != 0) + return result; if (s) - s[0] = '\1'; - - result = nstrftime (s, maxsize, format, tp, tz, ns); - - if (s) - { - if (result == 0 && s[0] != '\0') - return 0; - s += result + 1; - } + s += result + 1; maxsize -= result + 1; total += result; - len = strlen (format); + size_t len = strlen (format); if (len == format_len) - return total; + break; total++; format += len + 1; format_len -= len + 1; } + + errno = saved_errno; + return total; } static Lisp_Object @@ -1379,10 +1375,11 @@ format_time_string (char const *format, ptrdiff_t formatlen, while (true) { - buf[0] = '\1'; + errno = 0; len = emacs_nmemftime (buf, size, format, formatlen, tmp, tz, ns); - if ((0 < len && len < size) || (len == 0 && buf[0] == '\0')) + if (len != 0 || errno == 0) break; + eassert (errno == ERANGE); /* Buffer was too small, so make it bigger and try again. */ len = emacs_nmemftime (NULL, SIZE_MAX, format, formatlen, tmp, tz, ns); commit 846657afaf021e8a796335d740ac4a34056abbeb Author: Paul Eggert Date: Sun Aug 16 14:22:56 2020 -0700 Update from Gnulib This incorporates: 2020-08-16 time_rz: remove unused functions 2020-08-16 time_rz: fix issues with mktime_z failures 2020-08-16 nstrftime: Guide inlining also on clang 2020-08-16 intprops: Avoid bogus warning on clang 2020-08-16 libc-config: Enable __REDIRECT macro also on clang 2020-08-16 regex: Use initializer shorthand syntax also with clang 2020-08-16 regex: Use space optimization also with clang 2020-08-16 Use _Static_assert and static_assert when present on clang 2020-08-16 Use 'throw ()' for optimization in C++ mode also on clang 2020-08-16 stdio: Don't break attribute 'scanf' on clang 2020-08-16 Fix "warning: 'format' attribute ...: rpl_printf" 2020-08-16 Fix "warning: attribute declaration must precede definition" 2020-08-16 Fix undesired warnings 2020-08-16 Don't use Autoconf quadrigraphsxo 2020-08-16 Fix quoting of AC_LANG_PROGRAM arguments 2020-08-16 Assume autoconf >= 2.64 2020-08-15 nstrftime: be more predictable about errno 2020-08-15 canonicalize: Fix autoconf test on MSVC/clang 2020-08-15 Support compiling without -loldnames on native Windows 2020-08-14 mktime, mktime-internal: Remove obsolete code 2020-08-14 Assume tzset exists * lib/c++defs.h, lib/canonicalize-lgpl.c, lib/cdefs.h, lib/dup2.c: * lib/fcntl.in.h, lib/getopt-cdefs.in.h, lib/intprops.h, lib/md5.h: * lib/mktime.c, lib/nstrftime.c, lib/open.c, lib/regcomp.c: * lib/regex_internal.h, lib/stdio.in.h, lib/stdlib.in.h: * lib/strftime.h, lib/string.in.h, lib/sys_select.in.h: * lib/sys_stat.in.h, lib/sys_time.in.h, lib/time.in.h, lib/time_rz.c: * lib/unistd.in.h, lib/verify.h, m4/00gnulib.m4: * m4/absolute-header.m4, m4/alloca.m4, m4/canonicalize.m4, m4/dup2.m4: * m4/fchmodat.m4, m4/fcntl.m4, m4/fdopendir.m4, m4/fpending.m4: * m4/futimens.m4, m4/getdtablesize.m4, m4/getloadavg.m4: * m4/gnulib-common.m4, m4/include_next.m4, m4/largefile.m4: * m4/manywarnings.m4, m4/mktime.m4, m4/nstrftime.m4, m4/open-slash.m4: * m4/pselect.m4, m4/pthread_sigmask.m4, m4/time_h.m4, m4/utimens.m4: * m4/utimensat.m4, m4/utimes.m4, m4/warnings.m4: Copy from Gnulib. * lib/gnulib.mk.in: Regenerate. diff --git a/lib/c++defs.h b/lib/c++defs.h index 90e6fd62e6..6a9bf295eb 100644 --- a/lib/c++defs.h +++ b/lib/c++defs.h @@ -146,6 +146,16 @@ _GL_EXTERN_C int _gl_cxxalias_dummy #endif +/* _GL_CXXALIAS_MDA (func, rettype, parameters); + is to be used when func is a Microsoft deprecated alias, on native Windows. + It declares a C++ alias called GNULIB_NAMESPACE::func + that redirects to _func, if GNULIB_NAMESPACE is defined. + Example: + _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); + */ +#define _GL_CXXALIAS_MDA(func,rettype,parameters) \ + _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) + /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); except that the C function rpl_func may have a slightly different diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 9f99098839..0b89d2a184 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -52,7 +52,9 @@ # include "pathmax.h" # include "malloca.h" # include "filename.h" -# if HAVE_GETCWD +# if defined _WIN32 && !defined __CYGWIN__ +# define __getcwd _getcwd +# elif HAVE_GETCWD # if IN_RELOCWRAPPER /* When building the relocatable program wrapper, use the system's getcwd function, not the gnulib override, otherwise we would get a link error. diff --git a/lib/cdefs.h b/lib/cdefs.h index 4f89f4e4bf..0cc27806a1 100644 --- a/lib/cdefs.h +++ b/lib/cdefs.h @@ -85,7 +85,7 @@ # define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct # define __NTHNL(fct) __attribute__ ((__nothrow__)) fct # else -# if defined __cplusplus && __GNUC_PREREQ (2,8) +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4) # define __THROW throw () # define __THROWNL throw () # define __NTH(fct) __LEAF_ATTR fct throw () @@ -194,7 +194,7 @@ Example: int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ -#if defined __GNUC__ && __GNUC__ >= 2 +#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4) # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) # ifdef __cplusplus @@ -465,7 +465,8 @@ #if (!defined _Static_assert && !defined __cplusplus \ && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ - && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__)) + && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \ + || defined __STRICT_ANSI__)) # define _Static_assert(expr, diagnostic) \ extern int (*__Static_assert_function (void)) \ [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] diff --git a/lib/dup2.c b/lib/dup2.c index 9bc3951f3d..323e19b25e 100644 --- a/lib/dup2.c +++ b/lib/dup2.c @@ -52,7 +52,7 @@ dup2_nothrow (int fd, int desired_fd) TRY_MSVC_INVAL { - result = dup2 (fd, desired_fd); + result = _dup2 (fd, desired_fd); } CATCH_MSVC_INVAL { @@ -64,7 +64,7 @@ dup2_nothrow (int fd, int desired_fd) return result; } # else -# define dup2_nothrow dup2 +# define dup2_nothrow _dup2 # endif static int diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h index 0a21c957ba..6f16bc6692 100644 --- a/lib/fcntl.in.h +++ b/lib/fcntl.in.h @@ -97,6 +97,12 @@ _GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef creat +# define creat _creat +# endif +_GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode)); # else _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); # endif @@ -106,6 +112,9 @@ _GL_CXXALIASWARN (creat); /* Assume creat is always declared. */ _GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " "use gnulib module creat for portability"); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef creat +# define creat _creat #endif #if @GNULIB_FCNTL@ @@ -146,6 +155,12 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef open +# define open _open +# endif +_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); # else _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); # endif @@ -159,6 +174,9 @@ _GL_CXXALIASWARN (open); /* Assume open is always declared. */ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " "use gnulib module open for portability"); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef open +# define open _open #endif #if @GNULIB_OPENAT@ diff --git a/lib/getopt-cdefs.in.h b/lib/getopt-cdefs.in.h index c510ab163c..674838c666 100644 --- a/lib/getopt-cdefs.in.h +++ b/lib/getopt-cdefs.in.h @@ -57,7 +57,7 @@ #endif #ifndef __THROW -# if defined __cplusplus && __GNUC_PREREQ (2,8) +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4) # define __THROW throw () # else # define __THROW diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 92d0621c61..7b4fc74219 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -682,7 +682,6 @@ HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@ HAVE_TIMEGM = @HAVE_TIMEGM@ HAVE_TIMEZONE_T = @HAVE_TIMEZONE_T@ HAVE_TYPE_VOLATILE_SIG_ATOMIC_T = @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@ -HAVE_TZSET = @HAVE_TZSET@ HAVE_UNISTD_H = @HAVE_UNISTD_H@ HAVE_UNLINKAT = @HAVE_UNLINKAT@ HAVE_UNLOCKPT = @HAVE_UNLOCKPT@ @@ -1159,7 +1158,7 @@ ifeq (,$(OMIT_GNULIB_MODULE_absolute-header)) # Use this preprocessor expression to decide whether #include_next works. # Do not rely on a 'configure'-time test for this, since the expression # might appear in an installed header, which is used by some other compiler. -HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER) +HAVE_INCLUDE_NEXT = (__GNUC__ || __clang__ || 60000000 <= __DECC_VER) endif ## end gnulib module absolute-header @@ -3185,7 +3184,6 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $( -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -e 's|@''HAVE_TIMEZONE_T''@|$(HAVE_TIMEZONE_T)|g' \ - -e 's|@''HAVE_TZSET''@|$(HAVE_TZSET)|g' \ -e 's|@''REPLACE_CTIME''@|$(REPLACE_CTIME)|g' \ -e 's|@''REPLACE_GMTIME''@|$(REPLACE_GMTIME)|g' \ -e 's|@''REPLACE_LOCALTIME''@|$(REPLACE_LOCALTIME)|g' \ diff --git a/lib/intprops.h b/lib/intprops.h index 220f532e49..f2f70b3e73 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -396,7 +396,7 @@ For now, assume all versions of GCC-like compilers generate bogus warnings for _Generic. This matters only for compilers that lack relevant builtins. */ -#if __GNUC__ +#if __GNUC__ || defined __clang__ # define _GL__GENERIC_BOGUS 1 #else # define _GL__GENERIC_BOGUS 0 diff --git a/lib/md5.h b/lib/md5.h index 3c6048242b..c728ba1b6f 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -40,7 +40,7 @@ #endif #ifndef __THROW -# if defined __cplusplus && __GNUC_PREREQ (2,8) +# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major__ >= 4) # define __THROW throw () # else # define __THROW diff --git a/lib/mktime.c b/lib/mktime.c index 92c00b2b14..5b4c144eca 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -94,7 +94,7 @@ my_tzset (void) const char *tz = getenv ("TZ"); if (tz != NULL && strchr (tz, '/') != NULL) _putenv ("TZ="); -# elif HAVE_TZSET +# else tzset (); # endif } diff --git a/lib/nstrftime.c b/lib/nstrftime.c index 2816cf4d58..7d5a97f763 100644 --- a/lib/nstrftime.c +++ b/lib/nstrftime.c @@ -21,7 +21,6 @@ # define HAVE_TM_GMTOFF 1 # define HAVE_TM_ZONE 1 # define HAVE_TZNAME 1 -# define HAVE_TZSET 1 # include "../locale/localeinfo.h" #else # include @@ -34,6 +33,7 @@ #endif #include +#include #include #if HAVE_TZNAME && !HAVE_DECL_TZNAME @@ -163,7 +163,10 @@ extern char *tzname[]; size_t _w = pad == L_('-') || width < 0 ? 0 : width; \ size_t _incr = _n < _w ? _w : _n; \ if (_incr >= maxsize - i) \ - return 0; \ + { \ + errno = ERANGE; \ + return 0; \ + } \ if (p) \ { \ if (_n < _w) \ @@ -365,7 +368,7 @@ tm_diff (const struct tm *a, const struct tm *b) #define ISO_WEEK1_WDAY 4 /* Thursday */ #define YDAY_MINIMUM (-366) static int iso_week_days (int, int); -#ifdef __GNUC__ +#if defined __GNUC__ || defined __clang__ __inline__ #endif static int @@ -389,7 +392,6 @@ iso_week_days (int yday, int wday) #endif #ifdef my_strftime -# undef HAVE_TZSET # define extra_args , tz, ns # define extra_args_spec , timezone_t tz, int ns #else @@ -449,6 +451,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) size_t maxsize = (size_t) -1; #endif + int saved_errno = errno; int hour12 = tp->tm_hour; #ifdef _NL_CURRENT /* We cannot make the following values variables since we must delay @@ -523,7 +526,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) { /* POSIX.1 requires that local time zone information be used as though strftime called tzset. */ -# if HAVE_TZSET +# ifndef my_strftime if (!*tzset_called) { tzset (); @@ -1188,7 +1191,13 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) time_t t; ltm = *tp; + ltm.tm_yday = -1; t = mktime_z (tz, <m); + if (ltm.tm_yday < 0) + { + errno = EOVERFLOW; + return 0; + } /* Generate string value for T using time_t arithmetic; this works even if sizeof (long) < sizeof (time_t). */ @@ -1417,7 +1426,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) /* POSIX.1 requires that local time zone information be used as though strftime called tzset. */ -# if HAVE_TZSET +# ifndef my_strftime if (!*tzset_called) { tzset (); @@ -1486,5 +1495,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) *p = L_('\0'); #endif + errno = saved_errno; return i; } diff --git a/lib/open.c b/lib/open.c index 751b42d7dc..0f7c6e9b9d 100644 --- a/lib/open.c +++ b/lib/open.c @@ -30,7 +30,11 @@ static int orig_open (const char *filename, int flags, mode_t mode) { +#if defined _WIN32 && !defined __CYGWIN__ + return _open (filename, flags, mode); +#else return open (filename, flags, mode); +#endif } /* Specification. */ diff --git a/lib/regcomp.c b/lib/regcomp.c index 84044be5e0..a4b95b0b2f 100644 --- a/lib/regcomp.c +++ b/lib/regcomp.c @@ -558,7 +558,7 @@ weak_alias (__regerror, regerror) static const bitset_t utf8_sb_map = { /* Set the first 128 bits. */ -# if defined __GNUC__ && !defined __STRICT_ANSI__ +# if (defined __GNUC__ || __clang_major__ >= 4) && !defined __STRICT_ANSI__ [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX # else # if 4 * BITSET_WORD_BITS < ASCII_CHARS diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 9a0c2ed97c..0c72e3f7b0 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -335,7 +335,7 @@ typedef struct Idx idx; /* for BACK_REF */ re_context_type ctx_type; /* for ANCHOR */ } opr; -#if __GNUC__ >= 2 && !defined __STRICT_ANSI__ +#if (__GNUC__ >= 2 || defined __clang__) && !defined __STRICT_ANSI__ re_token_type_t type : 8; #else re_token_type_t type; diff --git a/lib/stdio.in.h b/lib/stdio.in.h index cbebc8462f..6d12cd826d 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -215,6 +215,11 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " "use gnulib module fclose for portable POSIX compliance"); #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef fcloseall +# define fcloseall _fcloseall +#endif + #if @GNULIB_FDOPEN@ # if @REPLACE_FDOPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -224,6 +229,12 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fdopen +# define fdopen _fdopen +# endif +_GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode)); # else _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); # endif @@ -233,6 +244,9 @@ _GL_CXXALIASWARN (fdopen); /* Assume fdopen is always declared. */ _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " "use gnulib module fdopen for portability"); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef fdopen +# define fdopen _fdopen #endif #if @GNULIB_FFLUSH@ @@ -297,6 +311,11 @@ _GL_CXXALIASWARN (fgets); # endif #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef fileno +# define fileno _fileno +#endif + #if @GNULIB_FOPEN@ # if @REPLACE_FOPEN@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -824,6 +843,11 @@ _GL_WARN_ON_USE (getline, "getline is unportable - " _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef getw +# define getw _getw +#endif + #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ struct obstack; /* Grow an obstack with formatted output. Return the number of @@ -940,7 +964,7 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)) -# if defined __GNUC__ +# if defined __GNUC__ || defined __clang__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) /* Don't break __attribute__((format(printf,M,N))). */ # define printf __printf__ @@ -1037,6 +1061,11 @@ _GL_CXXALIASWARN (puts); # endif #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef putw +# define putw _putw +#endif + #if @GNULIB_REMOVE@ # if @REPLACE_REMOVE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1114,7 +1143,7 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - " #if @GNULIB_SCANF@ # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@ -# if defined __GNUC__ +# if defined __GNUC__ || defined __clang__ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef scanf /* Don't break __attribute__((format(scanf,M,N))). */ @@ -1170,7 +1199,9 @@ _GL_CXXALIAS_SYS (snprintf, int, (char *restrict str, size_t size, const char *restrict format, ...)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (snprintf); +# endif #elif defined GNULIB_POSIXCHECK # undef snprintf # if HAVE_RAW_DECL_SNPRINTF @@ -1214,6 +1245,11 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " "POSIX compliance"); #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef tempnam +# define tempnam _tempnam +#endif + #if @GNULIB_TMPFILE@ # if @REPLACE_TMPFILE@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1382,7 +1418,9 @@ _GL_CXXALIAS_SYS (vfscanf, int, (FILE *restrict stream, const char *restrict format, va_list args)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (vfscanf); +# endif #endif #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ @@ -1436,7 +1474,9 @@ _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args)); # else _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (vscanf); +# endif #endif #if @GNULIB_VSNPRINTF@ @@ -1464,7 +1504,9 @@ _GL_CXXALIAS_SYS (vsnprintf, int, (char *restrict str, size_t size, const char *restrict format, va_list args)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (vsnprintf); +# endif #elif defined GNULIB_POSIXCHECK # undef vsnprintf # if HAVE_RAW_DECL_VSNPRINTF diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 5c598a275d..47a1309e63 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -217,6 +217,21 @@ _GL_WARN_ON_USE (canonicalize_file_name, # endif #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef ecvt +# define ecvt _ecvt +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef fcvt +# define fcvt _fcvt +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef gcvt +# define gcvt _gcvt +#endif + #if @GNULIB_GETLOADAVG@ /* Store max(NELEM,3) load average numbers in LOADAVG[]. The three numbers are the load average of the last 1 minute, the last 5 @@ -468,6 +483,11 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " # endif #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef mktemp +# define mktemp _mktemp +#endif + #if @GNULIB_POSIX_OPENPT@ /* Return an FD open to the master side of a pseudo-terminal. Flags should include O_RDWR, and may also include O_NOCTTY. */ @@ -546,10 +566,19 @@ _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - " # endif _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (putenv, int, (char *string)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putenv +# define putenv _putenv +# endif +_GL_CXXALIAS_MDA (putenv, int, (char *string)); # else _GL_CXXALIAS_SYS (putenv, int, (char *string)); # endif _GL_CXXALIASWARN (putenv); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef putenv +# define putenv _putenv #endif #if @GNULIB_QSORT_R@ diff --git a/lib/strftime.h b/lib/strftime.h index e850163157..fe0c4195a5 100644 --- a/lib/strftime.h +++ b/lib/strftime.h @@ -24,7 +24,12 @@ extern "C" { /* Just like strftime, but with two more arguments: POSIX requires that strftime use the local timezone information. Use the timezone __TZ instead. Use __NS as the number of - nanoseconds in the %N directive. */ + nanoseconds in the %N directive. + + On error, set errno and return 0. Otherwise, return the number of + bytes generated (not counting the trailing NUL), preserving errno + if the number is 0. This errno behavior is in draft POSIX 202x + plus some requested changes to POSIX. */ size_t nstrftime (char *restrict, size_t, char const *, struct tm const *, timezone_t __tz, int __ns); diff --git a/lib/string.in.h b/lib/string.in.h index c0c1a54f39..7d83668f6e 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -123,6 +123,12 @@ _GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module"); #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef memccpy +# define memccpy _memccpy +#endif + + /* Return the first instance of C within N bytes of S, or NULL. */ #if @GNULIB_MEMCHR@ # if @REPLACE_MEMCHR@ @@ -384,6 +390,12 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - " # endif _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strdup +# define strdup _strdup +# endif +_GL_CXXALIAS_MDA (strdup, char *, (char const *__s)); # else # if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup /* strdup exists as a function and as a macro. Get rid of the macro. */ @@ -401,6 +413,9 @@ _GL_CXXALIASWARN (strdup); _GL_WARN_ON_USE (strdup, "strdup is unportable - " "use gnulib module strdup for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef strdup +# define strdup _strdup #endif /* Append no more than N characters from SRC onto DEST. */ diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h index 7a7b157d54..72cb9ba7b0 100644 --- a/lib/sys_select.in.h +++ b/lib/sys_select.in.h @@ -177,14 +177,14 @@ rpl_fd_isset (SOCKET fd, fd_set * set) # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef close # define close close_used_without_including_unistd_h -# else +# elif !defined __clang__ _GL_WARN_ON_USE (close, "close() used without including "); # endif # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef gethostname # define gethostname gethostname_used_without_including_unistd_h -# else +# elif !defined __clang__ _GL_WARN_ON_USE (gethostname, "gethostname() used without including "); # endif @@ -219,7 +219,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set) # define setsockopt setsockopt_used_without_including_sys_socket_h # undef shutdown # define shutdown shutdown_used_without_including_sys_socket_h -# else +# elif !defined __clang__ _GL_WARN_ON_USE (socket, "socket() used without including "); _GL_WARN_ON_USE (connect, diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index 89e167f6d1..3e0e4b27b7 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -391,6 +391,12 @@ struct stat #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef chmod +# define chmod _chmod +#endif + + #if @GNULIB_FCHMODAT@ # if @REPLACE_FCHMODAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -432,7 +438,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf)); # else _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (fstat); +# endif #elif @GNULIB_OVERRIDES_STRUCT_STAT@ # undef fstat # define fstat fstat_used_without_requesting_gnulib_module_fstat @@ -800,6 +808,12 @@ _GL_WARN_ON_USE (stat, "stat is unportable - " #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef umask +# define umask _umask +#endif + + #if @GNULIB_UTIMENSAT@ /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat implementation relies on futimesat, which on Solaris 10 makes an invocation diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h index d30b26719b..1c12d5f13d 100644 --- a/lib/sys_time.in.h +++ b/lib/sys_time.in.h @@ -135,7 +135,7 @@ _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef close # define close close_used_without_including_unistd_h -# else +# elif !defined __clang__ _GL_WARN_ON_USE (close, "close() used without including "); # endif diff --git a/lib/time.in.h b/lib/time.in.h index 1d11650e77..32e6ec03ef 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -135,13 +135,19 @@ _GL_CXXALIASWARN (nanosleep); # endif _GL_FUNCDECL_RPL (tzset, void, (void)); _GL_CXXALIAS_RPL (tzset, void, (void)); -# else -# if ! @HAVE_TZSET@ -_GL_FUNCDECL_SYS (tzset, void, (void)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef tzset +# define tzset _tzset # endif +_GL_CXXALIAS_MDA (tzset, void, (void)); +# else _GL_CXXALIAS_SYS (tzset, void, (void)); # endif _GL_CXXALIASWARN (tzset); +# elif defined _WIN32 && !defined __CYGWIN__ +# undef tzset +# define tzset _tzset # endif /* Return the 'time_t' representation of TP and normalize TP. */ diff --git a/lib/time_rz.c b/lib/time_rz.c index 5d85963c9e..95438cf876 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -54,31 +54,6 @@ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; matters; the pointer is never dereferenced. */ static timezone_t const local_tz = (timezone_t) 1; -#if HAVE_TM_ZONE || HAVE_TZNAME - -/* Return true if the values A and B differ according to the rules for - tm_isdst: A and B differ if one is zero and the other positive. */ -static bool -isdst_differ (int a, int b) -{ - return !a != !b && 0 <= a && 0 <= b; -} - -/* Return true if A and B are equal. */ -static int -equal_tm (const struct tm *a, const struct tm *b) -{ - return ! ((a->tm_sec ^ b->tm_sec) - | (a->tm_min ^ b->tm_min) - | (a->tm_hour ^ b->tm_hour) - | (a->tm_mday ^ b->tm_mday) - | (a->tm_mon ^ b->tm_mon) - | (a->tm_year ^ b->tm_year) - | isdst_differ (a->tm_isdst, b->tm_isdst)); -} - -#endif - /* Copy to ABBRS the abbreviation at ABBR with size ABBR_SIZE (this includes its trailing null byte). Append an extra null byte to mark the end of ABBRS. */ @@ -327,17 +302,25 @@ mktime_z (timezone_t tz, struct tm *tm) timezone_t old_tz = set_tz (tz); if (old_tz) { - time_t t = mktime (tm); -#if HAVE_TM_ZONE || HAVE_TZNAME - time_t badtime = -1; struct tm tm_1; - if ((t != badtime - || (localtime_r (&t, &tm_1) && equal_tm (tm, &tm_1))) - && !save_abbr (tz, tm)) - t = badtime; + tm_1.tm_sec = tm->tm_sec; + tm_1.tm_min = tm->tm_min; + tm_1.tm_hour = tm->tm_hour; + tm_1.tm_mday = tm->tm_mday; + tm_1.tm_mon = tm->tm_mon; + tm_1.tm_year = tm->tm_year; + tm_1.tm_yday = -1; + tm_1.tm_isdst = tm->tm_isdst; + time_t t = mktime (&tm_1); + bool ok = 0 <= tm_1.tm_yday; +#if HAVE_TM_ZONE || HAVE_TZNAME + ok = ok && save_abbr (tz, &tm_1); #endif - if (revert_tz (old_tz)) - return t; + if (revert_tz (old_tz) && ok) + { + *tm = tm_1; + return t; + } } return -1; } diff --git a/lib/unistd.in.h b/lib/unistd.in.h index a81a14fe87..357a35e388 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -273,6 +273,12 @@ _GL_INLINE_HEADER_BEGIN _GL_FUNCDECL_RPL (access, int, (const char *file, int mode) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (access, int, (const char *file, int mode)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef access +# define access _access +# endif +_GL_CXXALIAS_MDA (access, int, (const char *file, int mode)); # else _GL_CXXALIAS_SYS (access, int, (const char *file, int mode)); # endif @@ -286,11 +292,22 @@ _GL_WARN_ON_USE (access, "access does not always support X_OK - " "also, this function is a security risk - " "use the gnulib module faccessat instead"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef access +# define access _access #endif #if @GNULIB_CHDIR@ +# if defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef chdir +# define chdir _chdir +# endif +_GL_CXXALIAS_MDA (chdir, int, (const char *file)); +# else _GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIASWARN (chdir); #elif defined GNULIB_POSIXCHECK # undef chdir @@ -298,6 +315,9 @@ _GL_CXXALIASWARN (chdir); _GL_WARN_ON_USE (chown, "chdir is not always in - " "use gnulib module chdir for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef chdir +# define chdir _chdir #endif @@ -342,6 +362,12 @@ _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and " # endif _GL_FUNCDECL_RPL (close, int, (int fd)); _GL_CXXALIAS_RPL (close, int, (int fd)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef close +# define close _close +# endif +_GL_CXXALIAS_MDA (close, int, (int fd)); # else _GL_CXXALIAS_SYS (close, int, (int fd)); # endif @@ -354,6 +380,9 @@ _GL_CXXALIASWARN (close); /* Assume close is always declared. */ _GL_WARN_ON_USE (close, "close does not portably work on sockets - " "use gnulib module close for portability"); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef close +# define close _close #endif @@ -382,6 +411,12 @@ _GL_WARN_ON_USE (copy_file_range, # endif _GL_FUNCDECL_RPL (dup, int, (int oldfd)); _GL_CXXALIAS_RPL (dup, int, (int oldfd)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup +# define dup _dup +# endif +_GL_CXXALIAS_MDA (dup, int, (int oldfd)); # else _GL_CXXALIAS_SYS (dup, int, (int oldfd)); # endif @@ -392,6 +427,9 @@ _GL_CXXALIASWARN (dup); _GL_WARN_ON_USE (dup, "dup is unportable - " "use gnulib module dup for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef dup +# define dup _dup #endif @@ -407,6 +445,12 @@ _GL_WARN_ON_USE (dup, "dup is unportable - " # endif _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup2 +# define dup2 _dup2 +# endif +_GL_CXXALIAS_MDA (dup2, int, (int oldfd, int newfd)); # else _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); # endif @@ -417,6 +461,9 @@ _GL_CXXALIASWARN (dup2); _GL_WARN_ON_USE (dup2, "dup2 is unportable - " "use gnulib module dup2 for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef dup2 +# define dup2 _dup2 #endif @@ -517,6 +564,43 @@ _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef execl +# define execl _execl +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef execle +# define execle _execle +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef execlp +# define execlp _execlp +#endif + + +#if defined _WIN32 && !defined __CYGWIN__ +# undef execv +# define execv _execv +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef execve +# define execve _execve +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef execvp +# define execvp _execvp +#endif + +#if defined _WIN32 && !defined __CYGWIN__ +# undef execvpe +# define execvpe _execvpe +#endif + + #if @GNULIB_FACCESSAT@ # if @REPLACE_FACCESSAT@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -692,6 +776,12 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " # endif _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getcwd +# define getcwd _getcwd +# endif +_GL_CXXALIAS_MDA (getcwd, char *, (char *buf, size_t size)); # else /* Need to cast, because on mingw, the second parameter is int size. */ @@ -704,6 +794,9 @@ _GL_CXXALIASWARN (getcwd); _GL_WARN_ON_USE (getcwd, "getcwd is unportable - " "use gnulib module getcwd for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef getcwd +# define getcwd _getcwd #endif @@ -1038,6 +1131,12 @@ _GL_WARN_ON_USE (getpass, "getpass is unportable - " #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef getpid +# define getpid _getpid +#endif + + #if @GNULIB_GETUSERSHELL@ /* Return the next valid login shell on the system, or NULL when the end of the list has been reached. */ @@ -1110,6 +1209,12 @@ _GL_WARN_ON_USE (group_member, "group_member is unportable - " # endif _GL_FUNCDECL_RPL (isatty, int, (int fd)); _GL_CXXALIAS_RPL (isatty, int, (int fd)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef isatty +# define isatty _isatty +# endif +_GL_CXXALIAS_MDA (isatty, int, (int fd)); # else _GL_CXXALIAS_SYS (isatty, int, (int fd)); # endif @@ -1120,6 +1225,9 @@ _GL_CXXALIASWARN (isatty); _GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - " "use gnulib module isatty for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef isatty +# define isatty _isatty #endif @@ -1231,6 +1339,12 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - " # endif _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef lseek +# define lseek _lseek +# endif +_GL_CXXALIAS_MDA (lseek, off_t, (int fd, off_t offset, int whence)); # else _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); # endif @@ -1241,6 +1355,9 @@ _GL_CXXALIASWARN (lseek); _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " "systems - use gnulib module lseek for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef lseek +# define lseek _lseek #endif @@ -1373,6 +1490,12 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " _GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef read +# define read _read +# endif +_GL_CXXALIAS_MDA (read, ssize_t, (int fd, void *buf, size_t count)); # else /* Need to cast, because on mingw, the third parameter is unsigned int count @@ -1380,6 +1503,9 @@ _GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count)); _GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count)); # endif _GL_CXXALIASWARN (read); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef read +# define read _read #endif @@ -1462,6 +1588,12 @@ _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " # endif _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (rmdir, int, (char const *name)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rmdir +# define rmdir _rmdir +# endif +_GL_CXXALIAS_MDA (rmdir, int, (char const *name)); # else _GL_CXXALIAS_SYS (rmdir, int, (char const *name)); # endif @@ -1472,6 +1604,9 @@ _GL_CXXALIASWARN (rmdir); _GL_WARN_ON_USE (rmdir, "rmdir is unportable - " "use gnulib module rmdir for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef rmdir +# define rmdir _rmdir #endif @@ -1530,6 +1665,12 @@ _GL_WARN_ON_USE (sleep, "sleep is unportable - " #endif +#if defined _WIN32 && !defined __CYGWIN__ +# undef swab +# define swab _swab +#endif + + #if @GNULIB_SYMLINK@ # if @REPLACE_SYMLINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1654,6 +1795,12 @@ _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " # endif _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (unlink, int, (char const *file)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef unlink +# define unlink _unlink +# endif +_GL_CXXALIAS_MDA (unlink, int, (char const *file)); # else _GL_CXXALIAS_SYS (unlink, int, (char const *file)); # endif @@ -1664,6 +1811,9 @@ _GL_CXXALIASWARN (unlink); _GL_WARN_ON_USE (unlink, "unlink is not portable - " "use gnulib module unlink for portability"); # endif +#elif defined _WIN32 && !defined __CYGWIN__ +# undef unlink +# define unlink _unlink #endif @@ -1735,6 +1885,12 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - " _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); +# elif defined _WIN32 && !defined __CYGWIN__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef write +# define write _write +# endif +_GL_CXXALIAS_MDA (write, ssize_t, (int fd, const void *buf, size_t count)); # else /* Need to cast, because on mingw, the third parameter is unsigned int count @@ -1742,6 +1898,9 @@ _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); # endif _GL_CXXALIASWARN (write); +#elif defined _WIN32 && !defined __CYGWIN__ +# undef write +# define write _write #endif _GL_INLINE_HEADER_END diff --git a/lib/verify.h b/lib/verify.h index 58172f3cb7..0ba8d57907 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -23,11 +23,15 @@ /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC) works as per C11. This is supported by GCC 4.6.0 and later, in C - mode. + mode, and by clang (also in C++ mode). Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as - per C2X, and define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) - works as per C++17. This is supported by GCC 9.1 and later. + per C2X. This is supported by GCC 9.1 and later, and by clang in + C++1z mode. + + Define _GL_HAVE_STATIC_ASSERT1 if static_assert (R) works as per + C++17. This is supported by GCC 9.1 and later, and by clang in + C++1z mode. Support compilers claiming conformance to the relevant standard, and also support GCC when not pedantic. If we were willing to slow @@ -35,7 +39,8 @@ since this affects only the quality of diagnostics, why bother? */ #ifndef __cplusplus # if (201112L <= __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__))) + || (!defined __STRICT_ANSI__ \ + && (4 < __GNUC__ + (6 <= __GNUC_MINOR__) || 4 <= __clang_major__))) # define _GL_HAVE__STATIC_ASSERT 1 # endif # if (202000L <= __STDC_VERSION__ \ @@ -43,7 +48,15 @@ # define _GL_HAVE__STATIC_ASSERT1 1 # endif #else -# if 201703L <= __cplusplus || 9 <= __GNUC__ +# if 4 <= __clang_major__ +# define _GL_HAVE__STATIC_ASSERT 1 +# endif +# if 4 <= __clang_major__ && 201411 <= __cpp_static_assert +# define _GL_HAVE__STATIC_ASSERT1 1 +# endif +# if 201703L <= __cplusplus \ + || 9 <= __GNUC__ \ + || (4 <= __clang_major__ && 201411 <= __cpp_static_assert) # define _GL_HAVE_STATIC_ASSERT1 1 # endif #endif diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4 index 06eff4f386..14628c363b 100644 --- a/m4/00gnulib.m4 +++ b/m4/00gnulib.m4 @@ -1,44 +1,12 @@ -# 00gnulib.m4 serial 7 +# 00gnulib.m4 serial 8 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl This file must be named something that sorts before all other -dnl gnulib-provided .m4 files. The first part is needed until such time -dnl as we can assume Autoconf 2.64, with its improved AC_DEFUN_ONCE and -dnl m4_divert semantics. The second part is needed until the clang fix -dnl has been included in Autoconf. - -# Until autoconf 2.63, handling of the diversion stack required m4_init -# to be called first; but this does not happen with aclocal. Wrapping -# the entire execution in another layer of the diversion stack fixes this. -# Worse, prior to autoconf 2.62, m4_wrap depended on the underlying m4 -# for whether it was FIFO or LIFO; in order to properly balance with -# m4_init, we need to undo our push just before anything wrapped within -# the m4_init body. The way to ensure this is to wrap both sides of -# m4_init with a one-shot macro that does the pop at the right time. -m4_ifndef([_m4_divert_diversion], -[m4_divert_push([KILL]) -m4_define([gl_divert_fixup], [m4_divert_pop()m4_define([$0])]) -m4_define([m4_init], - [gl_divert_fixup()]m4_defn([m4_init])[gl_divert_fixup()])]) - - -# AC_DEFUN_ONCE([NAME], VALUE) -# ---------------------------- -# Define NAME to expand to VALUE on the first use (whether by direct -# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. -# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This -# definition is slower than the version in Autoconf 2.64, because it -# can only use interfaces that existed since 2.59; but it achieves the -# same effect. Quoting is necessary to avoid confusing Automake. -m4_version_prereq([2.63.263], [], -[m4_define([AC][_DEFUN_ONCE], - [AC][_DEFUN([$1], - [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], - [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl -[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) +dnl gnulib-provided .m4 files. It is needed until the clang fix has +dnl been included in Autoconf. # The following definitions arrange to use a compiler option # -Werror=implicit-function-declaration in AC_CHECK_DECL, when the diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4 index 39726ba57b..c043233de3 100644 --- a/m4/absolute-header.m4 +++ b/m4/absolute-header.m4 @@ -1,4 +1,4 @@ -# absolute-header.m4 serial 16 +# absolute-header.m4 serial 17 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -22,23 +22,21 @@ dnl From Derek Price. AC_DEFUN([gl_ABSOLUTE_HEADER], [AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_PREPROC_REQUIRE()dnl -dnl FIXME: gl_absolute_header and ac_header_exists must be used unquoted -dnl until we can assume autoconf 2.64 or newer. m4_foreach_w([gl_HEADER_NAME], [$1], [AS_VAR_PUSHDEF([gl_absolute_header], [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>], - m4_defn([gl_absolute_header]), + [gl_absolute_header], [AS_VAR_PUSHDEF([ac_header_exists], [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl - if test AS_VAR_GET(ac_header_exists) = yes; then + if test AS_VAR_GET([ac_header_exists]) = yes; then gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME])) fi AS_VAR_POPDEF([ac_header_exists])dnl ])dnl AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])), - ["AS_VAR_GET(gl_absolute_header)"], + ["AS_VAR_GET([gl_absolute_header])"], [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.]) AS_VAR_POPDEF([gl_absolute_header])dnl ])dnl diff --git a/m4/alloca.m4 b/m4/alloca.m4 index b777f8450c..d841489630 100644 --- a/m4/alloca.m4 +++ b/m4/alloca.m4 @@ -1,4 +1,4 @@ -# alloca.m4 serial 17 +# alloca.m4 serial 18 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2020 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -102,7 +102,7 @@ AH_VERBATIM([STACK_DIRECTION], STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ -@%:@undef STACK_DIRECTION])dnl +#undef STACK_DIRECTION])dnl AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) ]) ]) diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index bdc5c8f71a..14ea3e12fa 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,4 +1,4 @@ -# canonicalize.m4 serial 31 +# canonicalize.m4 serial 33 dnl Copyright (C) 2003-2007, 2009-2020 Free Software Foundation, Inc. @@ -56,7 +56,16 @@ AC_DEFUN([gl_CANONICALIZE_LGPL], AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([canonicalize_file_name getcwd readlink]) + AC_CHECK_FUNCS_ONCE([canonicalize_file_name readlink]) + + dnl On native Windows, we use _getcwd(), regardless whether getcwd() is + dnl available through the linker option '-loldnames'. + AC_REQUIRE([AC_CANONICAL_HOST]) + case "$host_os" in + mingw*) ;; + *) AC_CHECK_FUNCS([getcwd]) ;; + esac + AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) AC_REQUIRE([gl_FUNC_REALPATH_WORKS]) AC_CHECK_HEADERS_ONCE([sys/param.h]) @@ -70,6 +79,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], AC_CHECK_FUNCS_ONCE([realpath]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [ + rm -rf conftest.a conftest.d touch conftest.a mkdir conftest.d AC_RUN_IFELSE([ diff --git a/m4/dup2.m4 b/m4/dup2.m4 index 462bfd0e52..a82798d6bb 100644 --- a/m4/dup2.m4 +++ b/m4/dup2.m4 @@ -1,4 +1,4 @@ -#serial 26 +#serial 27 dnl Copyright (C) 2002, 2005, 2007, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,6 +16,7 @@ AC_DEFUN([gl_FUNC_DUP2], #include #include #include + ]GL_MDA_DEFINES[ #ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4 index e3f2f04816..cf5c87999c 100644 --- a/m4/fchmodat.m4 +++ b/m4/fchmodat.m4 @@ -1,4 +1,4 @@ -# fchmodat.m4 serial 4 +# fchmodat.m4 serial 5 dnl Copyright (C) 2004-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -40,7 +40,7 @@ AC_DEFUN([gl_FUNC_FCHMODAT], #ifndef S_IRWXO #define S_IRWXO 0007 #endif - ]], + ]GL_MDA_DEFINES], [[ int permissive = S_IRWXU | S_IRWXG | S_IRWXO; int desired = S_IRUSR | S_IWUSR; diff --git a/m4/fcntl.m4 b/m4/fcntl.m4 index 562ae2395d..ea24f3d64e 100644 --- a/m4/fcntl.m4 +++ b/m4/fcntl.m4 @@ -1,4 +1,4 @@ -# fcntl.m4 serial 9 +# fcntl.m4 serial 10 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -34,6 +34,7 @@ AC_DEFUN([gl_FUNC_FCNTL], #include #include #include + ]GL_MDA_DEFINES[ #ifndef RLIM_SAVED_CUR # define RLIM_SAVED_CUR RLIM_INFINITY #endif diff --git a/m4/fdopendir.m4 b/m4/fdopendir.m4 index d9cc1a0017..9937a74ea8 100644 --- a/m4/fdopendir.m4 +++ b/m4/fdopendir.m4 @@ -1,4 +1,4 @@ -# serial 12 +# serial 14 # See if we need to provide fdopendir. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -25,10 +25,12 @@ AC_DEFUN([gl_FUNC_FDOPENDIR], else AC_CACHE_CHECK([whether fdopendir works], [gl_cv_func_fdopendir_works], - [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM([[ #include #include #include +]GL_MDA_DEFINES[ #if !HAVE_DECL_FDOPENDIR extern # ifdef __cplusplus @@ -36,12 +38,14 @@ extern # endif DIR *fdopendir (int); #endif -]], [int result = 0; - int fd = open ("conftest.c", O_RDONLY); - if (fd < 0) result |= 1; - if (fdopendir (fd)) result |= 2; - if (close (fd)) result |= 4; - return result;])], +]], + [[int result = 0; + int fd = open ("conftest.c", O_RDONLY); + if (fd < 0) result |= 1; + if (fdopendir (fd)) result |= 2; + if (close (fd)) result |= 4; + return result; + ]])], [gl_cv_func_fdopendir_works=yes], [gl_cv_func_fdopendir_works=no], [case "$host_os" in diff --git a/m4/fpending.m4 b/m4/fpending.m4 index ea9725e489..edabcec5f0 100644 --- a/m4/fpending.m4 +++ b/m4/fpending.m4 @@ -1,4 +1,4 @@ -# serial 22 +# serial 23 # Copyright (C) 2000-2001, 2004-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -25,7 +25,7 @@ AC_DEFUN([gl_FUNC_FPENDING], AC_CACHE_CHECK([for __fpending], [gl_cv_func___fpending], [ AC_LINK_IFELSE( - [AC_LANG_PROGRAM([$fp_headers], + [AC_LANG_PROGRAM([[$fp_headers]], [[return ! __fpending (stdin);]])], [gl_cv_func___fpending=yes], [gl_cv_func___fpending=no]) diff --git a/m4/futimens.m4 b/m4/futimens.m4 index dc5cfa9411..145b8ff0d5 100644 --- a/m4/futimens.m4 +++ b/m4/futimens.m4 @@ -1,4 +1,4 @@ -# serial 8 +# serial 9 # See if we need to provide futimens replacement. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -24,7 +24,8 @@ AC_DEFUN([gl_FUNC_FUTIMENS], #include #include #include -]], [[struct timespec ts[2]; +]GL_MDA_DEFINES], + [[struct timespec ts[2]; int fd = creat ("conftest.file", 0600); struct stat st; if (fd < 0) return 1; diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4 index ab2e3feb37..af328644ad 100644 --- a/m4/getdtablesize.m4 +++ b/m4/getdtablesize.m4 @@ -1,4 +1,4 @@ -# getdtablesize.m4 serial 7 +# getdtablesize.m4 serial 8 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -29,13 +29,16 @@ AC_DEFUN([gl_FUNC_GETDTABLESIZE], dnl correctly require setrlimit before getdtablesize() can report dnl a larger value. AC_RUN_IFELSE([ - AC_LANG_PROGRAM([[#include ]], - [int size = getdtablesize(); - if (dup2 (0, getdtablesize()) != -1) - return 1; - if (size != getdtablesize()) - return 2; - ])], + AC_LANG_PROGRAM( + [[#include ] + GL_MDA_DEFINES + ], + [[int size = getdtablesize(); + if (dup2 (0, getdtablesize()) != -1) + return 1; + if (size != getdtablesize()) + return 2; + ]])], [gl_cv_func_getdtablesize_works=yes], [gl_cv_func_getdtablesize_works=no], [case "$host_os" in diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 index 8e96965d82..9fe328efc0 100644 --- a/m4/getloadavg.m4 +++ b/m4/getloadavg.m4 @@ -7,7 +7,7 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -#serial 9 +#serial 10 # Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. # New applications should use gl_GETLOADAVG instead. @@ -147,7 +147,7 @@ fi AC_CHECK_HEADERS([nlist.h], [AC_CHECK_MEMBERS([struct nlist.n_un.n_name], [], [], - [@%:@include ]) + [#include ]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct nlist x; #ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 03da2287d4..33e56faa98 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 55 +# gnulib-common.m4 serial 57 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -480,14 +480,6 @@ AC_DEFUN([gl_FEATURES_H], AC_SUBST([HAVE_FEATURES_H]) ]) -# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) -# ---------------------------------------------------- -# Backport of autoconf-2.63b's macro. -# Remove this macro when we can assume autoconf >= 2.64. -m4_ifndef([AS_VAR_IF], -[m4_define([AS_VAR_IF], -[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) - # gl_PROG_CC_C99 # Modifies the value of the shell variable CC in an attempt to make $CC # understand ISO C99 source code. @@ -660,6 +652,72 @@ AC_DEFUN([gl_CACHE_VAL_SILENT], as_echo_n="$saved_as_echo_n" ]) -# AS_VAR_COPY was added in autoconf 2.63b -m4_define_default([AS_VAR_COPY], -[AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])]) +dnl Expands to some code for use in .c programs that, on native Windows, defines +dnl the Microsoft deprecated alias function names to the underscore-prefixed +dnl actual function names. With this macro, these function names are available +dnl without linking with '-loldnames' and without generating warnings. +dnl Usage: Use it after all system header files are included. +dnl #include <...> +dnl #include <...> +dnl ]GL_MDA_DEFINES[ +dnl ... +AC_DEFUN([GL_MDA_DEFINES],[ +AC_REQUIRE([_GL_MDA_DEFINES]) +[$gl_mda_defines] +]) +AC_DEFUN([_GL_MDA_DEFINES], +[gl_mda_defines=' +#if defined _WIN32 && !defined __CYGWIN__ +#define access _access +#define chdir _chdir +#define chmod _chmod +#define close _close +#define creat _creat +#define dup _dup +#define dup2 _dup2 +#define ecvt _ecvt +#define execl _execl +#define execle _execle +#define execlp _execlp +#define execv _execv +#define execve _execve +#define execvp _execvp +#define execvpe _execvpe +#define fcloseall _fcloseall +#define fcvt _fcvt +#define fdopen _fdopen +#define fileno _fileno +#define gcvt _gcvt +#define getcwd _getcwd +#define getpid _getpid +#define getw _getw +#define isatty _isatty +#define j0 _j0 +#define j1 _j1 +#define jn _jn +#define lfind _lfind +#define lsearch _lsearch +#define lseek _lseek +#define memccpy _memccpy +#define mkdir _mkdir +#define mktemp _mktemp +#define open _open +#define putenv _putenv +#define putw _putw +#define read _read +#define rmdir _rmdir +#define strdup _strdup +#define swab _swab +#define tempnam _tempnam +#define tzset _tzset +#define umask _umask +#define unlink _unlink +#define utime _utime +#define wcsdup _wcsdup +#define write _write +#define y0 _y0 +#define y1 _y1 +#define yn _yn +#endif +' +]) diff --git a/m4/include_next.m4 b/m4/include_next.m4 index 9009e293b5..33601aa3b4 100644 --- a/m4/include_next.m4 +++ b/m4/include_next.m4 @@ -1,4 +1,4 @@ -# include_next.m4 serial 24 +# include_next.m4 serial 25 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -176,42 +176,40 @@ AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], [AC_CHECK_HEADERS_ONCE([$1]) ]) -dnl FIXME: gl_next_header and gl_header_exists must be used unquoted -dnl until we can assume autoconf 2.64 or newer. m4_foreach_w([gl_HEADER_NAME], [$1], [AS_VAR_PUSHDEF([gl_next_header], [gl_cv_next_]m4_defn([gl_HEADER_NAME])) if test $gl_cv_have_include_next = yes; then - AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) + AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) else AC_CACHE_CHECK( [absolute name of <]m4_defn([gl_HEADER_NAME])[>], - m4_defn([gl_next_header]), + [gl_next_header], [m4_if([$2], [check], [AS_VAR_PUSHDEF([gl_header_exists], [ac_cv_header_]m4_defn([gl_HEADER_NAME])) - if test AS_VAR_GET(gl_header_exists) = yes; then + if test AS_VAR_GET([gl_header_exists]) = yes; then AS_VAR_POPDEF([gl_header_exists]) ]) gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME) AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME)) - AS_VAR_SET(gl_next_header, ['"'$gl_header'"']) + AS_VAR_SET([gl_next_header], ['"'$gl_header'"']) m4_if([$2], [check], [else - AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>']) + AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) fi ]) ]) fi AC_SUBST( AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), - [AS_VAR_GET(gl_next_header)]) + [AS_VAR_GET([gl_next_header])]) if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' gl_next_as_first_directive='<'gl_HEADER_NAME'>' else # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' - gl_next_as_first_directive=AS_VAR_GET(gl_next_header) + gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) fi AC_SUBST( AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), diff --git a/m4/largefile.m4 b/m4/largefile.m4 index f7140dd0a3..f4c5d3a5ce 100644 --- a/m4/largefile.m4 +++ b/m4/largefile.m4 @@ -30,12 +30,12 @@ m4_version_prereq([2.70], [] ,[ # _AC_SYS_LARGEFILE_TEST_INCLUDES # ------------------------------- m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES], -[@%:@include +[#include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -@%:@define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) +#define LARGE_OFF_T (((off_t) 1 << 31 << 31) - 1 + ((off_t) 1 << 31 << 31)) int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]];[]dnl @@ -54,7 +54,7 @@ m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE], [AC_LANG_PROGRAM([$5], [$6])], [$3=no; break]) m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])( - [AC_LANG_PROGRAM([@%:@define $1 $2 + [AC_LANG_PROGRAM([#define $1 $2 $5], [$6])], [$3=$2; break]) $3=unknown diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index d18da048d9..a37cd15b69 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -1,4 +1,4 @@ -# manywarnings.m4 serial 20 +# manywarnings.m4 serial 21 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -39,8 +39,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # Specialization for _AC_LANG = C. -# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.63b. -m4_defun([gl_MANYWARN_ALL_GCC(C)], +AC_DEFUN([gl_MANYWARN_ALL_GCC(C)], [ AC_LANG_PUSH([C]) @@ -210,8 +209,7 @@ m4_defun([gl_MANYWARN_ALL_GCC(C)], ]) # Specialization for _AC_LANG = C++. -# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.63b. -m4_defun([gl_MANYWARN_ALL_GCC(C++)], +AC_DEFUN([gl_MANYWARN_ALL_GCC(C++)], [ gl_MANYWARN_ALL_GCC_CXX_IMPL([$1]) ]) diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 8d9b827fe2..4e7e423fa5 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 32 +# serial 35 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2020 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -31,7 +31,6 @@ AC_DEFUN([gl_FUNC_MKTIME_WORKS], dnl in Autoconf and because it invokes AC_LIBOBJ. AC_CHECK_HEADERS_ONCE([unistd.h]) AC_CHECK_DECLS_ONCE([alarm]) - AC_CHECK_FUNCS_ONCE([tzset]) AC_REQUIRE([gl_MULTIARCH]) AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime], [if test $APPLE_UNIVERSAL_BUILD = 1; then @@ -55,13 +54,12 @@ AC_DEFUN([gl_FUNC_MKTIME_WORKS], # include #endif +]GL_MDA_DEFINES[ + #ifndef TIME_T_IS_SIGNED # define TIME_T_IS_SIGNED 0 #endif -/* Work around redefinition to rpl_putenv by other config tests. */ -#undef putenv - static time_t time_t_max; static time_t time_t_min; diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4 index 6f2762aa27..e4eb87de0b 100644 --- a/m4/nstrftime.m4 +++ b/m4/nstrftime.m4 @@ -1,4 +1,4 @@ -# serial 35 +# serial 36 # Copyright (C) 1996-1997, 1999-2007, 2009-2020 Free Software Foundation, Inc. # @@ -17,8 +17,6 @@ AC_DEFUN([gl_FUNC_GNU_STRFTIME], AC_REQUIRE([gl_TM_GMTOFF]) - AC_CHECK_FUNCS_ONCE([tzset]) - AC_DEFINE([my_strftime], [nstrftime], [Define to the name of the strftime replacement function.]) ]) diff --git a/m4/open-slash.m4 b/m4/open-slash.m4 index 1e57c96960..5d84f2b548 100644 --- a/m4/open-slash.m4 +++ b/m4/open-slash.m4 @@ -1,4 +1,4 @@ -# open-slash.m4 serial 1 +# open-slash.m4 serial 2 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -25,6 +25,7 @@ AC_DEFUN([gl_OPEN_TRAILING_SLASH_BUG], #if HAVE_UNISTD_H # include #endif +]GL_MDA_DEFINES[ int main () { int result = 0; diff --git a/m4/pselect.m4 b/m4/pselect.m4 index f3e5afe0b3..08a5823c6f 100644 --- a/m4/pselect.m4 +++ b/m4/pselect.m4 @@ -1,4 +1,4 @@ -# pselect.m4 serial 8 +# pselect.m4 serial 9 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,7 +37,8 @@ AC_DEFUN([gl_FUNC_PSELECT], #endif #include #include -]],[[ +]GL_MDA_DEFINES], +[[ fd_set set; dup2(0, 16); FD_ZERO(&set); diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index d67511f73d..030862de01 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 18 +# pthread_sigmask.m4 serial 19 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -220,6 +220,7 @@ int main () #include #include #include +]GL_MDA_DEFINES[ static volatile int sigint_occurred; static void sigint_handler (int sig) diff --git a/m4/time_h.m4 b/m4/time_h.m4 index d0f89327c4..a15c09dc07 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -121,7 +121,6 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) - HAVE_TZSET=1; AC_SUBST([HAVE_TZSET]) dnl Even GNU libc does not have timezone_t yet. HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) dnl If another module says to replace or to not replace, do that. diff --git a/m4/utimens.m4 b/m4/utimens.m4 index 65617ac862..3d31085fc6 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl serial 10 +dnl serial 11 AC_DEFUN([gl_UTIMENS], [ @@ -24,7 +24,8 @@ AC_DEFUN([gl_UTIMENS], #include #include #include -]], [[ int fd = open ("conftest.file", O_RDWR); +]GL_MDA_DEFINES], + [[int fd = open ("conftest.file", O_RDWR); if (fd < 0) return 1; if (futimesat (fd, NULL, NULL)) return 2; ]])], diff --git a/m4/utimensat.m4 b/m4/utimensat.m4 index 2bc1bfebb5..e9e4f26b1c 100644 --- a/m4/utimensat.m4 +++ b/m4/utimensat.m4 @@ -1,4 +1,4 @@ -# serial 6 +# serial 7 # See if we need to provide utimensat replacement. dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -23,7 +23,8 @@ AC_DEFUN([gl_FUNC_UTIMENSAT], #include #include #include -]], [[int result = 0; +]GL_MDA_DEFINES], + [[int result = 0; const char *f = "conftest.file"; if (close (creat (f, 0600))) return 1; diff --git a/m4/utimes.m4 b/m4/utimes.m4 index e1056bbba4..877bfd2a73 100644 --- a/m4/utimes.m4 +++ b/m4/utimes.m4 @@ -1,5 +1,5 @@ # Detect some bugs in glibc's implementation of utimes. -# serial 7 +# serial 8 dnl Copyright (C) 2003-2005, 2009-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -34,6 +34,7 @@ AC_DEFUN([gl_FUNC_UTIMES], #include #include #include +]GL_MDA_DEFINES[ static int inorder (time_t a, time_t b, time_t c) diff --git a/m4/warnings.m4 b/m4/warnings.m4 index d272365f0a..d4e4b07345 100644 --- a/m4/warnings.m4 +++ b/m4/warnings.m4 @@ -1,4 +1,4 @@ -# warnings.m4 serial 14 +# warnings.m4 serial 16 dnl Copyright (C) 2008-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,8 +23,6 @@ m4_ifdef([AS_VAR_APPEND], # The effects of this macro depend on the current language (_AC_LANG). AC_DEFUN([gl_COMPILER_OPTION_IF], [ -dnl FIXME: gl_Warn must be used unquoted until we can assume Autoconf -dnl 2.64 or newer. AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl AS_LITERAL_IF([$1], @@ -34,13 +32,13 @@ case $gl_positive in -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;; esac m4_pushdef([gl_Positive], [$gl_positive])])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [ +AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], [gl_Warn], [ gl_save_compiler_FLAGS="$gl_Flags" gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["]) - AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])], - [AS_VAR_SET(gl_Warn, [yes])], - [AS_VAR_SET(gl_Warn, [no])]) + AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([[]])])], + [AS_VAR_SET([gl_Warn], [yes])], + [AS_VAR_SET([gl_Warn], [no])]) gl_Flags="$gl_save_compiler_FLAGS" ]) AS_VAR_IF(gl_Warn, [yes], [$2], [$3]) @@ -59,8 +57,7 @@ AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS], [_AC_LANG_DISPATCH([$0], _AC_LANG, $@)]) # Specialization for _AC_LANG = C. This macro can be AC_REQUIREd. -# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.63b. -m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)], +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)], [ AC_LANG_PUSH([C]) gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL @@ -68,8 +65,7 @@ m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C)], ]) # Specialization for _AC_LANG = C++. This macro can be AC_REQUIREd. -# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.63b. -m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)], +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)], [ AC_LANG_PUSH([C++]) gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL @@ -77,8 +73,7 @@ m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(C++)], ]) # Specialization for _AC_LANG = Objective C. This macro can be AC_REQUIREd. -# Use of m4_defun rather than AC_DEFUN works around a bug in autoconf < 2.63b. -m4_defun([gl_UNKNOWN_WARNINGS_ARE_ERRORS(Objective C)], +AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS(Objective C)], [ AC_LANG_PUSH([Objective C]) gl_UNKNOWN_WARNINGS_ARE_ERRORS_IMPL commit 8c68a15f2ab484dabea4d4c2c760061d8ef440db Author: Jonas Bernoulli Date: Sun Aug 16 22:24:59 2020 +0200 Allow overriding read--expression-try-read bindings * lisp/simple.el (read--expression): No longer bind read--expression-try-read here. * lisp/simple.el (read-expression-map): Bind read--expression-try-read here (bug#42893). This new specialized command was recently added in [1: 4a6dd13fa4]. It reestablishes the bindings every time `read--expression' is invoked, which is wrong because it makes it impossible for users to remove these bindings. 1: 4a6dd13fa42c87175ac72e1980f31cac56582db3 Change 'M-:' to not error out on incomplete expressions. diff --git a/lisp/simple.el b/lisp/simple.el index 1cb93c5722..b45fb87887 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1558,6 +1558,8 @@ in *Help* buffer. See also the command `describe-char'." ;; Might as well bind TAB to completion, since inserting a TAB char is ;; much too rarely useful. (define-key m "\t" 'completion-at-point) + (define-key m "\r" 'read--expression-try-read) + (define-key m "\n" 'read--expression-try-read) (set-keymap-parent m minibuffer-local-map) m)) @@ -1654,8 +1656,6 @@ function `read-from-minibuffer'." (set-syntax-table emacs-lisp-mode-syntax-table) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil t) - (local-set-key "\r" 'read--expression-try-read) - (local-set-key "\n" 'read--expression-try-read) (run-hooks 'eval-expression-minibuffer-setup-hook)) (read-from-minibuffer prompt initial-contents read-expression-map t commit bdda935a7d9519b71822270cf98328ae236b257d Merge: ada0b9b94e df2ae3f9c1 Author: Lars Ingebrigtsen Date: Sun Aug 16 20:25:53 2020 +0200 Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs commit ada0b9b94e60806e854140881289dfeafc837062 Author: Lars Ingebrigtsen Date: Sun Aug 16 20:25:44 2020 +0200 Implement list-system-processes on OpenBSD * src/sysdep.c: Implement list-system-processes on OpenBSD: (bug#13881). Based on a patch by Jérémie Courrèges-Anglas. diff --git a/src/sysdep.c b/src/sysdep.c index 6b54ed3b6e..b1371cd411 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -49,7 +49,7 @@ along with GNU Emacs. If not, see . */ # include #endif -#if defined DARWIN_OS || defined __FreeBSD__ +#if defined DARWIN_OS || defined __FreeBSD__ || defined __OpenBSD__ # include #endif @@ -3061,37 +3061,43 @@ list_system_processes (void) return proclist; } -#elif defined DARWIN_OS || defined __FreeBSD__ +#elif defined DARWIN_OS || defined __FreeBSD__ || defined __OpenBSD__ Lisp_Object list_system_processes (void) { #ifdef DARWIN_OS int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL}; +#elif defined __OpenBSD__ + int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0, + sizeof (struct kinfo_proc), 4096}; #else int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC}; #endif size_t len; + size_t mibsize = sizeof mib / sizeof mib[0]; struct kinfo_proc *procs; size_t i; Lisp_Object proclist = Qnil; - if (sysctl (mib, 3, NULL, &len, NULL, 0) != 0 || len == 0) + if (sysctl (mib, mibsize, NULL, &len, NULL, 0) != 0 || len == 0) return proclist; procs = xmalloc (len); - if (sysctl (mib, 3, procs, &len, NULL, 0) != 0 || len == 0) + if (sysctl (mib, mibsize, procs, &len, NULL, 0) != 0 || len == 0) { xfree (procs); return proclist; } - len /= sizeof (struct kinfo_proc); + len /= sizeof procs[0]; for (i = 0; i < len; i++) { #ifdef DARWIN_OS proclist = Fcons (INT_TO_INTEGER (procs[i].kp_proc.p_pid), proclist); +#elif defined __OpenBSD__ + proclist = Fcons (INT_TO_INTEGER (procs[i].p_pid), proclist); #else proclist = Fcons (INT_TO_INTEGER (procs[i].ki_pid), proclist); #endif commit df2ae3f9c1d01a8be4ea08062501dbce680de3d1 Author: João Távora Date: Sun Aug 16 19:03:37 2020 +0100 Don't let docless variables hide function signature In Elisp mode, ElDoc will try the variable's docstring first, then the function signature. If the former doesn't have one, don't hide the latter. * lisp/progmodes/elisp-mode.el (elisp-eldoc-var-docstring): If no symbol docstring, don't declare any. diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 2f44118edb..21ba42a0fe 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -1420,10 +1420,12 @@ Intended for `eldoc-documentation-functions' (which see)." (defun elisp-eldoc-var-docstring (callback &rest _ignored) "Document variable at point. Intended for `eldoc-documentation-functions' (which see)." - (let ((sym (elisp--current-symbol))) - (when sym (funcall callback (elisp-get-var-docstring sym) - :thing sym - :face 'font-lock-variable-name-face)))) + (let* ((sym (elisp--current-symbol)) + (docstring (and sym (elisp-get-var-docstring sym)))) + (when docstring + (funcall callback docstring + :thing sym + :face 'font-lock-variable-name-face)))) (defun elisp-get-fnsym-args-string (sym &optional index) "Return a string containing the parameter list of the function SYM. commit 1eae0a8784f5c2635f9dda1b78066ecee01dec10 Author: Stefan Kangas Date: Sat Aug 15 02:53:35 2020 +0200 Add new option flyspell-correct-on-mouse-3 * lisp/textmodes/flyspell.el (flyspell-correct-on-mouse-3): New option to bind 'flyspell-correct-word' to 'mouse-3'. (flyspell--set-correct-on-mouse-3): New function to update option. (flyspell-mode): Update 'flyspell-mouse-map' if above option is set. * doc/emacs/fixit.texi (Spelling): Mention the new option. * etc/NEWS: Announce the new option. diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi index 5046146dda..507e780f58 100644 --- a/doc/emacs/fixit.texi +++ b/doc/emacs/fixit.texi @@ -445,12 +445,14 @@ use @code{flyspell-region} or @code{flyspell-buffer} for that. @findex flyspell-correct-word-before-point When Flyspell mode highlights a word as misspelled, you can click on it with @kbd{mouse-2} (@code{flyspell-correct-word}) to display a menu -of possible corrections and actions. In addition, @kbd{C-.} or +of possible corrections and actions. If you want this menu on +@kbd{mouse-3} instead, customize the variable +@code{flyspell-correct-on-mouse-3}. In addition, @kbd{C-.} or @kbd{@key{ESC}-@key{TAB}} (@code{flyspell-auto-correct-word}) will propose various successive corrections for the word at point, and -@w{@kbd{C-c $}} (@code{flyspell-correct-word-before-point}) will pop up a -menu of possible corrections. Of course, you can always correct the -misspelled word by editing it manually in any way you like. +@w{@kbd{C-c $}} (@code{flyspell-correct-word-before-point}) will pop +up a menu of possible corrections. Of course, you can always correct +the misspelled word by editing it manually in any way you like. @findex flyspell-prog-mode Flyspell Prog mode works just like ordinary Flyspell mode, except diff --git a/etc/NEWS b/etc/NEWS index 1a7f18d66e..3f52d26c11 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -875,6 +875,16 @@ height of lines or width of chars. When non-nil, use a new xwidget webkit session after bookmark jump. Otherwise, it will use 'xwidget-webkit-last-session'. +** Flyspell mode + ++++ +*** Corrections and actions menu can be optionally bound to mouse-3. +When Flyspell mode highlights a word as misspelled, you can click on +it to display a menu of possible corrections and actions. You can now +easily bind this menu to mouse-3 (usually the right mouse button) +instead of mouse-2 (the default) by customizing the new option +'flyspell-correct-on-mouse-3'. + * New Modes and Packages in Emacs 28.1 diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index b6ebb9f098..8608f85088 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -445,6 +445,22 @@ like \"Some." map) "Minor mode keymap for Flyspell mode--for the whole buffer.") +;; correct on mouse 3 +(defun flyspell--set-correct-on-mouse-3 (var value) + (set-default var value) + (if value + (progn (define-key flyspell-mouse-map [mouse-2] nil) + (define-key flyspell-mouse-map [mouse-3] 'flyspell-correct-word)) + (define-key flyspell-mouse-map [mouse-2] 'flyspell-correct-word) + (define-key flyspell-mouse-map [mouse-3] nil))) + +(defcustom flyspell-correct-on-mouse-3 nil + "Non-nil means to bind `mouse-3' to `flyspell-correct-word'. +If this is set, also unbind `mouse-2'." + :type 'boolean + :set 'flyspell--set-correct-on-mouse-3 + :version "28.1") + ;; dash character machinery (defvar flyspell-consider-dash-as-word-delimiter-flag nil "Non-nil means that the `-' char is considered as a word delimiter.") @@ -514,7 +530,10 @@ in your init file. :group 'flyspell (if flyspell-mode (condition-case err - (flyspell-mode-on) + (progn + (when flyspell-correct-on-mouse-3 + (flyspell--set-correct-on-mouse-3 'flyspell-correct-on-mouse-3 t)) + (flyspell-mode-on)) (error (message "Error enabling Flyspell mode:\n%s" (cdr err)) (flyspell-mode -1))) (flyspell-mode-off))) commit a0653f809f8b39f5b0a62a1043c3b11dc229054c Author: Stefan Kangas Date: Sat Aug 15 02:43:17 2020 +0200 Remove redundant :group args from flyspell.el * lisp/textmodes/flyspell.el: Remove redundant :group args. diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 39a1b488a7..b6ebb9f098 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -57,7 +57,6 @@ (defcustom flyspell-highlight-flag t "How Flyspell should indicate misspelled words. Non-nil means use highlight, nil means use minibuffer messages." - :group 'flyspell :type 'boolean) (defcustom flyspell-mark-duplications-flag t @@ -65,12 +64,10 @@ Non-nil means use highlight, nil means use minibuffer messages." See `flyspell-mark-duplications-exceptions' to add exceptions to this rule. Detection of repeated words is not implemented in \"large\" regions; see variable `flyspell-large-region'." - :group 'flyspell :type 'boolean) (defcustom flyspell-case-fold-duplications t "Non-nil means Flyspell matches duplicate words case-insensitively." - :group 'flyspell :type 'boolean :version "27.1") @@ -87,7 +84,6 @@ dictionary name (`ispell-local-dictionary' or EXCEPTION-LIST is a list of strings. The checked word is downcased before comparing with these exceptions." - :group 'flyspell :type '(alist :key-type (choice (const :tag "All dictionaries" nil) regexp) :value-type (repeat string)) @@ -97,7 +93,6 @@ downcased before comparing with these exceptions." "If non-nil, sort the corrections before popping them. The sorting is controlled by the `flyspell-sort-corrections-function' variable, and defaults to sorting alphabetically." - :group 'flyspell :version "21.1" :type 'boolean) @@ -109,8 +104,7 @@ function takes three parameters -- the two correction candidates to be sorted, and the third parameter is the word that's being corrected." :version "26.1" - :type 'function - :group 'flyspell) + :type 'function) (defun flyspell-sort-corrections-alphabetically (corr1 corr2 _) (string< corr1 corr2)) @@ -130,14 +124,12 @@ Flyspell uses a different face (`flyspell-duplicate') to highlight it. This variable specifies how far to search to find such a duplicate. -1 means no limit (search the whole buffer). 0 means do not search for duplicate unrecognized spellings." - :group 'flyspell :version "24.5" ; -1 -> 400000 :type '(choice (const :tag "no limit" -1) number)) (defcustom flyspell-delay 3 "The number of seconds to wait before checking, after a \"delayed\" command." - :group 'flyspell :type 'number) (defcustom flyspell-persistent-highlight t @@ -147,12 +139,10 @@ is highlighted, and the highlight is turned off as soon as point moves off the misspelled word. Make sure this variable is non-nil if you use `flyspell-region'." - :group 'flyspell :type 'boolean) (defcustom flyspell-highlight-properties t "Non-nil means highlight incorrect words even if a property exists for this word." - :group 'flyspell :type 'boolean) (defcustom flyspell-default-delayed-commands @@ -164,7 +154,6 @@ Make sure this variable is non-nil if you use `flyspell-region'." backward-delete-char-untabify) "The standard list of delayed commands for Flyspell. See `flyspell-delayed-commands'." - :group 'flyspell :version "21.1" :type '(repeat (symbol))) @@ -172,7 +161,6 @@ See `flyspell-delayed-commands'." "List of commands that are \"delayed\" for Flyspell mode. After these commands, Flyspell checking is delayed for a short time, whose length is specified by `flyspell-delay'." - :group 'flyspell :type '(repeat (symbol))) (defcustom flyspell-default-deplacement-commands @@ -182,7 +170,6 @@ whose length is specified by `flyspell-delay'." scroll-down) "The standard list of deplacement commands for Flyspell. See variable `flyspell-deplacement-commands'." - :group 'flyspell :version "21.1" :type '(repeat (symbol))) @@ -190,18 +177,15 @@ See variable `flyspell-deplacement-commands'." "List of commands that are \"deplacement\" for Flyspell mode. After these commands, Flyspell checking is performed only if the previous command was not the very same command." - :group 'flyspell :version "21.1" :type '(repeat (symbol))) (defcustom flyspell-issue-welcome-flag t "Non-nil means that Flyspell should display a welcome message when started." - :group 'flyspell :type 'boolean) (defcustom flyspell-issue-message-flag t "Non-nil means that Flyspell emits messages when checking words." - :group 'flyspell :type 'boolean) (defcustom flyspell-incorrect-hook nil @@ -213,7 +197,6 @@ of possible corrections as returned by `ispell-parse-output'. If any of the functions return non-nil, the word is not highlighted as incorrect." - :group 'flyspell :version "21.1" :type 'hook) @@ -225,14 +208,12 @@ when flyspell is started, the value of that variable is used instead of `flyspell-default-dictionary' to select the default dictionary. Otherwise, if `flyspell-default-dictionary' is nil, it means to use Ispell's ultimate default dictionary." - :group 'flyspell :version "21.1" :type '(choice string (const :tag "Default" nil))) (defcustom flyspell-tex-command-regexp "\\(\\(begin\\|end\\)[ \t]*{\\|\\(cite[a-z*]*\\|label\\|ref\\|eqref\\|usepackage\\|documentclass\\)[ \t]*\\(\\[[^]]*\\]\\)?{[^{}]*\\)" "A string that is the regular expression that matches TeX commands." - :group 'flyspell :version "21.1" :type 'regexp) @@ -241,34 +222,29 @@ Ispell's ultimate default dictionary." TeX math environments are discovered by `texmathp', implemented inside AUCTeX package. That package may be found at URL `https://www.gnu.org/software/auctex/'" - :group 'flyspell :type 'boolean) (defcustom flyspell-dictionaries-that-consider-dash-as-word-delimiter '("francais" "deutsch8" "norsk") "List of dictionary names that consider `-' as word delimiter." - :group 'flyspell :version "21.1" :type '(repeat (string))) (defcustom flyspell-abbrev-p nil "If non-nil, add correction to abbreviation table." - :group 'flyspell :version "21.1" :type 'boolean) (defcustom flyspell-use-global-abbrev-table-p nil "If non-nil, prefer global abbrev table to local abbrev table." - :group 'flyspell :version "21.1" :type 'boolean) (defcustom flyspell-mode-line-string " Fly" "String displayed on the mode line when flyspell is active. Set this to nil if you don't want a mode line indicator." - :group 'flyspell :type '(choice string (const :tag "None" nil))) (defcustom flyspell-large-region 1000 @@ -282,30 +258,25 @@ Doubled words are not detected in a large region, because Ispell does not check for them. If this variable is nil, all regions are treated as small." - :group 'flyspell :version "21.1" :type '(choice number (const :tag "All small" nil))) (defcustom flyspell-insert-function (function insert) "Function for inserting word by flyspell upon correction." - :group 'flyspell :type 'function) (defcustom flyspell-before-incorrect-word-string nil "String used to indicate an incorrect word starting." - :group 'flyspell :type '(choice string (const nil))) (defcustom flyspell-after-incorrect-word-string nil "String used to indicate an incorrect word ending." - :group 'flyspell :type '(choice string (const nil))) (defvar flyspell-mode-map) (defcustom flyspell-use-meta-tab t "Non-nil means that flyspell uses M-TAB to correct word." - :group 'flyspell :type 'boolean :initialize 'custom-initialize-default :set (lambda (sym val) @@ -316,8 +287,7 @@ If this variable is nil, all regions are treated as small." (defcustom flyspell-auto-correct-binding [(control ?\;)] "The key binding for flyspell auto correction." - :type 'key-sequence - :group 'flyspell) + :type 'key-sequence) ;;*---------------------------------------------------------------------*/ ;;* Mode specific options */ @@ -493,8 +463,7 @@ like \"Some." (t :underline t :inherit error)) "Flyspell face for misspelled words." - :version "24.4" - :group 'flyspell) + :version "24.4") (defface flyspell-duplicate '((((supports :underline (:style wave))) @@ -503,8 +472,7 @@ like \"Some." :underline t :inherit warning)) "Flyspell face for words that appear twice in a row. See also `flyspell-duplicate-distance'." - :version "24.4" - :group 'flyspell) + :version "24.4") (defvar flyspell-overlay nil) commit b06ef8d5e9bf596a396c971a75cdc2718bfd2ac1 Author: Stefan Kangas Date: Sat Aug 15 04:55:35 2020 +0200 Mark XEmacs compat alias as obsolete * lisp/subr.el (user-original-login-name): Mark as obsolete. This XEmacs compat alias was obsoleted even by XEmacs, so there is no point in keeping it around. diff --git a/lisp/subr.el b/lisp/subr.el index 8eb4cf452d..0bd09c6556 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1649,7 +1649,8 @@ be a list of the form returned by `event-start' and `event-end'." (defalias 'point-at-eol 'line-end-position) (defalias 'point-at-bol 'line-beginning-position) -(defalias 'user-original-login-name 'user-login-name) +(define-obsolete-function-alias 'user-original-login-name + 'user-login-name "28.1") ;;;; Hook manipulation functions. commit ba9a2b6c27b3f17e4d320ff9cbee17c79c07d5db Author: Steven Allen Date: Sun Aug 16 14:31:27 2020 +0200 Set the current buffer in esh-mode before running filter functions * lisp/eshell/esh-mode.el: (eshell-output-filter): Match current-buffer behavior of comint-output-filter (bug#42870). This change (a) sets the current buffer to the process-buffer when invoking preoutput filter functions and (b) only invokes them when the process-buffer is live. Otherwise, the preoutput filter functions be invoked in whatever buffer happens to be focused, breaking hooks that read buffer-local variables. diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index d0147b345a..8799007c59 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -690,46 +690,47 @@ newline." "Send the output from PROCESS (STRING) to the interactive display. This is done after all necessary filtering has been done." (let ((oprocbuf (if process (process-buffer process) - (current-buffer))) - (inhibit-point-motion-hooks t) - (inhibit-modification-hooks t)) - (let ((functions eshell-preoutput-filter-functions)) - (while (and functions string) - (setq string (funcall (car functions) string)) - (setq functions (cdr functions)))) - (if (and string oprocbuf (buffer-name oprocbuf)) - (let (opoint obeg oend) - (with-current-buffer oprocbuf - (setq opoint (point)) - (setq obeg (point-min)) - (setq oend (point-max)) - (let ((buffer-read-only nil) - (nchars (length string)) - (ostart nil)) - (widen) - (goto-char eshell-last-output-end) - (setq ostart (point)) - (if (<= (point) opoint) - (setq opoint (+ opoint nchars))) - (if (< (point) obeg) - (setq obeg (+ obeg nchars))) - (if (<= (point) oend) - (setq oend (+ oend nchars))) + (current-buffer))) + (inhibit-point-motion-hooks t) + (inhibit-modification-hooks t)) + (when (and string oprocbuf (buffer-name oprocbuf)) + (with-current-buffer oprocbuf + (let ((functions eshell-preoutput-filter-functions)) + (while (and functions string) + (setq string (funcall (car functions) string)) + (setq functions (cdr functions)))) + (when string + (let (opoint obeg oend) + (setq opoint (point)) + (setq obeg (point-min)) + (setq oend (point-max)) + (let ((buffer-read-only nil) + (nchars (length string)) + (ostart nil)) + (widen) + (goto-char eshell-last-output-end) + (setq ostart (point)) + (if (<= (point) opoint) + (setq opoint (+ opoint nchars))) + (if (< (point) obeg) + (setq obeg (+ obeg nchars))) + (if (<= (point) oend) + (setq oend (+ oend nchars))) ;; Let the ansi-color overlay hooks run. (let ((inhibit-modification-hooks nil)) (insert-before-markers string)) - (if (= (window-start) (point)) - (set-window-start (selected-window) - (- (point) nchars))) - (if (= (point) eshell-last-input-end) - (set-marker eshell-last-input-end - (- eshell-last-input-end nchars))) - (set-marker eshell-last-output-start ostart) - (set-marker eshell-last-output-end (point)) - (force-mode-line-update)) - (narrow-to-region obeg oend) - (goto-char opoint) - (eshell-run-output-filters)))))) + (if (= (window-start) (point)) + (set-window-start (selected-window) + (- (point) nchars))) + (if (= (point) eshell-last-input-end) + (set-marker eshell-last-input-end + (- eshell-last-input-end nchars))) + (set-marker eshell-last-output-start ostart) + (set-marker eshell-last-output-end (point)) + (force-mode-line-update)) + (narrow-to-region obeg oend) + (goto-char opoint) + (eshell-run-output-filters))))))) (defun eshell-run-output-filters () "Run the `eshell-output-filter-functions' on the current output." commit 9f464ccaf9acc36b22bc292c6c572048e147d281 Author: Mattias Engdegård Date: Sun Aug 16 11:06:45 2020 +0200 Stop using calc for ntlm time computation * lisp/net/ntlm.el: Don't require calc. (ntlm-compute-timestamp): Use plain arithmetic instead of calc. (ntlm--time-to-timestamp): New helper function. diff --git a/lisp/net/ntlm.el b/lisp/net/ntlm.el index ebcd21948b..9401430799 100644 --- a/lisp/net/ntlm.el +++ b/lisp/net/ntlm.el @@ -69,7 +69,6 @@ (require 'md4) (require 'hmac-md5) -(require 'calc) (defgroup ntlm nil "NTLM (NT LanManager) authentication." @@ -133,32 +132,27 @@ is not given." domain ;buffer field )))) -(defun ntlm-compute-timestamp () - "Compute an NTLMv2 timestamp. +(defun ntlm--time-to-timestamp (time) + "Convert TIME to an NTLMv2 timestamp. Return a unibyte string representing the number of tenths of a microsecond since January 1, 1601 as a 64-bit little-endian -signed integer." - ;; FIXME: This can likely be significantly simplified using the new - ;; bignums support! - (let* ((s-to-tenths-of-us "mul(add(lsh($1,16),$2),10000000)") - (us-to-tenths-of-us "mul($3,10)") - (ps-to-tenths-of-us "idiv($4,100000)") - (tenths-of-us-since-jan-1-1601 - (apply #'calc-eval (concat "add(add(add(" - s-to-tenths-of-us "," - us-to-tenths-of-us ")," - ps-to-tenths-of-us ")," - ;; tenths of microseconds between - ;; 1601-01-01 and 1970-01-01 - "116444736000000000)") - 'rawnum (time-convert nil 'list))) - result-bytes) - (dotimes (_byte 8) - (push (calc-eval "and($1,16#FF)" 'rawnum tenths-of-us-since-jan-1-1601) - result-bytes) - (setq tenths-of-us-since-jan-1-1601 - (calc-eval "rsh($1,8,64)" 'rawnum tenths-of-us-since-jan-1-1601))) - (apply #'unibyte-string (nreverse result-bytes)))) +signed integer. TIME must be on the form (HIGH LOW USEC PSEC)." + (let* ((s (+ (ash (nth 0 time) 16) (nth 1 time))) + (us (nth 2 time)) + (ps (nth 3 time)) + (tenths-of-us-since-jan-1-1601 + (+ (* s 10000000) (* us 10) (/ ps 100000) + ;; tenths of microseconds between 1601-01-01 and 1970-01-01 + 116444736000000000))) + (apply #'unibyte-string + (mapcar (lambda (i) + (logand (ash tenths-of-us-since-jan-1-1601 (* i -8)) + #xff)) + (number-sequence 0 7))))) + +(defun ntlm-compute-timestamp () + "Current time as an NTLMv2 timestamp, as a unibyte string." + (ntlm--time-to-timestamp (time-convert nil 'list))) (defun ntlm-generate-nonce () "Generate a random nonce, not to be used more than once.