Paul Eggert [Mon, 27 Feb 2012 07:09:05 +0000 (23:09 -0800)]
regex: re_search etc. should return -2 when memory exhausted
This bug was uncovered when testing 'grep'. Without the fix,
re_search and friends return -1 when memory is exhausted, but -1
means no match, and this causes grep to falsely report no-match
instead of memory-exhaustion. See
<http://sources.redhat.com/bugzilla/show_bug.cgi?id=13762>.
* lib/regexec.c (re_search_stub): Return -2 (not -1) if there is
trouble; this can occur if re_search_internal ran out of memory.
Bruno Haible [Mon, 27 Feb 2012 00:44:57 +0000 (01:44 +0100)]
modf-ieee: Work around test failures on *BSD, IRIX, OSF/1, Cygwin.
* m4/modf-ieee.m4: New file.
* m4/modf.m4 (gl_FUNC_MODF): If gl_FUNC_MODF_IEEE is present, test
whether modf works with NaN and Inf. Replace it if not.
* lib/math.in.h (modf): New declaration.
* lib/modf.c: New file.
* m4/math_h.m4 (gl_MATH_H): Test whether modf is declared.
(gl_MATH_H_DEFAULTS): Initialize GNULIB_MODF, REPLACE_MODF.
* modules/math (Makefile.am): Substitute GNULIB_MODF, REPLACE_MODF.
* modules/modf (Files): Add lib/modf.c.
(Depends-on): Add math, isfinite, trunc, isinf.
(configure.ac): Addrange to compile lib/modf.c if needed.
* modules/modf-ieee (Files): Add m4/modf-ieee.m4, m4/minus-zero.m4,
m4/signbit.m4.
(configure.ac): Invoke gl_FUNC_MODF_IEEE.
* tests/test-math-c++.cc: Check the declaration of modf.
* doc/posix-functions/modf.texi: Mention the modf-ieee module.
Bruno Haible [Sat, 25 Feb 2012 23:36:01 +0000 (00:36 +0100)]
fmodl, remainder*: Avoid wrong results due to rounding errors.
* lib/fmodl.c (fmodl): Correct the result if it is not within the
expected bounds.
* lib/remainderf.c (remainderf): Likewise.
* lib/remainder.c (remainder): Likewise.
* lib/remainderl.c (remainderl): Likewise.
Bruno Haible [Sat, 25 Feb 2012 12:13:59 +0000 (13:13 +0100)]
fabs tests: More tests.
* tests/test-fabs.c: Include <string.h>, minus-zero.h.
(zero): New variable.
(main): Add tests for signed zero.
* modules/fabs-tests (Files): Add tests/minus-zero.h.
Bruno Haible [Sat, 25 Feb 2012 12:13:10 +0000 (13:13 +0100)]
fabsf tests: More tests.
* tests/test-fabsf.c: Include <string.h>, minus-zero.h.
(zero): New variable.
(main): Add tests for signed zero.
* modules/fabsf-tests (Files): Add tests/minus-zero.h.
Bruno Haible [Sat, 25 Feb 2012 00:45:18 +0000 (01:45 +0100)]
atanl: Provide function definition on MSVC.
* m4/atanl.m4 (gl_FUNC_ATANL): Test also whether atanl can be used as a
function pointer.
* lib/math.in.h (atanl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:42:45 +0000 (01:42 +0100)]
acosl: Provide function definition on MSVC.
* m4/acosl.m4 (gl_FUNC_ACOSL): Test also whether acosl can be used as a
function pointer.
* lib/math.in.h (acosl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:39:34 +0000 (01:39 +0100)]
asinl: Provide function definition on MSVC.
* m4/asinl.m4 (gl_FUNC_ASINL): Test also whether asinl can be used as a
function pointer.
* lib/math.in.h (asinl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:36:41 +0000 (01:36 +0100)]
tanl: Provide function definition on MSVC.
* m4/tanl.m4 (gl_FUNC_TANL): Test also whether tanl can be used as a
function pointer.
* lib/math.in.h (tanl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:31:58 +0000 (01:31 +0100)]
cosl: Provide function definition on MSVC.
* m4/cosl.m4 (gl_FUNC_COSL): Test also whether cosl can be used as a
function pointer.
* lib/math.in.h (cosl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:30:14 +0000 (01:30 +0100)]
sinl: Provide function definition on MSVC.
* m4/sinl.m4 (gl_FUNC_SINL): Test also whether sinl can be used as a
function pointer.
* lib/math.in.h (sinl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:27:00 +0000 (01:27 +0100)]
logl: Provide function definition on MSVC.
* m4/logl.m4 (gl_FUNC_LOGL): Test also whether logl can be used as a
function pointer.
* lib/math.in.h (logl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:24:28 +0000 (01:24 +0100)]
expl: Provide function definition on MSVC.
* m4/expl.m4 (gl_FUNC_EXPL): Test also whether expl can be used as a
function pointer.
* lib/math.in.h (expl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:10:38 +0000 (01:10 +0100)]
sqrtl: Provide function definition on MSVC.
* m4/sqrtl.m4 (gl_FUNC_SQRTL): Test also whether sqrtl can be used as
a function pointer.
* lib/math.in.h (sqrtl): Undefine if it does not exist as a function.
Bruno Haible [Sat, 25 Feb 2012 00:17:22 +0000 (01:17 +0100)]
ceill: Provide function definition on MSVC.
* m4/ceill.m4 (gl_FUNC_CEILL_LIBS): Test also whether ceill can be
used as a function pointer.
* lib/math.in.h (ceill): Undefine if it is not declared as a function.
Bruno Haible [Sat, 25 Feb 2012 00:15:03 +0000 (01:15 +0100)]
floorl: Provide function definition on MSVC.
* m4/floorl.m4 (gl_FUNC_FLOORL_LIBS): Test also whether floorl can be
used as a function pointer.
* lib/math.in.h (floorl): Undefine if it is not declared as a function.
Bruno Haible [Sat, 25 Feb 2012 00:09:12 +0000 (01:09 +0100)]
ceilf: Provide function definition on MSVC.
* m4/ceilf.m4 (gl_FUNC_CEILF_LIBS): Test also whether ceilf can be
used as a function pointer.
* lib/math.in.h (ceilf): Undefine if it is not declared as a function.
Bruno Haible [Sat, 25 Feb 2012 00:07:19 +0000 (01:07 +0100)]
floorf: Provide function definition on MSVC.
* m4/floorf.m4 (gl_FUNC_FLOORF_LIBS): Test also whether floorf can be
used as a function pointer.
* lib/math.in.h (floorf): Undefine if it is not declared as a function.
Stanislav Brabec [Fri, 24 Feb 2012 20:24:44 +0000 (12:24 -0800)]
regex: fix false multibyte matches in some regular expressions
See <http://sourceware.org/bugzilla/show_bug.cgi?id=13637>
and <http://sourceware.org/ml/libc-alpha/2012-02/msg00521.html>.
* lib/regex_internal.c (re_string_skip_chars):
Fix miscomputation of remain_len that may cause incomplete
multi-byte character and false match.
Paul Eggert [Mon, 20 Feb 2012 00:12:06 +0000 (01:12 +0100)]
acl: Don't use GETACLCNT and similar ops, since they are unreliable.
- There were several instances of this pattern:
for (;;) {
n = acl (f, GETACLCNT, 0, NULL);
[ allocate an array A of size N ]
if (acl (f, GETACL, n, a) == n)
break;
}
This loop might never terminate if some other process is constantly
manipulating the file's ACL. The loop should be rewritten to
terminate.
- The acl (... GETACLNT ...) call is merely an optimization; its value
is merely a hint as to how big to make the array. A better
optimization is to avoid the acl (... GETACLNT ...) call entirely,
and just guess a reasonably-big size, growing the size and trying
again if it's not large enough. This guarantees termination, and
saves a system call.
* lib/acl-internal.h: Include <limits.h>.
(MIN, SIZE_MAX): New macros.
* lib/file-has-acl.c (file_has_acl) [Solaris]: Read the entries into
a stack-allocated buffer, and use malloc if it does not fit. Don't
use GETACLCNT.
* lib/set-mode-acl.c (qset_acl) [Solaris]: Likewise.
Bruno Haible [Sun, 19 Feb 2012 21:17:05 +0000 (22:17 +0100)]
acl: Fix endless loop on Solaris with vxfs.
* lib/file-has-acl.c (file_has_acl) [Solaris]: Treat a failing
acl()/facl() call for ACE_GETACL like a failing call for ACE_GETACLCNT.
* lib/set-mode-acl.c (qset_acl) [Solaris]: Likewise.
* lib/copy-acl.c (qcopy_acl)[Solaris]: Likewise.
* tests/test-sameacls.c (main)[Solaris]: Likewise.
Reported by Bill Jones in
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10639>, via Paul Eggert.
Bruno Haible [Sun, 19 Feb 2012 20:59:07 +0000 (21:59 +0100)]
acl: Fix copy-acl test failure on Solaris 11 2011-11.
* lib/file-has-acl.c (NEW_ACE_WRITEA_DATA): New macro.
(acl_ace_nontrivial): Relax the restrictions on access_masks[] so
that this function returns 0 in some more cases.
Bruno Haible [Sun, 19 Feb 2012 14:06:52 +0000 (15:06 +0100)]
Fix test failure in many locales on Solaris 11.
* tests/test-pipe-filter-gi1.c (main): Don't use range expression in
'tr' arguments.
* tests/test-pipe-filter-ii1.c (main): Likewise.
* build-aux/bootstrap (check_versions): Run 'tr' command with range
expressions in the C locale.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_POSIX): Likewise.
* m4/host-os.m4 (gl_HOST_OS): Likewise.
GNUmakefile: simplify detection of unconfigured trees
* top/GNUmakefile: Use $(wildcard) instead of $(shell) to determine
whether the tree make is being run from is already configured or
not. Related simplifications.