Bruno Haible [Mon, 22 Oct 2018 22:06:52 +0000 (00:06 +0200)]
Assume Autoconf >= 2.63.
* DEPENDENCIES: Mention the requirement.
* gnulib-tool (DEFAULT_AUTOCONF_MINVERSION): Bump to 2.63.
(func_get_filelist): Don't list m4/onceonly.m4 any more.
* pygnulib/GLModuleSystem.py (getFiles): Likewise.
* m4/onceonly.m4: Remove file.
Bruno Haible [Mon, 22 Oct 2018 00:38:39 +0000 (02:38 +0200)]
localename: Fine-tune support for per-thread locales on Solaris 11.4.
* lib/localename-table.h: New file, extracted from lib/localename.c.
* lib/localename-table.c: Likewise.
* lib/localename.c: Include localename-table.h.
(get_locale_t_name, newlocale, duplocale, freelocale): Invoke
locale_hash_function instead of pointer_hash.
* modules/localename (Files): Add lib/localename-table.h,
lib/localename-table.c.
(lib_SOURCES): Add localename-table.c.
* m4/intlsolaris.m4 (gt_INTL_SOLARIS): Require AC_CANONICAL_HOST. Test
for Solaris 11.4 locale system only on Solaris. Test for it
independently whether getlocalename_l exists.
* m4/intl.m4 (gt_INTL_SUBDIR_CORE): Don't test for 'uselocale' and
'getlocalename_l'. Instead, invoke gt_INTL_SOLARIS. Set
HAVE_NAMELESS_LOCALES.
* modules/gettext (Files): Add m4/intlsolaris.m4.
Bruno Haible [Mon, 22 Oct 2018 00:34:07 +0000 (02:34 +0200)]
Small update from gettext.
* m4/intl.m4: Update from gettext:
- 2018-01-02: Fix 'ar' invocation when cross-compiling and in 64-bit
mode on AIX.
- 2018-01-02: Don't use -lc explicitly when linking with libtool.
- 2017-05-19: (AM_INTL_SUBDIR): Require AC_C_FLEXIBLE_ARRAY_MEMBER.
Akim Demaille [Fri, 12 Oct 2018 04:46:09 +0000 (06:46 +0200)]
timevar: use gethrxtime to get wall clock time
clock_gettime is not portable. gethrxtime takes the best available
option to get the wall clock time, including clock_gettime (monotonic
clock), and gettime (non monotonic).
Also, using xtime_t instead of float preserves the precision.
Suggested by Bruno Haible.
* lib/xtime.h (xtime_make): Handle overflows of nanoseconds.
* modules/timevar (Depends-on): We need gethrxtime.
We no longer use times().
(Link): Update.
* lib/timevar.h (timevar_time_def): Use xtime_t.
* lib/timevar.c (set_to_current_time): Use gethrxtime.
(timevar_print): Instead of checking whether the timings themselves
are large enough for the timevar to be printed, check the percentages.
Bruno Haible [Sun, 14 Oct 2018 07:21:24 +0000 (09:21 +0200)]
wcsnrtombs: Work around Solaris 11.4 bug.
* m4/wcsnrtombs.m4 (gl_WCSNRTOMBS_WORKS_IN_TRADITIONAL_LOCALE): New
macro.
(gl_FUNC_WCSNRTOMBS): Invoke it.
* doc/posix-functions/wcsnrtombs.texi: Mention the Solaris bug.
Bruno Haible [Sun, 14 Oct 2018 07:19:12 +0000 (09:19 +0200)]
mbsnrtowcs: Work around Solaris 11.4 bug.
* m4/mbsnrtowcs.m4 (gl_MBSNRTOWCS_WORKS_IN_TRADITIONAL_LOCALE): New
macro.
(gl_FUNC_MBSNRTOWCS): Invoke it.
* doc/posix-functions/mbsnrtowcs.texi: Mention the Solaris bug.
* m4/floor.m4 (gl_FUNC_FLOOR_LIBS): Use 'floor' also through a function
pointer.
* m4/ceil.m4 (gl_FUNC_CEIL_LIBS): Use 'ceil' also through a function
pointer.
* m4/trunc.m4 (gl_FUNC_TRUNC): Use 'trunc' also through a function
pointer.
* m4/truncf.m4 (gl_FUNC_TRUNCF): Use 'truncf' also through a function
pointer.
* m4/truncl.m4 (gl_FUNC_TRUNCL): Use 'truncl' also through a function
pointer.
Akim Demaille [Thu, 11 Oct 2018 15:54:35 +0000 (17:54 +0200)]
timevar: expect that getrusage is available
Don't keep both times and getrusage as backend: both are guaranteed by
gnulib, a single one suffices. Using getrusage is open to possibly
tracking other types of resources in the future.
* modules/timevar (Depends-on): Add getrusage.
(configure.ac): Remove gl_TIMEVAR.
(Files): Remove m4/timevar.m4.
* m4/timevar.m4: Remove, rely on gnulib for getrusage.
* lib/timevar.h (timevar_enabled): Clarify documentation.
* lib/timevar.c: Remove all the code about times.
Remove all the CPP guards about getrusage: expect it to be present
(courtesy of gnulib).
Bruno Haible [Fri, 12 Oct 2018 09:12:53 +0000 (11:12 +0200)]
mountlist: Improve support for Solaris in 64-bit mode.
Reported by David Wood <David.Wood@deshaw.com> in
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6816>.
* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): On Solaris 8 or
newer, define MOUNTED_GETEXTMNTENT instead of MOUNTED_GETMNTENT2.
* lib/mountlist.c: Add code for MOUNTED_GETEXTMNTENT case.
Paul Eggert [Mon, 8 Oct 2018 23:53:59 +0000 (16:53 -0700)]
fts: cleanup after FTS_NOATIME removal
* lib/fts_.h (FTS_VERBATIM, FTS_OPTIONMASK, FTS_NAMEONLY)
(FTS_STOP): Shrink to minimal values. We don’t need to
worry about binary compatibility in Gnulib, and the old way
of doing things had a hole in the user options that caused
FTS_OPTIONMASK to not work as desired.
This reverts commit da4d6974013c822af1498941e32db774b2031765.
We cannot guarantee that O_NOATIME works: e.g. openat fails
with EPERM if the effective user ID of the caller does not match
the owner of the file and the caller is not privileged.
Downstream findutils has never picked up FTS_NOATIME. Discussed at
<https://lists.gnu.org/r/bug-gnulib/2018-09/msg00122.html>.
* lib/fts_.h (FTS_NOATIME): Remove bit flag.
(FTS_OPTIONMASK): Adjust.
* lib/fts.c (diropen, fts_open, fts_build): Likewise.
(fd_ring_check): Likewise.
bootstrap, gnulib-tool: use https instead of insecure rsync
The rsync command does not do any authentication and thus allows
man-in-the-middle attacks. Better use wget over https, although
this is slower.
* build-aux/bootstrap (download_po_files, po_download_command_format):
Don't try using rsync; always use wget over https to fetch PO files.
* gnulib-tool (func_import): Likewise.
* pygnulib/GLImport.py (GLImport.execute): Likewise.
bootstrap, gnulib-tool: correct the translations wget command
Using the -np (--no-parent) option doesn't prevent wget from
traversing the given URL to a default depth of 5, and since
the domain directory contains a href="/latest/" link, this
means that wget searches through all domains anyway and will
also download PO files that are meant for other packages.
When getting the PO files for the nano domain, for example,
you will end up with af.po and ast.po (and many others) too,
but there are no African nor Asturian translations for nano.
So, use the --level option instead, to stop wget from looking
any further than the given URL.
* build-aux/bootstrap (po_download_command_format2): Restrict
recursion to a single level.
* gnulib-tool (func_import): Likewise.
* pygnulib/GLImport.py (GLImport.execute): Likewise.
Bruno Haible [Fri, 5 Oct 2018 19:53:24 +0000 (21:53 +0200)]
raise: Make it possible to namespace the defined symbol.
* lib/raise.c (raise): Undefine only after the replacement function has
been defined.
(raise): Renamed from rpl_raise.
(raise_nothrow): Move to the end of the compilation unit.
Akim Demaille [Tue, 2 Oct 2018 04:19:19 +0000 (06:19 +0200)]
timevar: rely on gnulib modules for time portability.
* modules/timevar (Depends-on): Add sys_time, sys_times, and times.
* m4/timevar.m4: Don't check for clock_t and struct tms,
guaranteed by gnulib.
* lib/timevar.h: Use extern "C" protection.
Include <stdio.h> for FILE.
* lib/timevar.c: Include sys/time.h, sys/times.h unconditionally,
they are guaranteed by gnulib.
Remove uses of clock as (now useless) fallback.
Bruno Haible [Thu, 4 Oct 2018 22:22:57 +0000 (00:22 +0200)]
fcntl: Make it possible to namespace the defined symbol.
* lib/fcntl.c (fcntl): Undefine only after the replacement function has
been defined.
(fcntl): Renamed from rpl_fcntl.
(rpl_fcntl_DUPFD, rpl_fcntl_DUPFD_CLOEXEC): New functions, extracted
from fcntl.
(klibc_fcntl): Move to the end of the compilation unit.
Tom Tromey [Mon, 1 Oct 2018 20:57:45 +0000 (14:57 -0600)]
mkostemp, mkostemps: Fix compilation error in C++ mode on Mac OS X.
Attempting to use the mkostemp module in gdb caused a build failure
when using the C++ namespace feature, because mkostemp was not
declared. On OS X, mkostemp is declared in unistd.h, so this patch
extends the existing special case in stdlib.in.h to cover mkostemp and
mkostemps.
* lib/stdlib.in.h: Include <unistd.h> for mkostemp and mkostemps
on OS X.
hmac-sha512: fix hash for keys > blocksize (128 bytes)
* lib/hmac-sha512.c (hmac_sha512): Set the computed/shortened
key length to that output by sha512, not the blocksize.
Otherwise uninitialized data from the stack
is used when computing the hash.
* tests/test-hmac-sha512.c: Add a shortened key test case.
Reported at https://github.com/coreutils/gnulib/pull/5
Bruno Haible [Sun, 30 Sep 2018 17:27:56 +0000 (19:27 +0200)]
timevar: Include documentation in gnulib manual.
* doc/timevar.texi: Change node and section name to 'Profiling of
program phases'.
In the code snippets, tweak the #includes and use GNU coding style.
* doc/gnulib.texi: Include timevar.texi.
Paul Eggert [Wed, 19 Sep 2018 02:05:26 +0000 (19:05 -0700)]
dfa: tweak allocation performance
* lib/dfa.c (merge_nfa_state, dfaoptimize):
Prefer ptrdiff_t for indexes some more.
Use char for flags, as it’s wide enough.
Allocate queue and flags together, with one malloc call.
No need to use xnmalloc since the multiplication and
addition cannot overflow (it’s already been checked by
earlier allocation). Prefer memset to open-coding.
Paul Eggert [Wed, 19 Sep 2018 01:24:27 +0000 (18:24 -0700)]
dfa: prune states as we go
* lib/dfa.c (prune): Remove.
(merge_nfa_state): Prune as we go instead of at the end.
Prefer ptrdiff_t for indexes, as this helps the compiler a bit.
Simplify constraint checking a bit.
Paul Eggert [Tue, 18 Sep 2018 22:25:51 +0000 (15:25 -0700)]
dfa: reorder enum for efficiency
* lib/dfa.c (END): Now -1 again. Reorder other elements
of the enumeration to make it easier for GCC to generate
efficient code by using fewer comparisons to check for
ranges of values.
(atom): Take advantage of the reordering.
Even when similar states exist in alternation, the DFA treats them
as separate items, which may complicate the transition in NFA and
cause slowdown. This change assembles the states into one. For
example, ab|ac is changed into a(b|c). This change speeds-up
matching for many branched patterns. For example, grep speeds up
more than 30× in:
seq 10000 | sed 's/$/ abcdefghijklmnopqrstuvwxyz/; s/$/./' >in
time -p env LC_ALL=C grep -vf in in
* lib/dfa.c (prune): New function.
(merge_nfa_state): New function. It merges similar NFA states.
(dfaoptimize): New function. It seeks merged and removed nodes.
(dfaanalyze): Call new function.
(dfautf8noss): Change name from dfaoptimize because of addition of new
function.
(dfacomp): Update caller.
Simplifying the initial state enables easier optimization of the NFA.
* lib/dfa.c (enum token): Add new element BEG.
(prtok): Adjust due to adding element BEG.
(dfaparse): Put BEG at a head of tokens.
(state_index): Adjust due to adding element BEG.
(dfaanalyze): Concatenate BEG to other tokens, and simplify to
build initial state.
(dfamust): Adjust due to adding element BEG. DFAMUST ignores it.
Bruno Haible [Tue, 18 Sep 2018 20:58:23 +0000 (22:58 +0200)]
file-has-acl: Fix test failure on Cygwin 2.9.
* m4/acl.m4 (gl_FUNC_ACL): Update comments regarding Cygwin.
* lib/acl-internal.h: Likewise.
(HAVE_ACL_EXTENDED_FILE): Undefine on Cygwin.
* lib/acl-internal.c: Update comments regarding Cygwin.
* lib/acl_entries.c: Likewise.
* lib/file-has-acl.c: Likewise.
(file_has_acl): For Cygwin, use a different way to determine whether
the "default" ACL of a directory is nontrivial.
* lib/get-permissions.c: Update comments regarding Cygwin.
* lib/set-permissions.c: Likewise.
Paul Eggert [Tue, 18 Sep 2018 19:19:02 +0000 (12:19 -0700)]
doc: OS X 10.11 lacked ns time functions
According to <https://github.com/zeromq/libzmq/issues/2175>,
nanosecond-resolution timestamp functions were introduced
in macOS 10.12, so document the last version (OS X 10.11)
where they were absent.
Paul Eggert [Sun, 16 Sep 2018 21:41:36 +0000 (14:41 -0700)]
timespec: new function current_timespec
* lib/gettime.c (gettime): Prefer clock_gettime to nanotime,
and don’t worry about it failing on a CLOCK_REALTIME arg.
POSIX requires it to succeed and I don’t know of any
counterexamples where the fallbacks would work.
(current_timespec): New function, taken from Emacs. It is more
convenient than gettime, and can help register allocation.
* lib/timespec.h: Include arg-nonnull.h.
(current_timespec): New declaration.
(gettime, settime): Declare args to be nonnull.
* modules/timespec (Depends-on): Add snippet/arg-nonnull.
Bruno Haible [Sun, 16 Sep 2018 17:12:44 +0000 (19:12 +0200)]
setlocale: Improve locale handling on macOS 10.12 or newer.
* lib/setlocale.c: Include header files for CoreFoundation. Declare
gl_locale_name_canonicalize.
(libintl_setlocale): Try harder to set a locale for categories LC_CTYPE
and LC_MESSAGES.
* m4/setlocale.m4 (gl_PREREQ_SETLOCALE): Add comment.