summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.x-sc_file_system1
-rw-r--r--.x-sc_useless_cpp_parens1
-rw-r--r--ChangeLog429
-rw-r--r--Makefile.maint104
-rw-r--r--NEWS33
-rw-r--r--README12
-rw-r--r--README-hacking (renamed from README-cvs)27
-rw-r--r--THANKS1
-rw-r--r--TODO6
-rwxr-xr-xbootstrap98
-rw-r--r--bootstrap.conf54
-rw-r--r--build-aux/.cvsignore1
-rw-r--r--build-aux/.gitignore1
-rw-r--r--configure.ac6
-rw-r--r--doc/ChangeLog6
-rw-r--r--doc/coreutils.texi39
-rw-r--r--gl/lib/savewd.c308
-rw-r--r--lib/.cvsignore15
-rw-r--r--lib/.gitignore15
-rw-r--r--lib/ChangeLog34
-rw-r--r--lib/printf-parse.c45
-rw-r--r--lib/randperm.c8
-rw-r--r--lib/tsearch.c698
-rw-r--r--lib/vasnprintf.c76
-rw-r--r--lib/xfts.c4
-rw-r--r--m4/.cvsignore4
-rw-r--r--m4/.gitignore4
-rw-r--r--man/Makefile.am35
-rw-r--r--src/c99-to-c89.diff29
-rw-r--r--src/copy.c65
-rw-r--r--src/cp.c24
-rw-r--r--src/csplit.c4
-rw-r--r--src/date.c19
-rw-r--r--src/dd.c6
-rw-r--r--src/df.c21
-rw-r--r--src/dircolors.c11
-rw-r--r--src/du.c8
-rw-r--r--src/env.c7
-rw-r--r--src/fs.h43
-rw-r--r--src/install.c4
-rw-r--r--src/ls.c4
-rw-r--r--src/nl.c6
-rw-r--r--src/printf.c4
-rw-r--r--src/readlink.c4
-rw-r--r--src/remove.c118
-rw-r--r--src/shuf.c17
-rw-r--r--src/sort.c37
-rw-r--r--src/stat.c4
-rw-r--r--src/system.h3
-rw-r--r--tests/chgrp/Makefile.am2
-rwxr-xr-xtests/chgrp/basic21
-rw-r--r--tests/chmod/Makefile.am2
-rw-r--r--tests/chown/Makefile.am2
-rw-r--r--tests/cp/Makefile.am2
-rwxr-xr-xtests/cp/cp-parents9
-rwxr-xr-xtests/cp/parent-perm-race76
-rwxr-xr-xtests/dd/misc16
-rw-r--r--tests/du/Makefile.am5
-rwxr-xr-xtests/du/slink8
-rw-r--r--tests/expr/Makefile.am2
-rw-r--r--tests/factor/Makefile.am2
-rw-r--r--tests/general/Makefile.am4
-rw-r--r--tests/install/Makefile.am2
-rwxr-xr-xtests/install/basic-17
-rw-r--r--tests/ln/Makefile.am2
-rw-r--r--tests/ls/Makefile.am5
-rw-r--r--tests/misc/Makefile.am5
-rwxr-xr-xtests/misc/date3
-rwxr-xr-xtests/misc/df-P60
-rwxr-xr-xtests/misc/pwd-long2
-rwxr-xr-xtests/misc/pwd-unreadable-parent70
-rwxr-xr-xtests/misc/shuf14
-rwxr-xr-xtests/misc/sort-compress10
-rwxr-xr-xtests/misc/tty-eof24
-rw-r--r--tests/mkdir/Makefile.am2
-rw-r--r--tests/mv/Makefile.am4
-rw-r--r--tests/readlink/Makefile.am2
-rwxr-xr-xtests/readlink/can-e38
-rwxr-xr-xtests/readlink/can-f60
-rwxr-xr-xtests/readlink/can-m62
-rw-r--r--tests/rm/Makefile.am2
-rwxr-xr-xtests/rm/fail-eacces3
-rw-r--r--tests/rmdir/Makefile.am2
-rw-r--r--tests/seq/Makefile.am2
-rw-r--r--tests/stty/Makefile.am2
-rw-r--r--tests/tee/Makefile.am2
-rw-r--r--tests/touch/Makefile.am5
87 files changed, 1733 insertions, 1311 deletions
diff --git a/.x-sc_file_system b/.x-sc_file_system
index 76ba25590..a2e38877a 100644
--- a/.x-sc_file_system
+++ b/.x-sc_file_system
@@ -5,3 +5,4 @@ config-log
po/
src/df.c
src/stat.c
+tests/misc/df-P
diff --git a/.x-sc_useless_cpp_parens b/.x-sc_useless_cpp_parens
index 404405dce..01eb4b4e5 100644
--- a/.x-sc_useless_cpp_parens
+++ b/.x-sc_useless_cpp_parens
@@ -10,3 +10,4 @@
^lib/strtod.c
^lib/xstrtol.c
^m4/
+^tests/misc/pwd-unreadable-parent
diff --git a/ChangeLog b/ChangeLog
index ac107fe40..4a806612c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,428 @@
+2007-03-12 Jim Meyering <jim@meyering.net>
+
+ Make bootstrap.conf a tiny bit more generic.
+ * bootstrap.conf (XGETTEXT_OPTIONS): Exclude gettext-related .m4
+ files when e.g., AM_GNU_GETTEXT([external] appears in configure.ac.
+
+2007-03-10 Jim Meyering <jim@meyering.net>
+
+ Try to fix today's NFS-related failure: Treat ESTALE like EACCES.
+ * gl/lib/savewd.c: Copy this file from gnulib, then change
+ "errno != EACCES" to (errno != EACCES && errno != ESTALE).
+ The symptom was this failure in tests/install/basic-1:
+ ginstall: cannot create directory `rel/a': Stale NFS file handle
+
+ The preceding change solved part of the problem. Now ginstall fails.
+ * tests/install/basic-1: Temporarily, don't redirect ginstall's
+ stderr to /dev/null, so I can see why the NFS autobuilder's NFS test
+ is failing.
+
+ * tests/install/basic-1: When setting up an unreadable "." in an
+ inaccessible parent, make the parent inaccessible *after* making "."
+ unreadable. Otherwise, running "chmod a-r ." in an already-
+ inaccessible parent would fail on NFS with "Stale NFS file handle".
+ Reported by Bob Proulx.
+
+ * Makefile.maint (po-check): Exclude c99-to-c89.diff.
+
+2007-03-09 Jim Meyering <jim@meyering.net>
+
+ Avoid test failures on Darwin 7.9.0 (MacOS X 10.3.9)
+ * tests/chgrp/basic: Don't let failure by chgrp to set the
+ group of a symlink make this test fail. Do give a diagnostic.
+ In the chgrp-no-change-ctime test, add darwin7.9.0 as another
+ known-failing system.
+ When failing on some other system, print $host_triplet, too.
+ Also avoid test failures on Darwin 8.8.x (MacOS X 10.4).
+ Reported by Peter Fales.
+
+2007-03-08 Jim Meyering <jim@meyering.net>
+
+ * src/c99-to-c89.diff: Reflect the new c99'ism, update offsets.
+
+2007-03-08 Paul Eggert <eggert@cs.ucla.edu>
+
+ rm without -f: give a better diagnostic when euidaccess fails.
+ * src/remove.c (write_protected_non_symlink): Return int, not bool,
+ so that we can indicate failure too (as a postive error number).
+ (prompt): If write_protected_non_symlink fails, report that error
+ number and fail rather than charging ahead and removing the dubious
+ entry. Redo the logic of printing a diagnostic so that we need to
+ invoke quote (full_filename (...)) only once. More details at:
+ <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9952/focus=9996>
+
+2007-03-08 Jim Meyering <jim@meyering.net>
+
+ Generalize a few more cvs-isms.
+ * bootstrap (checkout_only_file): Rename from CVS_only_file.
+ Change comments and diagnostics not to say "CVS".
+
+ * bootstrap: Run libtool, if necessary.
+
+ Make bootstrap a little more general.
+ * bootstrap (build_aux): Factor out/use this definition.
+ Formally require a "AC_CONFIG_AUX_DIR($build_aux)" line in configure.ac.
+ (insert_sorted_if_absent): Move function definition "up", to
+ precede new first use.
+ If $build_aux/ doesn't exist initially, create it, and
+ mark it as ignored.
+
+2007-03-03 Andrew Church <achurch@achurch.org> (tiny change)
+ Paul Eggert <eggert@cs.ucla.edu>
+
+ Fix a bug: cp -x would fail to set mount point permissions.
+ * NEWS: mention cp -x bug fix
+ * src/copy.c (copy_internal): Don't return immediately after
+ copying a mount point that we do not intend to recurse under.
+ Based on a patch by Andrew Church.
+
+2007-03-03 Jim Meyering <jim@meyering.net>
+
+ pwd-unreadable-parent: Skip test on ia64/Linux, too.
+ * tests/misc/pwd-unreadable-parent: Also skip when $REPLACE_GETCWD.
+ Reported by Bob Proulx.
+
+2007-03-02 Jim Meyering <jim@meyering.net>
+
+ pwd-unreadable-parent: Skip test on non-Linux/GNU systems.
+ * tests/misc/pwd-unreadable-parent: Rather than trying to decide
+ whether this test has a chance of succeeding, run it only when
+ $(host_os) is linux-gnu. It was failing on powerpc-apple-darwin8.8.0
+ * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Add host_os=$(host_os).
+
+ * tests/misc/pwd-long: Also allow "+" in $PWD.
+
+ Remove another coreutils-ism. Formatting cleanup.
+ * Makefile.maint (my-distcheck): Update an outdated comment.
+ (emit_upload_commands): Use $(PACKAGE) rather than "coreutils".
+ (my-distcheck): Skip the c99/c89 check if there's no such .diff file.
+
+2007-03-01 Jim Meyering <jim@meyering.net>
+
+ * Makefile.maint (warn_cflags): Hoist, adding "-Dlint -O".
+ (my-distcheck): Use the new variable, instead of too-long literal.
+
+ Make "make syntax-check" rules less coreutils-specific.
+ * Makefile.maint (sc_cast_of_x_alloc_return_value): Use CVS_LIST_EXCEPT.
+ (sc_cast_of_alloca_return_value): Likewise.
+ (sc_root_tests): Do nothing if there is no check-root target
+ in tests/Makefile.am.
+
+ Run the writable-files check only for release-building targets.
+ * Makefile.maint (local-checks-available): Remove writable-files.
+ (alpha beta major): Put it here, instead.
+
+ "make syntax-check" now runs only Makefile.cfg-selected tests
+ * Makefile.maint (syntax-check-rules): Hoist this definition so that
+ it precedes the indirect use in the definition of $(local-check).
+ (local-check): Use :=, not just "=".
+ (syntax-check): Depend on $(local-check), not $(syntax-check-rules).
+
+2007-02-28 Bruno Haible <bruno@clisp.org>
+
+ * bootstrap.conf (gnulib_modules): Replace xreadlink with
+ xreadlink-with-size. Add xreadlink.
+ * src/copy.c (copy_internal): Update.
+ * src/ls.c (is_directory): Update.
+ * src/stat.c (print_stat): Update.
+ * src/readlink.c (main): Use the one-argument xreadlink function.
+
+2007-02-28 Paul Eggert <eggert@cs.ucla.edu>
+
+ * doc/coreutils.texi (Common options): --si outputs "M", not "MB".
+ Problem reported by Philip Rowlands in
+ <http://lists.gnu.org/archive/html/bug-coreutils/2007-02/msg00283.html>.
+
+2007-02-28 Jim Meyering <jim@meyering.net>
+
+ * .x-sc_file_system: Add the new test, tests/misc/df-P, to this
+ list of exceptions, for the "make distcheck" sc_file_system rule.
+
+ * Makefile.maint (gnulib_snapshot_date): Remove now-unused definition.
+
+2007-02-27 Paul Eggert <eggert@cs.ucla.edu>
+
+ Make df -P immune to effects of e.g., the BLOCK_SIZE envvar.
+ * NEWS: With -P, the default block size and output format is not
+ affected by DF_BLOCK_SIZE, BLOCK_SIZE, or BLOCKSIZE.
+ * src/df.c (main): Implement this.
+
+2007-02-27 Jim Meyering <jim@meyering.net>
+
+ Add a test for the above.
+ * tests/misc/df-P: New file.
+ * tests/misc/Makefile.am (TESTS): Add df-P.
+
+2007-02-25 Jim Meyering <jim@meyering.net>
+
+ * Makefile.maint (announcement): Adjust so that it works with
+ announce-gen's --gnulib-snapshot-time-stamp option.
+ Indent one of the command lines using TAB, not 8 spaces.
+
+ Post-release version change.
+ * NEWS: Add a line for 6.8+.
+ * configure.ac (AC_INIT): Set new version string.
+
+2007-02-24 Jim Meyering <jim@meyering.net>
+
+ Version 6.8.
+ * NEWS: Record release date and new version number.
+ * configure.ac (AC_INIT): New version number.
+
+ Don't skip this test on new-enough Linux/GNU systems.
+ * tests/misc/pwd-unreadable-parent: Test $REPLACE_GETCWD = 0,
+ rather than for __GETCWD_PREFIX in config.h (the latter is no
+ longer defined, ever, due to gnulib changes).
+ * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define REPLACE_GETCWD.
+
+ Remove the "gnits" option; it prohibits my using "+" as a version
+ string suffix, and all it does (beyond the default "gnu" option)
+ is to _require_ the THANKS file.
+ * configure.ac (AM_INIT_AUTOMAKE): Remove it.
+
+ Remove all AUTOMAKE_OPTIONS settings in Makefile.am files.
+ * tests/chgrp/Makefile.am, tests/chmod/Makefile.am:
+ * tests/chown/Makefile.am, tests/cp/Makefile.am:
+ * tests/du/Makefile.am, tests/expr/Makefile.am:
+ * tests/factor/Makefile.am, tests/general/Makefile.am:
+ * tests/install/Makefile.am, tests/ln/Makefile.am:
+ * tests/ls/Makefile.am, tests/mkdir/Makefile.am:
+ * tests/mv/Makefile.am, tests/readlink/Makefile.am:
+ * tests/rm/Makefile.am, tests/rmdir/Makefile.am:
+ * tests/seq/Makefile.am, tests/stty/Makefile.am:
+ * tests/tee/Makefile.am, tests/touch/Makefile.am:
+
+ * README: Document the OSF/1 4.0d build failure and work-around.
+ Reported by Bruno Haible.
+
+ * NEWS: Use a simple "+" suffix to denote pre-release, not "-dirty".
+ Nicer connotations.
+ * configure.ac: Use 6.7+, not 6.7-dirty.
+
+2007-02-24 Paul Eggert <eggert@cs.ucla.edu>
+
+ * NEWS: sort no longer compresses temporaries by default.
+ * bootstrap.conf: Remove findprog.
+ * doc/coreutils.texi (sort invocation): The default is to not
+ compress. Don't treat "" specially.
+ * src/sort.c: Don't include findprog.h.
+ (create_temp): Compress only if the user specified --compress-program.
+ * tests/misc/sort-compress: Adjusts tests to match new behavior.
+
+2007-02-24 Jim Meyering <jim@meyering.net>
+
+ Avoid a shell syntax error, when building with an inadequate Perl.
+ * man/Makefile.am (.x.1): Add quotes around $(PERL) in case, since
+ it can expand to "/.../missing perl".
+
+ * man/Makefile.am (.x.1): Warn when unable to update a man page.
+ Suggestion from Bruno Haible.
+
+2007-02-23 Bruno Haible <bruno@clisp.org>
+
+ Handle better the combination of old Perl and a pre-c99 compiler.
+ * man/Makefile.am (.x.1): If the autoconf test has determined that
+ perl is missing or not a sufficient version, do nothing.
+
+ * tests/readlink/can-e: Put the closing double-quote at the end of a
+ backquoted word, not in the middle. Works around a bug in sh on
+ OSF/1 4.0d.
+ * tests/readlink/can-f: Likewise.
+ * tests/readlink/can-m: Likewise.
+
+ * tests/du/slink: Skip the test if executing on an nfsv3 file system.
+ This avoids a test failure at least on OSF/1 4.0d.
+
+2007-02-23 Jim Meyering <jim@meyering.net>
+
+ * src/date.c (usage): Split a diagnostic that had grown to be
+ longer than the C89 maximum of 509 bytes.
+
+2007-02-23 Ed Santiago <ed@edsantiago.com>
+
+ * src/date.c (usage): Mention that --rfc-3339 uses space, not 'T',
+ for a separator. Include sample RFC 2822 and 3339 output.
+
+2007-02-23 Jim Meyering <jim@meyering.net>
+
+ With -Dlint, make shuf free all heap-allocated storage.
+ * src/shuf.c (main): Move declaration of input_lines to
+ function scope, and initialize to NULL, so we can free it.
+ [lint]: Free all malloc'd memory.
+ * tests/misc/shuf: Also test shuf's -e and -i options.
+
+2007-02-22 Jim Meyering <jim@meyering.net>
+
+ Merge in a change from some other incarnation of this file (gzip?)
+ * bootstrap (gnulib_tool): Skip get_translations if there is no po/ dir.
+
+ Adjust preceding change not to perform an unaligned access.
+ * src/copy.c (copy_reg): Undo previous change. Instead, make
+ it clearer that we're using a single-byte sentinel, and
+ [lint]: Initialize sizeof (uintptr_t) - 1 bytes after the sentinel.
+ Reported by Andreas Schwab.
+
+ Placate valgrind, wrt ./cp --sparse=always
+ * src/copy.c (copy_reg): Place the sentinel by setting a
+ full word's worth of bits, not just a single byte's worth.
+ This avoids a harmless (but distracting) case of memory being
+ used-uninitialized.
+
+2007-02-21 Paul Eggert <eggert@cs.ucla.edu>
+
+ Honor dd's noatime flag if possible, even if not supported on build fs
+ * doc/coreutils.texi (dd invocation): Warn that noatime might not be
+ reliable.
+ * src/dd.c (flags, usage): Look at O_NOATIME, not
+ HAVE_WORKING_O_NOATIME, to decide whether to support the noatime
+ flag, so that dd attempts O_NOATIME even if the build file system
+ does not support it. Problem reported by Jim Meyering today in
+ bug-coreutils.
+ * tests/dd/misc: Generate a warning, not a failure, if noatime
+ exists but fails.
+
+2007-02-21 Jim Meyering <jim@meyering.net>
+
+ * tests/misc/date: Remove vestigial use of Data::Dumper.
+
+2007-02-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ * src/copy.c (cached_umask): Cast -1 to mode_t to avoid a warning
+ about out-of-range initializer with Sun C 5.8.
+
+2007-02-20 Jim Meyering <jim@meyering.net>
+
+ * bootstrap (CVS_only_file): Use README-hacking.
+
+ Now that we use GIT, not cvs, rename README-cvs.
+ * README-hacking: Renamed from...
+ Update to reflect that we now use git.
+
+ * README-cvs: ...this.
+
+ * src/env.c (main): When invoked with no arguments (i.e. when printing
+ the environment), use a local variable to iterate through the global
+ "environ" array, rather than "environ" itself. This is solely to
+ avoid changing the environment for an LD_PRELOAD-substituted "puts"
+ or "exit" function. Tiny patch by Harvey Eneman. See
+ <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9735>.
+ * THANKS: Update.
+
+ * bootstrap: Move definitions of temporary directory names and the
+ new bt_regex "up" to precede all uses, so it's clearer what their
+ scope is. Also, use [.], rather than \\., since the former works
+ even if eval'd.
+
+ * bootstrap: Remove occurrences of $bt (._bootmp) from lib/Makefile.
+ Based on the bison 2007-02-19 change by Joel E. Denny.
+
+2007-02-19 Paul Eggert <eggert@cs.ucla.edu>
+
+ * NEWS: sort now uses a --compress-program option rather than
+ an environment variable.
+ * doc/coreutils.texi (sort invocation): Document this.
+ * src/sort.c (usage): Likewise.
+ (COMPRESS_PROGRAM_OPTION): New const.
+ (long_options, create_temp, main): Support new option.
+ * tests/misc/sort-compress: Test it.
+
+2007-02-19 Jim Meyering <jim@meyering.net>
+
+ * bootstrap: Fix typo s/dowloading/downloading/ in --help output.
+
+2007-02-18 Jim Meyering <jim@meyering.net>
+
+ * src/system.h: Don't include exit.h, now that it's subsumed
+ by the gnulib-generated stdlib.h.
+
+ * tests/rm/fail-eacces: Skip this test when running as root.
+ Reported by Matthew Woehlke.
+
+ * bootstrap: Use "._bootmp" as the temporary directory name,
+ not ".#bootmp". The latter's "#" caused trouble with the new,
+ gnulib-added "LINK_WARNING_H = $(top_srcdir)/.#bootmp/..." line.
+
+2007-02-14 Paul Eggert <eggert@cs.ucla.edu>
+
+ * bootstrap.conf (gnulib_modules): Add c-strcase. Remove strcase.
+ * src/dircolors.c: Include c-strcase.h.
+ (dc_parse_stream): Use c_strcasecmp rather than
+ strcasecmp to avoid unreliable results in locales like Turkish
+ where strcasecmp is incompatible with the C locale.
+
+2007-02-13 Jim Meyering <jim@meyering.net>
+
+ Also check for and print stderr output, in case a program fails.
+ * tests/misc/tty-eof: Occasionally (not reproducible), this
+ test would fail, with one or more programs exiting nonzero, e.g.,
+ tty-eof: sha224sum exited with status 1 (expected 0)
+ Now, maybe we'll get a clue, the next time that happens.
+
+2007-02-12 Jim Meyering <jim@meyering.net>
+
+ * .x-sc_useless_cpp_parens: Ignore a false-positive in a shell script.
+
+ * tests/misc/pwd-unreadable-parent: Skip the test if we're
+ definitely using the replacement.
+ * tests/misc/Makefile.am (TESTS_ENVIRONMENT): Define CONFIG_HEADER.
+
+2007-02-10 Jim Meyering <jim@meyering.net>
+
+ Remove excess leading spaces that would make help2man misbehave.
+ * src/printf.c (usage): Remove excess spaces on 2nd line of %b desc.
+ * src/nl.c (usage): Remove excess spaces on 2nd line of pBRE desc.
+ * src/dd.c (usage): Remove excess spaces on 2nd line of sync desc.
+ * src/date.c (usage): Use two spaces after each optional flag, not one.
+ Reported by Thomas Huriaux in <http://bugs.debian.org/410407>.
+
+ * Makefile.maint (longopt_re): Relax the regexp, making square
+ brackets optional, so it matches the newly reported violations, too.
+
+ * src/csplit.c (usage): Use two spaces (not one) to separate
+ each option string from its description, so help2man formats
+ the derived man page properly. Reported by Thomas Huriaux in
+ <http://bugs.debian.org/410407>.
+ * src/df.c (usage): Likewise.
+ * src/du.c (usage): Likewise.
+ * src/install.c (usage): Likewise.
+ * src/ls.c (usage): Likewise.
+
+2007-02-03 Jim Meyering <jim@meyering.net>
+
+ Test for today's gnulib/lib/getcwd.c fix affecting pwd and readlink
+ * NEWS: Mention the bug fix.
+ * tests/misc/pwd-unreadable-parent: New file.
+ * tests/misc/Makefile.am (TESTS): Ad pwd-unreadable-parent.
+
+2007-02-02 Paul Eggert <eggert@cs.ucla.edu>
+
+ * NEWS: Document fix for cp --preserve=mode.
+ * src/copy.c (copy_internal): Omit the group- or other-writeable
+ permissions when creating a directory, to avoid a race condition
+ if the special mode bits aren't right just after the directory is
+ created.
+ * src/cp.c (make_dir_parents_private): Likewise.
+ * tests/cp/parent-perm-race: Test for the "cp --preserve=mode"
+ race fix in copy.c.
+
+ * NEWS: Document fix for cp --parents.
+ * src/cp.c (make_dir_parents_private): Report the error sooner with
+ "cp --parents DIR/FILE DEST" when DIR is a non-directory, thus not
+ creating the directory, DEST/DIR.
+ * tests/cp/cp-parents: Test for the non-race-condition bug fixed
+ by the above change.
+
+2007-02-02 Jim Meyering <jim@meyering.net>
+
+ * src/nl.c (proc_text): Use "NULL", not "(struct re_registers *) 0".
+
+ * src/c99-to-c89.diff: Make shred.c Index: and a/b prefixes
+ consistent, so this can be applied with patch -p0.
+ Reported by Matthew Woehlke.
+
+ * Makefile.maint (patch-check): Use patch with its -p2 option,
+ since that makes this check slightly more strict.
+
2007-01-29 Jim Meyering <jim@meyering.net>
Plug a leak in ls.
@@ -160,6 +585,10 @@
Use reap_some.
(avoid_trashing_input, merge, sort, main): Adapt to mergefps.
+ The idea of compressing sorts temporary files was first
+ suggested/implemented by Jay Soffian in 1998, and again
+ by Charles Randall in 2001.
+
2007-01-20 Jim Meyering <jim@meyering.net>
* tests/misc/pwd-long: Work properly even when run from the
diff --git a/Makefile.maint b/Makefile.maint
index d526baacd..c1da0d559 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -69,23 +69,23 @@ export LC_ALL = C
# in system.h. E.g. today I removed from tail.c a useless definition of
# ENOSYS. It was useless because system.h ensures it's defined.
+# Collect the names of rules starting with `sc_'.
+syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
+.PHONY: $(syntax-check-rules)
+
# Checks that don't require cvs.
# Run `changelog-check' last, as previous test may reveal problems requiring
# new ChangeLog entries.
local-checks-available = \
- po-check copyright-check writable-files m4-check author_mark_check \
+ po-check copyright-check m4-check author_mark_check \
changelog-check patch-check strftime-check $(syntax-check-rules) \
makefile_path_separator_check \
makefile-check check-AUTHORS
.PHONY: $(local-checks-available)
-local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
+local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
-# Collect the names of rules starting with `sc_'.
-syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
-.PHONY: $(syntax-check-rules)
-
-syntax-check: $(syntax-check-rules)
+syntax-check: $(local-check)
# @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
# $$(find -type f -name '*.[chly]') && \
# { echo '$(ME): found conditional include' 1>&2; \
@@ -103,16 +103,12 @@ sc_cast_of_argument_to_free:
exit 1; } || :
sc_cast_of_x_alloc_return_value:
- @grep -nE --exclude=$(srcdir)/lib/xalloc.h \
- --exclude=$(srcdir)/lib/regex.c \
- '\*\) *x(m|c|re)alloc\>' \
- $(srcdir)/{lib,src}/*.[chy] && \
+ @grep -nE '\*\) *x(m|c|re)alloc\>' $$($(CVS_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
exit 1; } || :
sc_cast_of_alloca_return_value:
- @grep -nE '\*\) *alloca\>' \
- $(srcdir)/src/*.[chy] && \
+ @grep -nE '\*\) *alloca\>' $$($(CVS_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast alloca return value' 1>&2; \
exit 1; } || :
@@ -132,7 +128,7 @@ sc_prohibit_atoi_atof:
# Using EXIT_SUCCESS as the first argument to error is misleading,
# since when that parameter is 0, error does not exit. Use `0' instead.
sc_error_exit_success:
- @grep -nF 'error (EXIT_SUCCESS,' \
+ @grep -nF 'error (EXIT_SUCCESS,' \
$$(find -type f -name '*.[chly]') && \
{ echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
exit 1; } || :
@@ -212,7 +208,9 @@ sc_prohibit_jm_in_m4:
1>&2; exit 1; } || :
sc_root_tests:
- @t1=sc-root.expected; t2=sc-root.actual; \
+ @if test -d tests \
+ && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
+ t1=sc-root.expected; t2=sc-root.actual; \
grep -nl '^PRIV_CHECK_ARG=require-root' \
$$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1; \
sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
@@ -221,7 +219,8 @@ sc_root_tests:
rm -f $$t1 $$t2; \
test "$$diff" \
&& { echo 'tests/Makefile.am: missing check-root action'>&2; \
- exit 1; } || :
+ exit 1; } || :; \
+ fi
headers_with_interesting_macro_defs = \
exit.h \
@@ -301,7 +300,7 @@ sc_trailing_blank:
# Match lines like the following, but where there is only one space
# between the options and the description:
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
-longopt_re = --[a-z][0-9A-Za-z-]*(\[=[0-9A-Za-z-]*\])?
+longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
sc_two_space_separator_in_usage:
@grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
$$($(CVS_LIST_EXCEPT)) && \
@@ -329,7 +328,7 @@ sc_useless_cpp_parens:
patch-check:
rm -rf src-c89 $@.1 $@.2
cp -a src src-c89
- (cd src-c89; patch -V never --fuzz=0) < src/c99-to-c89.diff \
+ (cd src-c89; patch -p2 -V never --fuzz=0) < src/c99-to-c89.diff \
> $@.1 2>&1
if test "$${REGEN_PATCH+set}" = set; then \
diff -upr src src-c89 > new-diff || : ; fi
@@ -368,22 +367,22 @@ makefile-check:
&& { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
news-date-check: NEWS
- today=`date +%Y-%m-%d`; \
- if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
- >/dev/null; then \
- :; \
- else \
- echo "version or today's date is not in NEWS" 1>&2; \
- exit 1; \
+ today=`date +%Y-%m-%d`; \
+ if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
+ >/dev/null; then \
+ :; \
+ else \
+ echo "version or today's date is not in NEWS" 1>&2; \
+ exit 1; \
fi
changelog-check:
- if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
- >/dev/null; then \
- :; \
- else \
- echo "$(VERSION) not in ChangeLog" 1>&2; \
- exit 1; \
+ if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
+ >/dev/null; then \
+ :; \
+ else \
+ echo "$(VERSION) not in ChangeLog" 1>&2; \
+ exit 1; \
fi
m4-check:
@@ -401,6 +400,7 @@ po-check:
for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do \
case $$file in \
djgpp/* | man/*) continue;; \
+ */c99-to-c89.diff) continue;; \
esac; \
case $$file in \
*.[ch]) \
@@ -470,7 +470,7 @@ copyright-check:
# Abort early if this tag has already been used.
vc-tag-check:
used=no; \
- if $(VC) --help | grep CVS; then \
+ if $(VC) --help | grep CVS; then \
$(CVS) -n log -h README|grep -e $(this-vc-tag): >/dev/null \
&& used=yes; \
else \
@@ -514,11 +514,11 @@ null_AM_MAKEFLAGS = \
AUTOHEADER=false \
MAKEINFO=false
-# Detect format-string/arg-list mismatches that would normally be obscured
-# by the use of _(). The --disable-nls effectively defines away that macro,
-# and building with CFLAGS='-Wformat -Werror' causes any format warning to be
-# treated as a failure. Also, check for shadowing problems with -Wshadow,
-# and for pointer arithmetic problems with -Wpointer-arith.
+warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
+
+# Use -Wformat -Werror to detect format-string/arg-list mismatches.
+# Also, check for shadowing problems with -Wshadow, and for pointer
+# arithmetic problems with -Wpointer-arith.
# These CFLAGS are pretty strict. If you build this target, you probably
# have to have a recent version of gcc and glibc headers.
TMPDIR ?= /tmp
@@ -529,7 +529,7 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
cd $(t)/$(distdir) \
&& ./configure --disable-nls \
- && $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow -Wpointer-arith' \
+ && $(MAKE) CFLAGS='$(warn_cflags)' \
AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
&& $(MAKE) dvi \
&& $(MAKE) check \
@@ -537,11 +537,13 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
(cd $(t) && mv $(distdir) $(distdir).old \
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
- cd $(t)/$(distdir) \
- && (cd src && patch -V never --fuzz=0 <c99-to-c89.diff) \
- && ./configure --disable-largefile \
- CFLAGS='-Werror -ansi -pedantic -Wno-long-long' \
- && $(MAKE)
+ if test -f $(srcdir)/src/c99-to-c89.diff; then \
+ cd $(t)/$(distdir) \
+ && (cd src && patch -V never --fuzz=0 <c99-to-c89.diff) \
+ && ./configure --disable-largefile \
+ CFLAGS='-Werror -ansi -pedantic -Wno-long-long' \
+ && $(MAKE); \
+ fi
-rm -rf $(t)
@echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \
@@ -564,12 +566,12 @@ xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
rel-files = $(xd-delta) $(DIST_ARCHIVES)
-# Approximate date of last "update" by the date on the ChangeLog file.
-gnulib_snapshot_date = \
- $$(date -u --date $$(stat --printf @%Y $(gnulib_dir)/ChangeLog) \
- '+%Y-%m-%d %T %z')
+# Approximate the date of last gnulib "update" by the ChangeLog file's
+# mtime, and provide that date in the announcement.
announcement: NEWS ChangeLog $(rel-files)
- @./build-aux/announce-gen \
+ @cl_date=$$(stat --printf @%Y $(gnulib_dir)/ChangeLog); \
+ utc_date=$$(date -u --date $$cl_date '+%Y-%m-%d %T %z'); \
+ ./build-aux/announce-gen \
--release-type=$(RELEASE_TYPE) \
--package=$(PACKAGE) \
--prev=$(PREV_VERSION) \
@@ -577,7 +579,7 @@ announcement: NEWS ChangeLog $(rel-files)
--gpg-key-id=$(gpg_key_ID) \
--news=NEWS \
--bootstrap-tools=autoconf,automake,bison,gnulib \
- --gnulib-snapshot-date=$(gnulib_snapshot_date) \
+ --gnulib-snapshot-time-stamp="$$utc_date" \
$(addprefix --url-dir=, $(url_dir_list))
## ---------------- ##
@@ -594,7 +596,7 @@ emit_upload_commands:
@echo =====================================
@echo =====================================
@echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
- @echo " --to $(gnu_rel_host):coreutils \\"
+ @echo " --to $(gnu_rel_host):$(PACKAGE) \\"
@echo " $(rel-files)"
@echo '# send the /tmp/announcement e-mail'
@echo =====================================
@@ -604,7 +606,7 @@ $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
xdelta delta -9 $^ $@ || :
.PHONY: alpha beta major
-alpha beta major: news-date-check changelog-check $(local-check)
+alpha beta major: news-date-check changelog-check $(local-check) writable-files
test $@ = major \
&& { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
diff --git a/NEWS b/NEWS
index ad0fd1d24..57c51e128 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,16 @@
GNU coreutils NEWS -*- outline -*-
-* Noteworthy changes in release 6.7-dirty (????-??-??) [stable]
+* Noteworthy changes in release 6.8+ (????-??-??) [not-unstable]
+
+** Bug fixes
+
+ cp -x (--one-file-system) would fail to set mount point permissions
+
+ The default block size and output format for df -P are now unaffected by
+ the DF_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE environment variables. It
+ is still affected by POSIXLY_CORRECT, though.
+
+* Noteworthy changes in release 6.8 (2007-02-24) [not-unstable]
** Bug fixes
@@ -10,6 +20,16 @@ GNU coreutils NEWS -*- outline -*-
chmod no longer fails in an environment (e.g., a chroot) with openat
support but with insufficient /proc support.
+ "cp --parents F/G D" no longer creates a directory D/F when F is not
+ a directory (and F/G is therefore invalid).
+
+ "cp --preserve=mode" would create directories that briefly had
+ too-generous permissions in some cases. For example, when copying a
+ directory with permissions 777 the destination directory might
+ temporarily be setgid on some file systems, which would allow other
+ users to create subfiles with the same group as the directory. Fix
+ similar problems with 'install' and 'mv'.
+
cut no longer dumps core for usage like "cut -f2- f1 f2" with two or
more file arguments. This was due to a double-free bug, introduced
in coreutils-5.3.0.
@@ -24,6 +44,9 @@ GNU coreutils NEWS -*- outline -*-
a reasonable diagnostic. Before, it would print this:
"mv: cannot remove `/etc/passwd': Not a directory".
+ pwd and "readlink -e ." no longer fail unnecessarily when a parent
+ directory is unreadable.
+
"rm -rf /etc/passwd" (run by non-root) now prints a diagnostic.
Before it would print nothing.
@@ -31,11 +54,9 @@ GNU coreutils NEWS -*- outline -*-
** New features
- By default, sort usually compresses each temporary file it writes.
- When sorting very large inputs, this can result in sort using far
- less temporary disk space and in improved performance.
-
-** New features
+ sort's new --compress-program=PROG option specifies a compression
+ program to use when writing and reading temporary files.
+ This can help save both time and disk space when sorting large inputs.
sort accepts the new option -C, which acts like -c except no diagnostic
is printed. Its --check option now accepts an optional argument, and
diff --git a/README b/README
index cff225dbe..236b2d51a 100644
--- a/README
+++ b/README
@@ -97,6 +97,18 @@ Here is one possible patch to correct the problem:
+#ifndef __LP64__
+************************
+OSF/1 4.0d build failure
+------------------------
+
+If you use /usr/bin/make on an OSF/1 4.0d system, it will fail due
+to the presence of the "[" target. That version of make appears to
+treat "[" as some syntax relating to locks. To work around that,
+the best solution is to use GNU make. Otherwise, simply remove
+all mention of "[$(EXEEXT)" from src/Makefile.
+
+
+
**********************
Running tests as root:
----------------------
diff --git a/README-cvs b/README-hacking
index dd2783754..6a2714ad4 100644
--- a/README-cvs
+++ b/README-hacking
@@ -1,13 +1,15 @@
-*- outline -*-
-These notes intend to help people working on the CVS version of
-this package.
+These notes intend to help people working on the checked-out sources.
+These requirements do not apply when building from a distribution tarball.
* Requirements
-Only the sources are installed in the CVS repository (to ease the
-maintenance, merges etc.), therefore you will have to get the latest
-stable versions of the maintainer tools we depend upon, including:
+We've opted to keep only the highest-level sources in the GIT repository.
+This eases our maintenance burden, (fewer merges etc.), but imposes more
+requirements on anyone wishing to build from the just-checked-out sources.
+For example, you have to use the latest stable versions of the maintainer
+tools we depend upon, including:
- Automake <http://www.gnu.org/software/automake/>
- Autoconf <http://www.gnu.org/software/autoconf/>
@@ -23,13 +25,13 @@ suggest using test version 1.3.5 (or later, if one becomes available).
Valgrind <http://valgrind.org/> is also highly recommended, if
Valgrind supports your architecture.
-Only building the initial full source tree will be a bit painful,
-later, a plain `cvs update -P && make' should be sufficient.
+Only building the initial full source tree will be a bit painful.
+Later, a plain `git-pull && make' should be sufficient.
-* First CVS checkout
+* First GIT checkout
Obviously, if you are reading these notes, you did manage to check out
-this package from CVS. The next step is to get other files needed to
+this package from GIT. The next step is to get other files needed to
build, which are extracted from other source packages:
$ ./bootstrap
@@ -41,9 +43,9 @@ And there you are! Just
$ make check
At this point, there should be no difference between your local copy,
-and the CVS master copy:
+and the GIT master copy:
- $ cvs diff
+ $ git-diff
should output no difference.
@@ -51,8 +53,7 @@ Enjoy!
-----
-Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
-Inc.
+Copyright (C) 2002-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/THANKS b/THANKS
index 25b97edf0..1d7aae341 100644
--- a/THANKS
+++ b/THANKS
@@ -193,6 +193,7 @@ Hans Verkuil hans@wyst.hobby.nl
Harald Dunkel harald.dunkel@t-online.de
Harry Liu rliu@lek.ugcs.caltech.edu
Harti Brandt brandt@fokus.fraunhofer.de
+Harvey Eneman Harvey.Eneman@oracle.com
Helen Faulkner helen_ml_faulkner@yahoo.co.uk
Herbert Xu herbert@gondor.apana.org.au
Holger Berger hberger@ess.nec.de
diff --git a/TODO b/TODO
index b2f52aa34..61fe29c36 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,9 @@
+printf:
+ Now that gnulib supports *printf("%a"), import one of the
+ *printf-posix modules so that printf(1) will support %a even on
+ platforms where the native *printf(3) is deficient.
+ Suggestion form Eric Blake.
+
strip: add an option to specify the program used to strip binaries.
suggestion from Karl Berry
diff --git a/bootstrap b/bootstrap
index 28fb9ef15..7d214d3bf 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
-# Bootstrap this package from CVS.
+# Bootstrap this package from checked-out sources.
# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
@@ -29,6 +29,11 @@ nl='
LC_ALL=C
export LC_ALL
+# Temporary directory names.
+bt='._bootmp'
+bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
+bt2=${bt}2
+
usage() {
echo >&2 "\
Usage: $0 [OPTION]...
@@ -38,14 +43,14 @@ Options:
--gnulib-srcdir=DIRNAME Specify the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
- do not want to waste your bandwidth dowloading
+ do not want to waste your bandwidth downloading
them again.
--copy Copy files instead of creating symbolic links.
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
--skip-po Do not download po files.
- --cvs-user=USERNAME Set the CVS username to be used when accessing
- the gnulib repository.
+ --cvs-user=USERNAME Set the username to use when checking out
+ sources from the gnulib repository.
If the file .bootstrap.conf exists in the current working directory, its
contents are read as shell variables to configure the bootstrap.
@@ -85,17 +90,18 @@ extract_package_name='
'
package=`sed -n "$extract_package_name" configure.ac` || exit
+build_aux=build-aux
# Extra files from gnulib, which override files from other sources.
-gnulib_extra_files='
- build-aux/install-sh
- build-aux/missing
- build-aux/mdate-sh
- build-aux/texinfo.tex
- build-aux/depcomp
- build-aux/config.guess
- build-aux/config.sub
+gnulib_extra_files="
+ $build_aux/install-sh
+ $build_aux/missing
+ $build_aux/mdate-sh
+ $build_aux/texinfo.tex
+ $build_aux/depcomp
+ $build_aux/config.guess
+ $build_aux/config.sub
doc/INSTALL
-'
+"
# Other locale categories that need message catalogs.
EXTRA_LOCALE_CATEGORIES=
@@ -112,7 +118,7 @@ excluded_files=
# File that should exist in the top directory of a checked out hierarchy,
# but not in a distribution tarball.
-CVS_only_file=README-cvs
+checkout_only_file=README-hacking
# Whether to use copies instead of symlinks.
copy=false
@@ -137,7 +143,7 @@ do
--skip-po)
SKIP_PO=t;;
--force)
- CVS_only_file=;;
+ checkout_only_file=;;
--copy)
copy=true;;
*)
@@ -146,12 +152,38 @@ do
esac
done
-if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
+if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
exit 1
fi
-echo "$0: Bootstrapping CVS $package..."
+# If $STR is not already on a line by itself in $FILE, insert it,
+# sorting the new contents of the file and replacing $FILE with the result.
+insert_sorted_if_absent() {
+ file=$1
+ str=$2
+ echo "$str" | sort -u - $file | cmp -s - $file \
+ || echo "$str" | sort -u - $file -o $file \
+ || exit 1
+}
+
+# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
+grep '^[ ]*AC_CONFIG_AUX_DIR('$build_aux')' configure.ac >/dev/null ||
+ {
+ echo "$0: expected line not found in configure.ac. Add the following:" >&2
+ echo " AC_CONFIG_AUX_DIR($build_aux)" >&2.
+ }
+
+# If $build_aux doesn't exist, create it now, otherwise some bits
+# below will malfunction. If creating it, also mark it as ignored.
+if test ! -d $build_aux; then
+ mkdir $build_aux
+ for ig in .cvsignore .gitignore; do
+ test -f $ig && insert_sorted_if_absent $ig $build_aux
+ done
+fi
+
+echo "$0: Bootstrapping from checked-out $package sources..."
cleanup_gnulib() {
status=$?
@@ -245,7 +277,9 @@ case $SKIP_PO in
WGET_COMMAND='';;
esac
- get_translations po $package || exit
+ if test -d po; then
+ get_translations po $package || exit
+ fi
if test -d runtime-po; then
get_translations runtime-po $package-runtime || exit
@@ -314,7 +348,8 @@ cp_mark_as_generated()
if test -z "$c1"; then
cmp -s "$cp_src" "$cp_dst" || {
echo "$0: cp -f $cp_src $cp_dst" &&
- cp -f "$cp_src" "$cp_dst"
+ rm -f "$cp_dst" &&
+ sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
}
else
# Copy the file first to get proper permissions if it
@@ -323,7 +358,7 @@ cp_mark_as_generated()
(
echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
- cat "$cp_src"
+ sed "s!$bt_regex/!!g" "$cp_src"
) > $cp_dst-t &&
if cmp -s "$cp_dst-t" "$cp_dst"; then
rm -f "$cp_dst-t"
@@ -350,16 +385,6 @@ version_controlled_file() {
test $found = yes
}
-# If $STR is not already on a line by itself in $FILE, insert it,
-# sorting the new contents of the file and replacing $FILE with the result.
-insert_sorted_if_absent() {
- file=$1
- str=$2
- echo "$str" | sort -u - $file | cmp -s - $file \
- || echo "$str" | sort -u - $file -o $file \
- || exit
-}
-
slurp() {
for dir in . `(cd $1 && find * -type d -print)`; do
copied=
@@ -371,7 +396,7 @@ slurp() {
done
if test $file = Makefile.am; then
copied=$copied${sep}gnulib.mk; sep=$nl
- remove_intl='/^[^#].*\/intl/s/^/#/'
+ remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
rm -f $dir/gnulib.mk &&
@@ -415,9 +440,6 @@ slurp() {
# Create boot temporary directories to import from gnulib and gettext.
-
-bt='.#bootmp'
-bt2=${bt}2
rm -fr $bt $bt2 &&
mkdir $bt $bt2 || exit
@@ -426,7 +448,7 @@ mkdir $bt $bt2 || exit
gnulib_tool_options="\
--import\
--no-changelog\
- --aux-dir $bt/build-aux\
+ --aux-dir $bt/$build_aux\
--doc-base $bt/doc\
--lib lib$package\
--m4-base $bt/m4/\
@@ -456,11 +478,17 @@ rm -fr $bt $bt2 || exit
# Reconfigure, getting other files.
for command in \
+ libtool \
'aclocal --force -I m4' \
'autoconf --force' \
'autoheader --force' \
'automake --add-missing --copy --force-missing';
do
+ if test "$command" = libtool; then
+ grep '^[ ]*AM_PROG_LIBTOOL\>' configure.ac >/dev/null ||
+ continue
+ command='libtoolize -c -f'
+ fi
echo "$0: $command ..."
$command || exit
done
diff --git a/bootstrap.conf b/bootstrap.conf
index 631f2eddf..30433216d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -38,12 +38,13 @@ obsolete_gnulib_modules='
gnulib_modules="
$avoided_gnulib_modules
$obsolete_gnulib_modules
- acl alloca announce-gen argmatch assert backupfile base64 c-strtod
+ acl alloca announce-gen argmatch assert backupfile base64
+ c-strcase c-strtod
c-strtold calloc canon-host canonicalize chown cloexec
config-h configmake
closeout cycle-check d-ino d-type diacrit dirfd dirname dup2
error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl
- file-type fileblocks filemode filenamecat findprog fnmatch-gnu
+ file-type fileblocks filemode filenamecat fnmatch-gnu
fopen-safer
fprintftime fsusage ftruncate fts getdate getgroups gethrxtime
getline getloadavg getndelim2 getopt getpagesize getpass-gnu
@@ -60,13 +61,13 @@ gnulib_modules="
rpmatch
safe-read same
save-cwd savedir savewd settime sha1 sig2str ssize_t stat-macros
- stat-time stdbool stdlib-safer stpcpy strcase strftime
+ stat-time stdbool stdlib-safer stpcpy strftime
strpbrk strtoimax strtoumax strverscmp sys_stat timespec tzset
unicodeio unistd-safer unlink-busy unlinkdir unlocked-io
uptime userspec utimecmp utimens vasprintf verify version-etc-fsf
wcwidth winsz-ioctl winsz-termios xalloc xgetcwd xgethostname
- xmemcoll xnanosleep xreadlink xstrtod xstrtoimax xstrtol
- xstrtold xstrtoumax yesno
+ xmemcoll xnanosleep xreadlink xreadlink-with-size xstrtod xstrtoimax
+ xstrtol xstrtold xstrtoumax yesno
"
# Other locale categories that need message catalogs.
@@ -80,17 +81,32 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--flag=wrapf:1:c-format\\\
'
-# Gettext supplies these files, but we don't need them since
-# we don't have an intl subdirectory.
-excluded_files='
- m4/glibc2.m4
- m4/intdiv0.m4
- m4/lcmessage.m4
- m4/lock.m4
- m4/printf-posix.m4
- m4/size_max.m4
- m4/uintmax_t.m4
- m4/ulonglong.m4
- m4/visibility.m4
- m4/xsize.m4
-'
+# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]"
+# appears in configure.ac, exclude some unnecessary files.
+# Without grep's -E option (not portable enough, pre-configure),
+# the following test is ugly. Also, this depends on the existence
+# of configure.ac, not the obsolescent-named configure.in. But if
+# you're using this infrastructure, you should care about such things.
+
+gettext_external=0
+grep '^[ ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null &&
+ gettext_external=1
+grep '^[ ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null &&
+ gettext_external=1
+
+if test $gettext_external = 1; then
+ # Gettext supplies these files, but we don't need them since
+ # we don't have an intl subdirectory.
+ excluded_files='
+ m4/glibc2.m4
+ m4/intdiv0.m4
+ m4/lcmessage.m4
+ m4/lock.m4
+ m4/printf-posix.m4
+ m4/size_max.m4
+ m4/uintmax_t.m4
+ m4/ulonglong.m4
+ m4/visibility.m4
+ m4/xsize.m4
+ '
+fi
diff --git a/build-aux/.cvsignore b/build-aux/.cvsignore
index e1e4fc01e..e43d5c51c 100644
--- a/build-aux/.cvsignore
+++ b/build-aux/.cvsignore
@@ -6,6 +6,7 @@ config.sub
depcomp
gnupload
install-sh
+link-warning.h
mdate-sh
missing
mkinstalldirs
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
index e028c63b7..fc92044fd 100644
--- a/build-aux/.gitignore
+++ b/build-aux/.gitignore
@@ -6,6 +6,7 @@ config.sub
depcomp
gnupload
install-sh
+link-warning.h
mdate-sh
missing
texinfo.tex
diff --git a/configure.ac b/configure.ac
index 66f079b40..0895aa3ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 1991, 1993-2006 Free Software Foundation, Inc.
+# Copyright (C) 1991, 1993-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,14 +20,14 @@
dnl Written by Jim Meyering.
AC_PREREQ(2.61)
-AC_INIT([GNU coreutils],[6.7-dirty],[bug-coreutils@gnu.org])
+AC_INIT([GNU coreutils],[6.8+],[bug-coreutils@gnu.org])
AC_CONFIG_SRCDIR(src/ls.c)
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])
AB_INIT()
-AM_INIT_AUTOMAKE([1.10 gnits dist-bzip2])
+AM_INIT_AUTOMAKE([1.10 dist-bzip2])
AC_PROG_CC_STDC
AM_PROG_CC_C_O
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 6835cf7bc..f296614f0 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2007-02-27 Paul Eggert <eggert@cs.ucla.edu>
+
+ * coreutils.texi (df invocation): With -P, the default block size
+ and output format is not affected by DF_BLOCK_SIZE, BLOCK_SIZE, or
+ BLOCKSIZE.
+
2007-01-30 Paul Eggert <eggert@cs.ucla.edu>
* coreutils.texi
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index f738d8399..23451fe73 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -558,8 +558,8 @@ symbolic link to a directory. @xref{Target directory}.
@itemx --si
@opindex --si
@cindex SI output
-Append an SI-style abbreviation to each size, such as @samp{MB} for
-megabytes. Powers of 1000 are used, not 1024; @samp{MB} stands for
+Append an SI-style abbreviation to each size, such as @samp{M} for
+megabytes. Powers of 1000 are used, not 1024; @samp{M} stands for
1,000,000 bytes. This option is equivalent to
@option{--block-size=si}. Use the @option{-h} or
@option{--human-readable} option if
@@ -3467,20 +3467,6 @@ value as the directory for temporary files instead of @file{/tmp}. The
@option{--temporary-directory} (@option{-T}) option in turn overrides
the environment variable.
-@vindex GNUSORT_COMPRESSOR
-To improve performance when sorting very large files, GNU sort will,
-by default, try to compress temporary files with the program
-@file{gzip}. The environment variable @env{GNUSORT_COMPRESSOR} can be
-set to the name of another program to be used. The program specified
-must compress standard input to standard output when no arguments are
-given to it, and it must decompress standard input to standard output
-when the @option{-d} argument is given to it. If the program exits
-with nonzero status, sort will terminate with an error. To disable
-compression of temporary files, set the variable to the empty string.
-Whitespace and the backslash character should not appear in the
-program name. They are reserved for future use.
-
-
The following options affect the ordering of output lines. They may be
specified globally or as part of a specific key field. If no key
fields are specified, global options apply to comparison of entire
@@ -3647,6 +3633,18 @@ Other options are:
@table @samp
+@item --compress-program=@var{prog}
+Compress any temporary files with the program @var{prog}.
+
+With no arguments, @var{prog} must compress standard input to standard
+output, and when given the @option{-d} option it must decompress
+standard input to standard output.
+
+Terminate with an error if @var{prog} exits with nonzero status.
+
+Whitespace and the backslash character should not appear in
+@var{prog}; they are reserved for future use.
+
@item -k @var{pos1}[,@var{pos2}]
@itemx --key=@var{pos1}[,@var{pos2}]
@opindex -k
@@ -7439,6 +7437,8 @@ Use non-blocking I/O.
@opindex noatime
@cindex access time
Do not update the file's access time.
+Some older file systems silently ignore this flag, so it is a good
+idea to test it on your files before relying on it.
@item noctty
@opindex noctty
@@ -9481,6 +9481,13 @@ some network mounts), the columns are misaligned.
@item
The labels in the header output line are changed to conform to @acronym{POSIX}.
+
+@item
+The default block size and output format are unaffected by the
+@env{DF_BLOCK_SIZE}, @env{BLOCK_SIZE} and @env{BLOCKSIZE} environment
+variables. However, the default block size is still affected by
+@env{POSIXLY_CORRECT}: it is 512 if @env{POSIXLY_CORRECT} is set, 1024
+otherwise. @xref{Block size}.
@end enumerate
@optSi
diff --git a/gl/lib/savewd.c b/gl/lib/savewd.c
new file mode 100644
index 000000000..a6ee23517
--- /dev/null
+++ b/gl/lib/savewd.c
@@ -0,0 +1,308 @@
+/* Save and restore the working directory, possibly using a child process.
+
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* Written by Paul Eggert. */
+
+#include <config.h>
+
+#include "savewd.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include "dirname.h"
+#include "fcntl-safer.h"
+
+
+/* Save the working directory into *WD, if it hasn't been saved
+ already. Return true if a child has been forked to do the real
+ work. */
+static bool
+savewd_save (struct savewd *wd)
+{
+ switch (wd->state)
+ {
+ case INITIAL_STATE:
+ /* Save the working directory, or prepare to fall back if possible. */
+ {
+ int fd = open_safer (".", O_RDONLY);
+ if (0 <= fd)
+ {
+ wd->state = FD_STATE;
+ wd->val.fd = fd;
+ break;
+ }
+ if (errno != EACCES && errno != ESTALE)
+ {
+ wd->state = ERROR_STATE;
+ wd->val.errnum = errno;
+ break;
+ }
+ }
+ wd->state = FORKING_STATE;
+ wd->val.child = -1;
+ /* Fall through. */
+ case FORKING_STATE:
+ if (wd->val.child < 0)
+ {
+ /* "Save" the initial working directory by forking a new
+ subprocess that will attempt all the work from the chdir
+ until until the next savewd_restore. */
+ wd->val.child = fork ();
+ if (wd->val.child != 0)
+ {
+ if (0 < wd->val.child)
+ return true;
+ wd->state = ERROR_STATE;
+ wd->val.errnum = errno;
+ }
+ }
+ break;
+
+ case FD_STATE:
+ case FD_POST_CHDIR_STATE:
+ case ERROR_STATE:
+ case FINAL_STATE:
+ break;
+
+ default:
+ assert (false);
+ }
+
+ return false;
+}
+
+int
+savewd_chdir (struct savewd *wd, char const *dir, int options,
+ int open_result[2])
+{
+ int fd = -1;
+ int result = 0;
+
+ /* Open the directory if requested, or if avoiding a race condition
+ is requested and possible. */
+ if (open_result
+ || (options & (HAVE_WORKING_O_NOFOLLOW ? SAVEWD_CHDIR_NOFOLLOW : 0)))
+ {
+ fd = open (dir,
+ (O_RDONLY | O_DIRECTORY | O_NOCTTY | O_NONBLOCK
+ | (options & SAVEWD_CHDIR_NOFOLLOW ? O_NOFOLLOW : 0)));
+
+ if (open_result)
+ {
+ open_result[0] = fd;
+ open_result[1] = errno;
+ }
+
+ if (fd < 0 && ((errno != EACCES && errno != ESTALE)
+ || (options & SAVEWD_CHDIR_READABLE)))
+ result = -1;
+ }
+
+ if (result == 0 && ! (0 <= fd && options & SAVEWD_CHDIR_SKIP_READABLE))
+ {
+ if (savewd_save (wd))
+ {
+ open_result = NULL;
+ result = -2;
+ }
+ else
+ {
+ result = (fd < 0 ? chdir (dir) : fchdir (fd));
+
+ if (result == 0)
+ switch (wd->state)
+ {
+ case FD_STATE:
+ wd->state = FD_POST_CHDIR_STATE;
+ break;
+
+ case ERROR_STATE:
+ case FD_POST_CHDIR_STATE:
+ case FINAL_STATE:
+ break;
+
+ case FORKING_STATE:
+ assert (wd->val.child == 0);
+ break;
+
+ default:
+ assert (false);
+ }
+ }
+ }
+
+ if (0 <= fd && ! open_result)
+ {
+ int e = errno;
+ close (fd);
+ errno = e;
+ }
+
+ return result;
+}
+
+int
+savewd_restore (struct savewd *wd, int status)
+{
+ switch (wd->state)
+ {
+ case INITIAL_STATE:
+ case FD_STATE:
+ /* The working directory is the desired directory, so there's no
+ work to do. */
+ break;
+
+ case FD_POST_CHDIR_STATE:
+ /* Restore the working directory using fchdir. */
+ if (fchdir (wd->val.fd) == 0)
+ {
+ wd->state = FD_STATE;
+ break;
+ }
+ else
+ {
+ int chdir_errno = errno;
+ close (wd->val.fd);
+ wd->state = ERROR_STATE;
+ wd->val.errnum = chdir_errno;
+ }
+ /* Fall through. */
+ case ERROR_STATE:
+ /* Report an error if asked to restore the working directory. */
+ errno = wd->val.errnum;
+ return -1;
+
+ case FORKING_STATE:
+ /* "Restore" the working directory by waiting for the subprocess
+ to finish. */
+ {
+ pid_t child = wd->val.child;
+ if (child == 0)
+ _exit (status);
+ if (0 < child)
+ {
+ int child_status;
+ while (waitpid (child, &child_status, 0) < 0)
+ assert (errno == EINTR);
+ wd->val.child = -1;
+ if (! WIFEXITED (child_status))
+ raise (WTERMSIG (child_status));
+ return WEXITSTATUS (child_status);
+ }
+ }
+ break;
+
+ default:
+ assert (false);
+ }
+
+ return 0;
+}
+
+void
+savewd_finish (struct savewd *wd)
+{
+ switch (wd->state)
+ {
+ case INITIAL_STATE:
+ case ERROR_STATE:
+ break;
+
+ case FD_STATE:
+ case FD_POST_CHDIR_STATE:
+ close (wd->val.fd);
+ break;
+
+ case FORKING_STATE:
+ assert (wd->val.child < 0);
+ break;
+
+ default:
+ assert (false);
+ }
+
+ wd->state = FINAL_STATE;
+}
+
+/* Return true if the actual work is currently being done by a
+ subprocess.
+
+ A true return means that the caller and the subprocess should
+ resynchronize later with savewd_restore, using only their own
+ memory to decide when to resynchronize; they should not consult the
+ file system to decide, because that might lead to race conditions.
+ This is why savewd_chdir is broken out into another function;
+ savewd_chdir's callers _can_ inspect the file system to decide
+ whether to call savewd_chdir. */
+static inline bool
+savewd_delegating (struct savewd const *wd)
+{
+ return wd->state == FORKING_STATE && 0 < wd->val.child;
+}
+
+int
+savewd_process_files (int n_files, char **file,
+ int (*act) (char *, struct savewd *, void *),
+ void *options)
+{
+ int i = 0;
+ int last_relative;
+ int exit_status = EXIT_SUCCESS;
+ struct savewd wd;
+ savewd_init (&wd);
+
+ for (last_relative = n_files - 1; 0 <= last_relative; last_relative--)
+ if (! IS_ABSOLUTE_FILE_NAME (file[last_relative]))
+ break;
+
+ for (; i < last_relative; i++)
+ {
+ if (! savewd_delegating (&wd))
+ {
+ int s = act (file[i], &wd, options);
+ if (exit_status < s)
+ exit_status = s;
+ }
+
+ if (! IS_ABSOLUTE_FILE_NAME (file[i + 1]))
+ {
+ int r = savewd_restore (&wd, exit_status);
+ if (exit_status < r)
+ exit_status = r;
+ }
+ }
+
+ savewd_finish (&wd);
+
+ for (; i < n_files; i++)
+ {
+ int s = act (file[i], &wd, options);
+ if (exit_status < s)
+ exit_status = s;
+ }
+
+ return exit_status;
+}
diff --git a/lib/.cvsignore b/lib/.cvsignore
index fd60d1c23..df34a8b6c 100644
--- a/lib/.cvsignore
+++ b/lib/.cvsignore
@@ -22,6 +22,11 @@ backupfile.h
base64.c
base64.h
basename.c
+c-ctype.c
+c-ctype.h
+c-strcase.h
+c-strcasecmp.c
+c-strncasecmp.c
c-strtod.c
c-strtod.h
c-strtold.c
@@ -180,6 +185,7 @@ lstat.h
malloc.c
mbchar.c
mbchar.h
+mbscasecmp.c
mbswidth.c
mbswidth.h
mbuiter.h
@@ -213,6 +219,8 @@ mountlist.h
mpsort.c
mpsort.h
nanosleep.c
+netinet_in.h
+netinet_in_.h
obstack.c
obstack.h
offtostr.c
@@ -301,8 +309,12 @@ stdint.h
stdint_.h
stdio--.h
stdio-safer.h
+stdio.h
+stdio_.h
stdlib--.h
stdlib-safer.h
+stdlib.h
+stdlib_.h
stpcpy.c
strcasecmp.c
strcspn.c
@@ -333,6 +345,8 @@ sys_time_.h
t-fpending
tempname.c
tempname.h
+time.h
+time_.h
time_r.c
time_r.h
timespec.h
@@ -377,6 +391,7 @@ xmemcoll.c
xmemcoll.h
xnanosleep.c
xnanosleep.h
+xreadlink-with-size.c
xreadlink.c
xreadlink.h
xstrndup.c
diff --git a/lib/.gitignore b/lib/.gitignore
index 251e279d6..d7233fe3d 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -19,6 +19,11 @@ backupfile.h
base64.c
base64.h
basename.c
+c-ctype.c
+c-ctype.h
+c-strcase.h
+c-strcasecmp.c
+c-strncasecmp.c
c-strtod.c
c-strtod.h
c-strtold.c
@@ -174,6 +179,7 @@ lstat.h
malloc.c
mbchar.c
mbchar.h
+mbscasecmp.c
mbswidth.c
mbswidth.h
mbuiter.h
@@ -207,6 +213,8 @@ mountlist.h
mpsort.c
mpsort.h
nanosleep.c
+netinet_in.h
+netinet_in_.h
obstack.c
obstack.h
offtostr.c
@@ -292,8 +300,12 @@ stdint.h
stdint_.h
stdio--.h
stdio-safer.h
+stdio.h
+stdio_.h
stdlib--.h
stdlib-safer.h
+stdlib.h
+stdlib_.h
stpcpy.c
strcasecmp.c
strcspn.c
@@ -324,6 +336,8 @@ sys_time_.h
t-fpending
tempname.c
tempname.h
+time.h
+time_.h
time_r.c
time_r.h
timespec.h
@@ -368,6 +382,7 @@ xmemcoll.c
xmemcoll.h
xnanosleep.c
xnanosleep.h
+xreadlink-with-size.c
xreadlink.c
xreadlink.h
xstrndup.c
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 793a227f9..49c0e93c8 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,37 @@
+2007-03-04 Jim Meyering <jim@meyering.net>
+
+ * vasnprintf.c (VASNPRINTF): Add missing semicolon.
+
+2007-03-02 Jim Meyering <jim@meyering.net>
+
+ * vasnprintf.c (VASNPRINTF): Remove cast of alloca return value.
+
+2007-03-01 Jim Meyering <jim@meyering.net>
+
+ Merge in changes from gnulib:
+ * vasnprintf.c: Add a comment explaining why coreutils has its own
+ version of this file.
+ Include <stdint.h>.
+ (SIZE_MAX): Remove definition (now, stdint.h covers that).
+ (EOVERFLOW): Remove definition (now done via the eoverflow module).
+ Update some #ifdef to #if.
+ Use HAVE_LONG_LONG_INT, not HAVE_LONG_LONG.
+ * printf-parse.c: Likewise.
+
+2007-02-28 Jim Meyering <jim@meyering.net>
+
+ * tsearch.c: Remove unused file.
+
+2007-02-23 Jim Meyering <jim@meyering.net>
+
+ * randperm.c (randperm_new): Comment: say that this function
+ returns a pointer to malloc'd storage.
+
+2007-02-18 Jim Meyering <jim@meyering.net>
+
+ * xfts.c: Include <stdlib.h> rather than exit.h, now that stdlib.h
+ is guaranteed to provide a valid definition of EXIT_FAILURE.
+
2007-01-19 Jim Meyering <jim@meyering.net>
* .cvsignore, .gitignore: Add sys, as well as more
diff --git a/lib/printf-parse.c b/lib/printf-parse.c
index f8e0ceda5..9493403eb 100644
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -1,5 +1,8 @@
/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2004, 2006 Free Software Foundation, Inc.
+ This file is intended to provide exactly the same functionality
+ as the version in gnulib, but without the need for the xsize module.
+
+ Copyright (C) 1999-2000, 2002-2003, 2006-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,21 +30,12 @@
/* Get size_t, NULL. */
#include <stddef.h>
-/* Get intmax_t. */
-#if HAVE_STDINT_H_WITH_UINTMAX
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H_WITH_UINTMAX
-# include <inttypes.h>
-#endif
+/* Get intmax_t, SIZE_MAX. */
+#include <stdint.h>
/* malloc(), realloc(), free(). */
#include <stdlib.h>
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
#if WIDE_CHAR_VERSION
# define PRINTF_PARSE wprintf_parse
# define CHAR_T wchar_t
@@ -329,7 +323,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
flags += 8;
cp++;
}
-#ifdef HAVE_INTMAX_T
+#if HAVE_INTMAX_T
else if (*cp == 'j')
{
if (sizeof (intmax_t) > sizeof (long))
@@ -385,11 +379,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
switch (c)
{
case 'd': case 'i':
-#ifdef HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
+ /* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_LONGLONGINT;
else
#endif
+ /* If 'long long' exists and is the same as 'long', we parse
+ "lld" into TYPE_LONGINT. */
if (flags >= 8)
type = TYPE_LONGINT;
else if (flags & 2)
@@ -400,11 +397,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
type = TYPE_INT;
break;
case 'o': case 'u': case 'x': case 'X':
-#ifdef HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
+ /* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_ULONGLONGINT;
else
#endif
+ /* If 'unsigned long long' exists and is the same as
+ 'unsigned long', we parse "llu" into TYPE_ULONGINT. */
if (flags >= 8)
type = TYPE_ULONGINT;
else if (flags & 2)
@@ -416,7 +416,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
break;
case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
case 'a': case 'A':
-#ifdef HAVE_LONG_DOUBLE
+#if HAVE_LONG_DOUBLE
if (flags >= 16 || (flags & 4))
type = TYPE_LONGDOUBLE;
else
@@ -425,7 +425,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
break;
case 'c':
if (flags >= 8)
-#ifdef HAVE_WINT_T
+#if HAVE_WINT_T
type = TYPE_WIDE_CHAR;
#else
goto error;
@@ -433,7 +433,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
else
type = TYPE_CHAR;
break;
-#ifdef HAVE_WINT_T
+#if HAVE_WINT_T
case 'C':
type = TYPE_WIDE_CHAR;
c = 'c';
@@ -441,7 +441,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
#endif
case 's':
if (flags >= 8)
-#ifdef HAVE_WCHAR_T
+#if HAVE_WCHAR_T
type = TYPE_WIDE_STRING;
#else
goto error;
@@ -449,7 +449,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
else
type = TYPE_STRING;
break;
-#ifdef HAVE_WCHAR_T
+#if HAVE_WCHAR_T
case 'S':
type = TYPE_WIDE_STRING;
c = 's';
@@ -459,11 +459,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
type = TYPE_POINTER;
break;
case 'n':
-#ifdef HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
+ /* If 'long long' exists and is larger than 'long': */
if (flags >= 16 || (flags & 4))
type = TYPE_COUNT_LONGLONGINT_POINTER;
else
#endif
+ /* If 'long long' exists and is the same as 'long', we parse
+ "lln" into TYPE_COUNT_LONGINT_POINTER. */
if (flags >= 8)
type = TYPE_COUNT_LONGINT_POINTER;
else if (flags & 2)
diff --git a/lib/randperm.c b/lib/randperm.c
index faf34dde1..c4438ddfb 100644
--- a/lib/randperm.c
+++ b/lib/randperm.c
@@ -1,6 +1,6 @@
/* Generate random permutations.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -58,9 +58,9 @@ randperm_bound (size_t h, size_t n)
return bound;
}
-/* From R, allocate and return the first H elements of a random
- permutation of N elements. H must not exceed N. Return NULL if H
- is zero. */
+/* From R, allocate and return a malloc'd array of the first H elements
+ of a random permutation of N elements. H must not exceed N.
+ Return NULL if H is zero. */
size_t *
randperm_new (struct randint_source *r, size_t h, size_t n)
diff --git a/lib/tsearch.c b/lib/tsearch.c
deleted file mode 100644
index 379f0db96..000000000
--- a/lib/tsearch.c
+++ /dev/null
@@ -1,698 +0,0 @@
-/* Copyright (C) 1995, 1996, 1997, 2000, 2005, 2006 Free Software
- Foundation, Inc.
-
- This file is part of the GNU C Library.
- Contributed by Bernd Schmidt <crux@Pool.Informatik.RWTH-Aachen.DE>, 1997.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA. */
-
-/* Tree search for red/black trees.
- The algorithm for adding nodes is taken from one of the many "Algorithms"
- books by Robert Sedgewick, although the implementation differs.
- The algorithm for deleting nodes can probably be found in a book named
- "Introduction to Algorithms" by Cormen/Leiserson/Rivest. At least that's
- the book that my professor took most algorithms from during the "Data
- Structures" course...
-
- Totally public domain. */
-
-/* Red/black trees are binary trees in which the edges are colored either red
- or black. They have the following properties:
- 1. The number of black edges on every path from the root to a leaf is
- constant.
- 2. No two red edges are adjacent.
- Therefore there is an upper bound on the length of every path, it's
- O(log n) where n is the number of nodes in the tree. No path can be longer
- than 1+2*P where P is the length of the shortest path in the tree.
- Useful for the implementation:
- 3. If one of the children of a node is NULL, then the other one is red
- (if it exists).
-
- In the implementation, not the edges are colored, but the nodes. The color
- interpreted as the color of the edge leading to this node. The color is
- meaningless for the root node, but we color the root node black for
- convenience. All added nodes are red initially.
-
- Adding to a red/black tree is rather easy. The right place is searched
- with a usual binary tree search. Additionally, whenever a node N is
- reached that has two red successors, the successors are colored black and
- the node itself colored red. This moves red edges up the tree where they
- pose less of a problem once we get to really insert the new node. Changing
- N's color to red may violate rule 2, however, so rotations may become
- necessary to restore the invariants. Adding a new red leaf may violate
- the same rule, so afterwards an additional check is run and the tree
- possibly rotated.
-
- Deleting is hairy. There are mainly two nodes involved: the node to be
- deleted (n1), and another node that is to be unchained from the tree (n2).
- If n1 has a successor (the node with a smallest key that is larger than
- n1), then the successor becomes n2 and its contents are copied into n1,
- otherwise n1 becomes n2.
- Unchaining a node may violate rule 1: if n2 is black, one subtree is
- missing one black edge afterwards. The algorithm must try to move this
- error upwards towards the root, so that the subtree that does not have
- enough black edges becomes the whole tree. Once that happens, the error
- has disappeared. It may not be necessary to go all the way up, since it
- is possible that rotations and recoloring can fix the error before that.
-
- Although the deletion algorithm must walk upwards through the tree, we
- do not store parent pointers in the nodes. Instead, delete allocates a
- small array of parent pointers and fills it while descending the tree.
- Since we know that the length of a path is O(log n), where n is the number
- of nodes, this is likely to use less memory. */
-
-/* Tree rotations look like this:
- A C
- / \ / \
- B C A G
- / \ / \ --> / \
- D E F G B F
- / \
- D E
-
- In this case, A has been rotated left. This preserves the ordering of the
- binary tree. */
-
-#include <config.h>
-
-#if __GNUC__
-# define alloca __builtin_alloca
-#else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
- # pragma alloca
-# else
-char *alloca ();
-# endif
-# endif
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <search.h>
-
-#ifndef weak_alias
-# define __tsearch tsearch
-# define __tfind tfind
-# define __tdelete tdelete
-# define __twalk twalk
-# define __tdestroy tdestroy
-#endif
-
-#ifndef _LIBC
-# define weak_alias(f,g)
-# define internal_function
-#endif
-
-typedef struct node_t
-{
- /* Callers expect this to be the first element in the structure - do not
- move! */
- const void *key;
- struct node_t *left;
- struct node_t *right;
- unsigned int red:1;
-} *node;
-typedef const struct node_t *const_node;
-
-#undef DEBUGGING
-
-#ifdef DEBUGGING
-
-/* Routines to check tree invariants. */
-
-# include <assert.h>
-
-# define CHECK_TREE(a) check_tree(a)
-
-static void
-check_tree_recurse (node p, int d_sofar, int d_total)
-{
- if (p == NULL)
- {
- assert (d_sofar == d_total);
- return;
- }
-
- check_tree_recurse (p->left, d_sofar + (p->left && !p->left->red), d_total);
- check_tree_recurse (p->right, d_sofar + (p->right && !p->right->red), d_total);
- if (p->left)
- assert (!(p->left->red && p->red));
- if (p->right)
- assert (!(p->right->red && p->red));
-}
-
-static void
-check_tree (node root)
-{
- int cnt = 0;
- node p;
- if (root == NULL)
- return;
- root->red = 0;
- for(p = root->left; p; p = p->left)
- cnt += !p->red;
- check_tree_recurse (root, 0, cnt);
-}
-
-
-#else
-
-# define CHECK_TREE(a)
-
-#endif
-
-/* Possibly "split" a node with two red successors, and/or fix up two red
- edges in a row. ROOTP is a pointer to the lowest node we visited, PARENTP
- and GPARENTP pointers to its parent/grandparent. P_R and GP_R contain the
- comparison values that determined which way was taken in the tree to reach
- ROOTP. MODE is 1 if we need not do the split, but must check for two red
- edges between GPARENTP and ROOTP. */
-static void
-maybe_split_for_insert (node *rootp, node *parentp, node *gparentp,
- int p_r, int gp_r, int mode)
-{
- node root = *rootp;
- node *rp, *lp;
- rp = &(*rootp)->right;
- lp = &(*rootp)->left;
-
- /* See if we have to split this node (both successors red). */
- if (mode == 1
- || ((*rp) != NULL && (*lp) != NULL && (*rp)->red && (*lp)->red))
- {
- /* This node becomes red, its successors black. */
- root->red = 1;
- if (*rp)
- (*rp)->red = 0;
- if (*lp)
- (*lp)->red = 0;
-
- /* If the parent of this node is also red, we have to do
- rotations. */
- if (parentp != NULL && (*parentp)->red)
- {
- node gp = *gparentp;
- node p = *parentp;
- /* There are two main cases:
- 1. The edge types (left or right) of the two red edges differ.
- 2. Both red edges are of the same type.
- There exist two symmetries of each case, so there is a total of
- 4 cases. */
- if ((p_r > 0) != (gp_r > 0))
- {
- /* Put the child at the top of the tree, with its parent
- and grandparent as successors. */
- p->red = 1;
- gp->red = 1;
- root->red = 0;
- if (p_r < 0)
- {
- /* Child is left of parent. */
- p->left = *rp;
- *rp = p;
- gp->right = *lp;
- *lp = gp;
- }
- else
- {
- /* Child is right of parent. */
- p->right = *lp;
- *lp = p;
- gp->left = *rp;
- *rp = gp;
- }
- *gparentp = root;
- }
- else
- {
- *gparentp = *parentp;
- /* Parent becomes the top of the tree, grandparent and
- child are its successors. */
- p->red = 0;
- gp->red = 1;
- if (p_r < 0)
- {
- /* Left edges. */
- gp->left = p->right;
- p->right = gp;
- }
- else
- {
- /* Right edges. */
- gp->right = p->left;
- p->left = gp;
- }
- }
- }
- }
-}
-
-/* Find or insert datum into search tree.
- KEY is the key to be located, ROOTP is the address of tree root,
- COMPAR the ordering function. */
-void *
-__tsearch (const void *key, void **vrootp, __compar_fn_t compar)
-{
- node q;
- node *parentp = NULL, *gparentp = NULL;
- node *rootp = (node *) vrootp;
- node *nextp;
- int r = 0, p_r = 0, gp_r = 0; /* No they might not, Mr Compiler. */
-
- if (rootp == NULL)
- return NULL;
-
- /* This saves some additional tests below. */
- if (*rootp != NULL)
- (*rootp)->red = 0;
-
- CHECK_TREE (*rootp);
-
- nextp = rootp;
- while (*nextp != NULL)
- {
- node root = *rootp;
- r = (*compar) (key, root->key);
- if (r == 0)
- return root;
-
- maybe_split_for_insert (rootp, parentp, gparentp, p_r, gp_r, 0);
- /* If that did any rotations, parentp and gparentp are now garbage.
- That doesn't matter, because the values they contain are never
- used again in that case. */
-
- nextp = r < 0 ? &root->left : &root->right;
- if (*nextp == NULL)
- break;
-
- gparentp = parentp;
- parentp = rootp;
- rootp = nextp;
-
- gp_r = p_r;
- p_r = r;
- }
-
- q = (struct node_t *) malloc (sizeof (struct node_t));
- if (q != NULL)
- {
- *nextp = q; /* link new node to old */
- q->key = key; /* initialize new node */
- q->red = 1;
- q->left = q->right = NULL;
- }
- if (nextp != rootp)
- /* There may be two red edges in a row now, which we must avoid by
- rotating the tree. */
- maybe_split_for_insert (nextp, rootp, parentp, r, p_r, 1);
-
- return q;
-}
-#ifdef weak_alias
-weak_alias (__tsearch, tsearch)
-#endif
-
-
-/* Find datum in search tree.
- KEY is the key to be located, ROOTP is the address of tree root,
- COMPAR the ordering function. */
-void *
-__tfind (key, vrootp, compar)
- const void *key;
- void *const *vrootp;
- __compar_fn_t compar;
-{
- node *rootp = (node *) vrootp;
-
- if (rootp == NULL)
- return NULL;
-
- CHECK_TREE (*rootp);
-
- while (*rootp != NULL)
- {
- node root = *rootp;
- int r;
-
- r = (*compar) (key, root->key);
- if (r == 0)
- return root;
-
- rootp = r < 0 ? &root->left : &root->right;
- }
- return NULL;
-}
-#ifdef weak_alias
-weak_alias (__tfind, tfind)
-#endif
-
-
-/* Delete node with given key.
- KEY is the key to be deleted, ROOTP is the address of the root of tree,
- COMPAR the comparison function. */
-void *
-__tdelete (const void *key, void **vrootp, __compar_fn_t compar)
-{
- node p, q, r, retval;
- int cmp;
- node *rootp = (node *) vrootp;
- node root, unchained;
- /* Stack of nodes so we remember the parents without recursion. It's
- _very_ unlikely that there are paths longer than 40 nodes. The tree
- would need to have around 250.000 nodes. */
- int stacksize = 40;
- int sp = 0;
- node **nodestack = (node **) alloca (sizeof (node *) * stacksize);
-
- if (rootp == NULL)
- return NULL;
- p = *rootp;
- if (p == NULL)
- return NULL;
-
- CHECK_TREE (p);
-
- while ((cmp = (*compar) (key, (*rootp)->key)) != 0)
- {
- if (sp == stacksize)
- {
- node **newstack;
- stacksize += 20;
- newstack = (node **) alloca (sizeof (node *) * stacksize);
- nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
- }
-
- nodestack[sp++] = rootp;
- p = *rootp;
- rootp = ((cmp < 0)
- ? &(*rootp)->left
- : &(*rootp)->right);
- if (*rootp == NULL)
- return NULL;
- }
-
- /* This is bogus if the node to be deleted is the root... this routine
- really should return an integer with 0 for success, -1 for failure
- and errno = ESRCH or something. */
- retval = p;
-
- /* We don't unchain the node we want to delete. Instead, we overwrite
- it with its successor and unchain the successor. If there is no
- successor, we really unchain the node to be deleted. */
-
- root = *rootp;
-
- r = root->right;
- q = root->left;
-
- if (q == NULL || r == NULL)
- unchained = root;
- else
- {
- node *parent = rootp, *up = &root->right;
- for (;;)
- {
- if (sp == stacksize)
- {
- node **newstack;
- stacksize += 20;
- newstack = (node **) alloca (sizeof (node *) * stacksize);
- nodestack = memcpy (newstack, nodestack, sp * sizeof (node *));
- }
- nodestack[sp++] = parent;
- parent = up;
- if ((*up)->left == NULL)
- break;
- up = &(*up)->left;
- }
- unchained = *up;
- }
-
- /* We know that either the left or right successor of UNCHAINED is NULL.
- R becomes the other one, it is chained into the parent of UNCHAINED. */
- r = unchained->left;
- if (r == NULL)
- r = unchained->right;
- if (sp == 0)
- *rootp = r;
- else
- {
- q = *nodestack[sp-1];
- if (unchained == q->right)
- q->right = r;
- else
- q->left = r;
- }
-
- if (unchained != root)
- root->key = unchained->key;
- if (!unchained->red)
- {
- /* Now we lost a black edge, which means that the number of black
- edges on every path is no longer constant. We must balance the
- tree. */
- /* NODESTACK now contains all parents of R. R is likely to be NULL
- in the first iteration. */
- /* NULL nodes are considered black throughout - this is necessary for
- correctness. */
- while (sp > 0 && (r == NULL || !r->red))
- {
- node *pp = nodestack[sp - 1];
- p = *pp;
- /* Two symmetric cases. */
- if (r == p->left)
- {
- /* Q is R's brother, P is R's parent. The subtree with root
- R has one black edge less than the subtree with root Q. */
- q = p->right;
- if (q != NULL && q->red)
- {
- /* If Q is red, we know that P is black. We rotate P left
- so that Q becomes the top node in the tree, with P below
- it. P is colored red, Q is colored black.
- This action does not change the black edge count for any
- leaf in the tree, but we will be able to recognize one
- of the following situations, which all require that Q
- is black. */
- q->red = 0;
- p->red = 1;
- /* Left rotate p. */
- p->right = q->left;
- q->left = p;
- *pp = q;
- /* Make sure pp is right if the case below tries to use
- it. */
- nodestack[sp++] = pp = &q->left;
- q = p->right;
- }
- /* We know that Q can't be NULL here. We also know that Q is
- black. */
- if ((q->left == NULL || !q->left->red)
- && (q->right == NULL || !q->right->red))
- {
- /* Q has two black successors. We can simply color Q red.
- The whole subtree with root P is now missing one black
- edge. Note that this action can temporarily make the
- tree invalid (if P is red). But we will exit the loop
- in that case and set P black, which both makes the tree
- valid and also makes the black edge count come out
- right. If P is black, we are at least one step closer
- to the root and we'll try again the next iteration. */
- q->red = 1;
- r = p;
- }
- else
- {
- /* Q is black, one of Q's successors is red. We can
- repair the tree with one operation and will exit the
- loop afterwards. */
- if (q->right == NULL || !q->right->red)
- {
- /* The left one is red. We perform the same action as
- in maybe_split_for_insert where two red edges are
- adjacent but point in different directions:
- Q's left successor (let's call it Q2) becomes the
- top of the subtree we are looking at, its parent (Q)
- and grandparent (P) become its successors. The former
- successors of Q2 are placed below P and Q.
- P becomes black, and Q2 gets the color that P had.
- This changes the black edge count only for node R and
- its successors. */
- node q2 = q->left;
- q2->red = p->red;
- p->right = q2->left;
- q->left = q2->right;
- q2->right = q;
- q2->left = p;
- *pp = q2;
- p->red = 0;
- }
- else
- {
- /* It's the right one. Rotate P left. P becomes black,
- and Q gets the color that P had. Q's right successor
- also becomes black. This changes the black edge
- count only for node R and its successors. */
- q->red = p->red;
- p->red = 0;
-
- q->right->red = 0;
-
- /* left rotate p */
- p->right = q->left;
- q->left = p;
- *pp = q;
- }
-
- /* We're done. */
- sp = 1;
- r = NULL;
- }
- }
- else
- {
- /* Comments: see above. */
- q = p->left;
- if (q != NULL && q->red)
- {
- q->red = 0;
- p->red = 1;
- p->left = q->right;
- q->right = p;
- *pp = q;
- nodestack[sp++] = pp = &q->right;
- q = p->left;
- }
- if ((q->right == NULL || !q->right->red)
- && (q->left == NULL || !q->left->red))
- {
- q->red = 1;
- r = p;
- }
- else
- {
- if (q->left == NULL || !q->left->red)
- {
- node q2 = q->right;
- q2->red = p->red;
- p->left = q2->right;
- q->right = q2->left;
- q2->left = q;
- q2->right = p;
- *pp = q2;
- p->red = 0;
- }
- else
- {
- q->red = p->red;
- p->red = 0;
- q->left->red = 0;
- p->left = q->right;
- q->right = p;
- *pp = q;
- }
- sp = 1;
- r = NULL;
- }
- }
- --sp;
- }
- if (r != NULL)
- r->red = 0;
- }
-
- free (unchained);
- return retval;
-}
-#ifdef weak_alias
-weak_alias (__tdelete, tdelete)
-#endif
-
-
-/* Walk the nodes of a tree.
- ROOT is the root of the tree to be walked, ACTION the function to be
- called at each node. LEVEL is the level of ROOT in the whole tree. */
-static void
-internal_function
-trecurse (const void *vroot, __action_fn_t action, int level)
-{
- const_node root = (const_node) vroot;
-
- if (root->left == NULL && root->right == NULL)
- (*action) (root, leaf, level);
- else
- {
- (*action) (root, preorder, level);
- if (root->left != NULL)
- trecurse (root->left, action, level + 1);
- (*action) (root, postorder, level);
- if (root->right != NULL)
- trecurse (root->right, action, level + 1);
- (*action) (root, endorder, level);
- }
-}
-
-
-/* Walk the nodes of a tree.
- ROOT is the root of the tree to be walked, ACTION the function to be
- called at each node. */
-void
-__twalk (const void *vroot, __action_fn_t action)
-{
- const_node root = (const_node) vroot;
-
- CHECK_TREE (root);
-
- if (root != NULL && action != NULL)
- trecurse (root, action, 0);
-}
-#ifdef weak_alias
-weak_alias (__twalk, twalk)
-#endif
-
-
-
-/* The standardized functions miss an important functionality: the
- tree cannot be removed easily. We provide a function to do this. */
-static void
-internal_function
-tdestroy_recurse (node root, void (*freefct)(void *))
-{
- if (root->left != NULL)
- tdestroy_recurse (root->left, freefct);
- if (root->right != NULL)
- tdestroy_recurse (root->right, freefct);
- (*freefct) ((void *) root->key);
- /* Free the node itself. */
- free (root);
-}
-
-void
-__tdestroy (void *vroot, void (*freefct)(void *))
-{
- node root = (node) vroot;
-
- CHECK_TREE (root);
-
- if (root != NULL)
- tdestroy_recurse (root, freefct);
-}
-#ifdef weak_alias
-weak_alias (__tdestroy, tdestroy)
-#endif
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 78ead8e3c..8be7ac480 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -1,5 +1,8 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2006 Free Software Foundation, Inc.
+ This file is intended to provide exactly the same functionality
+ as the version in gnulib, but without the need for the xsize module.
+
+ Copyright (C) 1999, 2002-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,7 +26,6 @@
#endif
#include <config.h>
-
#ifndef IN_LIBINTL
# include <alloca.h>
#endif
@@ -37,6 +39,7 @@
#include <stdio.h> /* snprintf(), sprintf() */
#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
+#include <stdint.h> /* SIZE_MAX */
#include <string.h> /* memcpy(), strlen() */
#include <errno.h> /* errno */
#include <limits.h> /* CHAR_BIT, INT_MAX */
@@ -47,17 +50,8 @@
# include "printf-parse.h"
#endif
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
-/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
-#ifndef EOVERFLOW
-# define EOVERFLOW E2BIG
-#endif
-
-#ifdef HAVE_WCHAR_T
-# ifdef HAVE_WCSLEN
+#if HAVE_WCHAR_T
+# if HAVE_WCSLEN
# define local_wcslen wcslen
# else
/* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
@@ -152,7 +146,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
#if HAVE_ALLOCA
if (buf_neededlength < 4000 / sizeof (CHAR_T))
{
- buf = (CHAR_T *) alloca (buf_neededlength * sizeof (CHAR_T));
+ buf = alloca (buf_neededlength * sizeof (CHAR_T));
buf_malloced = NULL;
}
else
@@ -254,7 +248,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
case TYPE_COUNT_LONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longint_pointer = length;
break;
-#ifdef HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
case TYPE_COUNT_LONGLONGINT_POINTER:
*a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
break;
@@ -338,7 +332,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
{
case 'd': case 'i': case 'u':
-# ifdef HAVE_LONG_LONG
+# if HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
@@ -369,7 +363,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 'o':
-# ifdef HAVE_LONG_LONG
+# if HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
@@ -397,7 +391,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 'x': case 'X':
-# ifdef HAVE_LONG_LONG
+# if HAVE_LONG_LONG_INT
if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
tmp_length =
(unsigned int) (sizeof (unsigned long long) * CHAR_BIT
@@ -426,7 +420,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 'f': case 'F':
-# ifdef HAVE_LONG_DOUBLE
+# if HAVE_LONG_DOUBLE
if (type == TYPE_LONGDOUBLE)
tmp_length =
(unsigned int) (LDBL_MAX_EXP
@@ -450,7 +444,6 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 'e': case 'E': case 'g': case 'G':
- case 'a': case 'A':
tmp_length =
12; /* sign, decimal point, exponent etc. */
tmp_length += precision;
@@ -458,8 +451,31 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
goto out_of_memory;
break;
+ case 'a': case 'A':
+# if HAVE_LONG_DOUBLE
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ tmp_length =
+ (unsigned int) (DBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length += 12;
+ if (tmp_length < 12)
+ goto out_of_memory;
+ break;
+
case 'c':
-# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION
+# if HAVE_WINT_T && !WIDE_CHAR_VERSION
if (type == TYPE_WIDE_CHAR)
tmp_length = MB_CUR_MAX;
else
@@ -468,7 +484,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
break;
case 's':
-# ifdef HAVE_WCHAR_T
+# if HAVE_WCHAR_T
if (type == TYPE_WIDE_STRING)
{
tmp_length =
@@ -551,7 +567,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
switch (type)
{
-#ifdef HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
case TYPE_ULONGLONGINT:
*p++ = 'l';
@@ -559,15 +575,15 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
#endif
case TYPE_LONGINT:
case TYPE_ULONGINT:
-#ifdef HAVE_WINT_T
+#if HAVE_WINT_T
case TYPE_WIDE_CHAR:
#endif
-#ifdef HAVE_WCHAR_T
+#if HAVE_WCHAR_T
case TYPE_WIDE_STRING:
#endif
*p++ = 'l';
break;
-#ifdef HAVE_LONG_DOUBLE
+#if HAVE_LONG_DOUBLE
case TYPE_LONGDOUBLE:
*p++ = 'L';
break;
@@ -705,7 +721,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
SNPRINTF_BUF (arg);
}
break;
-#ifdef HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
case TYPE_LONGLONGINT:
{
long long int arg = a.arg[dp->arg_index].a.a_longlongint;
@@ -725,7 +741,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
SNPRINTF_BUF (arg);
}
break;
-#ifdef HAVE_LONG_DOUBLE
+#if HAVE_LONG_DOUBLE
case TYPE_LONGDOUBLE:
{
long double arg = a.arg[dp->arg_index].a.a_longdouble;
@@ -739,7 +755,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
SNPRINTF_BUF (arg);
}
break;
-#ifdef HAVE_WINT_T
+#if HAVE_WINT_T
case TYPE_WIDE_CHAR:
{
wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
@@ -753,7 +769,7 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
SNPRINTF_BUF (arg);
}
break;
-#ifdef HAVE_WCHAR_T
+#if HAVE_WCHAR_T
case TYPE_WIDE_STRING:
{
const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
diff --git a/lib/xfts.c b/lib/xfts.c
index f06fa7b1b..1402e95e3 100644
--- a/lib/xfts.c
+++ b/lib/xfts.c
@@ -1,6 +1,6 @@
/* xfts.c -- a wrapper for fts_open
- Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,8 +21,8 @@
#include <config.h>
#include <stdbool.h>
+#include <stdlib.h>
-#include "exit.h"
#include "error.h"
#include "gettext.h"
diff --git a/m4/.cvsignore b/m4/.cvsignore
index c224f222d..faa76a48c 100644
--- a/m4/.cvsignore
+++ b/m4/.cvsignore
@@ -123,6 +123,7 @@ lstat.m4
mbchar.m4
mbiter.m4
mbrtowc.m4
+mbscasecmp.m4
mbstate_t.m4
mbswidth.m4
md5.m4
@@ -192,7 +193,9 @@ stdbool.m4
stdint.m4
stdint_h.m4
stdio-safer.m4
+stdio_h.m4
stdlib-safer.m4
+stdlib_h.m4
stpcpy.m4
strcase.m4
strcspn.m4
@@ -214,6 +217,7 @@ sys_socket_h.m4
sys_stat_h.m4
sys_time_h.m4
tempname.m4
+time_h.m4
time_r.m4
timespec.m4
tm_gmtoff.m4
diff --git a/m4/.gitignore b/m4/.gitignore
index 53f4fb36e..30fc58e57 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -117,6 +117,7 @@ lstat.m4
mbchar.m4
mbiter.m4
mbrtowc.m4
+mbscasecmp.m4
mbstate_t.m4
mbswidth.m4
md5.m4
@@ -184,7 +185,9 @@ stdbool.m4
stdint.m4
stdint_h.m4
stdio-safer.m4
+stdio_h.m4
stdlib-safer.m4
+stdlib_h.m4
stpcpy.m4
strcase.m4
strcspn.m4
@@ -206,6 +209,7 @@ sys_socket_h.m4
sys_stat_h.m4
sys_time_h.m4
tempname.m4
+time_h.m4
time_r.m4
timespec.m4
tm_gmtoff.m4
diff --git a/man/Makefile.am b/man/Makefile.am
index d6a146e63..32df9d176 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -1,7 +1,6 @@
# Make coreutils man pages. -*-Makefile-*-
-# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 2002-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -154,18 +153,26 @@ mapped_name = `echo $*|sed 's/install/ginstall/; s/test/[/'`
# That is necessary to avoid failures for programs that are also shell built-in
# functions like echo, false, printf, pwd.
.x.1:
- @rm -f $@
- @echo "Updating man page $@"; \
- rm -rf $t; \
- mkdir $t; \
- (cd $t && $(LN_S) ../../src/$(mapped_name) $*); \
- $(PERL) -- $(srcdir)/help2man \
- --source='$(PACKAGE_STRING)' \
- --include=$(srcdir)/$*.x \
- --output=$t/$@ $t/$*
- @sed 's|$*\.td/||g' $t/$@ > $@
- @chmod a-w $@
- @rm -rf $t
+ @case '$(PERL)' in \
+ *"/missing "*) \
+ echo 'WARNING: cannot update man page $@ since perl is missing' \
+ 'or inadequate' 1>&2 \
+ ;; \
+ *) \
+ rm -f $@ \
+ && { echo "Updating man page $@"; \
+ rm -rf $t; \
+ mkdir $t; \
+ (cd $t && $(LN_S) ../../src/$(mapped_name) $*); \
+ $(PERL) -- $(srcdir)/help2man \
+ --source='$(PACKAGE_STRING)' \
+ --include=$(srcdir)/$*.x \
+ --output=$t/$@ $t/$*; \
+ } \
+ && sed 's|$*\.td/||g' $t/$@ > $@ \
+ && chmod a-w $@ \
+ && rm -rf $t ;; \
+ esac
check-local: check-x-vs-1 check-programs-vs-x
diff --git a/src/c99-to-c89.diff b/src/c99-to-c89.diff
index 04db772c4..5545f6a11 100644
--- a/src/c99-to-c89.diff
+++ b/src/c99-to-c89.diff
@@ -31,7 +31,24 @@ index 4728bdd..7477da5 100644
if (top->unremovable)
hash_free (top->unremovable);
obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
-@@ -1481,6 +1483,7 @@ rm_1 (Dirstack_state *ds, char const *fi
+@@ -815,6 +817,7 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
+
+ if (write_protected || x->interactive == RMI_ALWAYS)
+ {
++ char const *quoted_name = quote (full_filename (filename));
+ if (write_protected <= 0
+ && cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0)
+ {
+@@ -832,8 +835,6 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
+ write_protected = EISDIR;
+ }
+
+- char const *quoted_name = quote (full_filename (filename));
+-
+ if (0 < write_protected)
+ {
+ error (0, write_protected, _("cannot remove %s"), quoted_name);
+@@ -1487,6 +1488,7 @@ rm_1 (Dirstack_state *ds, char const *filename,
return RM_ERROR;
}
@@ -39,7 +56,7 @@ index 4728bdd..7477da5 100644
struct stat st;
cache_stat_init (&st);
cycle_check_init (&ds->cycle_check_state);
-@@ -1503,6 +1506,7 @@ rm_1 (Dirstack_state *ds, char const *fi
+@@ -1509,6 +1511,7 @@ rm_1 (Dirstack_state *ds, char const *filename,
AD_push_initial (ds);
AD_INIT_OTHER_MEMBERS ();
@@ -47,7 +64,7 @@ index 4728bdd..7477da5 100644
enum RM_status status = remove_entry (AT_FDCWD, ds, filename, &st, x, NULL);
if (status == RM_NONEMPTY_DIR)
{
-@@ -1519,6 +1523,8 @@ rm_1 (Dirstack_state *ds, char const *fi
+@@ -1525,6 +1528,8 @@ rm_1 (Dirstack_state *ds, char const *filename,
ds_clear (ds);
return status;
@@ -83,13 +100,13 @@ index 364a21c..7a24014 100644
+ }
+ }
}
-Index: shred.c
+Index: src/shred.c
===================================================================
RCS file: /fetish/cu/src/shred.c,v
retrieving revision 1.130
diff -u -p -r1.130 shred.c
---- shred.c 3 Sep 2006 02:53:16 -0000 1.130
-+++ shred.c 3 Oct 2006 13:48:24 -0000
+--- a/src/shred.c 3 Sep 2006 02:53:16 -0000 1.130
++++ b/src/shred.c 3 Oct 2006 13:48:24 -0000
@@ -464,7 +464,7 @@ dopass (int fd, char const *qname, off_t
out. Thus, it shouldn't give up on bad blocks. This
code works because lim is always a multiple of
diff --git a/src/copy.c b/src/copy.c
index d9ad254a9..49bbb8ce4 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -1,5 +1,5 @@
/* copy.c -- core functions for copying files and directories
- Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation.
+ Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -430,7 +430,17 @@ copy_reg (char const *src_name, char const *dst_name,
{
char *cp;
- buf[n_read] = 1; /* Sentinel to stop loop. */
+ /* Sentinel to stop loop. */
+ buf[n_read] = '\1';
+#ifdef lint
+ /* Usually, buf[n_read] is not the byte just before a "word"
+ (aka uintptr_t) boundary. In that case, the word-oriented
+ test below (*wp++ == 0) would read some uninitialized bytes
+ after the sentinel. To avoid false-positive reports about
+ this condition (e.g., from a tool like valgrind), set the
+ remaining bytes -- to any value. */
+ memset (buf + n_read + 1, 0, sizeof (word) - 1);
+#endif
/* Find first nonzero *word*, or the word with the sentinel. */
@@ -1005,6 +1015,7 @@ copy_internal (char const *src_name, char const *dst_name,
struct stat dst_sb;
mode_t src_mode;
mode_t dst_mode IF_LINT (= 0);
+ mode_t dst_mode_bits;
mode_t omitted_permissions;
bool restore_dst_mode = false;
char *earlier_file = NULL;
@@ -1504,13 +1515,16 @@ copy_internal (char const *src_name, char const *dst_name,
new_dst = true;
}
- /* If the ownership might change, omit some permissions at first, so
- unauthorized users cannot nip in before the file has the right
- ownership. */
+ /* If the ownership might change, or if it is a directory (whose
+ special mode bits may change after the directory is created),
+ omit some permissions at first, so unauthorized users cannot nip
+ in before the file is ready. */
+ dst_mode_bits = (x->set_mode ? x->mode : src_mode) & CHMOD_MODE_BITS;
omitted_permissions =
- (x->preserve_ownership
- ? (x->set_mode ? x->mode : src_mode) & (S_IRWXG | S_IRWXO)
- : 0);
+ (dst_mode_bits
+ & (x->preserve_ownership ? S_IRWXG | S_IRWXO
+ : S_ISDIR (src_mode) ? S_IWGRP | S_IWOTH
+ : 0));
delayed_ok = true;
@@ -1549,10 +1563,7 @@ copy_internal (char const *src_name, char const *dst_name,
(src_mode & ~S_IRWXUGO) != 0. However, common practice is
to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir
decide what to do with S_ISUID | S_ISGID | S_ISVTX. */
- mode_t mkdir_mode =
- ((x->set_mode ? x->mode : src_mode)
- & CHMOD_MODE_BITS & ~omitted_permissions);
- if (mkdir (dst_name, mkdir_mode) != 0)
+ if (mkdir (dst_name, dst_mode_bits & ~omitted_permissions) != 0)
{
error (0, errno, _("cannot create directory %s"),
quote (dst_name));
@@ -1593,19 +1604,20 @@ copy_internal (char const *src_name, char const *dst_name,
emit_verbose (src_name, dst_name, NULL);
}
- /* Are we crossing a file system boundary? */
+ /* Decide whether to copy the contents of the directory. */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
- return true;
-
- /* Copy the contents of the directory. */
-
- if (! copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
- copy_into_self))
{
- /* Don't just return here -- otherwise, the failure to read a
- single file in a source directory would cause the containing
- destination directory not to have owner/perms set properly. */
- delayed_ok = false;
+ /* Here, we are crossing a file system boundary and cp's -x option
+ is in effect: so don't copy the contents of this directory. */
+ }
+ else
+ {
+ /* Copy the contents of the directory. Don't just return if
+ this fails -- otherwise, the failure to read a single file
+ in a source directory would cause the containing destination
+ directory not to have owner/perms set properly. */
+ delayed_ok = copy_dir (src_name, dst_name, new_dst, &src_sb, dir, x,
+ copy_into_self);
}
}
else if (x->symbolic_link)
@@ -1709,7 +1721,7 @@ copy_internal (char const *src_name, char const *dst_name,
}
else if (S_ISLNK (src_mode))
{
- char *src_link_val = xreadlink (src_name, src_sb.st_size);
+ char *src_link_val = xreadlink_with_size (src_name, src_sb.st_size);
if (src_link_val == NULL)
{
error (0, errno, _("cannot read symbolic link %s"), quote (src_name));
@@ -1729,7 +1741,8 @@ copy_internal (char const *src_name, char const *dst_name,
FIXME: This behavior isn't documented, and seems wrong
in some cases, e.g., if the destination symlink has the
wrong ownership, permissions, or time stamps. */
- char *dest_link_val = xreadlink (dst_name, dst_sb.st_size);
+ char *dest_link_val =
+ xreadlink_with_size (dst_name, dst_sb.st_size);
if (STREQ (dest_link_val, src_link_val))
same_link = true;
free (dest_link_val);
@@ -1979,7 +1992,7 @@ chown_failure_ok (struct cp_options const *x)
extern mode_t
cached_umask (void)
{
- static mode_t mask = -1;
+ static mode_t mask = (mode_t) -1;
if (mask == (mode_t) -1)
{
mask = umask (0);
diff --git a/src/cp.c b/src/cp.c
index 8fe11a1e7..5759e0d07 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -1,5 +1,5 @@
/* cp.c -- file copying (main routines)
- Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation.
+ Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -415,6 +415,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
mode_t src_mode;
mode_t omitted_permissions;
mode_t mkdir_mode;
+ int src_errno;
/* This component does not exist. We must set
*new_dst and new->mode inside this loop because,
@@ -422,15 +423,28 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
make_dir_parents_private creates only e_dir/../a if
./b already exists. */
*new_dst = true;
- if (XSTAT (x, src, &stats))
+ src_errno = (XSTAT (x, src, &stats) != 0
+ ? errno
+ : S_ISDIR (stats.st_mode)
+ ? 0
+ : ENOTDIR);
+ if (src_errno)
{
- error (0, errno, _("failed to get attributes of %s"),
+ error (0, src_errno, _("failed to get attributes of %s"),
quote (src));
return false;
}
src_mode = stats.st_mode;
- omitted_permissions =
- x->preserve_ownership ? src_mode & (S_IRWXG | S_IRWXO) : 0;
+
+ /* If the ownership or special mode bits might change,
+ omit some permissions at first, so unauthorized users
+ cannot nip in before the file is ready. */
+ omitted_permissions = (src_mode
+ & (x->preserve_ownership
+ ? S_IRWXG | S_IRWXO
+ : x->preserve_mode
+ ? S_IWGRP | S_IWOTH
+ : 0));
/* POSIX says mkdir's behavior is implementation-defined when
(src_mode & ~S_IRWXUGO) != 0. However, common practice is
diff --git a/src/csplit.c b/src/csplit.c
index a26c80df3..c2105bc07 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -1,5 +1,5 @@
/* csplit - split a file into sections determined by context lines
- Copyright (C) 91, 1995-2006 Free Software Foundation, Inc.
+ Copyright (C) 91, 1995-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1484,7 +1484,7 @@ and output byte counts of each piece to standard output.\n\
Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
- -b, --suffix-format=FORMAT use sprintf FORMAT instead of %02d\n\
+ -b, --suffix-format=FORMAT use sprintf FORMAT instead of %02d\n\
-f, --prefix=PREFIX use PREFIX instead of `xx'\n\
-k, --keep-files do not remove output files on errors\n\
"), stdout);
diff --git a/src/date.c b/src/date.c
index 2dec4c37f..c64ab1c04 100644
--- a/src/date.c
+++ b/src/date.c
@@ -1,5 +1,5 @@
/* date - print or set the system date and time
- Copyright (C) 1989-2006 Free Software Foundation, Inc.
+ Copyright (C) 1989-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -142,10 +142,15 @@ Display the current time in the given FORMAT, or set the system date.\n\
"), stdout);
fputs (_("\
-r, --reference=FILE display the last modification time of FILE\n\
- -R, --rfc-2822 output date and time in RFC 2822 format\n\
+ -R, --rfc-2822 output date and time in RFC 2822 format.\n\
+ Example: Mon, 07 Aug 2006 12:34:56 -0600\n\
+"), stdout);
+ fputs (_("\
--rfc-3339=TIMESPEC output date and time in RFC 3339 format.\n\
TIMESPEC=`date', `seconds', or `ns' for\n\
date and time to the indicated precision.\n\
+ Date and time components are separated by\n\
+ a single space: 2006-08-07 12:34:56-06:00\n\
-s, --set=STRING set time described by STRING\n\
-u, --utc, --universal print or set Coordinated Universal Time\n\
"), stdout);
@@ -227,11 +232,11 @@ By default, date pads numeric fields with zeroes.\n\
fputs (_("\
The following optional flags may follow `%':\n\
\n\
- - (hyphen) do not pad the field\n\
- _ (underscore) pad with spaces\n\
- 0 (zero) pad with zeros\n\
- ^ use upper case if possible\n\
- # use opposite case if possible\n\
+ - (hyphen) do not pad the field\n\
+ _ (underscore) pad with spaces\n\
+ 0 (zero) pad with zeros\n\
+ ^ use upper case if possible\n\
+ # use opposite case if possible\n\
"), stdout);
fputs (_("\
\n\
diff --git a/src/dd.c b/src/dd.c
index c781da41c..27a4a08c4 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -265,7 +265,7 @@ static struct symbol_value const flags[] =
{"direct", O_DIRECT},
{"directory", O_DIRECTORY},
{"dsync", O_DSYNC},
- {"noatime", HAVE_WORKING_O_NOATIME ? O_NOATIME : 0},
+ {"noatime", O_NOATIME},
{"noctty", O_NOCTTY},
{"nofollow", HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0},
{"nolinks", O_NOLINKS},
@@ -452,7 +452,7 @@ Each CONV symbol may be:\n\
fputs (_("\
noerror continue after read errors\n\
sync pad every input block with NULs to ibs-size; when used\n\
- with block or unblock, pad with spaces rather than NULs\n\
+ with block or unblock, pad with spaces rather than NULs\n\
fdatasync physically write output file data before finishing\n\
fsync likewise, but also write metadata\n\
"), stdout);
@@ -472,7 +472,7 @@ Each FLAG symbol may be:\n\
fputs (_(" sync likewise, but also for metadata\n"), stdout);
if (O_NONBLOCK)
fputs (_(" nonblock use non-blocking I/O\n"), stdout);
- if (HAVE_WORKING_O_NOATIME)
+ if (O_NOATIME)
fputs (_(" noatime do not update access time\n"), stdout);
if (O_NOCTTY)
fputs (_(" noctty do not assign controlling terminal from file\n"),
diff --git a/src/df.c b/src/df.c
index 61a0b40f4..609787eea 100644
--- a/src/df.c
+++ b/src/df.c
@@ -1,5 +1,5 @@
/* df - summarize free disk space
- Copyright (C) 91, 1995-2006 Free Software Foundation, Inc.
+ Copyright (C) 91, 1995-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -748,7 +748,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-a, --all include dummy file systems\n\
- -B, --block-size=SIZE use SIZE-byte blocks\n\
+ -B, --block-size=SIZE use SIZE-byte blocks\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\n\
-H, --si likewise, but use powers of 1000 not 1024\n\
"), stdout);
@@ -796,10 +796,7 @@ main (int argc, char **argv)
inode_format = false;
show_all_fs = false;
show_listed_fs = false;
-
- human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
- &output_block_size);
-
+ human_output_opts = -1;
print_type = false;
file_systems_processed = false;
posix_format = false;
@@ -876,6 +873,18 @@ main (int argc, char **argv)
}
}
+ if (human_output_opts == -1)
+ {
+ if (posix_format)
+ {
+ human_output_opts = 0;
+ output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024);
+ }
+ else
+ human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
+ &output_block_size);
+ }
+
/* Fail if the same file system type was both selected and excluded. */
{
bool match = false;
diff --git a/src/dircolors.c b/src/dircolors.c
index a6c98893a..82eb1e088 100644
--- a/src/dircolors.c
+++ b/src/dircolors.c
@@ -24,6 +24,7 @@
#include "system.h"
#include "dircolors.h"
+#include "c-strcase.h"
#include "error.h"
#include "getline.h"
#include "obstack.h"
@@ -295,7 +296,7 @@ dc_parse_stream (FILE *fp, const char *filename)
}
unrecognized = false;
- if (strcasecmp (keywd, "TERM") == 0)
+ if (c_strcasecmp (keywd, "TERM") == 0)
{
if (STREQ (arg, term))
state = ST_TERMSURE;
@@ -324,9 +325,9 @@ dc_parse_stream (FILE *fp, const char *filename)
append_quoted (arg);
APPEND_CHAR (':');
}
- else if (strcasecmp (keywd, "OPTIONS") == 0
- || strcasecmp (keywd, "COLOR") == 0
- || strcasecmp (keywd, "EIGHTBIT") == 0)
+ else if (c_strcasecmp (keywd, "OPTIONS") == 0
+ || c_strcasecmp (keywd, "COLOR") == 0
+ || c_strcasecmp (keywd, "EIGHTBIT") == 0)
{
/* Ignore. */
}
@@ -335,7 +336,7 @@ dc_parse_stream (FILE *fp, const char *filename)
int i;
for (i = 0; slack_codes[i] != NULL; ++i)
- if (strcasecmp (keywd, slack_codes[i]) == 0)
+ if (c_strcasecmp (keywd, slack_codes[i]) == 0)
break;
if (slack_codes[i] != NULL)
diff --git a/src/du.c b/src/du.c
index 6a4c8c7c8..206d31842 100644
--- a/src/du.c
+++ b/src/du.c
@@ -1,5 +1,5 @@
/* du -- summarize disk usage
- Copyright (C) 1988-1991, 1995-2006 Free Software Foundation, Inc.
+ Copyright (C) 1988-1991, 1995-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -295,7 +295,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fragmentation, indirect blocks, and the like\n\
"), stdout);
fputs (_("\
- -B, --block-size=SIZE use SIZE-byte blocks\n\
+ -B, --block-size=SIZE use SIZE-byte blocks\n\
-b, --bytes equivalent to `--apparent-size --block-size=1'\n\
-c, --total produce a grand total\n\
-D, --dereference-args dereference FILEs that are symbolic links\n\
@@ -323,7 +323,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (_("\
-x, --one-file-system skip directories on different file systems\n\
-X FILE, --exclude-from=FILE Exclude files that match any pattern in FILE.\n\
- --exclude=PATTERN Exclude files that match PATTERN.\n\
+ --exclude=PATTERN Exclude files that match PATTERN.\n\
--max-depth=N print the total for a directory (or file, with --all)\n\
only if it is N or fewer levels below the command\n\
line argument; --max-depth=0 is the same as\n\
@@ -334,7 +334,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
directory, or any of its subdirectories\n\
--time=WORD show time as WORD instead of modification time:\n\
atime, access, use, ctime or status\n\
- --time-style=STYLE show times using style STYLE:\n\
+ --time-style=STYLE show times using style STYLE:\n\
full-iso, long-iso, iso, +FORMAT\n\
FORMAT is interpreted like `date'\n\
"), stdout);
diff --git a/src/env.c b/src/env.c
index 7283926de..d95ebfd7e 100644
--- a/src/env.c
+++ b/src/env.c
@@ -1,5 +1,5 @@
/* env - run a program in a modified environment
- Copyright (C) 1986, 1991-2005 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1991-2005, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -189,8 +189,9 @@ main (int argc, char **argv)
/* If no program is specified, print the environment and exit. */
if (argc <= optind)
{
- while (*environ)
- puts (*environ++);
+ char *const *e = environ;
+ while (*e)
+ puts (*e++);
exit (EXIT_SUCCESS);
}
diff --git a/src/fs.h b/src/fs.h
deleted file mode 100644
index 5ceea5b49..000000000
--- a/src/fs.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Define the magic numbers as given by statfs(2).
- Please send additions to bug-coreutils@gnu.org and meskes@debian.org.
- This file is generated automatically from ./stat.c. */
-
-#if defined __linux__
-# define S_MAGIC_AFFS 0xADFF
-# define S_MAGIC_DEVPTS 0x1CD1
-# define S_MAGIC_EXT 0x137D
-# define S_MAGIC_EXT2_OLD 0xEF51
-# define S_MAGIC_EXT2 0xEF53
-# define S_MAGIC_JFS 0x3153464a
-# define S_MAGIC_XFS 0x58465342
-# define S_MAGIC_HPFS 0xF995E849
-# define S_MAGIC_ISOFS 0x9660
-# define S_MAGIC_ISOFS_WIN 0x4000
-# define S_MAGIC_ISOFS_R_WIN 0x4004
-# define S_MAGIC_MINIX 0x137F
-# define S_MAGIC_MINIX_30 0x138F
-# define S_MAGIC_MINIX_V2 0x2468
-# define S_MAGIC_MINIX_V2_30 0x2478
-# define S_MAGIC_MSDOS 0x4d44
-# define S_MAGIC_FAT 0x4006
-# define S_MAGIC_NCP 0x564c
-# define S_MAGIC_NFS 0x6969
-# define S_MAGIC_PROC 0x9fa0
-# define S_MAGIC_SMB 0x517B
-# define S_MAGIC_XENIX 0x012FF7B4
-# define S_MAGIC_SYSV4 0x012FF7B5
-# define S_MAGIC_SYSV2 0x012FF7B6
-# define S_MAGIC_COH 0x012FF7B7
-# define S_MAGIC_UFS 0x00011954
-# define S_MAGIC_XIAFS 0x012FD16D
-# define S_MAGIC_NTFS 0x5346544e
-# define S_MAGIC_TMPFS 0x1021994
-# define S_MAGIC_REISERFS 0x52654973
-# define S_MAGIC_CRAMFS 0x28cd3d45
-# define S_MAGIC_ROMFS 0x7275
-# define S_MAGIC_RAMFS 0x858458f6
-# define S_MAGIC_SQUASHFS 0x73717368
-# define S_MAGIC_SYSFS 0x62656572
-#elif defined __GNU__
-# include <hurd/hurd_types.h>
-#endif
diff --git a/src/install.c b/src/install.c
index a5d832f86..8fc6a8a58 100644
--- a/src/install.c
+++ b/src/install.c
@@ -1,5 +1,5 @@
/* install - copy files and set attributes
- Copyright (C) 89, 90, 91, 1995-2006 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -683,7 +683,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-p, --preserve-timestamps apply access/modification times of SOURCE files\n\
to corresponding destination files\n\
-s, --strip strip symbol tables\n\
- -S, --suffix=SUFFIX override the usual backup suffix\n\
+ -S, --suffix=SUFFIX override the usual backup suffix\n\
-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY\n\
-T, --no-target-directory treat DEST as a normal file\n\
-v, --verbose print the name of each directory as it is created\n\
diff --git a/src/ls.c b/src/ls.c
index dbcc83ef4..3d4890080 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2798,7 +2798,7 @@ is_directory (const struct fileinfo *f)
static void
get_link_name (char const *filename, struct fileinfo *f, bool command_line_arg)
{
- f->linkname = xreadlink (filename, f->stat.st_size);
+ f->linkname = xreadlink_with_size (filename, f->stat.st_size);
if (f->linkname == NULL)
file_failure (command_line_arg, _("cannot read symbolic link %s"),
filename);
@@ -4335,7 +4335,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
(overridden by -a or -A)\n\
"), stdout);
fputs (_("\
- --indicator-style=WORD append indicator with style WORD to entry names:\n\
+ --indicator-style=WORD append indicator with style WORD to entry names:\n\
none (default), slash (-p),\n\
file-type (--file-type), classify (-F)\n\
-i, --inode print the index number of each file\n\
diff --git a/src/nl.c b/src/nl.c
index e8502a8ce..04c81183a 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -1,5 +1,5 @@
/* nl -- number lines of files
- Copyright (C) 89, 92, 1995-2006 Free Software Foundation, Inc.
+ Copyright (C) 89, 92, 1995-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -217,7 +217,7 @@ second character implies :. Type \\\\ for \\. STYLE is one of:\n\
t number only nonempty lines\n\
n number no lines\n\
pBRE number only lines that contain a match for the basic regular\n\
- expression, BRE\n\
+ expression, BRE\n\
\n\
FORMAT is one of:\n\
\n\
@@ -348,7 +348,7 @@ proc_text (void)
break;
case 'p':
switch (re_search (current_regex, line_buf.buffer, line_buf.length - 1,
- 0, line_buf.length - 1, (struct re_registers *) 0))
+ 0, line_buf.length - 1, NULL))
{
case -2:
error (EXIT_FAILURE, errno, _("error in regular expression search"));
diff --git a/src/printf.c b/src/printf.c
index 43fe5baf5..6205153bd 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -1,5 +1,5 @@
/* printf - format and print data
- Copyright (C) 1990-2006 Free Software Foundation, Inc.
+ Copyright (C) 1990-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -129,7 +129,7 @@ FORMAT controls the output as in C printf. Interpreted sequences are:\n\
fputs (_("\
%% a single %\n\
%b ARGUMENT as a string with `\\' escapes interpreted,\n\
- except that octal escapes are of the form \\0 or \\0NNN\n\
+ except that octal escapes are of the form \\0 or \\0NNN\n\
\n\
and all C format specifications ending with one of diouxXfeEgGcs, with\n\
ARGUMENTs converted to proper type first. Variable widths are handled.\n\
diff --git a/src/readlink.c b/src/readlink.c
index 800d235b4..121c7ffcf 100644
--- a/src/readlink.c
+++ b/src/readlink.c
@@ -1,5 +1,5 @@
/* readlink -- display value of a symbolic link.
- Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -159,7 +159,7 @@ main (int argc, char **argv)
value = (can_mode != -1
? canonicalize_filename_mode (fname, can_mode)
- : xreadlink (fname, 1024));
+ : xreadlink (fname));
if (value)
{
printf ("%s%s", value, (no_newline ? "" : "\n"));
diff --git a/src/remove.c b/src/remove.c
index 97184eb26..59ee9e562 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -704,20 +704,21 @@ is_empty_dir (int fd_cwd, char const *dir)
return saved_errno == 0 ? true : false;
}
-/* Return true if FILE is determined to be an unwritable non-symlink.
- Otherwise, return false (including when lstat'ing it fails).
+/* Return -1 if FILE is an unwritable non-symlink,
+ 0 if it is writable or some other type of file,
+ a positive error number if there is some problem in determining the answer.
Set *BUF to the file status.
This is to avoid calling euidaccess when FILE is a symlink. */
-static bool
+static int
write_protected_non_symlink (int fd_cwd,
char const *file,
Dirstack_state const *ds,
struct stat *buf)
{
if (cache_fstatat (fd_cwd, file, buf, AT_SYMLINK_NOFOLLOW) != 0)
- return false;
+ return errno;
if (S_ISLNK (buf->st_mode))
- return false;
+ return 0;
/* Here, we know FILE is not a symbolic link. */
/* In order to be reentrant -- i.e., to avoid changing the working
@@ -771,9 +772,16 @@ write_protected_non_symlink (int fd_cwd,
size_t file_name_len
= obstack_object_size (&ds->dir_stack) + strlen (file);
- return (file_name_len < MIN (PATH_MAX, 8192)
- ? euidaccess (full_filename (file), W_OK) != 0 && errno == EACCES
- : euidaccess_stat (buf, W_OK) != 0);
+ if (MIN (PATH_MAX, 8192) <= file_name_len)
+ return - euidaccess_stat (buf, W_OK);
+ if (euidaccess (full_filename (file), W_OK) == 0)
+ return 0;
+ if (errno == EACCES)
+ return -1;
+
+ /* Perhaps some other process has removed the file, or perhaps this
+ is a buggy NFS client. */
+ return errno;
}
}
@@ -794,75 +802,73 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
struct rm_options const *x, enum Prompt_action mode,
Ternary *is_empty)
{
- bool write_protected = false;
+ int write_protected = 0;
*is_empty = T_UNKNOWN;
if (x->interactive == RMI_NEVER)
return RM_OK;
- if (((!x->ignore_missing_files & ((x->interactive == RMI_ALWAYS)
- | x->stdin_tty))
- && (write_protected = write_protected_non_symlink (fd_cwd, filename,
- ds, sbuf)))
- || x->interactive == RMI_ALWAYS)
+ if (!x->ignore_missing_files
+ & ((x->interactive == RMI_ALWAYS) | x->stdin_tty))
+ write_protected = write_protected_non_symlink (fd_cwd, filename, ds, sbuf);
+
+ if (write_protected || x->interactive == RMI_ALWAYS)
{
- if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0)
+ if (write_protected <= 0
+ && cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0)
{
/* This happens, e.g., with `rm '''. */
- error (0, errno, _("cannot remove %s"),
- quote (full_filename (filename)));
- return RM_ERROR;
+ write_protected = errno;
}
- if (S_ISDIR (sbuf->st_mode) && !x->recursive)
+ if (write_protected <= 0)
{
- error (0, EISDIR, _("cannot remove %s"),
- quote (full_filename (filename)));
- return RM_ERROR;
+ /* Using permissions doesn't make sense for symlinks. */
+ if (S_ISLNK (sbuf->st_mode) && x->interactive != RMI_ALWAYS)
+ return RM_OK;
+
+ if (S_ISDIR (sbuf->st_mode) && !x->recursive)
+ write_protected = EISDIR;
}
- /* Using permissions doesn't make sense for symlinks. */
- if (S_ISLNK (sbuf->st_mode))
+ char const *quoted_name = quote (full_filename (filename));
+
+ if (0 < write_protected)
{
- if (x->interactive != RMI_ALWAYS)
- return RM_OK;
- write_protected = false;
+ error (0, write_protected, _("cannot remove %s"), quoted_name);
+ return RM_ERROR;
}
/* Issue the prompt. */
- {
- char const *quoted_name = quote (full_filename (filename));
-
- /* FIXME: use a variant of error (instead of fprintf) that doesn't
- append a newline. Then we won't have to declare program_name in
- this file. */
- if (S_ISDIR (sbuf->st_mode)
- && x->recursive
- && mode == PA_DESCEND_INTO_DIR
- && ((*is_empty = (is_empty_dir (fd_cwd, filename) ? T_YES : T_NO))
- == T_NO))
+ /* FIXME: use a variant of error (instead of fprintf) that doesn't
+ append a newline. Then we won't have to declare program_name in
+ this file. */
+ if (S_ISDIR (sbuf->st_mode)
+ && x->recursive
+ && mode == PA_DESCEND_INTO_DIR
+ && ((*is_empty = (is_empty_dir (fd_cwd, filename) ? T_YES : T_NO))
+ == T_NO))
+ fprintf (stderr,
+ (write_protected
+ ? _("%s: descend into write-protected directory %s? ")
+ : _("%s: descend into directory %s? ")),
+ program_name, quoted_name);
+ else
+ {
+ /* TRANSLATORS: You may find it more convenient to translate
+ the equivalent of _("%s: remove %s (write-protected) %s? ").
+ It should avoid grammatical problems with the output
+ of file_type. */
fprintf (stderr,
(write_protected
- ? _("%s: descend into write-protected directory %s? ")
- : _("%s: descend into directory %s? ")),
- program_name, quoted_name);
- else
- {
- /* TRANSLATORS: You may find it more convenient to translate
- the equivalent of _("%s: remove %s (write-protected) %s? ").
- It should avoid grammatical problems with the output
- of file_type. */
- fprintf (stderr,
- (write_protected
- ? _("%s: remove write-protected %s %s? ")
- : _("%s: remove %s %s? ")),
- program_name, file_type (sbuf), quoted_name);
- }
+ ? _("%s: remove write-protected %s %s? ")
+ : _("%s: remove %s %s? ")),
+ program_name, file_type (sbuf), quoted_name);
+ }
- if (!yesno ())
- return RM_USER_DECLINED;
- }
+ if (!yesno ())
+ return RM_USER_DECLINED;
}
return RM_OK;
}
diff --git a/src/shuf.c b/src/shuf.c
index 68003c259..bfc9f30a2 100644
--- a/src/shuf.c
+++ b/src/shuf.c
@@ -1,6 +1,6 @@
/* Shuffle lines of text.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -251,6 +251,7 @@ main (int argc, char **argv)
char const *outfile = NULL;
char *random_source = NULL;
char eolbyte = '\n';
+ char **input_lines = NULL;
int optc;
int n_operands;
@@ -258,7 +259,7 @@ main (int argc, char **argv)
size_t n_lines;
char **line;
struct randint_source *randint_source;
- size_t const *permutation;
+ size_t *permutation;
initialize_main (&argc, &argv);
program_name = argv[0];
@@ -366,8 +367,6 @@ main (int argc, char **argv)
}
else
{
- char **input_lines;
-
switch (n_operands)
{
case 0:
@@ -408,5 +407,15 @@ main (int argc, char **argv)
if (write_permuted_output (head_lines, line, lo_input, permutation) != 0)
error (EXIT_FAILURE, errno, _("write error"));
+#ifdef lint
+ free (permutation);
+ randint_all_free (randint_source);
+ if (input_lines)
+ {
+ free (input_lines[0]);
+ free (input_lines);
+ }
+#endif
+
return EXIT_SUCCESS;
}
diff --git a/src/sort.c b/src/sort.c
index c7ae0c8c0..58ca66a2e 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -30,7 +30,6 @@
#include "system.h"
#include "argmatch.h"
#include "error.h"
-#include "findprog.h"
#include "hard-locale.h"
#include "hash.h"
#include "inttostr.h"
@@ -281,7 +280,7 @@ static bool have_read_stdin;
static struct keyfield *keylist;
/* Program used to (de)compress temp files. Must accept -d. */
-static const char *compress_program;
+static char const *compress_program;
static void sortlines_temp (struct line *, size_t, struct line *);
@@ -339,6 +338,8 @@ Other options:\n\
\n\
-c, --check, --check=diagnose-first check for sorted input; do not sort\n\
-C, --check=quiet, --check=silent like -c, but do not report first bad line\n\
+ --compress-program=PROG compress temporaries with PROG;\n\
+ decompress them with PROG -d\n\
-k, --key=POS1[,POS2] start a key at POS1, end it at POS2 (origin 1)\n\
-m, --merge merge already sorted files; do not sort\n\
"), stdout);
@@ -390,6 +391,7 @@ native byte values.\n\
enum
{
CHECK_OPTION = CHAR_MAX + 1,
+ COMPRESS_PROGRAM_OPTION,
RANDOM_SOURCE_OPTION
};
@@ -399,6 +401,7 @@ static struct option const long_options[] =
{
{"ignore-leading-blanks", no_argument, NULL, 'b'},
{"check", optional_argument, NULL, CHECK_OPTION},
+ {"compress-program", required_argument, NULL, COMPRESS_PROGRAM_OPTION},
{"dictionary-order", no_argument, NULL, 'd'},
{"ignore-case", no_argument, NULL, 'f'},
{"general-numeric-sort", no_argument, NULL, 'g'},
@@ -839,28 +842,10 @@ pipe_fork (int pipefds[2], size_t tries)
static char *
create_temp (FILE **pfp, pid_t *ppid)
{
- static bool compress_program_known;
int tempfd;
struct tempnode *node = create_temp_file (&tempfd);
char *name = node->name;
- if (! compress_program_known)
- {
- compress_program = getenv ("GNUSORT_COMPRESSOR");
- if (compress_program == NULL)
- {
- static const char *default_program = "gzip";
- const char *path_program = find_in_path (default_program);
-
- if (path_program != default_program)
- compress_program = path_program;
- }
- else if (*compress_program == '\0')
- compress_program = NULL;
-
- compress_program_known = true;
- }
-
if (compress_program)
{
int pipefds[2];
@@ -882,8 +867,7 @@ create_temp (FILE **pfp, pid_t *ppid)
dup2_or_die (pipefds[0], STDIN_FILENO);
close (pipefds[0]);
- if (execlp (compress_program, compress_program,
- (char *) NULL) < 0)
+ if (execlp (compress_program, compress_program, (char *) NULL) < 0)
error (SORT_FAILURE, errno, _("couldn't execute %s"),
compress_program);
}
@@ -932,8 +916,7 @@ open_temp (const char *name, pid_t pid)
dup2_or_die (pipefds[1], STDOUT_FILENO);
close (pipefds[1]);
- if (execlp (compress_program, compress_program,
- "-d", (char *) NULL) < 0)
+ if (execlp (compress_program, compress_program, "-d", (char *) NULL) < 0)
error (SORT_FAILURE, errno, _("couldn't execute %s -d"),
compress_program);
}
@@ -2946,6 +2929,12 @@ main (int argc, char **argv)
checkonly = c;
break;
+ case COMPRESS_PROGRAM_OPTION:
+ if (compress_program && strcmp (compress_program, optarg) != 0)
+ error (SORT_FAILURE, 0, _("multiple compress programs specified"));
+ compress_program = optarg;
+ break;
+
case 'k':
key = key_init (&key_buf);
diff --git a/src/stat.c b/src/stat.c
index 315fe0c65..ca8423677 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1,5 +1,5 @@
/* stat.c -- display file or file system status
- Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -497,7 +497,7 @@ print_stat (char *pformat, size_t prefix_len, char m,
out_string (pformat, prefix_len, quote (filename));
if (S_ISLNK (statbuf->st_mode))
{
- char *linkname = xreadlink (filename, statbuf->st_size);
+ char *linkname = xreadlink_with_size (filename, statbuf->st_size);
if (linkname == NULL)
{
error (0, errno, _("cannot read symbolic link %s"),
diff --git a/src/system.h b/src/system.h
index 383388bab..763909bac 100644
--- a/src/system.h
+++ b/src/system.h
@@ -1,5 +1,5 @@
/* system-dependent definitions for coreutils
- Copyright (C) 1989, 1991-2006 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1991-2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -113,7 +113,6 @@ you must include <sys/types.h> before including this file
#include <stdbool.h>
#include <stdlib.h>
-#include <exit.h>
/* Exit statuses for programs like 'env' that exec other programs.
EXIT_FAILURE might not be 1, so use EXIT_FAIL in such programs. */
diff --git a/tests/chgrp/Makefile.am b/tests/chgrp/Makefile.am
index 6ffa9b753..8dffd0157 100644
--- a/tests/chgrp/Makefile.am
+++ b/tests/chgrp/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = \
default-no-deref \
basic \
diff --git a/tests/chgrp/basic b/tests/chgrp/basic
index 897900d00..475f12f8c 100755
--- a/tests/chgrp/basic
+++ b/tests/chgrp/basic
@@ -1,8 +1,7 @@
#!/bin/sh
# make sure chgrp is reasonable
-# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 2000-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -79,7 +78,11 @@ test `stat --printf=%g f` = $g1 || fail=1
# This should not change the group of f.
chgrp -h $g2 symlink
test `stat --printf=%g f` = $g1 || fail=1
-test `stat --printf=%g symlink` = $g2 || fail=1
+
+# Don't fail if chgrp failed to set the group of a symlink.
+# Some systems don't support that.
+test `stat --printf=%g symlink` = $g2 ||
+ echo 'info: failed to set group of symlink' 1>&2
chown --from=:$g1 :$g2 f; test `stat --printf=%g f` = $g2 || fail=1
@@ -110,15 +113,19 @@ sleep 1
chgrp $g1 f
# The following no-change chgrp command is supposed to update f's ctime,
-# but on OpenBSD, it appears to be a no-op for some file system types
-# (at least NFS) so g's ctime is more recent. This is not a big deal;
+# but on OpenBSD and Darwin 7.9.0 and 8.8.0 (aka MacOS X 10.3.9 and 10.4),
+# it appears to be a no-op for some file system types (at least NFS) so g's
+# ctime is more recent. This is not a big deal;
# this test works fine when the files are on a local file system (/tmp).
chgrp '' f
test "`ls -C -c -t f g`" = 'f g' || \
{
case $host_triplet in
- *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;;
- *) echo no-change chgrp failed to update ctime 1>&2; fail=1 ;;
+ *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;;
+ *darwin7.9.*|*darwin8.8.*)
+ echo ignoring known MacOS X-specific chgrp failure 1>&2 ;;
+ *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2;
+ fail=1 ;;
esac
}
diff --git a/tests/chmod/Makefile.am b/tests/chmod/Makefile.am
index 0eac48639..1388961a6 100644
--- a/tests/chmod/Makefile.am
+++ b/tests/chmod/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = \
inaccessible \
c-option \
diff --git a/tests/chown/Makefile.am b/tests/chown/Makefile.am
index e452a0110..61e65818f 100644
--- a/tests/chown/Makefile.am
+++ b/tests/chown/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = \
preserve-root \
basic \
diff --git a/tests/cp/Makefile.am b/tests/cp/Makefile.am
index 8c978ee42..f9925dbc4 100644
--- a/tests/cp/Makefile.am
+++ b/tests/cp/Makefile.am
@@ -17,8 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-AUTOMAKE_OPTIONS = 1.1 gnits
-
TESTS = \
file-perm-race parent-perm-race \
backup-dir \
diff --git a/tests/cp/cp-parents b/tests/cp/cp-parents
index 373e60776..6c123d225 100755
--- a/tests/cp/cp-parents
+++ b/tests/cp/cp-parents
@@ -2,7 +2,8 @@
# cp -R --parents dir-specified-with-trailing-slash/ other-dir
# would get a failed assertion.
-# Copyright (C) 2000, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2002, 2004, 2005, 2006, 2007 Free Software
+# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -48,6 +49,7 @@ cd $tmp || framework_failure=1
mkdir foo bar || framework_failure=1
mkdir -p a/b/c d e || framework_failure=1
+touch f || framework_failure=1
if test $framework_failure = 1; then
echo 'failure in testing framework'
@@ -65,6 +67,11 @@ cp -R --parents foo/ bar || fail=1
cp --verbose -a --parents a/b/c d > /dev/null 2>&1 || fail=1
test -d d/a/b/c || fail=1
+# With 6.7 and earlier, cp --parents f/g d would mistakenly create a
+# directory d/f, even though f is a regular file.
+cp --parents f/g d 2>/dev/null && fail=1
+test -d d/f && fail=1
+
# Check that re_protect works.
chmod go=w d/a
cp -a --parents d/a/b/c e || fail=1
diff --git a/tests/cp/parent-perm-race b/tests/cp/parent-perm-race
index 80c95a69b..d2870bcea 100755
--- a/tests/cp/parent-perm-race
+++ b/tests/cp/parent-perm-race
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure cp -pR --parents isn't too generous with parent permissions.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -32,37 +32,47 @@ framework_failure=0
mkdir -p $tmp || framework_failure=1
cd $tmp || framework_failure=1
-umask 022
-mkdir -p a d || framework_failure=1
-mkfifo a/fifo || {
- echo "$0: fifos not supported; skipping this test." 1>&2
- (exit 77); exit 77
-}
-
-# Copy a fifo's contents. That way, we can examine d/a's
-# state while cp is running.
-cp -p -R --copy-contents --parents a d &
-cp_pid=$!
-
-(
- # Now 'cp' is reading the fifo.
- # Check the permissions of the temporary destination
- # directory that 'cp' has made.
- ls -ld d/a >d/ls.out
-
- # Close the fifo so that "cp" can continue. But output first,
- # before exiting, otherwise some shells would optimize away the file
- # descriptor that holds the fifo open.
- echo foo
-) >a/fifo
-
-case `cat d/ls.out` in
-d???--[-S]--[-S]*)
- fail=0;;
-*)
- fail=1;;
-esac
-
-wait $cp_pid || fail=1
+umask 002
+mkdir mode ownership d || framework_failure=1
+chmod g+s d 2>/dev/null # The cp test is valid either way.
+
+fail=0
+
+for attr in mode ownership
+do
+ mkfifo $attr/fifo || {
+ echo "$0: fifos not supported; skipping this test." 1>&2
+ (exit 77); exit 77
+ }
+
+ # Copy a fifo's contents. That way, we can examine d/$attr's
+ # state while cp is running.
+ cp --preserve=$attr -R --copy-contents --parents $attr d &
+ cp_pid=$!
+
+ (
+ # Now 'cp' is reading the fifo.
+ # Check the permissions of the temporary destination
+ # directory that 'cp' has made.
+ ls -ld d/$attr >d/$attr.ls
+
+ # Close the fifo so that "cp" can continue. But output first,
+ # before exiting, otherwise some shells would optimize away the file
+ # descriptor that holds the fifo open.
+ echo foo
+ ) >$attr/fifo
+
+ ls_output=`cat d/$attr.ls` || fail=1
+ case $attr,$ls_output in
+ ownership,d???--[-S]--[-S]* | \
+ mode,d????-??-?* | \
+ mode,d??[-x]?w[-x]?-[-x]* )
+ ;;
+ *)
+ fail=1;;
+ esac
+
+ wait $cp_pid || fail=1
+done
(exit $fail); exit $fail
diff --git a/tests/dd/misc b/tests/dd/misc
index 513221bce..fa5cfbe20 100755
--- a/tests/dd/misc
+++ b/tests/dd/misc
@@ -29,6 +29,8 @@ if test "$VERBOSE" = yes; then
dd --version
fi
+fail=0
+warn=0
test_failure=0
echo data > $tmp_in || test_failure=1
ln $tmp_in $tmp_in2 || test_failure=1
@@ -63,8 +65,15 @@ sleep 1
if dd iflag=noatime if=$tmp_in of=$tmp_out 2> /dev/null; then
new_ls=`ls -u --full-time $tmp_in`
if test "x$old_ls" != "x$new_ls"; then
- echo "dd iflag=noatime updated atime; O_NOATIME bug in your kernel?" >&2
- fail=1
+ cat >&2 <<EOF
+=================================================================
+$0: WARNING!!!
+This operating system has the O_NOATIME file status flag,
+but it is silently ignored in some cases.
+Therefore, dd options like iflag=noatime may be silently ignored.
+=================================================================
+EOF
+ warn=77
fi
fi
@@ -77,6 +86,7 @@ fi
outbytes=`echo x | dd bs=3 ibs=10 obs=10 conv=sync 2>/dev/null | wc -c`
test "$outbytes" -eq 3 || fail=1
-rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out
+rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out || fail=1
+test $fail -eq 0 && fail=$warn
exit $fail
diff --git a/tests/du/Makefile.am b/tests/du/Makefile.am
index 152745016..3149cfac6 100644
--- a/tests/du/Makefile.am
+++ b/tests/du/Makefile.am
@@ -1,7 +1,6 @@
# Make coreutils tests for "du". -*-Makefile-*-
-# Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 2000, 2002-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,8 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = \
one-file-system \
inacc-dest \
diff --git a/tests/du/slink b/tests/du/slink
index d3d948ee9..21679345d 100755
--- a/tests/du/slink
+++ b/tests/du/slink
@@ -51,6 +51,14 @@ if test -s tmp; then
(exit 77); exit 77
fi
+df --type=nfsv3 . | tail -n +2 > tmp
+if test -s tmp; then
+ # At least on OSF/1 4.0d, when using an nfsv3 file system,
+ # each created symlink can end up having a size of 0.
+ echo "$0: skipping this test, since \`.' is on an NFS file system" 1>&2
+ (exit 77); exit 77
+fi
+
if test $framework_failure = 1; then
echo "$0: failure in testing framework" 1>&2
(exit 1); exit 1
diff --git a/tests/expr/Makefile.am b/tests/expr/Makefile.am
index e63e4a129..7440c74dc 100644
--- a/tests/expr/Makefile.am
+++ b/tests/expr/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.3b gnits
-
TESTS = basic
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/factor/Makefile.am b/tests/factor/Makefile.am
index a77612944..dedc143bb 100644
--- a/tests/factor/Makefile.am
+++ b/tests/factor/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.3b gnits
-
TESTS = basic
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index aba767aa8..1dbc1d1f6 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -1,7 +1,7 @@
## Process this file with automake to create Makefile.in.
## Makefile for Autoconf testsuite.
-## Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2000, 2003, 2007 Free Software Foundation, Inc.
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -18,8 +18,6 @@
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.
-AUTOMAKE_OPTIONS = gnits
-
SUITE = suite.at dd.at m4sh.at
EXTRA_DIST = $(SUITE) testsuite
diff --git a/tests/install/Makefile.am b/tests/install/Makefile.am
index 4e262ee9e..5544d7d50 100644
--- a/tests/install/Makefile.am
+++ b/tests/install/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.3 gnits
-
TESTS = trap basic-1 create-leading d-slashdot
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/install/basic-1 b/tests/install/basic-1
index 9ee4525a4..78a837552 100755
--- a/tests/install/basic-1
+++ b/tests/install/basic-1
@@ -1,8 +1,7 @@
#! /bin/sh
# Basic tests for "install".
-# Copyright (C) 1998, 2000, 2001, 2002, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 1998, 2000-2002, 2004-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -131,8 +130,8 @@ test -d xx/rel && fail=1
# Test that we can install from an unreadable directory with an
# inaccessible parent. coreutils 5.97 fails this test.
mkdir -p sub1/d || fail=1
-(cd sub1/d && chmod a-rx .. && chmod a-r . &&
- ginstall -d "$abs/xx/zz" rel/a rel/b 2> /dev/null) || fail=1
+(cd sub1/d && chmod a-r . && chmod a-rx .. &&
+ ginstall -d "$abs/xx/zz" rel/a rel/b) || fail=1
chmod 755 sub1 sub1/d || fail=1
test -d xx/zz || fail=1
test -d sub1/d/rel/a || fail=1
diff --git a/tests/ln/Makefile.am b/tests/ln/Makefile.am
index 0f970783c..7ae15a75b 100644
--- a/tests/ln/Makefile.am
+++ b/tests/ln/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.2 gnits
-
TESTS = hard-backup target-1 sf-1 misc backup-1
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/ls/Makefile.am b/tests/ls/Makefile.am
index 36d7b4f2c..461ba0756 100644
--- a/tests/ls/Makefile.am
+++ b/tests/ls/Makefile.am
@@ -1,7 +1,6 @@
# Make coreutils tests for "ls". -*-Makefile-*-
-# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006 Free
-# Software Foundation, Inc.
+# Copyright (C) 1997-2003, 2006-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,8 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-AUTOMAKE_OPTIONS = 1.2 gnits
-
TESTS = \
nameless-uid \
color-dtype-dir \
diff --git a/tests/misc/Makefile.am b/tests/misc/Makefile.am
index c4c279d67..1aa3516f8 100644
--- a/tests/misc/Makefile.am
+++ b/tests/misc/Makefile.am
@@ -28,6 +28,9 @@ TESTS_ENVIRONMENT = \
BUILD_SRC_DIR="`pwd`/../../src" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
+ CONFIG_HEADER=$(CONFIG_HEADER) \
+ REPLACE_GETCWD=$(REPLACE_GETCWD) \
+ host_os=$(host_os) \
PROG=`../../src/basename -- "$$tst"`
# Do not choose a name that is a shell keyword like 'if', or a
@@ -37,6 +40,8 @@ TESTS_ENVIRONMENT = \
# will execute the test script rather than the standard utility.
TESTS = \
+ df-P \
+ pwd-unreadable-parent \
cut \
wc-files0-from \
wc-files0 \
diff --git a/tests/misc/date b/tests/misc/date
index b9b253df3..0ff834552 100755
--- a/tests/misc/date
+++ b/tests/misc/date
@@ -1,7 +1,7 @@
#!/bin/sh
# Test "date".
-# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2005-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -296,7 +296,6 @@ foreach my $i (1..364)
{ENV_DEL => 'TZ'},
];
}
-use Data::Dumper;
# Append "\n" to each OUT=> RHS if the expected exit value is either
# zero or not specified (defaults to zero).
diff --git a/tests/misc/df-P b/tests/misc/df-P
new file mode 100755
index 000000000..3a5ec9b97
--- /dev/null
+++ b/tests/misc/df-P
@@ -0,0 +1,60 @@
+#!/bin/sh
+# Ensure that df -P is not affected by BLOCK_SIZE settings
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ df --version
+fi
+
+. $srcdir/../envvar-check
+. $srcdir/../lang-default
+
+pwd=`pwd`
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
+trap '(exit $?); exit $?' 1 2 13 15
+
+framework_failure=0
+mkdir -p $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+if test $framework_failure = 1; then
+ echo "$0: failure in testing framework" 1>&2
+ (exit 1); exit 1
+fi
+
+fail=0
+
+ df -P . > t1 || fail=1
+BLOCK_SIZE=1M df -P . > t2 || fail=1
+
+# Since disk utilization may be changing, compare only df's header line.
+# That records the block size. E.g., for "1M", it would be:
+# Filesystem 1048576-blocks Used Available Capacity Mounted on
+# while for 1K, it would be
+# Filesystem 1024-blocks Used Available Capacity Mounted on
+
+head -n1 t1 > exp || fail=1
+head -n1 t2 > out || fail=1
+
+cmp out exp || fail=1
+test $fail = 1 && diff out exp 2> /dev/null
+
+(exit $fail); exit $fail
diff --git a/tests/misc/pwd-long b/tests/misc/pwd-long
index 1306b327a..6fc83e258 100755
--- a/tests/misc/pwd-long
+++ b/tests/misc/pwd-long
@@ -97,7 +97,7 @@ until (++$i == $n);
my $build_src_dir = $ENV{BUILD_SRC_DIR};
$build_src_dir
or die "$ME: envvar BUILD_SRC_DIR not defined\n";
-if ($build_src_dir !~ m!^([-.:/\w]+)$!)
+if ($build_src_dir !~ m!^([-+.:/\w]+)$!)
{
warn "$0: skipping this test; odd build source directory name:\n"
. "$build_src_dir\n";
diff --git a/tests/misc/pwd-unreadable-parent b/tests/misc/pwd-unreadable-parent
new file mode 100755
index 000000000..72c666ef3
--- /dev/null
+++ b/tests/misc/pwd-unreadable-parent
@@ -0,0 +1,70 @@
+#!/bin/sh
+# Ensure that pwd and "readlink -e ." work even when a parent directory
+# is unreadable. Perform this test only on systems with a usable getcwd
+# function that has this capability.
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+if test "$VERBOSE" = yes; then
+ set -x
+ pwd --version
+ readlink --version
+fi
+
+test $host_os != linux-gnu &&
+ {
+ echo 1>&2 "$0: vendor getcwd may be inadequate; skipping this test"
+ (exit 77); exit 77
+ }
+
+# Linux ia64 has the gl_FUNC_GETCWD_ABORT_BUG, so we can't use
+# the system getcwd.
+test $REPLACE_GETCWD = 1 &&
+ {
+ echo 1>&2 "$0: can't use buggy system getcwd; skipping this test"
+ (exit 77); exit 77
+ }
+
+pwd=`pwd`
+t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
+trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
+trap '(exit $?); exit $?' 1 2 13 15
+
+framework_failure=0
+mkdir -p $tmp || framework_failure=1
+cd $tmp || framework_failure=1
+
+mkdir -p a/b || framework_failure=1
+cd a/b || framework_failure=1
+chmod a=x .. || framework_failure=1
+
+if test $framework_failure = 1; then
+ echo "$0: failure in testing framework" 1>&2
+ (exit 1); exit 1
+fi
+
+pwd_exe=$pwd/../../src/pwd
+
+fail=0
+$pwd_exe > exp || fail=1
+readlink -ev . > out || fail=1
+
+cmp out exp || fail=1
+test $fail = 1 && diff out exp 2> /dev/null
+
+(exit $fail); exit $fail
diff --git a/tests/misc/shuf b/tests/misc/shuf
index 760bd4921..a2d5891b2 100755
--- a/tests/misc/shuf
+++ b/tests/misc/shuf
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that shuf randomizes its input.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -51,8 +51,18 @@ cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; }
sort -n out > out1
cmp in out1 || { fail=1; echo "not a permutation" 1>&2; }
+# Exercise shuf's -i option.
+shuf -i 1-100 > out || fail=1
+cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; }
+sort -n out > out1
+cmp in out1 || { fail=1; echo "not a permutation" 1>&2; }
+
+# Exercise shuf's -e option.
+t=`shuf -e a b c d e | sort | fmt`
+test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; }
+
# Before coreutils-6.3, this would infloop.
-# "seq 1860" produces 8193 bytes of output.
+# "seq 1860" produces 8193 (8K + 1) bytes of output.
seq 1860 | shuf > /dev/null || fail=1
(exit $fail); exit $fail
diff --git a/tests/misc/sort-compress b/tests/misc/sort-compress
index af961d202..0cafb2e9f 100755
--- a/tests/misc/sort-compress
+++ b/tests/misc/sort-compress
@@ -57,28 +57,28 @@ EOF
chmod +x gzip
# This will find our new gzip in PATH
-PATH=.:$PATH sort -S 1k in > out || fail=1
+PATH=.:$PATH sort -S 1k --compress-program=gzip in > out || fail=1
cmp exp out || fail=1
test $fail = 1 && diff out exp 2> /dev/null
test -f ok || fail=1
rm -f ok
-# This is to make sure we can disable compression
-PATH=.:$PATH GNUSORT_COMPRESSOR= sort -S 1k in > out || fail=1
+# This is to make sure it works with no compression.
+PATH=.:$PATH sort -S 1k in > out || fail=1
cmp exp out || fail=1
test $fail = 1 && diff out exp 2> /dev/null
test -f ok && fail=1
# This is to make sure we can use something other than gzip
mv gzip dzip || fail=1
-GNUSORT_COMPRESSOR=./dzip sort -S 1k in > out || fail=1
+sort --compress-program=./dzip -S 1k in > out || fail=1
cmp exp out || fail=1
test $fail = 1 && diff out exp 2> /dev/null
test -f ok || fail=1
rm -f ok
# Make sure it can find other programs in PATH correctly
-PATH=.:$PATH GNUSORT_COMPRESSOR=dzip sort -S 1k in > out || fail=1
+PATH=.:$PATH sort --compress-program=dzip -S 1k in > out || fail=1
cmp exp out || fail=1
test $fail = 1 && diff out exp 2> /dev/null
test -f ok || fail=1
diff --git a/tests/misc/tty-eof b/tests/misc/tty-eof
index 37d4c3a04..ef60fda0a 100755
--- a/tests/misc/tty-eof
+++ b/tests/misc/tty-eof
@@ -1,7 +1,8 @@
#!/bin/sh
+# -*- perl -*-
# Test whether programs exit upon a single EOF from a tty.
-# Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -76,11 +77,12 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"),
uniq
wc
);
+ my $stderr = 'tty-eof.err';
foreach my $cmd ((@stdin_reading_commands), 'cut -f2')
{
my $exp = new Expect;
$exp->log_user(0);
- $exp->spawn($cmd)
+ $exp->spawn("$cmd 2> $stderr")
or (warn "$ME: cannot run `$cmd': $!\n"), $fail=1, next;
# No input for cut -f2.
$cmd =~ /^cut/
@@ -94,7 +96,7 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"),
defined $found || $cmd =~ /^cut/
or (warn "$ME: $cmd didn't produce expected output\n"),
$fail=1, next;
- defined defined $exp->exitstatus
+ defined $exp->exitstatus
or (warn "$ME: $cmd didn't exit after ^D from standard input\n"),
$fail=1, next;
my $s = $exp->exitstatus;
@@ -102,6 +104,22 @@ $@ and (warn "$ME: this script requires Perl's Expect package >=1.11\n"),
or (warn "$ME: $cmd exited with status $s (expected 0)\n"),
$fail=1;
$exp->hard_close();
+
+ # dd normally writes to stderr. If it exits successfully, we're done.
+ $cmd eq 'dd' && $s == 0
+ and next;
+
+ if (-s $stderr)
+ {
+ warn "$ME: $cmd wrote to stderr:\n";
+ system "cat $stderr";
+ $fail = 1;
+ }
+ }
+ continue
+ {
+ unlink $stderr
+ or warn "$ME: failed to remove stderr file from $cmd, $stderr: $!\n";
}
exit $fail
diff --git a/tests/mkdir/Makefile.am b/tests/mkdir/Makefile.am
index ab217af47..fc2ab777d 100644
--- a/tests/mkdir/Makefile.am
+++ b/tests/mkdir/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.1 gnits
-
TESTS = \
p-thru-slink \
p-3 p-1 p-2 p-v special-1 perm parents t-slash p-slashdot
diff --git a/tests/mv/Makefile.am b/tests/mv/Makefile.am
index dcc6d227f..71c911994 100644
--- a/tests/mv/Makefile.am
+++ b/tests/mv/Makefile.am
@@ -1,6 +1,6 @@
# Make coreutils tests for "mv". -*-Makefile-*-
-# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -18,8 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-AUTOMAKE_OPTIONS = 1.3 gnits
-
TESTS = \
hard-verbose \
backup-dir \
diff --git a/tests/readlink/Makefile.am b/tests/readlink/Makefile.am
index c6a5945cb..4ff7ef37a 100644
--- a/tests/readlink/Makefile.am
+++ b/tests/readlink/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = rl-1 can-e can-f can-m
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/readlink/can-e b/tests/readlink/can-e
index 40c8e9177..5e30ffc62 100755
--- a/tests/readlink/can-e
+++ b/tests/readlink/can-e
@@ -1,7 +1,7 @@
#!/bin/sh
# tests for canonicalize-existing mode (readlink -e).
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -76,58 +76,58 @@ fi
for p in "" "$pwd/$tmp/"; do
fail=1
- v=`readlink -e "${p}"regfile` || break
+ v=`readlink -e "${p}regfile"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -e "${p}"./regfile/` && break
+ v=`readlink -e "${p}./regfile/"` && break
test -z "$v" || break
- v=`readlink -e "${p}"subdir` || break
+ v=`readlink -e "${p}subdir"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -e "${p}"./subdir/` || break
+ v=`readlink -e "${p}./subdir/"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -e "${p}"missing` && break
+ v=`readlink -e "${p}missing"` && break
test -z "$v" || break
- v=`readlink -e "${p}"./missing/` && break
+ v=`readlink -e "${p}./missing/"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link1` || break
+ v=`readlink -e "${p}link1"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -e "${p}"./link1/` && break
+ v=`readlink -e "${p}./link1/"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link1/more` && break
+ v=`readlink -e "${p}link1/more"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link2` || break
+ v=`readlink -e "${p}link2"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -e "${p}"./link2/` || break
+ v=`readlink -e "${p}./link2/"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -e "${p}"link2/more` && break
+ v=`readlink -e "${p}link2/more"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link3` && break
+ v=`readlink -e "${p}link3"` && break
test -z "$v" || break
- v=`readlink -e "${p}"./link3/` && break
+ v=`readlink -e "${p}./link3/"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link3/more` && break
+ v=`readlink -e "${p}link3/more"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link4` && break
+ v=`readlink -e "${p}link4"` && break
test -z "$v" || break
- v=`readlink -e "${p}"./link4/` && break
+ v=`readlink -e "${p}./link4/"` && break
test -z "$v" || break
- v=`readlink -e "${p}"link4/more` && break
+ v=`readlink -e "${p}link4/more"` && break
test -z "$v" || break
fail=0
diff --git a/tests/readlink/can-f b/tests/readlink/can-f
index c0cf53063..c83e0ed70 100755
--- a/tests/readlink/can-f
+++ b/tests/readlink/can-f
@@ -1,7 +1,7 @@
#!/bin/sh
# tests for canonicalize mode (readlink -f).
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -76,91 +76,91 @@ fi
for p in "" "$pwd/$tmp/"; do
fail=1
- v=`readlink -f "${p}"regfile` || break
+ v=`readlink -f "${p}regfile"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -f "${p}"./regfile/` && break
+ v=`readlink -f "${p}./regfile/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"regfile/more` && break
+ v=`readlink -f "${p}regfile/more"` && break
test -z "$v" || break
- v=`readlink -f "${p}"./regfile/more/` && break
+ v=`readlink -f "${p}./regfile/more/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"subdir` || break
+ v=`readlink -f "${p}subdir"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -f "${p}"./subdir/` || break
+ v=`readlink -f "${p}./subdir/"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -f "${p}"subdir/more` || break
+ v=`readlink -f "${p}subdir/more"` || break
test "$v" = "$my_pwd/$tmp/subdir/more" || break
- v=`readlink -f "${p}"./subdir/more/` && break
+ v=`readlink -f "${p}./subdir/more/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"missing` || break
+ v=`readlink -f "${p}missing"` || break
test "$v" = "$my_pwd/$tmp/missing" || break
- v=`readlink -f "${p}"./missing/` && break
+ v=`readlink -f "${p}./missing/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"missing/more` && break
+ v=`readlink -f "${p}missing/more"` && break
test -z "$v" || break
- v=`readlink -f "${p}"./missing/more/` && break
+ v=`readlink -f "${p}./missing/more/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link1` || break
+ v=`readlink -f "${p}link1"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -f "${p}"./link1/` && break
+ v=`readlink -f "${p}./link1/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link1/more` && break
+ v=`readlink -f "${p}link1/more"` && break
test -z "$v" || break
- v=`readlink -f "${p}"./link1/more/` && break
+ v=`readlink -f "${p}./link1/more/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link2` || break
+ v=`readlink -f "${p}link2"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -f "${p}"./link2/` || break
+ v=`readlink -f "${p}./link2/"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -f "${p}"link2/more` || break
+ v=`readlink -f "${p}link2/more"` || break
test "$v" = "$my_pwd/$tmp/subdir/more" || break
- v=`readlink -f "${p}"./link2/more/` && break
+ v=`readlink -f "${p}./link2/more/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link2/more/more2` && break
+ v=`readlink -f "${p}link2/more/more2"` && break
test -z "$v" || break
- v=`readlink -f "${p}"./link2/more/more2/` && break
+ v=`readlink -f "${p}./link2/more/more2/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link3` || break
+ v=`readlink -f "${p}link3"` || break
test "$v" = "$my_pwd/$tmp/missing" || break
- v=`readlink -f "${p}"./link3/` && break
+ v=`readlink -f "${p}./link3/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link3/more` && break
+ v=`readlink -f "${p}link3/more"` && break
test -z "$v" || break
- v=`readlink -f "${p}"./link3/more/` && break
+ v=`readlink -f "${p}./link3/more/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link4` || break
+ v=`readlink -f "${p}link4"` || break
test "$v" = "$my_pwd/$tmp/subdir/missing" || break
- v=`readlink -f "${p}"./link4/` && break
+ v=`readlink -f "${p}./link4/"` && break
test -z "$v" || break
- v=`readlink -f "${p}"link4/more` && break
+ v=`readlink -f "${p}link4/more"` && break
test -z "$v" || break
fail=0
diff --git a/tests/readlink/can-m b/tests/readlink/can-m
index bdd4033ea..1d67c65d4 100755
--- a/tests/readlink/can-m
+++ b/tests/readlink/can-m
@@ -1,7 +1,7 @@
#!/bin/sh
# tests for canonicalize-missing mode (readlink -m).
-# Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -76,94 +76,94 @@ fi
for p in "" "$pwd/$tmp/"; do
fail=1
- v=`readlink -m "${p}"regfile` || break
+ v=`readlink -m "${p}regfile"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -m "${p}"./regfile/` || break
+ v=`readlink -m "${p}./regfile/"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -m "${p}"regfile/more` || break
+ v=`readlink -m "${p}regfile/more"` || break
test "$v" = "$my_pwd/$tmp/regfile/more" || break
- v=`readlink -m "${p}"./regfile/more/` || break
+ v=`readlink -m "${p}./regfile/more/"` || break
test "$v" = "$my_pwd/$tmp/regfile/more" || break
- v=`readlink -m "${p}"subdir` || break
+ v=`readlink -m "${p}subdir"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -m "${p}"./subdir/` || break
+ v=`readlink -m "${p}./subdir/"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -m "${p}"subdir/more` || break
+ v=`readlink -m "${p}subdir/more"` || break
test "$v" = "$my_pwd/$tmp/subdir/more" || break
- v=`readlink -m "${p}"./subdir/more/` || break
+ v=`readlink -m "${p}./subdir/more/"` || break
test "$v" = "$my_pwd/$tmp/subdir/more" || break
- v=`readlink -m "${p}"missing` || break
+ v=`readlink -m "${p}missing"` || break
test "$v" = "$my_pwd/$tmp/missing" || break
- v=`readlink -m "${p}"./missing/` || break
+ v=`readlink -m "${p}./missing/"` || break
test "$v" = "$my_pwd/$tmp/missing" || break
- v=`readlink -m "${p}"missing/more` || break
+ v=`readlink -m "${p}missing/more"` || break
test "$v" = "$my_pwd/$tmp/missing/more" || break
- v=`readlink -m "${p}"./missing/more/` || break
+ v=`readlink -m "${p}./missing/more/"` || break
test "$v" = "$my_pwd/$tmp/missing/more" || break
- v=`readlink -m "${p}"link1` || break
+ v=`readlink -m "${p}link1"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -m "${p}"./link1/` || break
+ v=`readlink -m "${p}./link1/"` || break
test "$v" = "$my_pwd/$tmp/regfile" || break
- v=`readlink -m "${p}"link1/more` || break
+ v=`readlink -m "${p}link1/more"` || break
test "$v" = "$my_pwd/$tmp/regfile/more" || break
- v=`readlink -m "${p}"./link1/more/` || break
+ v=`readlink -m "${p}./link1/more/"` || break
test "$v" = "$my_pwd/$tmp/regfile/more" || break
- v=`readlink -m "${p}"link2` || break
+ v=`readlink -m "${p}link2"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -m "${p}"./link2/` || break
+ v=`readlink -m "${p}./link2/"` || break
test "$v" = "$my_pwd/$tmp/subdir" || break
- v=`readlink -m "${p}"link2/more` || break
+ v=`readlink -m "${p}link2/more"` || break
test "$v" = "$my_pwd/$tmp/subdir/more" || break
- v=`readlink -m "${p}"./link2/more/` || break
+ v=`readlink -m "${p}./link2/more/"` || break
test "$v" = "$my_pwd/$tmp/subdir/more" || break
- v=`readlink -m "${p}"link2/more/more2` || break
+ v=`readlink -m "${p}link2/more/more2"` || break
test "$v" = "$my_pwd/$tmp/subdir/more/more2" || break
- v=`readlink -m "${p}"./link2/more/more2/` || break
+ v=`readlink -m "${p}./link2/more/more2/"` || break
test "$v" = "$my_pwd/$tmp/subdir/more/more2" || break
- v=`readlink -m "${p}"link3` || break
+ v=`readlink -m "${p}link3"` || break
test "$v" = "$my_pwd/$tmp/missing" || break
- v=`readlink -m "${p}"./link3/` || break
+ v=`readlink -m "${p}./link3/"` || break
test "$v" = "$my_pwd/$tmp/missing" || break
- v=`readlink -m "${p}"link3/more` || break
+ v=`readlink -m "${p}link3/more"` || break
test "$v" = "$my_pwd/$tmp/missing/more" || break
- v=`readlink -m "${p}"./link3/more/` || break
+ v=`readlink -m "${p}./link3/more/"` || break
test "$v" = "$my_pwd/$tmp/missing/more" || break
- v=`readlink -m "${p}"link4` || break
+ v=`readlink -m "${p}link4"` || break
test "$v" = "$my_pwd/$tmp/subdir/missing" || break
- v=`readlink -m "${p}"./link4/` || break
+ v=`readlink -m "${p}./link4/"` || break
test "$v" = "$my_pwd/$tmp/subdir/missing" || break
- v=`readlink -m "${p}"link4/more` || break
+ v=`readlink -m "${p}link4/more"` || break
test "$v" = "$my_pwd/$tmp/subdir/missing/more" || break
- v=`readlink -m "${p}"./link4/more/` || break
+ v=`readlink -m "${p}./link4/more/"` || break
test "$v" = "$my_pwd/$tmp/subdir/missing/more" || break
fail=0
diff --git a/tests/rm/Makefile.am b/tests/rm/Makefile.am
index 4c212b9d6..e94648945 100644
--- a/tests/rm/Makefile.am
+++ b/tests/rm/Makefile.am
@@ -18,8 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-AUTOMAKE_OPTIONS = 1.1 gnits
-
TESTS = \
i-never \
fail-eacces \
diff --git a/tests/rm/fail-eacces b/tests/rm/fail-eacces
index 29bc91154..b32284864 100755
--- a/tests/rm/fail-eacces
+++ b/tests/rm/fail-eacces
@@ -1,7 +1,7 @@
#!/bin/sh
# Ensure that rm -rf unremovable-non-dir gives a diagnostic.
-# Copyright (C) 2006 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ if test "$VERBOSE" = yes; then
fi
. $srcdir/../lang-default
+PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
diff --git a/tests/rmdir/Makefile.am b/tests/rmdir/Makefile.am
index e1c96437e..eadbaba33 100644
--- a/tests/rmdir/Makefile.am
+++ b/tests/rmdir/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = fail-perm ignore t-slash
EXTRA_DIST = $(TESTS)
diff --git a/tests/seq/Makefile.am b/tests/seq/Makefile.am
index 3af0268b9..7463a5d3a 100644
--- a/tests/seq/Makefile.am
+++ b/tests/seq/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.3b gnits
-
TESTS = basic
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/stty/Makefile.am b/tests/stty/Makefile.am
index 003b7eb13..5cd33b5f2 100644
--- a/tests/stty/Makefile.am
+++ b/tests/stty/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.2f gnits
-
TESTS = row-col-1 basic-1
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/tee/Makefile.am b/tests/tee/Makefile.am
index c4b8b2993..48f3239af 100644
--- a/tests/tee/Makefile.am
+++ b/tests/tee/Makefile.am
@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
-AUTOMAKE_OPTIONS = 1.4 gnits
-
TESTS = basic dash
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
diff --git a/tests/touch/Makefile.am b/tests/touch/Makefile.am
index aabdb0900..1fce9cd67 100644
--- a/tests/touch/Makefile.am
+++ b/tests/touch/Makefile.am
@@ -1,7 +1,6 @@
# Make coreutils tests for "touch". -*-Makefile-*-
-# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
-# Free Software Foundation, Inc.
+# Copyright (C) 1998-2007 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,8 +17,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
-AUTOMAKE_OPTIONS = 1.3 gnits
-
TESTS = \
read-only \
relative \