]> Savannah Git Hosting - gnulib.git/log
gnulib.git
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.

8 years agoparse-datetime: make it standalone
Paul Eggert [Tue, 25 Apr 2017 18:58:30 +0000 (11:58 -0700)]
parse-datetime: make it standalone

* lib/parse-datetime.y: Include <stdarg.h>, for va_start etc.
(_GL_ATTRIBUTE_FORMAT): New macro.
These are needed to get './gnulib-tool --test parse-datetime' to work.

8 years agonap.h: Port to native Windows.
Bruno Haible [Sun, 23 Apr 2017 17:19:35 +0000 (19:19 +0200)]
nap.h: Port to native Windows.

* tests/nap.h (nap_get_stat): Renamed from get_stat. Remove argument fd;
use nap_fd instead. On native Windows, close and reopen nap_fd.
(nap_works): Don't compare the ctimes, because on native Windows, these
are the creation times.
(nap): Update.

8 years agonap.h: Fix logic.
Bruno Haible [Sun, 23 Apr 2017 17:09:32 +0000 (19:09 +0200)]
nap.h: Fix logic.

* tests/nap.h (nap): Avoid signed integer overflow in loop.

8 years agoFix conflict between strerror_r-posix module and AC_FUNC_STRERROR_R.
Bruno Haible [Sun, 23 Apr 2017 17:02:08 +0000 (19:02 +0200)]
Fix conflict between strerror_r-posix module and AC_FUNC_STRERROR_R.

* modules/strerror_r-posix (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/error.c: Test GNULIB_STRERROR_R_POSIX before testing
HAVE_DECL_STRERROR_R, HAVE_STRERROR_R, or STRERROR_R_CHAR_P.
* lib/argp-help.c (__argp_failure): Likewise.

8 years agostrerror_r-posix: Revert commits from 2016-10-16,2016-11-04,2016-11-14.
Bruno Haible [Sun, 23 Apr 2017 16:27:44 +0000 (18:27 +0200)]
strerror_r-posix: Revert commits from 2016-10-16,2016-11-04,2016-11-14.

* m4/strerror_r.m4: Revert changes since 2016-10-16.
* lib/strerror_r.c: Likewise.

8 years agoTarget a C99 subset, not a C89 subset
Paul Eggert [Mon, 24 Apr 2017 03:54:35 +0000 (20:54 -0700)]
Target a C99 subset, not a C89 subset

For many years Gnulib has targeted C89 and has resisted using C99
features, as some Gnulib-using programs still wanted to target
C89.  As this no longer seems to be the case, relax the porting
requirements to allow some C99 features.  This is merely a change
to the documentation, to give other Gnulib developers a chance to
weigh in on the topic.
* doc/extern-inline.texi (extern inline):
* doc/gnulib-readme.texi (Portability guidelines):
* doc/gnulib-tool.texi (Initial import):
* doc/gnulib.texi (Header files):
Modernize to talk about C99 and C11 instead of C89 and C99.
* doc/gnulib-readme.texi (Portability guidelines):
Now a section, not merely a subsection, so that it
can be split up.  Modernize a bit.
(C language versions, C99 features assumed)
(C99 features avoided):
New sections.

8 years agodoc: New section "Modules that modify the way other modules work".
Bruno Haible [Sun, 23 Apr 2017 16:06:19 +0000 (18:06 +0200)]
doc: New section "Modules that modify the way other modules work".

* doc/gnulib.texi (Modules that modify the way other modules work): New
section.

8 years agostat-time: Update comments.
Bruno Haible [Sun, 23 Apr 2017 11:18:16 +0000 (13:18 +0200)]
stat-time: Update comments.

* lib/stat-time.h: Fix reference regarding st_ctime on Windows.
* tests/test-utimens-common.h: Add reference regarding st_ctime on
Windows.

8 years agoglob: Fix more memory leaks.
Bruno Haible [Sat, 1 Apr 2017 13:15:18 +0000 (15:15 +0200)]
glob: Fix more memory leaks.

* lib/glob.c (glob): Free allocated memory before returning.
Reported by Coverity via Tim Rühsen.

8 years agopoll: improve fast check for out-of-range NFD
Paul Eggert [Sun, 23 Apr 2017 01:48:39 +0000 (18:48 -0700)]
poll: improve fast check for out-of-range NFD

* lib/poll.c: Do not include intprops.h.
(poll): Compare NFD to INT_MAX, not to TYPE_MAXIMUM (nfds_t) / 2.
* modules/poll (Depends-on): Remove intprops.

8 years agoftoastr: cite a newer paper
Paul Eggert [Sun, 23 Apr 2017 01:34:07 +0000 (18:34 -0700)]
ftoastr: cite a newer paper

* lib/ftoastr.c (FTOASTR): In comment, cite Andrysco et al. 2016
instead of Loitsch 2010.

8 years agopoll: Enable argument check also in the Windows implementation.
Bruno Haible [Sun, 23 Apr 2017 01:25:10 +0000 (03:25 +0200)]
poll: Enable argument check also in the Windows implementation.

* lib/poll.c (poll) [WINDOWS_NATIVE]: Check value of nfd correctly.
Reported by Paul Eggert.

8 years agogetlogin_r: Work around bug in Mac OS X 10.12.
Bruno Haible [Sun, 23 Apr 2017 00:45:19 +0000 (02:45 +0200)]
getlogin_r: Work around bug in Mac OS X 10.12.

* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Test also against the Mac OS X
bug.
* lib/getlogin_r.c (getlogin_r): When getlogin_r returns a string of the
given size minus 1, call getlogin_r a second time, on a larger buffer.
* modules/getlogin_r (Depends-on): Add malloca.
* doc/posix-functions/getlogin_r.texi: Mention the Mac OS X bug.

8 years agoparse-datetime: fix %z and prefer signed int
Paul Eggert [Sat, 22 Apr 2017 22:13:24 +0000 (15:13 -0700)]
parse-datetime: fix %z and prefer signed int

%z problem reported by Pádraig Brady in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00103.html
While fixing it, I decided to prefer signed ints to size_t, as
they are less error-prone (e.g., ubsan catches overflow).
* lib/parse-datetime.y (textint, parser_control, lookup_word, yylex)
(parse_datetime2): Prefer ptrdiff_t to size_t for sizes and object
counts, since signed integers make for better debugging.
(date): Don’t assume %z works in printf formats.
(debug_strfdatetime, debug_strfdate, debug_strftime): Use int for
sizes of buffers known to be small, e.g., because we’re using snprintf.
(parse_datetime2): Simplify call to debug_mktime_not_ok.

8 years ago*printf: Work around rounding bug on Mac OS X.
Bruno Haible [Sat, 22 Apr 2017 14:27:45 +0000 (16:27 +0200)]
*printf: Work around rounding bug on Mac OS X.

* m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Test for Mac OS X 10.12 bug.
* doc/posix-functions/*printf.texi: Mention the rounding bugs of
Mac OS X and FreeBSD.
* doc/glibc-functions/*printf.texi: Likewise.

8 years agovasnprintf tests: Avoid warnings.
Bruno Haible [Sat, 22 Apr 2017 12:51:37 +0000 (14:51 +0200)]
vasnprintf tests: Avoid warnings.

* tests/test-vasnprintf-posix3.c (test_function, my_asnprintf,
test_vasnprintf, test_asnprintf): Don't define if there's nothing to
test.

8 years agosys_file tests: Avoid warning.
Bruno Haible [Sat, 22 Apr 2017 12:43:23 +0000 (14:43 +0200)]
sys_file tests: Avoid warning.

* tests/test-sys_file.c (main): Add a default clause to the switch
statement.

8 years agosethostname: Update doc.
Bruno Haible [Sat, 22 Apr 2017 12:39:09 +0000 (14:39 +0200)]
sethostname: Update doc.

* doc/glibc-functions/sethostname.texi: Mention differing prototype on
Mac OS X.

8 years agoquotearg tests: Avoid warnings.
Bruno Haible [Sat, 22 Apr 2017 12:24:36 +0000 (14:24 +0200)]
quotearg tests: Avoid warnings.

* tests/test-quotearg.c: Don't include test-quotearg.h if ENABLE_NLS is
false.

8 years agopoll: Enable argument check.
Bruno Haible [Sat, 22 Apr 2017 12:18:45 +0000 (14:18 +0200)]
poll: Enable argument check.

* lib/poll.c: Include intprops.h.
(poll): Check value of nfd correctly.
* modules/poll (Depends-on): Add intprops.

8 years agoget-rusage-data: Avoid warnings on Mac OS X.
Bruno Haible [Sat, 22 Apr 2017 11:51:02 +0000 (13:51 +0200)]
get-rusage-data: Avoid warnings on Mac OS X.

* lib/get-rusage-data.c: On Mac OS X, don't define
get_rusage_data_via_setrlimit nor get_rusage_data_via_iterator.
(get_rusage_data) [Mac OS X]: Just return 0.

8 years agoxbinary-io: Fix build error.
Bruno Haible [Sat, 22 Apr 2017 10:02:38 +0000 (12:02 +0200)]
xbinary-io: Fix build error.

* modules/xbinary-io (Depends-on): Add gettext-h.
* lib/xbinary-io.c: Include gettext.h and define _().
Reported by Gisle Vanem <gisle.vanem@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00089.html>.

8 years agoparse-datetime: overflow and debug cleanups
Paul Eggert [Sat, 22 Apr 2017 09:11:26 +0000 (02:11 -0700)]
parse-datetime: overflow and debug cleanups

This long patch was triggered by this bug report from Ruediger Meier:
http://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00028.html
I fixed the bug he noted, then found some others nearby, and then
still others.  Oh my goodness, there were a lot of bugs.  I cleaned
up some of the code to follow GNU standards while I was at it.
* lib/parse-datetime.y (ISDIGIT): Remove; all callers changed to
use c_isdigit.
(EPOCH_YEAR): Remove; unused.
(TM_YEAR_BASE): Now an enum rather than a macro.
(HOUR, debug_strfdatetime): Multiply hour by 3600, not 60, to get
time zone offset, since timezones now are in terms of seconds and
not minutes.
(long_time_t): Remove.  All uses replaced by time_t or intmax_t as
appropriate.  Verify that intmax_t is wide enough.
(time_overflow, time_zone_str): New functions, used to deal
more reliably with overflow.
(dbg_printf): Add printf attribute, to help catch integer width errors.
(textint, relative_time, parser_control, time_zone_hhmm, set_hhmmss)
(%union, to_hour, yylex, parse_datetime2):
Use intmax_t instead of long int and/or long_time_t.
All uses changed.
(DBGBUFSIZE): Move earlier.
(relative_time, set_hhmmss, parser_control):
Just use int for nanoseconds and for time zones; that’s wide enough.
(parser_control): Use bool for members like year_seen that can
be booleans instead of counters.  All uses changed.
Remove debug_default_input_timezone; no longer needed.
All uses removed.
(apply_relative_time): Return a bool overflow flag.
All uses changed to check for overflow.
(apply_relative_time, zone, date, relunit, relunit_snumber)
(signed_seconds, unsigned_seconds, yylex, parse_datetime2):
Check for integer overflow portably.
(str_days): Use just int for N, as it’s wide enough.
Prefer 2D char arrays to arrays of char * when it looks like
2D is a win on typical platforms.
Prefer snprintf to strncpy/strncat, for simplicity;
all buffers are smaller than INT_MAX so this is safe.
(TIME_ZONE_BUFSiZE, TM_YEAR_BUFSIZE): New constants.
(debug_print_current_time): Don’t assume tv_nsec is of type long,
as this is not true on x32.  Output "." before any nanoseconds.
(debug_print_current_time, parse_datetime2):
Output local zones using a more-consistent format.
(debug_print_current_time, date, parse_datetime2):
(main) [TEST]:
Don’t assume time_t is the same width as long.
(print_rel_part): New function, replacing ...
(PRINT_REL_PART): ... this macro, which was removed.  All uses changed.
(debug_print_relative_time): Use bool for boolean.
(local_zone): dsts_seen now counts only tDST instances.
(date): Fix printf of size_t to use %z.  Do not assume numeric
tokens have negative values merely because the context suggests
a syntax with "-" separating tokens.
(time_zone_hhmm): Return bool success indicator, which checks for
overflow.  Store result into PC->time_zone instead.  All callers
changed.
(tm_year_str): New function.  Return a bool success indicator and
store the result into a buffer.  All callers changed.  Output the
numerically correct string even if adding 1900 to the year would
overflow.
(to_tm_year): New function, replacing the old to_year.  All
callers changed.
(tm_diff): Sync with glibc.
(lookup_word): Use to_uchar instead of doing it by hand.
(TZBUFSIZE): Now local to the only function that needs it.
(debug_strfdatetime): Simplify now that time zones are int seconds.
(debug_strfdate): Work even if tm_year + 1900 would overflow.
(get_effective_timezone): Remove.  All uses removed.
(parse_datetime2): Use fprintf in pieces instead of snprintfing
to a fixed-size buffer.  Don’t assume that gmtime succeeds iff
localtime succeeds.  Use tm_gmtoff if available.  Simplify how
‘goto fail;’ works in conjunction with the ‘ok’ flag.
* m4/parse-datetime.m4 (gl_PARSE_DATETIME): Don’t define
TIME_T_FITS_IN_LONG_INT, as it is no longer needed.
* modules/parse-datetime (Depends-on): Add inttypes.

8 years agogettext-h: Avoid -Wundef warning.
Bruno Haible [Fri, 21 Apr 2017 23:37:22 +0000 (01:37 +0200)]
gettext-h: Avoid -Wundef warning.

* lib/gettext.h: Test the value of ENABLE_NLS only if it is defined.
Reported by Tim Rühsen <tim.ruehsen@gmx.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2017-04/msg00022.html>.

8 years agoerror: Avoid "function declaration isn't a prototype" warning.
Tim Rühsen [Wed, 5 Apr 2017 13:58:22 +0000 (15:58 +0200)]
error: Avoid "function declaration isn't a prototype" warning.

* lib/error.c (strerror_r): Turn K&R C prototype to an ANSI C prototype.

8 years agovasnprintf: Fix for MSVC 14.
Bruno Haible [Fri, 21 Apr 2017 15:24:48 +0000 (17:24 +0200)]
vasnprintf: Fix for MSVC 14.

* lib/vasnprintf.c (USE_MSVC__SNPRINTF): New macro.
Everywhere, use !HAVE_SNPRINTF_RETVAL_C99 || USE_MSVC__SNPRINTF instead
of !HAVE_SNPRINTF_RETVAL_C99.

8 years agombrtowc tests: Fix test failures on MSVC 14.
Bruno Haible [Fri, 21 Apr 2017 14:55:49 +0000 (16:55 +0200)]
mbrtowc tests: Fix test failures on MSVC 14.

* tests/test-mbrtowc-w32.c (test_one_locale): Accept MSVC's conversion
behaviour for invalid input.

8 years agombsinit: Fix for MSVC 14.
Bruno Haible [Fri, 21 Apr 2017 14:43:01 +0000 (16:43 +0200)]
mbsinit: Fix for MSVC 14.

* lib/mbsinit.c (mbsinit): If GNULIB_defined_mbstate_t, provide an
implementation that is in sync with mbrtowc.c. On other platforms, use
an adequate ad-hoc implementation.