Bruno Haible [Mon, 20 Feb 2017 21:34:24 +0000 (22:34 +0100)]
lock tests: Fix build failure on z/OS.
Reported by Daniel Richard G. <skunk@iskunk.org>.
* modules/lock-tests (configure.ac): Test for <semaphore.h>.
* tests/test-lock.c (USE_SEMAPHORE): Don't set if <semaphore.h> does not
exist.
Paul Eggert [Thu, 16 Feb 2017 08:17:56 +0000 (00:17 -0800)]
xbinary-io: rename from xsetmode
This patch is taken from suggestions by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00060.html
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00061.html
* lib/binary-io.c (__gl_setmode_check): Set errno to EINVAL,
not ENOTTY, when it is an inappropriate device.
* lib/binary-io.h (SET_BINARY): Resurrect.
* lib/xbinary-io.c: Rename from lib/xsetmode.c.
(xset_binary_mode_error): Rename from xsetmode_error.
* lib/xbinary-io.h: Rename from lib/xsetmode.h.
(xset_binary_mode): Rename from xsetmode.
All uses changed.
* modules/xbinary-io: Rename from modules/xsetmode.
Update file names.
* tests/test-binary-io.sh (tmpfiles): Remove no-longer-used file name.
* NEWS: Update to match revised behavior.
Paul Eggert [Wed, 15 Feb 2017 22:30:33 +0000 (14:30 -0800)]
xsetmode: new module
This is to fix a problem noted by Eric Blake.
Code was using xfreopen to change files to binary mode, but this
fails for stdout when in append mode. Such code should use
xsetmode instead.
* NEWS: Document incompatible changes to binary-io module.
* lib/binary-io.c (__gl_setmode_check) [__DJGPP__ || __EMX__]:
New function.
* lib/binary-io.h (__gl_setmode): Rename from set_binary_mode.
(set_binary_mode): New function, which also checks for tty.
* lib/xsetmode.c, lib/xsetmode.h, modules/xsetmode: New files.
Darshit Shah [Mon, 13 Feb 2017 17:40:33 +0000 (18:40 +0100)]
unicase: Update function protoype to match definition
* lib/unicase/special-casing.h (gl_unicase_special_lookup): Gperf 3.1
uses 'size_t' as the datatype for the 'len' parameter in the functions
it generates. Update the prototype specified here to match the newly
generated function.
Paul Eggert [Sun, 12 Feb 2017 08:11:46 +0000 (00:11 -0800)]
glob: port better to emscripten
Problem reported by Bruno Haible in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-02/msg00031.html
* lib/glob.c (glob): Don't assume HAVE_GETPWNAM_R || _LIBC.
Bruno Haible [Sat, 11 Feb 2017 12:41:49 +0000 (13:41 +0100)]
host-cpu-c-abi: Support for 64-bit AIX, 32-bit armhf on arm64, hppa64.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Define also HOST_CPU.
For the x32 ABI on x86_64, set HOST_CPU_C_ABI to 'x86_64-x32' and define
both __x86_64__ and __x86_64_x32__. For the ELFv2 ABI on powerpc64,
define both __powerpc64__ and __powerpc64_elfv2__. Recognize 64-bit
compilation on AIX. Recognize 32-bit compilation on arm64/Linux.
Distinguish hppa64 from hppa.
Bruno Haible [Tue, 31 Jan 2017 23:13:21 +0000 (00:13 +0100)]
lock: Fix link error (regression from 2017-01-05).
* lib/glthread/lock.h [USE_POSIX_THREADS_WEAK]: Declare also
pthread_rwlockattr_init, pthread_rwlockattr_setkind_np,
pthread_rwlockattr_destroy weak.
Reported by Tom G. Christensen <tgc@jupiterrise.com>.
Paul Eggert [Tue, 31 Jan 2017 02:20:43 +0000 (18:20 -0800)]
Port to PGI 16.10 x86-64
This patch fixes one real bug in gl_anylinked_list2.h, along with
some minor glitches that are not bugs. It does not silence PGI’s
thousands of bogus warnings when compiling test-intprops.c.
Fortunately, the warnings do not cause a failure.
* lib/c-ctype.h (_C_CTYPE_LOWER_A_THRU_F_N, _C_CTYPE_LOWER_N):
Rename parameter to avoid PGI warning about ‘#define f(n) 'n'’.
My goodness, PGI goes back a long ways - this predates C89!
* lib/gl_anylinked_list2.h (ASYNCSAFE): Fix bug caught by PGI.
For example, ASYNCSAFE (const void *) should expand to
‘const void *volatile’, not to ‘volatile const void *’.
* lib/spawn.in.h (POSIX_SPAWN_USEVFORK): Don't define if already defined.
* lib/verify.h (verify) [!__GNUC__]:
Use shorter albeit meaningless string to bypass silly compiler limits.
* tests/infinity.h (Infinityf, Infinityd, Infinityl) [__PGI]:
* tests/nan.h (NaNf, NaNd, NaNl):
Use static functions to avoid misguided compiler diagnostics.
Is there some reason we don’t use static functions on all platforms?
Paul Eggert [Sat, 21 Jan 2017 01:11:55 +0000 (17:11 -0800)]
parse-datetime: handle timezones reentrantly
This API change was prompted by a report by Pádraig Brady in:
https://bug.debian.org/851934#10
To help fix the bug, make parse_datetime2 more reentrant.
* NEWS: Document this incompatible change.
* lib/parse-datetime.h, lib/parse-datetime.y (parse_datetime2):
Add two arguments, the timezone and the timezone name.
All callers changed. If TZ="..." is specified, use it for
calculating defaults.
* lib/parse-datetime.y: Don't include xalloc.h or use xmalloc, as
this code should be usable in a library.
(mktime_ok, get_effective_timezone):
Accept timezone arg too. All callers changed.
(get_tz): Remove.
(get_effective_timezone): Check for failures.
* modules/parse-datetime: Add time_r, time_rz. Remove xalloc.
Eric Blake [Thu, 19 Jan 2017 20:26:30 +0000 (14:26 -0600)]
localename: port to cygwin 2.6
Cygwin 2.6 introduced uselocale() and thread-local locales in general,
but lacks any way to get at the name of each portion of a locale_t
object short of peeking behind an opaque object. Cygwin has just
been patched to add NL_LOCALE_NAME() patterned after glibc's
extension of the same name[1], but as that version of Cygwin has not
yet been released, we might as well work around it in the meantime.
* lib/localename.c (gl_locale_name_thread_unsafe): Add clause for
Cygwin.
* modules/localename (Depends-on): Add extensions, since
NL_LOCALE_NAME() is not visible without it.
Bruno Haible [Mon, 16 Jan 2017 21:07:51 +0000 (22:07 +0100)]
host-cpu-c-abi: Add support for armhf, arm64, x32, s390x.
* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI): Require gl_C_ASM. On x86_64
systems, distinguish x86_64 and x32. On arm systems, distinguish arm,
armhf, arm64, and no longer distinguish arm and armel. On s390x systems,
distinguish s390 and s390x.
* modules/host-cpu-c-abi (Files): Add m4/asm-underscore.m4.
* NEWS: Mention the change regarding 'armel'.
Paul Eggert [Mon, 16 Jan 2017 05:23:34 +0000 (21:23 -0800)]
localeinfo: case_folded_counterparts and WEOF
* NEWS: Document this.
* lib/localeinfo.c (case_folded_counterparts):
First arg is now wint_t, not wchar_t. This generalizes the
function to also work on WEOF, where it returns 0.
Paul Eggert [Sat, 14 Jan 2017 19:35:34 +0000 (11:35 -0800)]
strftime: %z is -00 if unknown
* lib/strftime.c (DO_TZ_OFFSET): Omit arg 'negative'; it's now
the caller's responsibility to set 'negative_number'. All uses changed.
(__strftime_internal): Put '-' before a zero UTC offset if the time
zone abbreviation starts with "-", which is the recently-introduced
tzdb convention for an unknown UTC offset that is arbitrarily set to 0.
* tests/test-strftime.c: Test for this.
Paul Eggert [Tue, 10 Jan 2017 22:35:34 +0000 (14:35 -0800)]
dfa: port to older GCC
Problem reported by Assaf Gordon in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00103.html
* modules/c99: New module. This merely attempts to use the latest
C version, which should be enough to solve this particular problem.
The idea is to document which Gnulib modules assume C99 or later.
* modules/dfa (Depends-on): Add it.
Paul Eggert [Tue, 10 Jan 2017 06:48:46 +0000 (22:48 -0800)]
dfa: shrink constraints from 4 bits to 3
* lib/dfa.c (newline_constraint, letter_constraint)
(other_constraint, prev_newline_dependent)
(prev_letter_dependent, NO_CONSTRAINT, BEGLINE_CONSTRAINT)
(ENDLINE_CONSTRAINT, BEGWORD_CONSTRAINT, ENDWORD_CONSTRAINT)
(LIMWORD_CONSTRAINT, NOTLIMWORD_CONSTRAINT):
Constraints need only 3 bits, not 4. Using smaller integers
shrinks the code a bit and makes grep a tad faster on x86-64.
Paul Eggert [Mon, 9 Jan 2017 19:49:35 +0000 (11:49 -0800)]
maint: remove stray .texi files
Although these were superseded by other files like
doc/posix-functions/ctime.texi, the old files were not removed.
* doc/ctime.texi, doc/inet_ntoa.texi: Remove.
Norihiro Tanaka [Sun, 8 Jan 2017 22:46:13 +0000 (07:46 +0900)]
dfa: simplify transition table allocation
* src/dfa.c (realloc_trans_if_necessary): Remove second argument.
Its value is derived from other variable. Update callers.
(dfastate): Remove calculation of max number of state.
Paul Eggert [Sun, 8 Jan 2017 20:44:29 +0000 (12:44 -0800)]
dfa: fix reallocation bug when matching newlines
Problem reported for sed by S. Gilles (Bug#25390).
* lib/dfa.c (realloc_trans_if_necessary): Move earlier.
(dfastate): Reallocate before moving any newline transition ...
(build_state): ... instead of reallocating here, where it is too late.
Paul Eggert [Sat, 7 Jan 2017 00:14:21 +0000 (16:14 -0800)]
getprogname: port to IRIX
* lib/getprogname.c (getprogname): Port to IRIX.
Based on an idea by Bastien Roucariès at:
http://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00096.html
via code from Bruno Haible at:
https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00249.html
Paul Eggert [Fri, 6 Jan 2017 21:36:57 +0000 (13:36 -0800)]
glob, intprops, xalloc: work around Clang bug
Work around LLVM bug 16404, which is still not fixed.
https://llvm.org/bugs/show_bug.cgi?id=16404
Problem reported by Nelson H. F. Beebe.
* lib/glob.c, lib/intprops.h, lib/xalloc-oversized.h (__has_builtin):
Remove.
* lib/glob.c (size_add_wrapv):
* lib/intprops.h (_GL_HAS_BUILTIN_OVERFLOW, _GL_HAS_BUILTIN_OVERFLOW_P):
* lib/xalloc-oversized.h (xalloc_oversized):
Do not use overflow builtins if Clang.
Pádraig Brady [Tue, 3 Jan 2017 00:52:13 +0000 (00:52 +0000)]
parse-datetime: fix generated paths for coverage files
* modules/parse-datetime: Adjust the paths for parse-datetime.y
within parse-datetime.c, so that gcc generates appropriate .gcno
files, allowing lcov to proceed without error. Previously it
would error trying to find "lib/lib/parse-datetime.y".
Pádraig Brady [Mon, 2 Jan 2017 21:31:49 +0000 (21:31 +0000)]
maint.mk: support parallel execution of coverage
* top/maint.mk (coverage): Run dependencies serially,
thus supporting parallel processing of each one,
particularly build-coverage, which builds and runs tests.
Bruno Haible [Thu, 5 Jan 2017 11:51:36 +0000 (12:51 +0100)]
lock: Provide guarantee to avoid writer starvation for rwlocks.
The rationale is: 1) Read-preferring read-write locks are prone to
writer starvation if the number of reader threads multiplied by the
percentage of time they have the lock held is too high. 2) Write-
preferring read-write locks are the only reliable way to avoid this.
3) There have been reports of 'test-lock' hanging on glibc systems
http://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00009.html,
and glibc indeed implements read-preferring rwlocks by default, see
http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html
and https://sourceware.org/bugzilla/show_bug.cgi?id=13701 .
* m4/pthread_rwlock_rdlock.m4: New file.
* m4/lock.m4 (gl_LOCK): Invoke gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER.
* lib/glthread/lock.h [USE_POSIX_THREADS]: Test
HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER. Use a different implementation
of rwlock initialization on glibc systems without
HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER. Use a different implementation
of rwlocks altogether on non-glibc systems without
HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER.
[USE_PTH_THREADS]: Use a different implementation of rwlocks altogether.
* lib/glthread/lock.c [USE_POSIX_THREADS]
(glthread_rwlock_init_for_glibc): New function.
[USE_POSIX_THREADS] (glthread_rwlock_rdlock_multithreaded): Update
comment.
[USE_PTH_THREADS]: New implementation of rwlocks.
[USE_WINDOWS_THREADS] (glthread_rwlock_rdlock_func): Prefer writers over
readers.
* modules/lock (Files): Add m4/pthread_rwlock_rdlock.m4.
(Depends-on): Add 'extensions'.
* tests/test-rwlock1.c: New file.
* lock-tests (Files): Add it.
(Depends-on): Add usleep.
(Makefile.am): Add test-rwlock1 to the tests.
Bruno Haible [Thu, 5 Jan 2017 10:04:52 +0000 (11:04 +0100)]
thread: Fix pth port.
* lib/glthread/thread.h (pth_init): Declare weak.
(glthread_create, glthread_sigmask, glthread_join, gl_thread_self,
gl_thread_exit): Make sure Pth is initialized before invoking any Pth
function.
Assaf Gordon [Thu, 5 Jan 2017 04:22:22 +0000 (23:22 -0500)]
parse-datetime: fix debug message on lone year number
Input dates such as
date -d "Apr 11 22:59:00 2011"
are parsed as date (Apr 11, with default year 2016), then time, then a
number (2011). Based on the combination of previously seen tokens,
'digits_to_date_time' determines 2011 to be a year value.
This fixes the debug messages to correctly show the updated year.
Before:
$ date --debug -d 'Apr 11 22:59:00 2011'
date: parsed date part: (Y-M-D) 2016-04-11
date: parsed time part: 22:59:00
date: parsed number part: today/this/now
After:
$ ./src/date --debug -d 'Apr 11 22:59:00 2011'
date: parsed date part: (Y-M-D) 2016-04-11
date: parsed time part: 22:59:00
date: parsed number part: year: 2011
* lib/parse-datetime.y (struct parser_control): Add 'year_seen',
'debug_year_seen' member fields.
(digits_to_date_time): Update 'year_seen' as needed.
(debug_print_current_time): Inform about year updates.
(parse_datetime2): Initialize year_seen,debug_year_seen member fields.
Assaf Gordon [Thu, 5 Jan 2017 04:19:51 +0000 (23:19 -0500)]
parse-datetime: fix local timezone debug messages
"Local timezones" are strings that affect only DST relative to the
default timezone. The debug messages in parse-datetime.y printed
wrong information when encountering local timezones.
Examples:
Here EET/EEST are time zones ('zone' token, with values +02:00/+03:00):
TZ=Asia/Tokyo ./src/date --debug -d '2011-12-11 EET'
TZ=Asia/Tokyo ./src/date --debug -d '2011-06-11 EEST'
When the default timezone relates to the zone strings, EET/EEST are
parsed as local timezones (tLOCAL_ZONE), and only change the DST
value (0/1, respectively):
TZ=Europe/Helsinki ./src/date --debug -d '2011-12-11 EET'
TZ=Europe/Helsinki ./src/date --debug -d '2011-06-11 EEST'
* lib/parse-datetime.y (debug_print_current_time): If local timezone was
seen, inform about DST change, don't print actual timezone.
(debug_strfdatetime): If local timezone was seen, use default timezone
(and adjust as needed) instead of using incorrect timezone.
(parse_datetime2): Use correct time-zone source string, and adjust
default timezone as needed.
Assaf Gordon [Thu, 5 Jan 2017 04:14:37 +0000 (23:14 -0500)]
parse-datetime: add debug warning about DST changes
Incorrect date arithmetic due to daylight saving time (DST) are a
common (false) bug report in coreutils.
Detect two such cases and print a warning:
1. year/month/day adjustments (performed on 'struct tm'),
where 'mktime' returns a different isdst value.
2. hour/minute/seconds/ns adjustments (performed on 'time_t'),
where the result of 'localtime(3)' on the value will return a
different isdst value.
Note: DST changes could be harmless or unnoticeable.
Examples (with 'TZ=America/New_York'):
Unnoticeable: result is 2016-Dec-14
$ date -d '2016-06-15 EDT + 6 months' +%b
Dec
Unnoticeable: result is 2016-Dec-15 11:00:00
$ date -d '2016-06-15 12:00:00 EDT + 6 months' +%F
2016-12-15
This is unexpected:
$ date -d '2016-06-01 EDT + 6 months' +%F
2016-11-30
The new debug warnings will show:
$ ./src/date --debug -d '2016-06-01 EDT + 6 months' +%F
...
date: warning: daylight saving time changed after date adjustment
...
* lib/parse-datetime.y (parse_datetime2): Detect DST changes, and print
an appropriate warning message.
Assaf Gordon [Thu, 5 Jan 2017 04:11:33 +0000 (23:11 -0500)]
parse-datetime: add debug warning about date arithmetic
Date arithmetic are done directly on the fields of 'struct tm',
which can result in invalid dates. Normalization with 'mktime(3)'
will then produce a different date - which might cause unexpected results.
Examples:
'2016-10-31 - 1 month' => 2016-09-31 normalized to 2016-10-01.
'2016-02-29 + 1 year' => 2017-02-29 normalized to 2017-03-01.
Note that date normalization is not inherently wrong and not rejected,
as it has legitimate uses:
'2016-12-29 + 5 days' => 2016-12-34 noramlized to 2017-01-03.
If the user asked to adjust months but 'mday' changed,
or user asked to adjust years but 'month' changed - warn about it.
$ ./src/date --debug -d '2016-10-31 - 1 month'
...
date: warning: when adding relative months/years, \
it is recommended to specify the 15th of the month
...
date: warning: month/year adjustment resulted in shifted dates:
date: adjusted Y M D: 2016 09 31
date: normalized Y M D: 2010 10 01
...
* lib/parse-datetime.y (parse_datetime2): Detect such cases and print
a warning message. Improve recommendation of when to use 15 of the month
or noon for date arithmetic.
Assaf Gordon [Thu, 5 Jan 2017 04:07:12 +0000 (23:07 -0500)]
parse-datetime: fix debug message of relative part after timezone
Relative part (e.g '+8 days') after a timezone string was not reported
(was only reported after a timezone number). Due to the parser's structure,
timezone strings with numbers were handled separately.
Paul Eggert [Tue, 3 Jan 2017 00:05:14 +0000 (16:05 -0800)]
doc: modernize for C11 etc.
* doc/gnulib-readme.texi (Portability guidelines): Modernize a bit
for C11, MinGW, etc. This responds to Paul Smith's question in:
http://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00014.html
Paul Eggert [Mon, 2 Jan 2017 20:22:17 +0000 (12:22 -0800)]
dfa: prefer functions to FETCH_WC macro
* lib/dfa.c (FETCH_WC): Remove, replacing with ...
(fetch_wc, bracket_fetch_wc): ... new functions. These store the
wint_t result into DFA->lex.wctok instead of to a separate arg.
All callers changed. Move more local decls closer to where
they're used.
Paul Eggert [Mon, 2 Jan 2017 05:23:18 +0000 (21:23 -0800)]
dfa: prefer functions and constants to macros
* lib/dfa.c: Prefer constants to macros where either will do.
(streq, isasciidigit, newline_constraint)
(letter_constraint, other_constraint, succeeds_in_context)
(prev_newline_constraint, prev_letter_constraint)
(prev_other_constraint, prev_newline_dependent)
(prev_letter_dependent, accepting, accepts_in_context):
Now static functions instead of function-like macros.
Use lower-case names accordingly. All uses changed.
Jim Meyering [Sat, 31 Dec 2016 16:06:24 +0000 (08:06 -0800)]
dfa: narrow the scope of many local variables
* lib/dfa.c: Now that we are no longer constrained to c89, move
declarations of many variables (often indices) "down" into the
scope(s) where used or to the point of definition. This is a
no-semantic-change diff.
Paul Eggert [Sun, 1 Jan 2017 02:59:23 +0000 (02:59 +0000)]
version-etc: new year
* build-aux/gendocs.sh (version):
* doc/gendocs_template:
* doc/gendocs_template_min:
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR):
Update copyright dates by hand in templates and the like.
* all files: Run 'make update-copyright'.
Tagging during a rebase doesn't make sense, but it at least should
not choke with:
$ ./build-aux/do-release-commit-and-tag 1.4.18 stable
./build-aux/do-release-commit-and-tag: line 146: test: too many arguments
do-release-commit-and-tag: not on branch (no branch, rebasing branch-1.4)
* build-aux/do-release-commit-and-tag (curr_br): $branch can
contain spaces when rebasing.
Eric Blake [Sat, 31 Dec 2016 02:37:10 +0000 (20:37 -0600)]
maint.mk: hoist gnulib_dir definition earlier
Commit 1894933 introduced a temporary warning during all uses of 'make':
Can't open /lib/intprops.h: No such file or directory.
due to an early evaluation of $(shell) prior to the default definition
of $(gnulib_dir). While that has been fixed in commit ffff79d, hoisting
the definition to the top will prevent further edits from inadvertently
reintroducing the problem.
* top/maint.mk (gnulib_dir): Move near top of file.
Jim Meyering [Sat, 31 Dec 2016 09:31:59 +0000 (01:31 -0800)]
maint.mk: do not always evaluate intprops-related shell
* top/maint.mk (_intprops_names): Change := to just "=" to avoid
using gnulib_dir undefined (gnulib_dir is defined later in the
file, which will be fixed separately), and besides, there is no
need to incur the cost of this shell invocation for every single
use of this .mk file. Reported by Eric Blake in
https://lists.gnu.org/archive/html/bug-gnulib/2016-12/msg00137.html
Paul Eggert [Fri, 30 Dec 2016 08:42:22 +0000 (00:42 -0800)]
dfa: simplify multibyte_prop etc.
This follows up on a change made when dfa.c was in grep, namely grep
commit c797046c7c13c2647182b919a79a4c5b4ecf82b1
dated 2015-08-12 07:35:03 -0700, which removed unused multibyte support.
That earlier simplification allows for some more simplification
and trimming down here.
* lib/dfa.c (struct mb_char_classes): New member nchars_alloc.
(struct lexer_state): New mamber brack.
(struct dfa, addtok_mb): multibyte_prop elements are now char, not int,
since they must be in the range 0..3 now.
Remove members mbcsets, nmbcsets, mbcsets_alloc, since
the brack member now supersedes them.
(parse_bracket_exp): Update dfa->lex.brack instead of dfa->mbcsets.
(addtok): Use dfa->lex.brack instead of dfa->mbcsets.
(dfaparse): Remove unnecessary initializations of already-0 storage.
(free_mbdata): Free d->lex.brack.chars instead of d->mbcsets.
(dfassbuild): No need to clear sup->mbcsets.
Paul Eggert [Fri, 30 Dec 2016 05:44:17 +0000 (21:44 -0800)]
dfa: wrap charclass inside a struct
This lets GCC check for aliases more accurately.
On my platform (gcc Ubuntu 5.4.0-6ubuntu1~16.04.4 x86-64,
en_US.utf8 locale) this makes 'grep -Fi -f list.txt list.txt >out'
about 1% faster, where list.txt is generated by 'aspell dump
master | head -n 100000 >list.txt'. Also, it shrinks the grep
text by 64 bytes, woohoo! See Bug#22239.
* lib/dfa.c (charclass): Wrap inside a struct. All uses changed.
(CHARCLASS_INIT, tstbit, setbit, clrbit, zeroset, fillset, notset)
(equal, emptyset, charclass_index, setbit_wc, setbit_case_fold_c):
Adjust to this, e.g., by using charclass * rather than charclass.
All callers changed as needed.
(copyset): Remove. All uses changed to simple assignment.
(parse_bracket_exp): Use zeroset instead of memset.
Eric Blake [Thu, 29 Dec 2016 21:05:34 +0000 (15:05 -0600)]
getopt: fix parallel test failure
I hit a testsuite failure due to a failure removing test-getopt.tmp,
when running tests in parallel.
* tests/test-getopt-posix.c (TEST_GETOPT_TMP_NAME): Set name.
* tests/test-getopt-gnu.c (TEST_GETOPT_TMP_NAME): Likewise.
* tests/test-getopt-main.h (main): Use different file names
in case test-getopt-gnu and test-getopt-posix run in parallel.
Bruno Haible [Sat, 24 Dec 2016 17:21:59 +0000 (18:21 +0100)]
lock test: Fix performance problem on multi-core machines.
* tests/test-lock.c (USE_VOLATILE): New macro.
(struct atomic_int): New type.
(init_atomic_int, get_atomic_int_value, set_atomic_int_value): New
functions.
(lock_checker_done, rwlock_checker_done, reclock_checker_done): Define
as 'struct atomic_int'.
(lock_checker_thread, test_lock, rwlock_checker_thread, test_rwlock,
reclock_checker_thread, test_recursive_lock): Use the new functions.
Reported by Eric Blake in
https://www.redhat.com/archives/libvir-list/2012-March/msg00854.html
and by Pádraig Brady in
http://lists.gnu.org/archive/html/bug-gnulib/2016-12/msg00117.html.
Paul Eggert [Mon, 19 Dec 2016 16:20:45 +0000 (08:20 -0800)]
getopt-posix-tests: fix Makefile typo
* modules/getopt-posix-tests (test_getopt_posix_LDADD):
Fix typo: the last ‘_’ was missing in the name.
I suspect that the typo explains this build failure:
https://buildfarm.opencsw.org/buildbot/builders/ggrep-solaris10-sparc/builds/39
although I can’t reproduce the problem on Solaris 10 sparc.
Paul Eggert [Mon, 19 Dec 2016 01:35:19 +0000 (17:35 -0800)]
dfa: improve worst-case 'replace' performance
See my note in Bug#22357#71.
* lib/dfa.c (insert, delete): Rework to avoid duplicate test.
(merge_constrained): New function, which is like
the old 'merge' function, except with a new argument C2.
Simplify the body by avoiding the need for different sections
of code depending on whether one input is exhausted.
(merge): Use the new function.
(delete): Return the constraint of the deleted position,
not the entire position. Caller changed.
(replace): Change from O(N*(N + log N)) to O(N log N) algorithm.