]> Savannah Git Hosting - gnulib.git/log
gnulib.git
7 years agorelocate: Make it easier to reclaim allocated memory.
Bruno Haible [Tue, 16 May 2017 18:57:23 +0000 (20:57 +0200)]
relocate: Make it easier to reclaim allocated memory.

* lib/relocatable.h (relocate2): New declaration/macro.
* lib/relocatable.c (relocate2): New function.
* doc/relocatable-maint.texi (Supporting Relocation): Mention the
relocate2 function.
* lib/localcharset.c (relocate2): Define fallback.
(get_charset_aliases): Invoke relocate2 instead of relocate. Free the
allocated memory.
* lib/javaversion.c (relocate2): Define fallback.
(javaexec_version): Invoke relocate2 instead of relocate. Free the
allocated memory.

7 years agorelocate: Simplify EMX specific code.
Bruno Haible [Tue, 16 May 2017 18:02:20 +0000 (20:02 +0200)]
relocate: Simplify EMX specific code.

* lib/relocatable.c (relocate): Assume pathname is non-NULL. Use
ISSLASH macro consistently. Avoid dangerous string concatenation idiom.

7 years agosigpipe tests: Fix file list.
Bruno Haible [Tue, 16 May 2017 17:38:06 +0000 (19:38 +0200)]
sigpipe tests: Fix file list.

* modules/sigpipe-tests (Files): Add tests/macros.h.

7 years agomanywarnings: update for GCC 7
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.

7 years agognulib-tool: Fix generated code when libtests contains module 'alloca'.
Bruno Haible [Mon, 15 May 2017 21:13:57 +0000 (23:13 +0200)]
gnulib-tool: Fix generated code when libtests contains module 'alloca'.

* gnulib-tool (func_emit_tests_Makefile_am): For libtests.a, use
@ALLOCA@, not @LTALLOCA@.

7 years agosys_select: Avoid "was expanded before it was required" warning.
Bruno Haible [Mon, 15 May 2017 17:27:45 +0000 (19:27 +0200)]
sys_select: Avoid "was expanded before it was required" warning.

* modules/sys_select (configure.ac): Require, not invoke,
gl_HEADER_SYS_SELECT.

7 years agoautoupdate
Karl Berry [Mon, 15 May 2017 15:35:02 +0000 (08:35 -0700)]
autoupdate

7 years agognulib-tool: improve GNU Make debugging
Paul Eggert [Mon, 15 May 2017 14:41:10 +0000 (07:41 -0700)]
gnulib-tool: improve GNU Make debugging

* gnulib-tool (func_emit_lib_Makefile_am): Omit unnecessary echo.
Report autoconf diagnostics when it fails, in the output makefile.

7 years agostat-time tests: Improve comment.
Bruno Haible [Sun, 14 May 2017 19:32:41 +0000 (21:32 +0200)]
stat-time tests: Improve comment.

* tests/test-stat-time.c: Add hyperlink, from Paul Eggert.

7 years agosame-inode: Adapt for windows-stat-inodes.
Bruno Haible [Sun, 14 May 2017 15:33:37 +0000 (17:33 +0200)]
same-inode: Adapt for windows-stat-inodes.

* lib/same-inode.h: Include <sys/types.h>.
(SAME_INODE) [_GL_WINDOWS_STAT_INODES]: Define specifically.
* modules/same-inode (Depends-on): Add sys_types.

7 years agowindows-stat-inodes: New module.
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.

7 years agostat-time tests: Workaround for native Windows.
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.

7 years agostat-time: Adapt for windows-stat-timespec.
Bruno Haible [Sun, 14 May 2017 15:35:16 +0000 (17:35 +0200)]
stat-time: Adapt for windows-stat-timespec.

* lib/stat-time.h (get_stat_birthtime) [_GL_WINDOWS_STAT_TIMESPEC]: Use
entire st_ctim field.

7 years agomaint.mk: update regex to reflect 2013 addition of "assume" to verify.h
Jim Meyering [Sun, 14 May 2017 01:18:22 +0000 (18:18 -0700)]
maint.mk: update regex to reflect 2013 addition of "assume" to verify.h

* top/maint.mk (sc_prohibit_verify_without_use): Don't reject a source
file that uses the assume macro, claiming that verify.h is unused.

7 years agoUse symbolic values for _WIN32_WINNT.
Bruno Haible [Sat, 13 May 2017 11:07:26 +0000 (13:07 +0200)]
Use symbolic values for _WIN32_WINNT.

* lib/ftruncate.c (_WIN32_WINNT): Use symbolic value _WIN32_WINNT_WIN2K.
* lib/sethostname.c (_WIN32_WINNT): Likewise.

7 years agoyear2038: New module.
Bruno Haible [Sat, 13 May 2017 01:04:54 +0000 (03:04 +0200)]
year2038: New module.

* m4/year2038.m4: New file.
* modules/year2038: New file.
* doc/year2038.texi: New file.
* doc/gnulib.texi: Include it.

7 years agolargefile: Simplify.
Bruno Haible [Sat, 13 May 2017 08:35:06 +0000 (10:35 +0200)]
largefile: Simplify.

* m4/sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): Remove unused definition
of _GL_WINDOWS_64_BIT_ST_SIZE.

7 years agolargefile: Improve and document.
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.

7 years agotruncate-tests: New module.
Bruno Haible [Sat, 13 May 2017 00:55:24 +0000 (02:55 +0200)]
truncate-tests: New module.

* tests/test-truncate.c: New file.
* modules/truncate-tests: New file.

7 years agotruncate: New module.
Bruno Haible [Sat, 13 May 2017 00:54:37 +0000 (02:54 +0200)]
truncate: New module.

* lib/unistd.in.h (truncate): New declaration.
* lib/truncate.c: New file.
* m4/truncate.m4: New file.
* m4/unistd_h.m4 (gl_UNISTD_H): Test whether 'truncate' is declared.
(gl_UNISTD_H_DEFAULTS): Initialize GNULIB_TRUNCATE, HAVE_TRUNCATE,
REPLACE_TRUNCATE.
* modules/unistd (Makefile.am): Substitute GNULIB_TRUNCATE,
HAVE_TRUNCATE, REPLACE_TRUNCATE.
* modules/truncate: New file.
* tests/test-unistd-c++.cc (truncate): Test signature.
* doc/posix-functions/truncate.texi: Mention the new module.

7 years agowindows-stat-timespec: New module.
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.

7 years agowindows-stat-override: New module.
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.

7 years agofstat: Fix module dependency conditions.
Bruno Haible [Sat, 13 May 2017 00:39:00 +0000 (02:39 +0200)]
fstat: Fix module dependency conditions.

* modules/fstat (Depends-on): Fix typo.

7 years agostat, fstat: Complete removal of old native Windows code.
Bruno Haible [Sat, 13 May 2017 00:36:19 +0000 (02:36 +0200)]
stat, fstat: Complete removal of old native Windows code.

* lib/stat.c: Remove old macrology for WINDOWS_NATIVE.
* lib/fstat.c: Likewise.
* lib/stat-w32.c: Likewise.

7 years agostat: Complete removal of REPLACE_FUNC_STAT_DIR code.
Bruno Haible [Sat, 13 May 2017 00:32:24 +0000 (02:32 +0200)]
stat: Complete removal of REPLACE_FUNC_STAT_DIR code.

* lib/stat.c: Remove all REPLACE_FUNC_STAT_DIR code.

7 years agoautoupdate
Karl Berry [Fri, 12 May 2017 13:18:50 +0000 (06:18 -0700)]
autoupdate

7 years agogetopt-posix: port to mingw
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

7 years agogettimeofday: Increase precision on mingw.
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.

7 years agopoll: Fix confusion between SOCKETs and FDs on native Windows.
Bruno Haible [Thu, 11 May 2017 14:31:25 +0000 (16:31 +0200)]
poll: Fix confusion between SOCKETs and FDs on native Windows.

Fix proposed by Daniel P. Berrange <berrange@redhat.com>.

* lib/poll.c [WINDOWS_NATIVE]: Undefine select.

7 years agoautoupdate
Karl Berry [Thu, 11 May 2017 13:50:43 +0000 (06:50 -0700)]
autoupdate

7 years agodoc: Clarify doc about socket functions on native Windows.
Bruno Haible [Thu, 11 May 2017 13:22:13 +0000 (15:22 +0200)]
doc: Clarify doc about socket functions on native Windows.

This reworks doc that was added on 2008-09-29.

* doc/posix-functions/select.texi: Fix copy-and-paste mistake and use
clearer wording.
* doc/posix-functions/accept.texi: Use clearer wording.
* doc/posix-functions/bind.texi: Likewise.
* doc/posix-functions/connect.texi: Likewise.
* doc/posix-functions/getpeername.texi: Likewise.
* doc/posix-functions/getsockname.texi: Likewise.
* doc/posix-functions/getsockopt.texi: Likewise.
* doc/posix-functions/ioctl.texi: Likewise.
* doc/posix-functions/listen.texi: Likewise.
* doc/posix-functions/recv.texi: Likewise.
* doc/posix-functions/recvfrom.texi: Likewise.
* doc/posix-functions/send.texi: Likewise.
* doc/posix-functions/sendto.texi: Likewise.
* doc/posix-functions/setsockopt.texi: Likewise.
* doc/posix-functions/shutdown.texi: Likewise.
* doc/posix-functions/socket.texi: Likewise.

7 years agopoll: Fix link error on native Windows.
Bruno Haible [Wed, 10 May 2017 22:38:03 +0000 (00:38 +0200)]
poll: Fix link error on native Windows.

* lib/poll.c [WINDOWS_NATIVE]: Undefine recv.

7 years agotime: Fix missing initialization of HAVE_TIMEZONE_T.
Bruno Haible [Wed, 10 May 2017 22:27:52 +0000 (00:27 +0200)]
time: Fix missing initialization of HAVE_TIMEZONE_T.

* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize HAVE_TIMEZONE_T
here...
* m4/sys_time_h.m4 (gl_HEADER_SYS_TIME_H_DEFAULTS): ... not here.
* m4/time_rz.m4 (gl_TIME_RZ): Require gl_HEADER_TIME_H_DEFAULTS, not
gl_HEADER_SYS_TIME_H_DEFAULTS.
* modules/time_rz (Depends-on): Add 'time'. Remove useless quoting.
(configure.ac): Remove useless quoting.

7 years agoImplement a way to opt out from MSVC support, part 2.
Bruno Haible [Wed, 10 May 2017 21:39:15 +0000 (23:39 +0200)]
Implement a way to opt out from MSVC support, part 2.

* modules/msvc-inval (Include): Document recommended idiom.
* modules/msvc-nothrow (Include): Likewise.

7 years agoImplement a way to opt out from MSVC support.
Bruno Haible [Wed, 10 May 2017 19:52:21 +0000 (21:52 +0200)]
Implement a way to opt out from MSVC support.

This is useful for Emacs.

* modules/msvc-nothrow (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/accept4.c: Include <io.h> as an alternative to msvc-nothrow.h.
* lib/error.c: Likewise.
* lib/fcntl.c: Likewise.
* lib/flock.c: Likewise.
* lib/fstat.c: Likewise.
* lib/fsync.c: Likewise.
* lib/ioctl.c: Likewise.
* lib/isapipe.c: Likewise.
* lib/lseek.c: Likewise.
* lib/nonblocking.c: Likewise.
* lib/poll.c: Likewise.
* lib/select.c: Likewise.
* lib/sockets.h: Likewise.
* lib/sockets.c: Likewise.
* lib/stdio-read.c: Likewise.
* lib/stdio-write.c: Likewise.
* lib/utimens.c: Likewise.
* lib/w32sock.h: Likewise.
* lib/w32spawn.h: Likewise.
* tests/test-cloexec.c: Likewise.
* tests/test-dup-safer.c: Likewise.
* tests/test-dup2.c: Likewise.
* tests/test-dup3.c: Likewise.
* tests/test-fcntl.c: Likewise.
* tests/test-pipe.c: Likewise.
* tests/test-pipe2.c: Likewise.
* lib/ftruncate.c: Likewise.
(chsize_nothrow): Renamed from chsize.
* lib/msvc-nothrow.c: Don't include msvc-inval.h if
HAVE_MSVC_INVALID_PARAMETER_HANDLER is not defined.
* lib/close.c: Likewise.
* lib/dup.c: Likewise.
* lib/fclose.c: Likewise.
* lib/raise.c: Likewise.
* tests/test-fgetc.c: Likewise.
* tests/test-fputc.c: Likewise.
* tests/test-fread.c: Likewise.
* tests/test-fwrite.c: Likewise.
* lib/getdtablesize.c: Likewise.
(_setmaxstdio_nothrow): Renamed from _setmaxstdio.
* lib/isatty.c: Don't include msvc-inval.h if
HAVE_MSVC_INVALID_PARAMETER_HANDLER is not defined.
Include <io.h> as an alternative to msvc-nothrow.h.
* lib/read.c: Likewise.
* lib/write.c: Likewise.
* lib/dup2.c: Likewise.
(dup2_nothrow): New function.
(ms_windows_dup2): Use it.
* m4/close.m4 (gl_FUNC_CLOSE): Invoke gl_MSVC_INVAL and test
HAVE_MSVC_INVALID_PARAMETER_HANDLER only if gl_MSVC_INVAL is defined.
* m4/dup.m4 (gl_FUNC_DUP): Likewise.
* m4/fdopen.m4 (gl_FUNC_FDOPEN): Likewise.
* m4/raise.m4 (gl_FUNC_RAISE): Likewise.
* m4/read.m4 (gl_FUNC_READ): Likewise.
* m4/write.m4 (gl_FUNC_WRITE): Likewise.
* doc/windows-without-msvc.texi: New file.
* doc/gnulib.texi (Native Windows Support without MSVC Support): New
section.

7 years agowait-process: Adjust native Windows support.
Bruno Haible [Wed, 10 May 2017 18:42:33 +0000 (20:42 +0200)]
wait-process: Adjust native Windows support.

* lib/wait-process.c: Use the usual condition for recognizing a native
Windows platform.

7 years agodoc: New chapter "Native Windows Support".
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.

7 years agodoc: Move section "Library version handling".
Bruno Haible [Wed, 10 May 2017 17:43:20 +0000 (19:43 +0200)]
doc: Move section "Library version handling".

* doc/gnulib.texi: Move section "Library version handling"
from chapter "Miscellaneous Notes" to chapter "Particular Modules".

7 years agodoc: Move section "Running self-tests under valgrind".
Bruno Haible [Wed, 10 May 2017 17:39:36 +0000 (19:39 +0200)]
doc: Move section "Running self-tests under valgrind".

* doc/gnulib.texi: Move section "Running self-tests under valgrind"
from chapter "Particular Modules" to chapter "Miscellaneous Notes".

7 years agodoc: New chapter "Build Infrastructure Modules".
Bruno Haible [Wed, 10 May 2017 17:35:44 +0000 (19:35 +0200)]
doc: New chapter "Build Infrastructure Modules".

* doc/gnulib.texi (Build Infrastructure Modules): New chapter.

7 years agoPrepare for reordering sections in the manual.
Bruno Haible [Wed, 10 May 2017 17:19:51 +0000 (19:19 +0200)]
Prepare for reordering sections in the manual.

* doc/gnulib.texi: Move several sections to separate files. Include
these files.
* doc/out-of-memory.texi: New file, extracted from doc/gnulib.texi.
* doc/obsolete.texi: Likewise.
* doc/extra-tests.texi: Likewise.
* doc/transversal.texi: Likewise.
* doc/namespace.texi: Likewise.
* doc/check-version.texi: Likewise.
* doc/windows-sockets.texi: Likewise.
* doc/windows-libtool.texi: Likewise.
* doc/licenses-texi.texi: Likewise.
* doc/build-automation.texi: Likewise.
* doc/c-locale.texi: Likewise.

7 years agoFix instructions how to update manual on www.gnu.org.
Bruno Haible [Wed, 10 May 2017 16:40:13 +0000 (18:40 +0200)]
Fix instructions how to update manual on www.gnu.org.

* doc/README: Add -I option, so that texi2dvi finds texinfo.tex.

7 years agotzset: Expand comment about TZ problem on native Windows.
Bruno Haible [Tue, 9 May 2017 19:27:27 +0000 (21:27 +0200)]
tzset: Expand comment about TZ problem on native Windows.

* lib/tzset.c (tzset): Elaborate comment, based on explanations by
Paul Eggert.
* lib/ctime.c (rpl_ctime): Likewise.
* lib/localtime.c (rpl_localtime): Likewise.
* lib/mktime.c (mktime): Likewise.
* lib/strftime-fixes.c (rpl_strftime): Likewise.
* lib/wcsftime.c (rpl_wcsftime): Likewise.

7 years agointprops: don’t depend on ‘verify’
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’.

7 years agoutimens: On native Windows, support 100ns resolution also if fd < 0.
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'.

7 years agoutimens: Improve error code on native Windows.
Bruno Haible [Sun, 7 May 2017 19:19:13 +0000 (21:19 +0200)]
utimens: Improve error code on native Windows.

* lib/utimens.c (fdutimens): If fd was not opened with O_RDWR, fail with
error code EACCES, not EINVAL.

8 years agoutime: Handle more Windows error codes.
Bruno Haible [Sun, 7 May 2017 19:09:25 +0000 (21:09 +0200)]
utime: Handle more Windows error codes.

* lib/utime.c (utime): Handle ERROR_BAD_NETPATH.
Based on explanations by Billy O'Neal.

8 years agocrypto/rijndael: Fix "strict-aliasing rules" warnings, alignment issues.
Bruno Haible [Fri, 5 May 2017 16:28:58 +0000 (18:28 +0200)]
crypto/rijndael: Fix "strict-aliasing rules" warnings, alignment issues.

* 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.

8 years agowctype-h-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 21:21:33 +0000 (23:21 +0200)]
wctype-h-c++-tests: Update.

* tests/test-wctype-h-c++.cc: Reorder to match lib/wchar.in.h.

8 years agowchar-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 21:19:40 +0000 (23:19 +0200)]
wchar-c++-tests: Update.

* tests/test-wchar-c++.cc (wcsftime): Declare, missing since 2017-04-30.

8 years agoutime-h-c++-tests: New module.
Bruno Haible [Fri, 5 May 2017 21:16:31 +0000 (23:16 +0200)]
utime-h-c++-tests: New module.

* tests/test-utime-h-c++.cc: New file.
(utime): Declare, missing since 2017-04-30.
* modules/utime-h-c++-tests: New file.

8 years agounistd-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 21:11:12 +0000 (23:11 +0200)]
unistd-c++-tests: Update.

* tests/test-unistd-c++.cc (isatty): Declare, missing since 2012-01-03.
(read): Declare, missing since 2011-04-15.
(sethostname): Declare, missing since 2011-12-03.

8 years agotime-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 21:04:27 +0000 (23:04 +0200)]
time-c++-tests: Update.

* tests/test-time-c++.cc (tzset): Declare, missing since 2017-05-01.
(localtime, gmtime): Declare, missing since 2017-04-30.
(ctime): Declare, missing since 2017-04-30.
(strftime): Declare, missing since 2017-04-30.
(tzalloc, tzfree, localtime_rz, mktime_z): Declare, missing since
2015-07-24.

8 years agosys_resource-c++-tests: New module.
Bruno Haible [Fri, 5 May 2017 20:43:41 +0000 (22:43 +0200)]
sys_resource-c++-tests: New module.

* tests/test-sys_resource-c++.cc: New file.
(getrusage): Declare, missing since 2012-04-13.
* modules/sys_resource-c++-tests: New file.

8 years agostrings-c++-tests: New module.
Bruno Haible [Fri, 5 May 2017 20:40:19 +0000 (22:40 +0200)]
strings-c++-tests: New module.

* tests/test-strings-c++.cc: New file.
(ffs): Declare, missing since 2011-07-12.
* modules/strings-c++-tests: New file.

8 years agostring-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 20:36:48 +0000 (22:36 +0200)]
string-c++-tests: Update.

* tests/test-string-c++.cc (ffsl): Declare, missing since 2011-07-15.
(ffsll): Declare, missing since 2011-07-15.

8 years agostdlib-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 20:29:18 +0000 (22:29 +0200)]
stdlib-c++-tests: Update.

* tests/test-stdlib-c++.cc (posix_openpt): Declare, missing since
2011-10-18.
(ptsname_r): Declare, missing since 2011-11-07.
(qsort_r): Declare, missing since 2014-08-29.
(random, srandom, initstate, setstate): Declare, missing since
2012-01-14.
(secure_getenv): Declare, missing since 2013-02-05.

8 years agostdio-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 20:13:37 +0000 (22:13 +0200)]
stdio-c++-tests: Update.

* tests/test-stdio-c++.cc (pclose): Declare, missing since 2011-09-18.

8 years agosignal-h-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 20:08:05 +0000 (22:08 +0200)]
signal-h-c++-tests: Update.

* tests/test-signal-h-c++.cc (raise): Remove redundant declaration.

8 years agomath-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 20:03:49 +0000 (22:03 +0200)]
math-c++-tests: Update.

* tests/test-math-c++.cc (fmaf): Declare, missing since 2011-10-17.
(fma): Declare, missing since 2011-10-17.
(fmal): Declare, missing since 2011-10-17.

8 years agolocale-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 19:57:14 +0000 (21:57 +0200)]
locale-c++-tests: Update.

* tests/test-locale-c++.cc (localeconv): Declare, missing since
2012-03-25.

8 years agointtypes-c++-tests: New module.
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.

8 years agodirent-c++-tests: Update.
Bruno Haible [Fri, 5 May 2017 19:38:07 +0000 (21:38 +0200)]
dirent-c++-tests: Update.

* tests/test-dirent-c++.cc (readdir): Declare, missing since 2011-09-13.
(rewinddir): Declare, missing since 2011-09-13.
(dirfd): Declare, missing since 2010-03-08.

8 years agoargp: Fix mistake in 2017-04-23 commit.
Bruno Haible [Thu, 4 May 2017 22:09:48 +0000 (00:09 +0200)]
argp: Fix mistake in 2017-04-23 commit.

* lib/argp-help.c (__argp_failure): If GNULIB_STRERROR_R_POSIX is set,
assume that strerror_r returns 'int', not 'char *'.

8 years agoargp: Fix typo.
Reuben Thomas [Thu, 4 May 2017 15:51:43 +0000 (17:51 +0200)]
argp: Fix typo.

* lib/argp-help.c (argp_doc): Fix spelling mistake in comment.

8 years agoutimens: port to Emacs + MS-Windows
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.

8 years agotzset: update doc for TZ problems on MS-Windows
Paul Eggert [Tue, 2 May 2017 01:00:56 +0000 (18:00 -0700)]
tzset: update doc for TZ problems on MS-Windows

* doc/posix-functions/ctime.texi,  doc/posix-functions/daylight.texi:
* doc/posix-functions/localtime.texi, doc/posix-functions/mktime.texi:
* doc/posix-functions/strftime.texi, doc/posix-functions/timezone.texi:
* doc/posix-functions/tzname.texi, doc/posix-functions/tzset.texi:
* doc/posix-functions/wcsftime.texi:
Mention some issues with TZ under MS-Windows.

8 years agocopy-file: Fix build error on mingw.
Bruno Haible [Mon, 1 May 2017 16:14:35 +0000 (18:14 +0200)]
copy-file: Fix build error on mingw.

* modules/copy-file (Depends-on): Add 'close'.

8 years agoFix recent ChangeLog entry.
Bruno Haible [Mon, 1 May 2017 15:40:15 +0000 (17:40 +0200)]
Fix recent ChangeLog entry.

8 years agotzset: Work around TZ problem on native Windows.
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.

8 years agomktime: Fix dependencies.
Bruno Haible [Mon, 1 May 2017 14:37:15 +0000 (16:37 +0200)]
mktime: Fix dependencies.

* modules/mktime (Depends-on): Add 'time'.

8 years agoNew module 'localtime-buffer', split off from module 'gettimeofday'.
Bruno Haible [Mon, 1 May 2017 14:10:46 +0000 (16:10 +0200)]
New module 'localtime-buffer', split off from module 'gettimeofday'.

* lib/localtime-buffer.h: New file.
* lib/localtime-buffer.c: New file, extracted from lib/gettimeofday.c.
* lib/time.in.h (tzset): New declaration.
(localtime, gmtime): Don't test GNULIB_GETTIMEOFDAY.
* lib/tzset.c: New file, extracted from lib/gettimeofday.c.
* lib/gettimeofday.c: Include localtime-buffer.h. Remove code that was
moved to lib/localtime-buffer.c or lib/tzset.c.
* m4/localtime-buffer.m4: New file.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize GNULIB_TZSET,
HAVE_TZSET, REPLACE_TZSET.
* m4/tzset.m4 (gl_FUNC_TZSET): Move code from m4/gettimeofday.m4 to
here, with modifications. Set HAVE_TZSET, REPLACE_TZSET. Invoke
gl_LOCALTIME_BUFFER_NEEDED.
(gl_FUNC_TZSET_CLOBBER): Don't require gl_HEADER_SYS_TIME_H; not needed
since 2007-01-18.
* m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Remove code that deals with
tzset.
(gl_FUNC_GETTIMEOFDAY_CLOBBER): Require gl_LOCALTIME_BUFFER_DEFAULTS.
Invoke gl_LOCALTIME_BUFFER_NEEDED instead of
gl_GETTIMEOFDAY_REPLACE_LOCALTIME.
(gl_GETTIMEOFDAY_REPLACE_LOCALTIME): Remove macro.
* modules/localtime-buffer: New file.
* modules/time (Depends-on): Remove 'gettimeofday'.
(Makefile.am): Substitute GNULIB_TZSET, HAVE_TZSET,
REPLACE_TZSET. Don't substitute GNULIB_GETTIMEOFDAY.
* modules/tzset (Description): Enable hyperlink to POSIX spec.
(Files): Add lib/tzset.c.
(Depends-on): Remove gettimeofday. Add localtime-buffer, time.
(configure.ac): Arrange to conditionally compile lib/tzset.c. Invoke
gl_TIME_MODULE_INDICATOR.
* modules/gettimeofday (Depends-on): Add localtime-buffer.

8 years agocopy-file: Preserve sub-second time stamps.
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.

8 years agowctype: Fix problems if <wchar.h> gets included after <wctype.h>.
Bruno Haible [Mon, 1 May 2017 10:58:28 +0000 (12:58 +0200)]
wctype: Fix problems if <wchar.h> gets included after <wctype.h>.

* lib/wctype.in.h: Include not only <ctype.h> but also <wchar.h>. Do so
also on MSVC.
Reported by Eli Zaretskii <eliz@gnu.org>.

8 years agowchar: Fix compilation error with the original mingw.org mingw.
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>.

8 years agoutimecmp: Add support for native Windows.
Bruno Haible [Mon, 1 May 2017 09:52:56 +0000 (11:52 +0200)]
utimecmp: Add support for native Windows.

* lib/utimecmp.c (SYSCALL_RESOLUTION): Set to 100 on native Windows.

8 years agoutimens: Add support for native Windows.
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>.

8 years agowcsftime: New module.
Bruno Haible [Sun, 30 Apr 2017 15:56:49 +0000 (17:56 +0200)]
wcsftime: New module.

* lib/wchar.in.h (wcsftime): New declaration.
* lib/wcsftime.c: New file.
* m4/wcsftime.m4: New file.
* m4/wchar_h.m4 (gl_WCHAR_H): Test for wcsftime declaration.
(gl_HEADER_TIME_H_DEFAULTS): Initialize GNULIB_WCSFTIME,
HAVE_WCSFTIME, REPLACE_WCSFTIME.
* modules/wchar (Makefile.am): Substitute GNULIB_WCSFTIME,
HAVE_WCSFTIME, REPLACE_WCSFTIME.
* modules/wcsftime: New file.
* doc/posix-functions/wcsftime.texi: Mention the new module.

8 years agostrftime-fixes: New module.
Bruno Haible [Sun, 30 Apr 2017 15:14:35 +0000 (17:14 +0200)]
strftime-fixes: New module.

* lib/time.in.h (strftime): New declaration.
* lib/strftime-fixes.c: New file.
* m4/strftime.m4 (gl_FUNC_GNU_STRFTIME): Inline gl_FUNC_STRFTIME macro.
(gl_FUNC_STRFTIME): Remove macro.
* m4/strftime-fixes.m4: New file.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize GNULIB_STRFTIME,
REPLACE_STRFTIME.
* modules/time (Makefile.am): Substitute GNULIB_STRFTIME,
REPLACE_STRFTIME.
* modules/strftime-fixes: New file.
* doc/posix-functions/strftime.texi: Mention the new module.

8 years agomktime: Work around TZ problem on native Windows.
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.

8 years agolocaltime: New module.
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.

8 years agoctime: New module.
Bruno Haible [Sun, 30 Apr 2017 11:19:24 +0000 (13:19 +0200)]
ctime: New module.

* lib/time.in.h (ctime): New declaration.
* lib/ctime.c: New file.
* m4/ctime.m4: New file.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize GNULIB_CTIME,
REPLACE_CTIME.
* modules/time (Makefile.am): Substitute GNULIB_CTIME, REPLACE_CTIME.
* modules/ctime: New file.
* doc/posix-functions/ctime.texi: Mention the new module.

8 years agogettimeofday: Provide higher resolution on native Windows.
Bruno Haible [Sun, 30 Apr 2017 10:15:08 +0000 (12:15 +0200)]
gettimeofday: Provide higher resolution on native Windows.

* lib/gettimeofday.c: Don't include <sys/timeb.h>.
(GetSystemTimePreciseAsFileTimeFuncType): New variable.
(initialize): Initialize it.
(gettimeofday) [WINDOWS_NATIVE]: Use it, and convert from FILETIME to
'struct timeval'. Don't use _ftime().
* m4/gettimeofday.m4 (gl_PREREQ_GETTIMEOFDAY): Don't test for
<sys/timeb.h> and _ftime.

8 years agoDocument the problem with the Cygwin environment variable TZ.
Bruno Haible [Sun, 30 Apr 2017 09:38:25 +0000 (11:38 +0200)]
Document the problem with the Cygwin environment variable TZ.

* doc/posix-functions/tzset.texi: Add note about TZ.
* doc/posix-functions/ctime.texi: Likewise.
* doc/posix-functions/localtime.texi: Likewise.
* doc/posix-functions/mktime.texi: Likewise.
* doc/posix-functions/strftime.texi: Likewise.
* doc/posix-functions/wcsftime.texi: Likewise.
* doc/pastposix-functions/ftime.texi: Likewise.

8 years agoutime-tests: New module.
Bruno Haible [Sun, 30 Apr 2017 09:13:56 +0000 (11:13 +0200)]
utime-tests: New module.

* tests/test-utime.c: New file, based on tests/test-utimens.h.
* tests/test-utimens-common.h: Include <sys/stat.h>.
* modules/utime-tests: New file.

8 years agoutime: New module.
Bruno Haible [Sun, 30 Apr 2017 01:08:46 +0000 (03:08 +0200)]
utime: New module.

* lib/utime.in.h: Add comment for snippets.
(utime): New declaration.
* lib/utime.c: New file.
* m4/utime.m4: New file.
* m4/utime_h.m4 (gl_UTIME_H): Test for utime declaration.
(gl_UTIME_H_DEFAULTS): Initialize GNULIB_UTIME, HAVE_UTIME,
REPLACE_UTIME.
* modules/utime-h (Depends-on): Add snippets.
(Makefile.am): Substitute GNULIB_UTIME, HAVE_UTIME, REPLACE_UTIME.
Insert snippets.
* modules/utime: New file.
* doc/posix-functions/utime.texi: Mention the new module.

8 years agoutime-h: Modernize handling of 'struct utimbuf'.
Bruno Haible [Sat, 29 Apr 2017 23:26:05 +0000 (01:26 +0200)]
utime-h: Modernize handling of 'struct utimbuf'.

* lib/utime.in.h: Include next <utime.h> if it exists.
(utimbuf): Define to _utimbuf on native Windows.
* m4/utime-h.m4 (gl_UTIME_H): Check for prerequisites of include_next.
Set UTIME_H on native Windows.
(gl_UTIME_MODULE_INDICATOR, gl_HEADER_UTIME_H_DEFAULTS): New macros.
* modules/utime-h (Depends-on): Add include_next.
(Makefile.am): Substitute also HAVE_UTIME_H, INCLUDE_NEXT,
PRAGMA_SYSTEM_HEADER, PRAGMA_COLUMNS, NEXT_UTIME_H.

* lib/utimens.c (utimbuf): Remove fallback definition.
* m4/utimens.m4 (gl_UTIMENS): Don't require
gl_CHECK_TYPE_STRUCT_UTIMBUF.
* m4/utimbuf.m4: Remove file.
* modules/utimens (Files): Remove m4/utimbuf.m4.

8 years agoMake use of module 'utime-h'.
Bruno Haible [Sat, 29 Apr 2017 22:03:50 +0000 (00:03 +0200)]
Make use of module 'utime-h'.

* modules/copy-file (Depends-on): Add utime-h.
* lib/copy-file.c: Assume that <utime.h> exists.
* m4/copy-file.m4 (gl_COPY_FILE): Don't test for <utime.h>.

* modules/utimens (Depends-on): Add utime-h.
* lib/utimens.c: Assume that <utime.h> exists.

8 years agoutime-h: New module.
Bruno Haible [Sun, 30 Apr 2017 08:21:22 +0000 (10:21 +0200)]
utime-h: New module.

* m4/utime_h.m4: New file.
* lib/utime.in.h: New file.
* modules/utime-h: New file.
* doc/posix-headers/utime.texi: Mention the new module.

* tests/test-utime-h.c: New file.
* modules/utime-h-tests: New file.

8 years agoFix a few typos.
Bruno Haible [Sun, 30 Apr 2017 08:15:55 +0000 (10:15 +0200)]
Fix a few typos.

* m4/fstat.m4 (gl_FUNC_FSTAT): Require AC_CANONICAL_HOST.
* m4/stat.m4 (gl_FUNC_STAT): Fix comment.
* doc/posix-functions/fstat.texi: Fix a plural typo.
* doc/posix-functions/stat.texi: Likewise.
* m4/include_next.m4: Update comments.

8 years agoerror: Fix mistake in 2017-04-23 commit.
Bruno Haible [Sat, 29 Apr 2017 21:01:39 +0000 (23:01 +0200)]
error: Fix mistake in 2017-04-23 commit.

* lib/error.c (print_errno_message): If GNULIB_STRERROR_R_POSIX is set,
assume that strerror_r returns 'int', not 'char *'.

8 years agostat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible [Sat, 29 Apr 2017 13:05:15 +0000 (15:05 +0200)]
stat: Fix time_t values and other problems on native Windows platforms.

* doc/posix-functions/stat.texi: Mention the problem with the Microsoft
implementations of stat().
* lib/stat.c: Include filename.h instead of dosname.h. Include
malloca.h, stat-w32.h.
(is_unc_root): New function.
(rpl_stat): New implementation for native Windows. Remove
REPLACE_FUNC_STAT_DIR code.
* m4/stat.m4 (gl_FUNC_STAT): On native Windows, set REPLACE_STAT always.
Don't define REPLACE_FUNC_STAT_DIR.
(gl_PREREQ_STAT): Require gl_HEADER_SYS_STAT_H.
* modules/stat (Files): Add lib/stat-w32.h, lib/stat-w32.c.
(Depends-on): Remove dosname. Add filename, malloca.
(configure.ac): Also compile lib/stat-w32.c.

8 years agofstat: Fix time_t values on native Windows platforms.
Bruno Haible [Sat, 29 Apr 2017 12:55:22 +0000 (14:55 +0200)]
fstat: Fix time_t values on native Windows platforms.

* doc/posix-functions/fstat.texi: Mention the problem with st_*time.
* lib/stat-w32.h: New file.
* lib/stat-w32.c: New file.
* lib/fstat.c: Don't include msvc-inval.h. Include msvc-nothrow.h,
stat-w32.h instead.
(fstat_nothrow): Remove function.
(rpl_fstat): Implement by means of _gl_fstat_by_handle.
* m4/fstat.m4 (gl_FUNC_FSTAT): On native Windows, set REPLACE_FSTAT
always.
(gl_PREREQ_FSTAT): Require gl_HEADER_SYS_STAT_H.
* modules/fstat (Files): Add lib/stat-w32.h, lib/stat-w32.c.
(Depends-on): Remove msvc-inval. Add pathmax, msvc-nothrow.
(configure.ac): Also compile lib/stat-w32.c.

8 years agogetopt: port to Solaris 10 with circa-1997 glibc getopt.h
Paul Eggert [Sat, 29 Apr 2017 18:09:39 +0000 (11:09 -0700)]
getopt: port to Solaris 10 with circa-1997 glibc getopt.h

Problem reported by Assaf Gordon and Gavin Smith in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00157.html
* lib/getopt-pfx-ext.h (_getopt_internal) [__GETOPT_PREFIX]:
#define this, too.

8 years agostrerror_r-posix: Fixes for MSVC 14.
Bruno Haible [Sat, 29 Apr 2017 11:23:28 +0000 (13:23 +0200)]
strerror_r-posix: Fixes for MSVC 14.

* lib/strerror_r.c: Include <stdarg.h>.
(strerror_r): Provide error messages for errno values 100...140.
* doc/posix-functions/strerror_r.texi: Mention the MSVC 14 problem.

8 years agonoreturn: New module.
Bruno Haible [Wed, 26 Apr 2017 21:25:11 +0000 (23:25 +0200)]
noreturn: New module.

* lib/noreturn.h: New file.
* modules/noreturn: New file.
* tests/test-noreturn.c: New file.
* modules/noreturn-tests: New file.
* tests/test-noreturn-c++.cc: New file.
* modules/noreturn-c++-tests: New file.

8 years agowctype-h: Fix compilation error with the original mingw.org mingw.
Bruno Haible [Thu, 27 Apr 2017 16:59:24 +0000 (18:59 +0200)]
wctype-h: Fix compilation error with the original mingw.org mingw.

* m4/wctype_h.m4 (gl_WCTYPE_H): Test for <crtdefs.h>. Set
HAVE_CRTDEFS_H.
* modules/wctype-h (Makefile.am): Substitute HAVE_CRTDEFS_H.
* lib/wctype.in.h (rpl_wint_t): If <crtdefs.h> does not exist, include
<stddef.h> instead.
Reported and proposed by Eli Zaretskii <eliz@gnu.org>.

8 years agonap.h: Fix compilation on non windows platforms
Pádraig Brady [Thu, 27 Apr 2017 04:46:55 +0000 (21:46 -0700)]
nap.h: Fix compilation on non windows platforms

* tests/nap.h: Move misplaced endif.

8 years agotime_rz: fix heap buffer overflow vulnerability
Pádraig Brady [Mon, 24 Apr 2017 08:43:36 +0000 (01:43 -0700)]
time_rz: fix heap buffer overflow vulnerability

This issue has been assigned CVE-2017-7476 and was
detected with American Fuzzy Lop 2.41b run on the
coreutils date(1) program with ASAN enabled.

  ERROR: AddressSanitizer: heap-buffer-overflow on address 0x...
  WRITE of size 8 at 0x60d00000cff8 thread T0
  #1 0x443020 in extend_abbrs lib/time_rz.c:88
  #2 0x443356 in save_abbr lib/time_rz.c:155
  #3 0x44393f in localtime_rz lib/time_rz.c:290
  #4 0x41e4fe in parse_datetime2 lib/parse-datetime.y:1798

A minimized reproducer is the following 120 byte TZ value,
which goes beyond the value of ABBR_SIZE_MIN (119) on x86_64.
Extend the aa...b portion to overwrite more of the heap.

  date -d $(printf 'TZ="aaa%020daaaaaab%089d"')

localtime_rz and mktime_z were affected since commit 4bc76593.
parse_datetime was affected since commit 4e6e16b3f.

* lib/time_rz.c (save_abbr): Rearrange the calculation determining
whether there is enough buffer space available.  The rearrangement
ensures we're only dealing with positive numbers, thus avoiding
the problematic promotion of signed to unsigned causing an invalid
comparison when zone_copy is more than ABBR_SIZE_MIN bytes beyond
the start of the buffer.
* tests/test-parse-datetime.c (main): Add a test case written by
Paul Eggert, which overwrites enough of the heap so that
standard glibc will fail with "free(): invalid pointer"
without the patch applied.
Reported and analyzed at https://bugzilla.redhat.com/1444774

8 years agoxalloc: add missing integer overflow check
Paul Eggert [Wed, 26 Apr 2017 18:38:30 +0000 (11:38 -0700)]
xalloc: add missing integer overflow check

* lib/xalloc.h (x2nrealloc): Also check for multiplication
overflow when P is null.