Jim Meyering [Thu, 18 May 2017 15:36:27 +0000 (08:36 -0700)]
fallthrough: update for GCC 7/8
* lib/quotearg.c (FALLTHROUGH): New macro.
Use it whenever one switch case falls through into the next,
replacing "/* Fall through */" comments. This exposed one
instance of an unwarranted "fall through" comment: unwarranted
because it preceded a "goto" label not a case statement.
* lib/freopen-safer.c (freopen_safer): Likewise.
* lib/fts.c (leaf_optimization_applies): Likewise.
* lib/unistr/u8-uctomb-aux.c (u8_uctomb_aux): Likewise.
* tests/test-getopt_long.h (getopt_long_loop): Likewise.
* tests/test-tsearch.c (mangle_tree): Likewise. Also include
tests/macros.h for the definition.
* tests/test-argp.c (group1_parser): Likewise.
* tests/test-getopt.h (getopt_loop): Likewise.
Paul Eggert [Fri, 19 May 2017 22:35:24 +0000 (15:35 -0700)]
argp: fix pointer-subtraction bug
* lib/argp-help.c (hol_append): Don’t subtract pointers to
different arrays, as this can run afoul of -fcheck-pointer-bounds.
See the thread containing Bruno Haible’s report in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00171.html
Paul Eggert [Fri, 19 May 2017 15:52:38 +0000 (08:52 -0700)]
closeout: don’t close stderr when sanitizing
* NEWS: Document this.
* lib/closeout.c (__has_feature): New macro, if not already defined.
(SANITIZE_ADDRESS): New constant.
(close_stdout): Don’t close stderr if sanitizing addresses.
Paul Eggert [Tue, 16 May 2017 16:23:52 +0000 (09:23 -0700)]
manywarnings: update for GCC 7
* build-aux/gcc-warning.spec:
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC):
Add GCC 7 warnings, notably -Wimplicit-fallthrough=5, which
requires a non-comment fallthrough attribute. This is a bit
cleaner than the comment versions.
* lib/strftime.c, lib/dfa.c, lib/fnmatch.c, lib/mbrtowc.c:
* lib/vasnprintf.c, tests/macros.h (FALLTHROUGH): New macro.
Use it whenever one switch case falls through into the next.
Bruno Haible [Sun, 14 May 2017 12:20:01 +0000 (14:20 +0200)]
windows-stat-inodes: New module.
* m4/windows-stat-inodes.m4: New file.
* m4/sys_types_h.m4 (gl_SYS_TYPES_H): Set WINDOWS_STAT_INODES.
* modules/sys_types (Makefile.am): Substitute WINDOWS_STAT_INODES.
* lib/sys_types.in.h [WINDOWS_STAT_INODES]: Override dev_t and ino_t.
(_GL_WINDOWS_STAT_INODES): New macro.
* lib/stat-w32.c: Set _WIN32_WINNT. Include <string.h>, verify.h.
(GetFileInformationByHandleExFunc): New variable.
(initialize): Initialize it.
(_gl_fstat_by_handle) [_GL_WINDOWS_STAT_INODES]: Initialize st_dev and
st_ino appropriately.
* lib/stat.c (rpl_stat): Use the directory entry based approach only as
a fallback, because it does not provide st_dev and st_ino values.
* modules/fstat (Depends-on): Add 'verify'.
* modules/windows-stat-inodes: New file.
* doc/windows-stat-inodes.texi: New file.
* doc/gnulib.texi: Include it.
* doc/posix-headers/sys_stat.texi: Mention the new module.
Bruno Haible [Sun, 14 May 2017 15:37:31 +0000 (17:37 +0200)]
stat-time tests: Workaround for native Windows.
* tests/test-stat-time.c: Include <stdio.h>, <time.h>.
(filename_stamp1, filename_testfile, filename_stamp2, filename_stamp3):
New variables.
(initialize_filenames): New function.
(main): Invoke it.
(cleanup, prepare_test): Update.
Bruno Haible [Sat, 13 May 2017 01:03:07 +0000 (03:03 +0200)]
largefile: Improve and document.
* m4/largefile.m4 (gl_LARGEFILE): Set WINDOWS_64_BIT_ST_SIZE to 0 if
the mingw headers already define 'stat' appropriately.
* modules/largefile (Description): Clarify.
* doc/largefile.texi: New file.
* doc/gnulib.texi: Include it.
* doc/posix-headers/sys_types.texi: Update.
Bruno Haible [Sat, 13 May 2017 00:51:05 +0000 (02:51 +0200)]
windows-stat-timespec: New module.
* modules/windows-stat-timespec: New file.
* m4/windows-stat-timespec.m4: New file.
* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Set WINDOWS_STAT_TIMESPEC.
* modules/sys_stat (Makefile.am): Substitute WINDOWS_STAT_TIMESPEC.
* lib/sys_stat.in.h (struct stat) [WINDOWS_STAT_TIMESPEC]: Declare with
fields st_atim, st_mtim, st_ctim.
(st_atime, st_mtime, st_ctime): Define as macros.
(_GL_WINDOWS_STAT_TIMESPEC): New macro.
* lib/stat-w32.h (_gl_convert_FILETIME_to_timespec)
[_GL_WINDOWS_STAT_TIMESPEC]: New declaration.
* lib/stat-w32.c (_gl_convert_FILETIME_to_timespec)
[_GL_WINDOWS_STAT_TIMESPEC]: New function.
(_gl_convert_FILETIME_to_POSIX): Adjust coding style.
(_gl_fstat_by_handle): If _GL_WINDOWS_STAT_TIMESPEC, convert the
FILETIME to 'struct timespec', not 'time_t'.
* lib/stat.c (rpl_stat): If _GL_WINDOWS_STAT_TIMESPEC, convert the
FILETIME to 'struct timespec', not 'time_t'.
* lib/stat-time.h (STAT_TIMESPEC): Define also if
_GL_WINDOWS_STAT_TIMESPEC.
* doc/windows-stat-timespec.texi: New file.
* doc/gnulib.texi: Include it.
Bruno Haible [Sat, 13 May 2017 00:46:43 +0000 (02:46 +0200)]
windows-stat-override: New module.
* lib/sys_stat.in.h (stat) [GNULIB_OVERRIDES_STRUCT_STAT]: Provide own
definition. Define GNULIB_defined_struct_stat.
(fstat, fstatat, lstat, stat) [GNULIB_OVERRIDES_STRUCT_STAT]: Provoke
link error if this symbol is used and the corresponding module is not
in use.
(_stat64, _stat32i64, _stati64, _stat32, _stat64i32): Don't redefine if
GNULIB_OVERRIDES_STRUCT_STAT.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Initialize
GNULIB_OVERRIDES_STRUCT_STAT.
* modules/sys_stat (Makefile.am): Substitute
GNULIB_OVERRIDES_STRUCT_STAT.
* modules/windows-stat-override: New file.
Paul Eggert [Fri, 12 May 2017 00:59:25 +0000 (17:59 -0700)]
getopt-posix: port to mingw
* lib/getopt.c (flockfile, funlockfile): Define on mingw.
Problem reported by Daniel P. Berrage in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00086.html
Bruno Haible [Thu, 11 May 2017 19:38:28 +0000 (21:38 +0200)]
gettimeofday: Increase precision on mingw.
* m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Require AC_CANONICAL_HOST.
Set REPLACE_GETTIMEOFDAY to 1 on mingw.
* lib/gettimeofday.c (gettimeofday): On native Windows, use the
GetSystemTimePreciseAsFileTime based implementation always.
* doc/posix-functions/gettimeofday.texi: Mention precision problem on
mingw.
Bruno Haible [Wed, 10 May 2017 18:30:45 +0000 (20:30 +0200)]
doc: New chapter "Native Windows Support".
* doc/gnulib.texi (Native Windows Support): New chapter.
* doc/windows-libtool.texi: Small wording changes.
* doc/windows-sockets.texi: Small wording and formatting changes.
Paul Eggert [Mon, 8 May 2017 17:37:48 +0000 (10:37 -0700)]
intprops: don’t depend on ‘verify’
Problem reported by Ævar Arnfjörð Bjarmason in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-05/msg00054.html
* lib/intprops.h: Do not include verify.h, and move compile-time
checks from here ...
* tests/test-intprops.c (main): ... to here, if they’re not here
already. Check widths of other standard integer types.
* modules/intprops (Depends-on): Remove ‘verify’.
Bruno Haible [Sun, 7 May 2017 19:50:30 +0000 (21:50 +0200)]
utimens: On native Windows, support 100ns resolution also if fd < 0.
* lib/utime.in.h: Include <time.h>.
(_gl_utimens_windows): New declaration.
* lib/utime.c (_gl_utimens_windows): New function, based on utime.
(utime): Invoke it.
* lib/utimens.c (fdutimens): On native Windows, call _gl_utimens_windows
instead of utime.
* modules/utime (Depends-on): Add 'time'.
* lib/rijndael-api-fst.c (rijndaelBlockEncrypt): Declare 'block' as a
union.
(rijndaelPadEncrypt, rijndaelBlockDecrypt): Likewise.
(rijndaelPadDecrypt): Likewise. Use local variable 'iv' to cache the
value of cipher->IV.
Bruno Haible [Fri, 5 May 2017 19:50:57 +0000 (21:50 +0200)]
inttypes-c++-tests: New module.
* tests/test-inttypes-c++.cc: New file.
(strtoimax): Declare, missing since 2012-01-05.
(strtoumax): Declare, missing since 2012-01-05.
* modules/inttypes-c++-tests: New file.
Paul Eggert [Tue, 2 May 2017 07:40:41 +0000 (00:40 -0700)]
utimens: port to Emacs + MS-Windows
Skip the new MS-Windows-specific code if Emacs.
* lib/utimens.c [EMACS_CONFIGUATION]:
Avoid new MS-Windows-specific code.
(USE_SETFILETIME): New macro.
(fdutimens): Use it.
Bruno Haible [Mon, 1 May 2017 15:27:53 +0000 (17:27 +0200)]
tzset: Work around TZ problem on native Windows.
* m4/tzset.m4 (gl_FUNC_TZSET): Require AC_CANONICAL_HOST. On native
Windows, set REPLACE_TZSET to 1.
* lib/tzset.c (tzset): On native Windows, fix TZ if necessary, and
invoke '_tzset' instead of 'tzset'.
* doc/posix-functions/tzset.texi: Mention the native Windows workaround.
* modules/time_rz (Depends-on): Add tzset.
* lib/time_rz.c (tzset): Remove fallback definition.
* m4/time_rz.m4 (gl_TIME_RZ): Don't test for tzset.
Bruno Haible [Mon, 1 May 2017 11:27:57 +0000 (13:27 +0200)]
copy-file: Preserve sub-second time stamps.
* lib/copy-file.c: Include stat-time.h, utimens.h instead of <utime.h>.
(qcopy_file_preserving): Use 'struct timespec' and utimens() to
transport the time stamps from the original file to the destination
file.
* m4/copy-file.m4 (gl_COPY_FILE): Don't test for utime, utimes.
* modules/copy-file (Depends-on): Add stat-time, utimns instead of
utime-h.
Bruno Haible [Mon, 1 May 2017 10:36:02 +0000 (12:36 +0200)]
wchar: Fix compilation error with the original mingw.org mingw.
* lib/wchar.in.h (rpl_wint_t): If <crtdefs.h> does not exist, include
<stddef.h> instead.
* m4/wint_t.m4 (gl_TYPE_WINT_T_PREREQ): New macro, extracted from
gl_WCTYPE_H.
* m4/wctype_h.m4 (gl_WCTYPE_H): Don't set HAVE_CRTDEFS_H here; require
gl_TYPE_WINT_T_PREREQ instead.
* m4/wchar_h.m4 (gl_WCHAR_H): Require gl_TYPE_WINT_T_PREREQ.
* modules/wchar (Makefile.am): Substitute HAVE_CRTDEFS_H.
Reported by Eli Zaretskii <eliz@gnu.org>.
Bruno Haible [Mon, 1 May 2017 09:50:08 +0000 (11:50 +0200)]
utimens: Add support for native Windows.
* lib/utimens.c: Include <windows.h>, msvc-nothrow.h.
(fdutimens): Provide a native Windows implementation, like utime.c with
added tv_nsec support.
* modules/utimens (Depends-on): Add msvc-nothrow, utime.
Suggested by Tim Rühsen <tim.ruehsen@gmx.de>.
Bruno Haible [Sun, 30 Apr 2017 14:34:54 +0000 (16:34 +0200)]
mktime: Work around TZ problem on native Windows.
* lib/mktime.c: Add #ifs to make the algorithmic workaround independent
from the native Windows workaround.
* m4/mktime.m4 (gl_FUNC_MKTIME_WORKS): New macro, extracted from
gl_FUNC_MKTIME. If guessing, set gl_cv_func_working_mktime to
'guessing no'.
(gl_FUNC_MKTIME): Require it. Require AC_CANONICAL_HOST.
Set REPLACE_MKTIME to 1 on native Windows. Define NEED_MKTIME_WORKING,
NEED_MKTIME_WINDOWS.
(gl_FUNC_MKTIME_INTERNAL): Require gl_FUNC_MKTIME_WORKS, not
gl_FUNC_MKTIME. Set WANT_MKTIME_INTERNAL, not REPLACE_MKTIME. Define
NEED_MKTIME_INTERNAL.
* m4/timegm.m4 (gl_FUNC_TIMEGM): Require gl_FUNC_MKTIME_WORKS, not
gl_FUNC_MKTIME. Cope with 'guessing yes' value.
* modules/mktime-internal (configure.ac): Test WANT_MKTIME_INTERNAL,
not REPLACE_MKTIME.
* doc/posix-functions/mktime.texi: Mention the native Windows
workaround.
Bruno Haible [Sun, 30 Apr 2017 11:32:40 +0000 (13:32 +0200)]
localtime: New module.
* lib/time.in.h (localtime): Declare also if requested by module
'localtime'.
* lib/localtime.c: New file.
* m4/localtime.m4: New file.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize GNULIB_LOCALTIME.
* modules/time (Makefile.am): Substitute GNULIB_LOCALTIME.
* modules/localtime: New file.
* doc/posix-functions/localtime.texi: Mention the new module.