Bruno Haible [Thu, 2 Jun 2011 22:10:00 +0000 (00:10 +0200)]
pipe2: Remove dependency on 'nonblocking' module.
* lib/pipe2.c: Include verify.h. Include nonblocking.h only if
O_NONBLOCK is defined by gnulib.
(pipe2) [WIN32]: If O_NONBLOCK is not defined by gnulib, verify that it
is zero.
* modules/pipe2 (Depends-on): Add verify. Remove nonblocking.
* tests/test-pipe2.c: Include nonblocking.h only if O_NONBLOCK is
defined by gnulib.
(get_nonblocking_flag): New function.
(main): Test O_NONBLOCK flag only if it is nonzero.
Jim Meyering [Fri, 3 Jun 2011 15:35:07 +0000 (17:35 +0200)]
maint.mk: add three prohibit-header-without-use rules
Prohibit use of cloexec.h, posixver.h, same.h without use.
* top/maint.mk (sc_prohibit_cloexec_without_use): New rule.
(sc_prohibit_posixver_without_use): Likewise.
(sc_prohibit_same_without_use): Likewise.
Paul Eggert [Thu, 2 Jun 2011 08:15:18 +0000 (01:15 -0700)]
allocator: 'die' routine is now given requested size
* lib/allocator.h (struct allocator.die): New size arg.
* lib/careadlinkat.c (careadlinkat): Pass size to 'die' function.
If the actual problem is an ssize_t limitation, not a size_t or
malloc failure, fail with errno==ENAMETOOLONG instead of calling 'die'.
Eric Blake [Tue, 24 May 2011 21:33:49 +0000 (15:33 -0600)]
strerror: drop strerror_r dependency
Since the errno module is responsible for introducing replacement
errno values, it should also be responsible for translating those
new values into strings. And by moving the replacements into a
file managed by the errno, we can then break the dependency between
strerror and strerror_r, so that strerror no longer drags in
multi-threading modules required by strerror_r.
Eric Blake [Tue, 24 May 2011 20:27:04 +0000 (14:27 -0600)]
perror: call strerror_r directly
No need to make a wrapper that burns static storage when we can
just use stack storage.
* modules/perror (Files): Drop strerror-impl.h.
* lib/perror.c (perror): Use our own stack buffer, rather than
calling a wrapper that uses static storage.
* doc/posix-functions/perror.texi (perror): Document a limitation
of our replacement.
Bruno Haible [Tue, 31 May 2011 21:31:26 +0000 (23:31 +0200)]
Fix link errors in tests: openat-die uses gettext-h.
* modules/areadlinkat-tests (Makefile.am): Link test-areadlinkat
against $(LIBINTL).
* modules/dirent-safer-tests (Makefile.am): Link test-dirent-safer
against $(LIBINTL).
* modules/fdopendir-tests (Makefile.am): Link test-fdopendir against
$(LIBINTL).
* modules/fdutimensat-tests (Makefile.am): Link test-fdutimensat
against $(LIBINTL).
* modules/linkat-tests (Makefile.am): Link test-linkat against
$(LIBINTL).
* modules/mkfifoat-tests (Makefile.am): Link test-mkfifoat against
$(LIBINTL).
* modules/openat-safer-tests (Makefile.am): Link test-openat-safer
against $(LIBINTL).
* modules/openat-tests (Makefile.am): Link test-fchownat, test-fstatat,
test-mkdirat, test-openat, test-unlinkat against $(LIBINTL).
* modules/readlinkat-tests (Makefile.am): Link test-readlinkat against
$(LIBINTL).
* modules/symlinkat-tests (Makefile.am): Link test-symlinkat against
$(LIBINTL).
* modules/utimensat-tests (Makefile.am): Link test-utimensat against
$(LIBINTL).
Reported by Tom G. Christensen <tgc@jupiterrise.com>.
Bruno Haible [Mon, 30 May 2011 22:44:51 +0000 (00:44 +0200)]
Fix link errors in tests: wait-process uses gettext-h.
* modules/nonblocking-pipe-tests (Makefile.am): Set
test_nonblocking_pipe_main_LDADD.
* modules/nonblocking-socket-tests (Makefile.am): Link
test-nonblocking-socket-main against $(LIBINTL).
Reported by Tom G. Christensen <tgc@jupiterrise.com>.
Bruno Haible [Sat, 28 May 2011 18:58:14 +0000 (20:58 +0200)]
wctype-h: Avoid namespace pollution on Solaris 2.6.
* lib/wctype.in.h: On Solaris, undefine 'multibyte' and a few other
identifiers.
* doc/posix-headers/wctype.texi: Mention the problem.
Reported by Tom G. Christensen <tgc@jupiterrise.com>.
Bruno Haible [Sun, 29 May 2011 12:57:40 +0000 (14:57 +0200)]
argp: Allow coexistence with strerror_r-posix module.
* lib/argp-help.c (__argp_failure): If strerror_r is defined as a macro
(either to __xpg_strerror_r by glibc's <string.h> or to rpl_strerror_r
by gnulib's <string.h> replacement), assume it has the POSIX signature,
not the glibc signature.
Bruno Haible [Sat, 28 May 2011 23:24:28 +0000 (01:24 +0200)]
gnulib-tool: Alternative structure of testdirs, similar to --import.
* gnulib-tool: New option --single-configure.
(func_usage): Document it.
(single_configure): New variable.
(func_modules_transitive_closure_separately,
func_modules_transitive_closure_separately,
func_determine_use_libtests, func_modules_add_dummy_separately,
func_modules_to_filelist_separately): New functions, extracted from
func_import.
(func_emit_tests_Makefile_am): Handle $single_configure = true case.
(func_import): Use the new functions.
(func_create_testdir): Set final_modules. Handle $single_configure =
true case.
Bruno Haible [Sat, 28 May 2011 20:06:11 +0000 (22:06 +0200)]
getloadavg: Remove an unreliable safety check.
* m4/getloadavg.m4 (gl_GETLOADAVG): Drop argument. Remove test whether
getloadavg.c is in place.
* modules/getloadavg (configure.ac): Drop argument of gl_GETLOADAVG.
Reported by Sam Steingold <sds@gnu.org>.
Bruno Haible [Sat, 28 May 2011 15:08:17 +0000 (17:08 +0200)]
Finish the conditional dependencies mechanism.
* gnulib-tool: New option --no-conditional-dependencies.
(func_usage): Document it. Don't mark --conditional-dependencies as
experimental.
(cond_dependencies): The possible values can now be true, false, empty.
(func_modules_transitive_closure, func_emit_autoconf_snippets): Update.
(func_import): Store setting in gnulib-cache.m4 and read it from there.
* doc/gnulib-tool.texi (Conditional dependencies): New section.
James Youngman [Thu, 26 May 2011 00:45:13 +0000 (01:45 +0100)]
getopt: for ambiguous options, enumerate the possibilities.
* lib/getopt.c (_getopt_internal_r): Merge glibc change printing
the ambiguous options when an ambiguous prefix is given. This was
http://sourceware.org/bugzilla/show_bug.cgi?id=7101. The merged
glibc change was
http://sourceware.org/git/?p=glibc.git;a=commit;h=bd25564e1e98910ed69043ed6a6f884ce60e5780.
Paul Eggert [Tue, 24 May 2011 23:47:01 +0000 (16:47 -0700)]
test-intprops: disable -Wtype-limits diagnostics
* tests/test-intprops.c: Use a pragma to ignore -Wtype-limits
diagnostics. Otherwise, the integer overflow macros generate many
diagnostics. Reported by Jim Meyering in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00528.html>.
Paul Eggert [Tue, 24 May 2011 23:45:14 +0000 (16:45 -0700)]
intprops: shorten, to pacify gcc -Woverlength-strings
* lib/intprops.h (_GL_INT_CONVERT, _GL_INT_NEGATE_CONVERT):
(_GL_BINARY_OP_OVERFLOW): Say "0 * (x)" rather than "(x) - (x)",
so that, for example, verify (INT_MULTIPLY_OVERFLOW (...)) is less
likely to run afoul of C compiler limits for string constant lengths.
See <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00528.html>.
Eric Blake [Wed, 18 May 2011 21:19:51 +0000 (15:19 -0600)]
strerror_r: enforce POSIX recommendations
POSIX recommends (but does not require) that strerror_r populate
buf even on error. But since we guarantee this behavior for
strerror, we might as well also guarantee it for strerror_r.
* lib/strerror_r.c (safe_copy): New helper method.
(strerror_r): Guarantee a non-empty string.
* tests/test-strerror_r.c (main): Enhance tests to incorporate
recent POSIX rulings and to match our strerror guarantees.
* doc/posix-functions/strerror_r.texi (strerror_r): Document this.
Eric Blake [Tue, 24 May 2011 16:14:52 +0000 (10:14 -0600)]
perror: avoid spurious test failure on HP-UX
The previous command has non-zero status. Even though 'exit 0'
is supposed to ignore prior status, HP-UX /bin/sh favors the
prior status if an exit trap is installed.
* tests/test-perror.sh: Use Exit to avoid wrong exit status.
Eric Blake [Tue, 24 May 2011 16:04:46 +0000 (10:04 -0600)]
tests: fix logic bug in init.sh
If the shell test loop first finds a marginal then a good shell, the
variable $gl_set_x_corrupts_stderr is still set to true and needlessly
drops $VERBOSE logging.
* tests/init.sh: (gl_set_x_corrupts_stderr_): Clear for successful
shell.
Jim Meyering [Tue, 24 May 2011 16:24:24 +0000 (18:24 +0200)]
utimensat: do not reference an out-of-scope buffer
Otherwise, with __linux__ defined, "times" would point to a buffer, "ts"
declared in an inner scope, yet "times" would be dereferenced outside
the scope in which "ts" was valid.
* lib/utimensat.c (rpl_utimensat) [__linux__]: Move the declaration
of ts[2] "out/up", so that the use of aliased "times" (via "times = ts;")
does not end up referencing an out-of-scope "ts"
Jim Meyering [Tue, 24 May 2011 11:44:41 +0000 (13:44 +0200)]
opendir-safer.c: don't clobber errno; don't close negative FD
* lib/opendir-safer.c (opendir_safer):
[HAVE_FDOPENDIR || GNULIB_FDOPENDIR]: Don't close a negative
file descriptor, and more importantly, don't clobber the
offending errno value with EINVAL. Before, upon failure
of dup_safer, we would pass the negative file descriptor to
fdopendir, which would clobber errno.
Paul Eggert [Mon, 23 May 2011 22:02:43 +0000 (15:02 -0700)]
gnulib-tool: fix portability problem with MacOS sed
A sed command like "/x/{s/a/b/}" is not portable; a newline is needed
before the "}". Problem reported by Leo in
<http://lists.gnu.org/archive/html/emacs-devel/2011-05/msg00717.html>.
* gnulib-tool (sed_dependencies_without_conditions):
Jim Meyering [Mon, 23 May 2011 15:15:30 +0000 (17:15 +0200)]
maint.mk: more tight_scope improvements
* top/maint.mk: (_gl_TS_var_match): Use $(_gl_TS_extern) here, too.
(_gl_TS_headers): Define only in if-0'd block.
(_gl_TS_dir): Omit the $(srcdir)/ prefix. Sometimes we need it,
sometimes we must *not* use it. Adjust uses accordingly.
(sc_tight_scope): Use much simpler grep-based test to determine
whether we skip this rule.
Jim Meyering [Mon, 23 May 2011 07:12:06 +0000 (09:12 +0200)]
maint.mk: generalize/improve the tight-scope rule
* top/maint.mk: Emit a warning when the test is skipped.
(_gl_TS_dir): Add $(srcdir)/ prefix.
(_gl_TS_function_match): Simplify, rather than trying
to enumerate common types. Otherwise, it would fail to match an
"extern unsigned char const *" declaration in idutils.
(_gl_TS_extern): Do not endorse use of "XTERN", but do provide
a way to support use of that type of macro.
(_gl_TS_var_match): Simplify regexp.
(_gl_TS_obj_files): New configurable variable.
(_gl_TS_headers): Likewise.
Paul Eggert [Mon, 23 May 2011 01:36:04 +0000 (18:36 -0700)]
verify: fix bug when gnulib <assert.h> is also included
* lib/verify.h (verify, verify_true): Define if _GL_VERIFY_H
is defined, not if _GL_STATIC_ASSERT_H is not defined.
Perhaps there's a better way, but this fixes the immediate problem.
Problem reported by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00478.html>.
Bruno Haible [Sun, 22 May 2011 14:39:23 +0000 (16:39 +0200)]
New module 'mktime-internal'.
* modules/mktime-internal: New file.
* m4/timegm.m4 (gl_PREREQ_TIMEGM): Move contents to ...
* m4/mktime.m4 (gl_FUNC_MKTIME_INTERNAL): New macro. Define
mktime_internal as a C macro if libc has __mktime_internal.
* modules/timegm (Depends-on): Add mktime-internal. Remove mktime. Add
conditions.
* MODULES.html.sh (Date and time <time.h>): Add mktime-internal.
Eric Blake [Sat, 21 May 2011 16:08:28 +0000 (10:08 -0600)]
strerror_r: avoid clobbering strerror on cygwin
Avoid cygwin strerror_r, since it clobbers strerror buffer through
cygwin 1.7.9. __xpg_strerror_r is okay, but if a program is
compiled on cygwin 1.7.8 or earlier, it is not available.
* lib/strerror_r.c (strerror_r): Don't use cygwin's strerror_r;
fall back instead to sys_errlist.
* modules/strerror (configure.ac): Add witness.
* tests/test-strerror_r.c (main): Enhance test.
* doc/posix-functions/strerror_r.texi (strerror_r): Document it.
* tests/test-perror2.c (main): Free memory before exit.
Paul Eggert [Fri, 20 May 2011 18:30:16 +0000 (11:30 -0700)]
intprops: remove assumption about A|B representation
* lib/intprops.h (_GL_BINARY_OP_OVERFLOW): Do not assume that A|B
is a valid integer if both A and B are. Although this is true for
all known practical hosts, the C standard doesn't guarantee it,
and the code need not assume it. Also, this change may work around
HP-UX 11.23 and IRIX 6.5 cc bugs reported by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00426.html>.
Eric Blake [Fri, 20 May 2011 17:09:53 +0000 (11:09 -0600)]
perror: work around FreeBSD bug
POSIX requires that 'errno = 0; perror ("")' print the same message
as strerror(0), but this failed if we were replacing strerror to work
around the FreeBSD bug of treating 0 as a failure.
The goal here is to _not_ replace perror on glibc, even though
strerror_r has to be replaced, because the strerror_r replacement is
only for the sake of correcting the signature rather than working
around bugs in the handling of any particular errnum value. Recall
that $gl_cv_func_strerror_r_works is only set if the POSIX signature
was detected in the first place.
* m4/perror.m4 (gl_FUNC_PERROR): Also replace perror if strerror_r
is broken. Move AC_LIBOBJ...
* modules/perror (configure.ac): Here.
* doc/posix-functions/perror.texi (perror): Document this.
* tests/test-perror2.c (main): Enhance test.
Eric Blake [Fri, 20 May 2011 16:42:26 +0000 (10:42 -0600)]
test-perror: check for strerror interactions
This uncovered a glibc bug, although not many people check for
perror failures, so for now I'm not working around it.
http://sourceware.org/bugzilla/show_bug.cgi?id=12792
Jim Meyering [Fri, 20 May 2011 09:53:34 +0000 (11:53 +0200)]
maint: replace misused "a" with "an"
* doc/intprops.texi: "a integer"
* doc/regex.texi: "a explanation"
* lib/alignof.h: "a object"
* lib/argmatch.h: "a explanation"
* lib/argp-help.c: "a option" and "a OPTION_DOC"
* lib/stdint.in.h: "a integer"
* lib/userspec.c: "a owner"
* doc/gnulib.texi: Fix "a idea", and reword.
Paul Eggert [Fri, 20 May 2011 02:16:43 +0000 (19:16 -0700)]
intprops-tests: work around HP-UX 11.23 cc bug with constants
* tests/test-intprops.c (VERIFY): New macro.
(main): Use it, instead of verify, to work around the compiler bug; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.
Paul Eggert [Fri, 20 May 2011 02:16:04 +0000 (19:16 -0700)]
intprops: work around IRIX 6.5 cc bug with 0u - 0u + -1
See http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html
* lib/intprops.h (_GL_INT_NEGATE_CONVERT): New macro.
(_GL_INT_SIGNED, _GL_INT_MAXIMUM, _GL_DIVIDE_OVERFLOW):
(_GL_REMAINDER_OVERFLOW): Use it.
Paul Eggert [Fri, 20 May 2011 02:15:19 +0000 (19:15 -0700)]
intprops-tests: revert unsigned part of previous change
* tests/test-intprops.c (UINT_MAX, ULONG_MAX, UINTMAX_MAX, U0, U1):
Remove; they weren't actually needed. All uses of U0 and U1 removed,
and other casts to 'unsigned int' reverted to 'u' suffixes. See
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>.
Eric Blake [Thu, 19 May 2011 19:35:39 +0000 (13:35 -0600)]
strerror_r: guarantee unchanged errno
POSIX guarantees that strerror doesn't change errno on success,
and since we implement strerror by using strerror_r, it makes
sense to make the same guarantee for strerror_r (rather, going
one step further to say that sterror_r does not corrupt errno,
since it returns an error value explicitly).
See also http://austingroupbugs.net/view.php?id=447
* lib/strerror_r.c (strerror_r): Guarantee unchanged errno.
* lib/strerror-impl.h (strerror): Set errno to match strerror_r
failure.
* tests/test-strerror_r.c (main): Enhance test.
Bruno Haible [Thu, 19 May 2011 19:49:01 +0000 (21:49 +0200)]
perror: Avoid clobbering the strerror buffer when possible.
* lib/strerror-impl.h: New file, extracted from lib/strerror.c.
* lib/strerror.c: Include it.
* modules/strerror (Files): Add lib/strerror-impl.h.
* lib/perror.c: Include <stdlib.h>, intprops.h, verify.h.
(my_strerror): New function, defined through lib/strerror-impl.h.
(perror): Use it instead of strerror.
* modules/perror (Files): Add lib/strerror-impl.h.
(Depends-on): Remove strerror. Add intprops, verify, strerror_r-posix.
Bruno Haible [Thu, 19 May 2011 18:57:21 +0000 (20:57 +0200)]
strerror_r: Avoid clobbering the strerror buffer when possible.
* lib/strerror.c: Define _NETBSD_SOURCE. Include <nl_types.h>.
(sys_nerr, sys_errlist): New declarations.
(strerror_r): Be careful not to clobber the strerror buffer on NetBSD,
HP-UX, native Win32, IRIX, and 32-bit Solaris.
* m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Test whether catgets exists.
Bruno Haible [Thu, 19 May 2011 18:45:59 +0000 (20:45 +0200)]
strerror_r: Fix test failure on mingw.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Don't define
EXTEND_STRERROR_R.
* lib/strerror_r.c (strerror_r): Test the various GNULIB_defined_*
macros from errno.in.h instead.
Eric Blake [Thu, 19 May 2011 16:17:18 +0000 (10:17 -0600)]
strerror: relax test for Solaris
Solaris returns "Error 0" for 0 vs. "Unknown error" for -1; while that
does not quite have the positive connotation that POSIX recommends, it
is distinct enough that we do not need to replace the native strerror
just to pick a better string.
The test is really trying to reject implementations that use the same
string for both 0 and 1 (modulo any %d output of the error number).
* tests/test-strerror.c (main): Permit Solaris behavior.
* tests/test-strerror_r.c (main): Likewise.
Paul Eggert [Thu, 19 May 2011 08:43:17 +0000 (01:43 -0700)]
intprop-tests: port to older and more-pedantic compilers
* modules/intprops-tests (Files): Add tests/macros.h.
* tests/test-intprops.c: Include macros.h.
(TYPE_IS_INTEGER): Use ASSERT, not verify, to test this macro, as
it's no longer documented to expand to an integer constant expression.
(TYPE_SIGNED): Use ASSERT, not verify, to test this macro when the
argument is floating point, as it's no longer documented to expand
to an integer constant expression in that case.
(UINT_MAX, ULONG_MAX, UINTMAX_MAX): Redefine to work around
compiler bugs reported by Bruno Haible. See
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.
(U0, U1): New constants, to work around the same bugs. Also,
in tests, use e.g., "(unsigned int) 39" rather than "39u".
Paul Eggert [Thu, 19 May 2011 08:36:25 +0000 (01:36 -0700)]
intprops: work around C compiler bugs
* lib/intprops.h (INT_MULTIPLY_RANGE_OVERFLOW): Work around compiler
bug in Sun C 5.11 2010/08/13 and other compilers; see
<http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.
Paul Eggert [Thu, 19 May 2011 08:34:14 +0000 (01:34 -0700)]
intprops: TYPE_IS_INTEGER, TYPE_SIGNED not integer constant exprs
* doc/intprops.texi (Integer Type Determination): Fix
documentation for TYPE_IS_INTEGER: it returns an constant
expression, not an integer constant expression. Fix doc for
TYPE_SIGNED: it returns an integer constant expression only if its
argument is an integer type. (TYPE_IS_INTEGER is the same, but is
hardly worth documented that way....)