Compare commits

..

146 Commits
v6.7 ... v6.8

Author SHA1 Message Date
Jim Meyering
cc2d4f6c46 Version 6.8.
* NEWS: Record release date and new version number.
* configure.ac (AC_INIT): New version number.
2007-02-24 21:16:52 +01:00
Jim Meyering
471eca0dd6 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.
2007-02-24 20:57:14 +01:00
Jim Meyering
e98137ddd4 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:
2007-02-24 13:57:51 +01:00
Jim Meyering
1b2056c435 * README: Document the OSF/1 4.0d build failure and work-around.
Reported by Bruno Haible.
2007-02-24 13:49:20 +01:00
Jim Meyering
f92a08e171 * 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 13:13:45 +01:00
Paul Eggert
3ea177e3fa * 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 12:24:27 +01:00
Jim Meyering
75460e090c 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".
2007-02-24 09:26:56 +01:00
Jim Meyering
90390c6a92 * man/Makefile.am (.x.1): Warn when unable to update a man page.
Suggestion from Bruno Haible.
2007-02-24 09:14:56 +01:00
Bruno Haible
63813d0950 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.
2007-02-24 08:51:19 +01:00
Bruno Haible
2e140cfb42 * 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.
2007-02-24 08:22:08 +01:00
Bruno Haible
33176a7269 * 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-24 08:20:37 +01:00
Jim Meyering
813de08e50 * randperm.c (randperm_new): Comment: say that this function
returns a pointer to malloc'd storage.
2007-02-23 22:16:12 +01:00
Jim Meyering
5a8a00e16e * src/date.c (usage): Split a diagnostic that had grown to be
longer than the C89 maximum of 509 bytes.
2007-02-23 17:50:40 +01:00
Ed Santiago
54bdcc09ae * 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 16:11:01 +01:00
Jim Meyering
cb121d8f36 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-23 15:18:16 +01:00
Jim Meyering
3a9070dce7 Correct typo in ChangeLog entry. 2007-02-22 23:51:43 +01:00
Jim Meyering
93f9b9be84 Merge in a change from some other incarnation of this file (gzip?)
* bootstrap (gnulib_tool): Skip get_translations if there is no po/ dir.
2007-02-22 23:37:19 +01:00
Paul Eggert
4e73fea3e3 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-22 19:09:35 +01:00
Jim Meyering
c450b625b4 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 uintptr_t-1 bytes after the sentinel.
Reported by Andreas Schwab.
2007-02-22 16:32:45 +01:00
Jim Meyering
f48ca7f500 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-22 12:50:36 +01:00
Jim Meyering
c25841e0d4 Add to .cvsignore and .gitignore files. 2007-02-21 22:45:09 +01:00
Jim Meyering
45a35825dc * tests/misc/date: Remove vestigial use of Data::Dumper. 2007-02-21 17:26:32 +01:00
Paul Eggert
cc388d140c * 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-21 17:23:05 +01:00
Jim Meyering
c46549dc38 * bootstrap (CVS_only_file): Use README-hacking. 2007-02-20 22:44:15 +01:00
Jim Meyering
2d2255272d * README-hacking: Update to reflect that we now use git. 2007-02-20 22:42:56 +01:00
Jim Meyering
4cf919bcdf Now that we use GIT, not cvs, rename README-cvs.
* README-hacking: Renamed from...
* README-cvs: ...this.
2007-02-20 22:37:18 +01:00
Jim Meyering
d7226387a9 * 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.
2007-02-20 17:23:51 +01:00
Jim Meyering
dd99d05b4a * 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.
2007-02-20 17:20:22 +01:00
Jim Meyering
fd32ffb4da * bootstrap: Remove occurrences of $bt (._bootmp) from lib/Makefile.
Based on the bison 2007-02-19 change by Joel E. Denny.
2007-02-20 17:08:10 +01:00
Paul Eggert
c363fcb9f0 * 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 22:11:18 +01:00
Jim Meyering
e189deb855 * bootstrap: Fix typo s/dowloading/downloading/ in --help output. 2007-02-19 18:44:21 +01:00
Jim Meyering
aeb892e592 Add to .cvsignore and .gitignore files. 2007-02-18 22:40:52 +01:00
Jim Meyering
6819756293 Rely on gnulib-generated stdlib.h, not exit.h.
* src/system.h: Don't include exit.h, now that it's subsumed
by the gnulib-generated stdlib.h.
* lib/xfts.c: Include <stdlib.h> rather than exit.h, now that stdlib.h
2007-02-18 22:34:37 +01:00
Jim Meyering
c95bb0c6f0 * tests/rm/fail-eacces: Skip this test when running as root.
Reported by Matthew Woehlke.
2007-02-18 17:40:06 +01:00
Jim Meyering
d07d81df27 * 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-18 12:06:01 +01:00
Paul Eggert
516f42ab40 * 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-15 08:16:30 +01:00
Jim Meyering
d163cd681a 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-13 22:27:27 +01:00
Jim Meyering
0d8ca457b3 * .x-sc_useless_cpp_parens: Ignore a false-positive in a shell script. 2007-02-12 20:09:12 +01:00
Jim Meyering
e152d05d82 * 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-12 01:20:20 +01:00
Jim Meyering
a09b047947 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>.
2007-02-10 22:30:18 +01:00
Jim Meyering
bbb61fa617 * Makefile.maint (longopt_re): Relax the regexp, making square
brackets optional, so it matches the newly reported violations, too.
2007-02-10 16:17:41 +01:00
Jim Meyering
0c2d21d3f2 * 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-10 16:15:34 +01:00
Jim Meyering
d282370566 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-03 20:02:48 +01:00
Paul Eggert
b28a8851ed * 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.
2007-02-03 18:45:46 +01:00
Paul Eggert
1c73876f5f * 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-03 18:12:11 +01:00
Jim Meyering
251f774621 * src/nl.c (proc_text): Use "NULL", not "(struct re_registers *) 0". 2007-02-02 08:57:47 +01:00
Jim Meyering
1d72903faf * 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-02-02 01:22:58 +01:00
Jim Meyering
82276cbd2e * vc-list-files: Select column 2, not 3 (hg-0.9.3's manifest format
now has only two columns).
2007-01-30 23:07:38 +01:00
Paul Eggert
c5d2da8ac8 * coreutils.texi: @item -> @itemx to fix some typos. 2007-01-30 22:56:48 +01:00
Paul Eggert
31bb8a431a * coreutils.texi (mkdir invocation): Say how to set the file
permission bits of a parent directory with mkdir -p.
2007-01-30 22:54:34 +01:00
Jim Meyering
c544a36826 Document new syntax: "chown +0:+287 file", "chgrp +99 file"
* coreutils.texi (Disambiguating names and IDs): New section.
(chown invocation, chgrp invocation): Mention the new syntax
with an xref to the new section.
2007-01-29 18:09:57 +01:00
Jim Meyering
bbe4be0c9a Regenerate .cvsignore and .gitignore files. 2007-01-29 15:38:50 +01:00
Jim Meyering
449a3751d1 Plug a leak in ls.
* src/ls.c (print_dir): Don't leak a "DIR"+fd upon failure to
determine dev/inode or upon detecting a symlink loop.
2007-01-29 14:18:28 +01:00
Jim Meyering
e4eaba04dd * src/ls.c: Rename three global variables.
(cwd_file): Rename from 'files'.
(cwd_n_alloc): Rename from 'nfiles'.
(cwd_n_used): Rename from 'files_index'.
2007-01-29 14:06:45 +01:00
Jim Meyering
fc9b328ab4 Shave 8 bytes off the size of "struct fileinfo".
* src/ls.c (fileinfo): Put all members of type "bool" together.
2007-01-29 12:25:01 +01:00
Paul Eggert
c1f8d48387 Modify "ls" to sort its data faster, using the new gnulib mpsort
module rather than qsort.  This is particularly a win in
environments where strcoll is slow, since mpsort typically calls
strcoll less often than qsort does.
* bootstrap.conf (gnulib_modules): Add mpsort.
* src/ls.c: Include mpsort.h.
(sorted_file, sorted_file_alloc): New vars, for a new vector of
pointers to the file info, for speed.
(clear_files, extract_dirs_from_files, sort_files, print_current_files):
(print_many_per_line, print_horizontal, print_with_commas):
(calculate_columns): Set and use new vector.
(initialize_ordering_vector): New function.
2007-01-29 12:08:52 +01:00
Jim Meyering
e7420f9781 Regenerate .cvsignore and .gitignore files, and reflect recent removal
of string.h-related lib/*.h files
2007-01-27 00:09:28 +01:00
Paul Eggert
2b0483aa03 Adjust to today's change to gnulib, which added a module for
string.h to replace the little include files like strcase.h.
* src/dircolors.c: Don't include strcase.h.
* src/system.h: Don't include mempcpy.h, memrchr.h, stpcpy.h, strpbrk.h.
2007-01-26 23:58:37 +01:00
Jim Meyering
9140950afb * src/dd.c (advance_input_after_read_error): Change diagnostic to
say "invalid file offset" rather than "screwy file offset".
2007-01-26 16:37:37 +01:00
Jim Meyering
e0b3b059b2 * .x-sc_cast_of_argument_to_free: Remove this file.
* Makefile.am (EXTRA_DIST): Likewise.
2007-01-26 11:11:15 +01:00
Dan Hipschman
2d2a0c8311 * src/sort.c (create_temp): Remove superfluous access-X_OK
check.  find_in_path does this for us.
2007-01-25 21:56:32 +01:00
Jim Meyering
11b626c20f Remove usually-skipped test.
* tests/cp/open-perm-race: Remove this file.  It is subsumed
by parent-perm-race.
* tests/cp/Makefile.am (TESTS): Remove open-perm-race.
* tests/sort/Makefile.am: Regenerate.
2007-01-24 10:36:02 +01:00
Jim Meyering
a16f807d7e Pass "make distcheck" again.
* src/sort.c (usage): Split a diagnostic that had grown to be
longer than the C89 maximum of 509 bytes.
* .x-sc_cast_of_argument_to_free: New file.  Allow a cast in sort.c.
FIXME: this is just temporary, while we wait to remove the offending
access-calling code.
* Makefile.am (EXTRA_DIST): Add .x-sc_cast_of_argument_to_free.
* Makefile.maint (sc_cast_of_argument_to_free): Use the
canonical, $$($(CVS_LIST_EXCEPT)).
* m4/.gitignore, m4/.cvsignore, lib/.gitignore, lib/.cvsignore: Update.
2007-01-24 09:32:56 +01:00
Paul Eggert
a0b2bc8de7 * NEWS: New option sort -C, proposed by XCU ERN 127, which looks
like it will be approved.  Also add --check=quiet, --check=silent
as long aliases, and --check=diagnose-first as an alias for -c.
* doc/coreutils.texi (sort invocation): Document this.
Also, mention that sort -c can take at most one file.
* src/sort.c: Implement this.
Include argmatch.h.
(usage): Document the change.
(CHECK_OPTION): New constant.
(long_options): --check now takes an optional argument, and is now
treated differently from 'c'.
(check_args, check_types): New constant arrays.
(check): New arg CHECKONLY, which suppresses diagnostic if -C.
(main): Parse the new options.
* tests/sort/Test.pm (02d, 02d, incompat5, incompat6):
New tests for -C.
2007-01-24 09:06:57 +01:00
Jim Meyering
a0d74a99b7 Fix a typo.
* tests/misc/sort-compress: Use $abs_top_builddir, not $top_builddir.
* tests/misc/Makefile.am (TESTS_ENVIRONMENT): Likewise.
2007-01-24 08:54:51 +01:00
Jim Meyering
124adb3a19 Don't depend on "which".
* tests/misc/sort-compress (SORT): Use $abs_builddir, now which.
* tests/misc/Makefile.am (TESTS_ENVIRONMENT): Export top_builddir.
2007-01-24 00:34:54 +01:00
Dan Hipschman
054defae19 Test sort compression.
* tests/misc/Makefile.am: Add the test.
* tests/misc/sort-compress: New file containing the tests.
2007-01-24 00:27:01 +01:00
Jim Meyering
1f7d56fda5 * NEWS: sort temp file compression: tweak wording.
* src/sort.c (struct sortfile) [name]: Declare member to be const.
2007-01-24 00:22:45 +01:00
Dan Hipschman
f33168da95 * src/sort.c (MAX_FORK_RETRIES_COMPRESS, MAX_FORK_RETRIES_DECOMPRESS):
In pipe_fork callers, use these named constants, not "2" and "8".
(proctab, nprocs): Declare to be "static".
(pipe_fork) [lint]: Initialize local, pid,
to avoid unwarranted may-be-used-uninitialized warning.
(create_temp): Use the active voice.  Describe parameters, too.

2007-01-21  James Youngman  <jay@gnu.org>

Centralize all the uses of sigprocmask().  Don't restore an invalid
saved mask.
* src/sort.c (enter_cs, leave_cs): New functions for protecting
code sequences against signal delivery.
* (exit_cleanup): Use enter_cs and leave_cs instead of
calling sigprocmask directly.
(create_temp_file, pipe_fork, zaptemp): Likewise

2007-01-21  Dan Hipschman  <dsh@linux.ucla.edu>

Add compression of temp files to sort.
* NEWS: Mention this.
* bootstrap.conf: Import findprog.
* configure.ac: Add AC_FUNC_FORK.
* doc/coreutils.texi: Document GNUSORT_COMPRESSOR environment
variable.
* src/sort.c (compress_program): New global, holds the name of the
external compression program.
(struct sortfile): New type used by mergepfs and friends instead
of filenames to hold PIDs of compressor processes.
(proctab): New global, holds compressor PIDs on which to wait.
(enum procstate, struct procnode): New types used by proctab.
(proctab_hasher, proctab_comparator): New functions for proctab.
(nprocs): New global, number of forked but unreaped children.
(reap, reap_some): New function, wait for/cleanup forked processes.
(register_proc, update_proc, wait_proc): New functions for adding,
modifying and removing proctab entries.
(create_temp_file): Change parameter type to pointer to file
descriptor, and return type to pointer to struct tempnode.
(dup2_or_die): New function used in create_temp and open_temp.
(pipe_fork): New function, creates a pipe and child process.
(create_temp): Creates a temp file and possibly a compression
program to which we filter output.
(open_temp): Opens a compressed temp file and creates a
decompression process through which to filter the input.
(mergefps): Change FILES parameter type to struct sortfile array
and update access accordingly.  Use open_temp and reap_some.
(avoid_trashing_input, merge): Change FILES parameter like
mergefps and call create_temp instead of create_temp_file.
(sort): Call create_temp instead of create_temp_file.
Use reap_some.
(avoid_trashing_input, merge, sort, main): Adapt to mergefps.
2007-01-24 00:00:21 +01:00
Jim Meyering
590a3f5b08 * tests/misc/pwd-long: Work properly even when run from the
wrong one of two or more bind-mounted sibling directories.
Suggestion from Mike Stone in <http://bugs.debian.org/380552>.
2007-01-20 21:58:31 +01:00
Paul Eggert
bdbd5d31f8 Standardize on list of signals when an app catches signals.
* src/csplit.c (main): Also catch SIGALRM, SIGPIPE, SIGPOLL,
SIGPROF, SIGVTALRM, SIGXCPU, SIGXFSZ.
* src/ls.c (main): Likewise (except SIGPIPE was already caught).
Note that ls.c is special, as it also catches SIGTSTP.
* src/sort.c (main): Likewise.  Also catch SIGQUIT.  More details in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9510>.
2007-01-20 09:54:20 +01:00
Jim Meyering
3d63c453d5 [lib/ChangeLog]
* .cvsignore, .gitignore: Add sys, as well as more
bootstrap-inserted file names.
[m4/ChangeLog]
* .cvsignore, .gitignore: Add more bootstrap-inserted file names.
2007-01-19 23:28:03 +01:00
Dan Hipschman
e175f0d5b2 * src/sort.c (cleanup): Clear temphead at the end.
(exit_cleanup): New function.
(main): Don't invoke atexit until we're ready.
Invoke it with exit_cleanup, not with cleanup and close_stdout,
to avoid a race condition with cleanup and signal handling.  More
details: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9508
2007-01-19 23:03:18 +01:00
Jim Meyering
fd77348fef * coreutils.texi (ls: General output formatting): Mention the
workarounds to accommodate the Apple Terminal bug.
2007-01-19 12:10:04 +01:00
Jim Meyering
03b1e07ae0 * src/c99-to-c89.diff: Adjust remove.c offsets. 2007-01-18 10:18:02 +01:00
Jim Meyering
0928c2414a Make "rm --interactive=never ..." never prompt.
* NEWS: Mention this.
* src/remove.h (enum rm_interactive): New ternary type.
(struct rm_options) [interactive]: Use it, here -- rather than bool.
* src/remove.c (prompt): Reflect type change.
* src/mv.c (rm_option_init): Initialize to RMI_NEVER now.
* src/rm.c (main): Add a FIXME comment for '-d' option.
Adapt to type change of rm_options.interactive.

* tests/rm/i-never: New file.  Test for the above fix.
* tests/rm/Makefile.am (TESTS): Add i-never.
2007-01-17 17:15:20 +01:00
Jim Meyering
d1ad73e0bf * bootstrap (gnulib_tool): When adding to .cvsignore and .gitignore,
emit foo.h, for each foo_.h.  This yields one false-positive, fts.h,
but that's ok, since fts_.h will eventually be renamed.
2007-01-15 11:31:51 +01:00
Jim Meyering
1e23a1785a * src/remove.c (remove_dir): Don't use errno in diagnostic.
Root-only test failure reported by Alex van Hout and Jon Grosshart in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9415/focus=9415>.
2007-01-15 10:39:32 +01:00
Jim Meyering
54050ea91d * bootstrap.conf (avoided_gnulib_modules): Fix my typo:
s/--avoid=canonicalize-lgpl/--avoid=canonicalize-gpl/
2007-01-15 10:32:09 +01:00
Jim Meyering
aa5a4fc172 * fchdir-stub.c: Remove file. No longer needed. 2007-01-14 17:18:51 +01:00
Bruno Haible
bb4112b407 Enable use of gnulib's new fchdir module.
* bootstrap.conf (avoided_gnulib_modules): Avoid canonicalize-lgpl,
since we use canonicalize.
(gnulib_modules): Add fchdir.
* m4/jm-macros.m4 (coreutils_MACROS): Remove fchdir-stub.
2007-01-14 17:15:49 +01:00
Jim Meyering
9c88531fb0 Put CU_TEST_NAME in the environment for each test run by "make check".
* Transform all Makefile.am files so that when running "make check",
CU_TEST_NAME is set to the name of the test.  This is so that when I
run valgrind-enabled (--log-file-qualifier=CU_TEST_NAME) "make check"
on the entire package it is more convenient to map a leak or error
found in a valgrind log file back to the offending test.
Use this command:
(echo tests/Makefile.am.in; find tests -name Makefile.am) \
 |xargs perl -pi -e '/^(\s*)PATH=...VG_PATH_PREFIX/ and ' \
   -e 'print $1,q|CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst |,"\\\n"'
2007-01-13 11:32:19 +01:00
Jim Meyering
9afcb30571 Regenerate .cvsignore and .gitignore files. 2007-01-13 11:22:01 +01:00
Jim Meyering
4e2fd4cca6 Avoid a leak in expr's implementation of the ":" (match) operator.
* src/expr.c (docolon): Free the regexp buffer using regfree, rather
than doing it manually, being careful to set fastmap to NULL first.
Free any re_regs.start and .end members, if necessary.
2007-01-11 19:31:27 +01:00
Jim Meyering
c6357f0cab * tests/misc/test-diag: Work also when libc's error function
reports the entire program name ("../../src/test"), rather than
just the final component.
2007-01-11 18:59:24 +01:00
Jim Meyering
fbcbba4b94 Merge branch 'master' of /cu 2007-01-11 14:50:09 +01:00
Jim Meyering
48545b5756 trivial merge 2007-01-11 14:49:19 +01:00
Jim Meyering
b5f1873022 Don't use fts_statp uninitialized for "chown -RLh --preserve-root ...".
* src/chown-core.c (FTSENT_IS_DIRECTORY): New macro.
(change_file_owner): Perform the ROOT_DEV_INO_CHECK only for a
directory.  Non-directory entries lack fts_statp data when using
the FTS_NOSTAT option.
2007-01-10 22:00:44 +01:00
Jim Meyering
dad7d86d57 * tests/sample-test: Update copyright date to 2007.
* Makefile.maint (copyright-check): Also check the copyright date
in tests/sample-test.
2007-01-07 18:38:56 +01:00
Jim Meyering
bce110cdd5 * tests/fmt/basic (pfx-only, pfx-of-pfx): New tests,
based on examples from G.P. Halkes in
<http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/9388>.
2007-01-06 10:42:17 +01:00
G.P. Halkes
37bcc27707 * src/fmt.c (copy_rest): Correct prefix handling.
Don't elide a line with the prefix followed by only white space.
(get_line): Move EOF-check to loop-termination condition.
* tests/fmt/basic (pfx-1): Adjust test to expect desired result.
(pfx-2): Remove test; its premise was contrary to the documentation.
2007-01-06 09:49:47 +01:00
Jim Meyering
ab58de37e6 Avoid a used-uninitialized bug for invalid input, i.e., when the size
of the input, not counting newlines, is 1 % 4.
* gl/lib/base64.c (base64_decode): Don't hard-code inlen==4.
It may be smaller when flushing.
2007-01-05 12:30:51 +01:00
Mike Frysinger
4082e3be7c * src/dircolors.hin: Add a TERM directive for cons25. 2007-01-05 09:52:10 +01:00
Jim Meyering
11bcfcc72a Use the release year, not the current year.
* src/groups.sh (version): Use a better name: @RELEASE_YEAR@.
* src/Makefile.am (RELEASE_YEAR): Define it.
(.sh): Use it.
Thanks to a prod from Eric Blake.
2007-01-04 15:34:29 +01:00
Jim Meyering
aa6a5547b3 Ensure that "group --version" always prints the current year.
* src/groups.sh (version): Use @CURRENT_YEAR@, rather than 2006.
* src/Makefile.am (.sh): Also substitute for @CURRENT_YEAR@.
Suggestion from Eric Blake.
2007-01-04 14:55:42 +01:00
Jim Meyering
c8e51ae68a * Makefile.cfg (local-checks-to-skip): Skip strftime-check, in
case you don't have convenient access to glibc info documentation.
2007-01-04 12:08:36 +01:00
Jim Meyering
2ed0544df4 .cvsignore, .gitignore: Add fchownat.c and wctype-related files. 2007-01-04 12:01:48 +01:00
Jim Meyering
3b933f1e33 [ChangeLog]
When decoding, always allow newlines in input, with almost no
performance impact.
* src/base64.c (do_decode): Initialize decode context.
Call base64_decode one more time, after all input is processed.
(usage): When decoding, newlines are always accepted.

* tests/misc/base64: Add a bunch of tests, for the above.
* gl/lib/base64.c: Include <string.h>.
(base64_decode_ctx_init, get_4, decode_4): New functions.
(base64_decode): Efficiently handle interspersed newlines.
(base64_decode_alloc): Update signature.
* gl/lib/base64.h (struct base64_decode_context): Define.
(base64_decode_ctx_init): Add prototype.
(base64_decode, base64_decode_alloc): Update prototypes.
[doc/ChangeLog]
* coreutils.texi (base64 invocation): When decoding, newlines
are always accepted.
2007-01-04 11:52:52 +01:00
Jim Meyering
99d9e13b9c * gl/lib/base64.c: Copied from gnulib.
* gl/lib/base64.h: Likewise.
2007-01-04 11:36:54 +01:00
Evan Hunt
419aa62c46 [oops] Document what the ".0" in e.g., "-k 2,3.0" means, and...
* coreutils.texi (sort invocation): ... that it can be applied to the
field-end spec, but not the field-start one.  Patch from Evan Hunt.

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-01-03 12:24:35 +01:00
Evan Hunt
482366105a Document what the ".0" in e.g., "-k 2,3.0" means, and...
* coreutils.texi (sort invocation): ... that it can be applied to the
field-end spec, but not the field-start one.  Patch from Evan Hunt.

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-01-03 12:04:24 +01:00
Bruno Haible
f28e07f81d Avoid spurious test failures on MacOS X 10.3.9, in a German locale.
* tests/chown/deref: Apply lang-default.
* tests/misc/split-a: Likewise.
* tests/mv/reply-no: Likewise.

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-01-03 10:51:37 +01:00
Bruno Haible
8563b4c051 * src/copy.c (copy_internal): Use mkfifo as a fallback if mknod fails.
Needed on MacOS X.

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-01-03 10:46:25 +01:00
Paul Eggert
f0b5e513d9 Now, "ls -FRL" always follows symbolic links on Linux.
* NEWS: Mention this bug fix.
* src/ls.c (gobble_file): Fix bug reported by
Nobuyuki Tsuchimura in
http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00152.html
where "ls -FRL" didn't follow a symbolic link in some cases on Linux.
* tests/ls/follow-slink: Add a test for this case.

Signed-off-by: Jim Meyering <jim@meyering.net>
2007-01-02 07:27:22 +01:00
Jim Meyering
3b8560a637 * tests/rm/fail-eperm: Instead, simply transform the actual output diagnostic.
Test failure reported by Bob Proulx.
2007-01-01 10:56:01 +01:00
Jim Meyering
b5ef9617c4 * tests/rm/fail-eperm: Revert last change. The PATH=... setting
is not honored at least on HP-UX 11.23 systems.
2007-01-01 09:51:43 +01:00
Jim Meyering
747e7a8da8 * bootstrap (gnulib_extra_files): Remove announce-gen.
* bootstrap.conf (gnulib_modules): Add it here instead, now that
it's a module.
2006-12-30 22:16:35 +01:00
Jim Meyering
d2ec687c1c * tests/misc/base64: Factor a long, repetitive string. 2006-12-30 17:46:09 +01:00
Jim Meyering
457b4e69f5 * src/c99-to-c89.diff: Adjust remove.c offsets. 2006-12-30 16:19:26 +01:00
Jim Meyering
d08d66ebc6 Clean up after the change of 2006-12-28.
* src/remove.c (AD_pop_and_chdir): Change **DIRP parameter to *DIRP,
now that this function never modifies the pointer.  Adjust comments
and code accordingly.
(remove_dir): Set "dirp" to NULL right after AD_pop_and_chdir call,
now that AD_pop_and_chdir no longer does that.
2006-12-30 16:12:23 +01:00
Jim Meyering
5017d1b4e1 * tests/rm/fail-eperm: Avoid spurious differences (the error function
from latest glibc no longer prints the full program_name): so don't
invoke rm via ../../src/rm.  Instead, invoke it via "PATH=../../src rm".
2006-12-30 12:50:43 +01:00
Jim Meyering
841d9a7d5d * tests/mv/acl (skip): Skip this test also if the destination
directory, which is on a different file system, lacks ACL support.
2006-12-30 11:49:04 +01:00
Jim Meyering
67b9752cd1 * src/copy.c (copy_reg): Rewrite a comment that was rendered
inaccurate by the 2006-10-18 change.
2006-12-30 09:34:31 +01:00
Jim Meyering
88891aef7e When moving "up" the hierarchy, be careful to remove a just-emptied
directory before opening ".", to avoid trouble with file system
implementations that cache readdir results at opendir-time.
* src/remove.c (AD_pop_and_chdir): Add a file descriptor parameter.
Don't update **DIRP.  Don't call fdopendir here.
(remove_dir): Call fdopendir here instead.
Report and patch from Mikulas Patocka:
<http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00170.html>
2006-12-28 19:37:07 +01:00
Jim Meyering
bbcfef38a3 Remove 2006-12-24 entry (the corresponding change was never committed).
The underlying problem was fixed on 2006-12-26, by requiring a new-enough
version of autoconf.
2006-12-28 09:25:26 +01:00
Jim Meyering
2eea35fcf2 * src/tail.c (usage): Mention +N for --bytes and --lines.
Suggestion from Evan Hunt.
2006-12-27 16:00:15 +01:00
Jim Meyering
f20cd37e51 * configure.ac: Require autoconf-2.61 and automake-1.10.
Without the former (even with autoconf-2.60), "make distcheck"
would fail (without the 2006-09-26 autoconf AC_CHECK_DECL fix),
due to an inttypes.h generated with CFLAGS including -pedantic.
With the old decl check, @HAVE_DECL_STRTOUMAX@ would be 0.
2006-12-27 11:27:54 +01:00
Jim Meyering
4b9e987554 * Makefile.maint (VC-tag): Define, so as to gpg-sign each release
tag, using the release version number as the message.
(vc-dist): Use $(VC-tag), rather than "$(VC) tag".

2006-12-24  Jim Meyering  <jim@meyering.net>

* Makefile.maint (my-distcheck): Don't *configure* with
restrictive CFLAGS ('-Werror -ansi -pedantic -Wno-long-long'),
since it ends up provoking errors in generation of inttypes.h
on an Ubuntu edgy-based system.  That leads to compilation
failure due to e.g., imaxabs redefinition.
Instead, configure with default CFLAGS, and compile the
package with restrictive CFLAGS.
2006-12-26 16:42:33 +01:00
Paul Eggert
f24ff8f42b * NEWS: dd bs= operands now silently override later ibs= and obs=,
as POSIX requires.
* src/dd.c (scanargs): Implement it.
* tests/dd/misc (outbytes): Test it.
* doc/coreutils.texi (dd invocation): Specify that bs=N
overrides later ibs and obs, undoing part of the
previous change.  (The behavior was wrong.)
2006-12-22 10:09:37 +01:00
Jim Meyering
699188aa87 * coreutils.texi (dd invocation): Specify that bs=N overrides only any
_preceding_ ibs and obs settings.  Spotted by Andreas Schwab.
2006-12-21 11:13:48 +01:00
Jim Meyering
a828a78563 * Makefile.maint (patch-check): Fix shell quoting. 2006-12-21 11:05:16 +01:00
Jim Meyering
2d4cd37758 * coreutils.texi (dd invocation): Add to the description of cbs. 2006-12-21 10:24:51 +01:00
Jim Meyering
f0ee72aa01 * coreutils.texi (dd invocation): Improve the documentation
for bs, ibs, obs, and cbs.  Suggestion from Dan Jacobson.
Patch by Olivier Delhomme.
2006-12-21 10:18:58 +01:00
Jim Meyering
c8ef95eaed "rm -rf /etc/motd" (run by non-root) now prints a diagnostic.
* src/remove.c (remove_entry): Handle EACCES for a non-directory, too.
Karl Berry reported that a cross-partition "mv /etc/issue ~"
failed with the um,... suboptimal diagnostic,
"mv: cannot remove `/etc/issue': Not a directory".
* tests/rm/Makefile.am (TESTS): Add fail-eacces.
* tests/rm/fail-eacces: New file.
* NEWS: Mention that both mv and rm are affected.
2006-12-21 08:58:11 +01:00
Jim Meyering
d69fc66d81 "cut -f 2- A B" no longer triggers a double-free bug
* src/cut.c (cut_fields): Set file-scoped global to NULL after
freeing it.  This avoids a double-free (and core dump on some systems)
for this usage: "echo 1>a; echo 2>b; cut -f2- a b".  Reported by
James Hunt in <http://bugzilla.redhat.com/220312>.
* NEWS: List this bug fix.
* THANKS: Mention him.
* tests/misc/cut: New file.
* tests/misc/Makefile.am (TESTS): Add cut.
2006-12-20 14:25:55 +01:00
Jim Meyering
4e48b4ce33 * tests/cp/open-perm-race: Correct the gdb-existence check.
Don't run either subsequent gdb command in a sub-shell.
Reported by Thomas Schwinge.
* THANKS: bring up to date.
2006-12-15 10:43:20 +01:00
Paul Eggert
6f005c8491 Make sure cp -p isn't too generous with file permissions.
* tests/cp/Makefile.am (TESTS): Add file-perm-race.
* tests/cp/file-perm-race: New file.
Signed-off-by: Jim Meyering <jim@meyering.net>
2006-12-15 09:50:40 +01:00
Paul Eggert
6f3efa15eb Ensure cp -pR --parents isn't too generous with parent permissions.
* tests/cp/Makefile.am (TESTS): Add parent-perm-race.
* tests/cp/parent-perm-race: New file.
Signed-off-by: Jim Meyering <jim@meyering.net>
2006-12-15 09:44:58 +01:00
Jim Meyering
33de42f2a8 * tests/chgrp/default-no-deref: Don't assume that files are created
with the primary group by default.  That's not true in a directory
with the set-GID bit set.
2006-12-14 21:07:49 +01:00
Jim Meyering
c97742932a Don't hang when there's no input tty.
* tests/cp/open-perm-race: Skip this test if there is no
controlling input `terminal'.
2006-12-14 19:32:10 +01:00
Jim Meyering
a6a1e73c0a Test for a hard-to-detect race fix, using gdb.
* tests/cp/open-perm-race: New file, to test for the
cp --preserve=ownership fix of 2006-12-06.
* tests/cp/Makefile.am (TESTS_ENVIRONMENT): Define abs_top_builddir.
(TESTS): Add open-perm-race.
2006-12-14 17:17:31 +01:00
Jim Meyering
c3154b2947 chgrp, chown: Don't prohibit -RLh, aka -RL with --no-dereference.
* src/chgrp.c (main): Don't prohibit -RLh, aka -RL with --no-dereference.
* src/chown.c (main): Likewise.
* src/chown-core.c (change_file_owner): Add to a comment.
* tests/chown/preserve-root: Add tests.
* doc/coreutils.texi (Treating / specially): With --preserve-root,
chgrp and chown will not modify "/", even through a symlink.
2006-12-14 15:41:50 +01:00
Jim Meyering
24852bf5b5 * NEWS: --preserve-root now works with chgrp, chmod, and chown.
* src/chmod.c (process_file): Do honor the --preserve-root option.
* src/chown-core.c (change_file_owner): Likewise, but here, also
handle the case in which a traversal would go "through" a symlink
to root.  Reported by Matthew M. Boedicker
* tests/chown/preserve-root: Test for the above.
* tests/chown/Makefile.am (TESTS): Add preserve-root.
2006-12-14 11:14:25 +01:00
Jim Meyering
56007809c3 * coreutils.texi: Remove two doubled words. 2006-12-14 09:15:51 +01:00
Jim Meyering
629214eaf8 * NEWS: Mention the chmod fix induced by the recent change to gnulib's openat.m4. 2006-12-14 00:22:50 +01:00
Andreas Schwab
ae3f43d3eb Don't fail if mv/acl test succeeds.
* tests/mv/acl (skip): Check for acl support in the file system.
* tests/mv/Makefile.am (XFAIL_TESTS): Remove.
(TESTS_ENVIRONMENT): Pass CONFIG_HEADER.
Signed-off-by: Jim Meyering <jim@meyering.net>
2006-12-13 22:26:23 +01:00
Paul Eggert
ec95137cc3 Remove some arbitrary restrictions on size fields,
so that commands like "sort -k 18446744073709551616" no longer fail merely
because 18446744073709551616 doesn't fit in uintmax_t.  The trick is that
these fields can all be treated as effectively infinity;  their exact
values don't matter, since no internal buffer can be that long.
* src/join.c (string_to_join_field): Verify that SIZE_MAX <= ULONG_MAX
if the code assumes this.  Silently truncate too-large values to SIZE_MAX,
as the remaining code will do the right thing in this case.
* src/sort.c (parse_field_count): Likewise.
* src/uniq.c (size_opt, main): Likewise.
* tests/join/Test.pm (bigfield): New test.
* tests/sort/Test.pm (bigfield): New test.
* tests/uniq/Test.pm (121): New test.
Signed-off-by: Jim Meyering <jim@meyering.net>
2006-12-13 22:03:54 +01:00
Jim Meyering
ae3ee95eb8 * tests/chgrp/default-no-deref: New test.
* tests/chgrp/Makefile.am (TESTS): Add default-no-deref.
2006-12-13 13:28:17 +01:00
Jim Meyering
a6895a8da2 * jm-macros.m4: Remove AC_FUNC_SETVBUF_REVERSED, now that it's a no-op. 2006-12-12 14:41:30 +01:00
Jim Meyering
8d550c12b8 * src/system.h (SETVBUF): Remove definition, now that the
autoconf macro, AC_FUNC_SETVBUF_REVERSED, does nothing.
* src/tee.c (tee_files): s/SETVBUF/setvbuf/.
* src/od.c (open_next_file): Likewise.
2006-12-12 14:34:23 +01:00
Jim Meyering
0ee9adb1fa * man/Makefile.am (.x.1): Make help2man use $(PACKAGE_STRING) as the
"source".  I.e. "GNU coreutils 6.7".
2006-12-09 19:20:56 +01:00
Jim Meyering
0473e718e6 * NEWS: With the change from "-pre" to "-dirty" suffix, also change
from NEXT_VER-pre to CUR_VER-dirty.  So, this is 6.7-dirty.
* configure.ac (AC_INIT): s/6.8-dirty/6.7-dirty/.
2006-12-09 15:57:06 +01:00
Jim Meyering
dab023dec1 * tests/uniq/Test.pm (test_vector): Skip the pipe-reading test
whenever uniq is expected to fail.  This should catch the other case
[test #112] in which uniq emits "cat: write error: Broken pipe" on
some systems.
2006-12-09 14:17:00 +01:00
Jim Meyering
939c480a79 Include bootstrap tool version info in the announcement form.
* Makefile.maint (gnulib_snapshot_date): Define.
(announcement): Use two new announce-gen options,
--bootstrap-tools and --gnulib-snapshot-date.
* Makefile.cfg (gnulib_dir): Set.
2006-12-08 10:28:05 +01:00
Jim Meyering
07af816554 Post-release version change.
* NEWS: Add a line for 6.8-dirty.
* configure.ac (AC_INIT): Set new version string.
2006-12-08 08:28:04 +01:00
Jim Meyering
6b49da0dc3 .prev-version: Record previous version: 6.7. 2006-12-08 00:19:29 +01:00
147 changed files with 4085 additions and 762 deletions

View File

@@ -1 +1 @@
6.6
6.7

View File

@@ -10,3 +10,4 @@
^lib/strtod.c
^lib/xstrtol.c
^m4/
^tests/misc/pwd-unreadable-parent

816
ChangeLog
View File

@@ -1,3 +1,819 @@
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.
* src/ls.c (print_dir): Don't leak a "DIR"+fd upon failure to
determine dev/inode or upon detecting a symlink loop.
* src/ls.c: Rename three global variables.
(cwd_file): Rename from 'files'.
(cwd_n_alloc): Rename from 'nfiles'.
(cwd_n_used): Rename from 'files_index'.
Shave 8 bytes off the size of "struct fileinfo".
* src/ls.c (fileinfo): Put all members of type "bool" together.
2007-01-28 Paul Eggert <eggert@cs.ucla.edu>
Modify "ls" to sort its data faster, using the new gnulib mpsort
module rather than qsort. This is particularly a win in
environments where strcoll is slow, since mpsort typically calls
strcoll less often than qsort does.
* bootstrap.conf (gnulib_modules): Add mpsort.
* src/ls.c: Include mpsort.h.
(sorted_file, sorted_file_alloc): New vars, for a new vector of
pointers to the file info, for speed.
(clear_files, extract_dirs_from_files, sort_files, print_current_files):
(print_many_per_line, print_horizontal, print_with_commas):
(calculate_columns): Set and use new vector.
(initialize_ordering_vector): New function.
2007-01-26 Paul Eggert <eggert@cs.ucla.edu>
Adjust to today's change to gnulib, which added a module for
string.h to replace the little include files like strcase.h.
* src/dircolors.c: Don't include strcase.h.
* src/system.h: Don't include mempcpy.h, memrchr.h, stpcpy.h, strpbrk.h.
2007-01-26 Jim Meyering <jim@meyering.net>
* src/dd.c (advance_input_after_read_error): Change diagnostic to
say "invalid file offset" rather than "screwy file offset".
* .x-sc_cast_of_argument_to_free: Remove this file.
* Makefile.am (EXTRA_DIST): Likewise.
2007-01-25 Dan Hipschman <dsh@linux.ucla.edu>
* src/sort.c (create_temp): Remove superfluous access-X_OK
check. find_in_path does this for us.
2007-01-24 Jim Meyering <jim@meyering.net>
Remove usually-skipped test.
* tests/cp/open-perm-race: Remove this file. It is subsumed
by parent-perm-race.
* tests/cp/Makefile.am (TESTS): Remove open-perm-race.
* tests/sort/Makefile.am: Regenerate.
Pass "make distcheck" again.
* src/sort.c (usage): Split a diagnostic that had grown to be
longer than the C89 maximum of 509 bytes.
* .x-sc_cast_of_argument_to_free: New file. Allow a cast in sort.c.
FIXME: this is just temporary, while we wait to remove the offending
access-calling code.
* Makefile.am (EXTRA_DIST): Add .x-sc_cast_of_argument_to_free.
* Makefile.maint (sc_cast_of_argument_to_free): Use the
canonical, $$($(CVS_LIST_EXCEPT)).
* m4/.gitignore, m4/.cvsignore, lib/.gitignore, lib/.cvsignore: Update.
2007-01-24 Paul Eggert <eggert@cs.ucla.edu>
* NEWS: New option sort -C, proposed by XCU ERN 127, which looks
like it will be approved. Also add --check=quiet, --check=silent
as long aliases, and --check=diagnose-first as an alias for -c.
* doc/coreutils.texi (sort invocation): Document this.
Also, mention that sort -c can take at most one file.
* src/sort.c: Implement this.
Include argmatch.h.
(usage): Document the change.
(CHECK_OPTION): New constant.
(long_options): --check now takes an optional argument, and is now
treated differently from 'c'.
(check_args, check_types): New constant arrays.
(check): New arg CHECKONLY, which suppresses diagnostic if -C.
(main): Parse the new options.
* tests/sort/Test.pm (02d, 02d, incompat5, incompat6):
New tests for -C.
2007-01-24 Jim Meyering <jim@meyering.net>
Fix a typo.
* tests/misc/sort-compress: Use $abs_top_builddir, not $top_builddir.
* tests/misc/Makefile.am (TESTS_ENVIRONMENT): Likewise.
Don't depend on "which".
* tests/misc/sort-compress (SORT): Use $abs_builddir, now which.
* tests/misc/Makefile.am (TESTS_ENVIRONMENT): Export top_builddir.
2007-01-24 Dan Hipschman <dsh@linux.ucla.edu>
Test sort compression.
* tests/misc/Makefile.am: Add the test.
* tests/misc/sort-compress: New file containing the tests.
2007-01-24 Jim Meyering <jim@meyering.net>
* NEWS: sort temp file compression: tweak wording.
* src/sort.c (struct sortfile) [name]: Declare member to be const.
2007-01-21 Jim Meyering <jim@meyering.net>
* src/sort.c (MAX_FORK_RETRIES_COMPRESS, MAX_FORK_RETRIES_DECOMPRESS):
In pipe_fork callers, use these named constants, not "2" and "8".
(proctab, nprocs): Declare to be "static".
(pipe_fork) [lint]: Initialize local, pid,
to avoid unwarranted may-be-used-uninitialized warning.
(create_temp): Use the active voice. Describe parameters, too.
2007-01-21 James Youngman <jay@gnu.org>
Centralize all the uses of sigprocmask(). Don't restore an invalid
saved mask.
* src/sort.c (enter_cs, leave_cs): New functions for protecting
code sequences against signal delivery.
* (exit_cleanup): Use enter_cs and leave_cs instead of
calling sigprocmask directly.
(create_temp_file, pipe_fork, zaptemp): Likewise
2007-01-21 Dan Hipschman <dsh@linux.ucla.edu>
Add compression of temp files to sort.
* NEWS: Mention this.
* bootstrap.conf: Import findprog.
* configure.ac: Add AC_FUNC_FORK.
* doc/coreutils.texi: Document GNUSORT_COMPRESSOR environment
variable.
* src/sort.c (compress_program): New global, holds the name of the
external compression program.
(struct sortfile): New type used by mergepfs and friends instead
of filenames to hold PIDs of compressor processes.
(proctab): New global, holds compressor PIDs on which to wait.
(enum procstate, struct procnode): New types used by proctab.
(proctab_hasher, proctab_comparator): New functions for proctab.
(nprocs): New global, number of forked but unreaped children.
(reap, reap_some): New function, wait for/cleanup forked processes.
(register_proc, update_proc, wait_proc): New functions for adding,
modifying and removing proctab entries.
(create_temp_file): Change parameter type to pointer to file
descriptor, and return type to pointer to struct tempnode.
(dup2_or_die): New function used in create_temp and open_temp.
(pipe_fork): New function, creates a pipe and child process.
(create_temp): Creates a temp file and possibly a compression
program to which we filter output.
(open_temp): Opens a compressed temp file and creates a
decompression process through which to filter the input.
(mergefps): Change FILES parameter type to struct sortfile array
and update access accordingly. Use open_temp and reap_some.
(avoid_trashing_input, merge): Change FILES parameter like
mergefps and call create_temp instead of create_temp_file.
(sort): Call create_temp instead of create_temp_file.
Use reap_some.
(avoid_trashing_input, merge, sort, main): Adapt to mergefps.
2007-01-20 Jim Meyering <jim@meyering.net>
* tests/misc/pwd-long: Work properly even when run from the
wrong one of two or more bind-mounted sibling directories.
Suggestion from Mike Stone in <http://bugs.debian.org/380552>.
2007-01-20 Paul Eggert <eggert@cs.ucla.edu>
Standardize on list of signals when an app catches signals.
* src/csplit.c (main): Also catch SIGALRM, SIGPIPE, SIGPOLL,
SIGPROF, SIGVTALRM, SIGXCPU, SIGXFSZ.
* src/ls.c (main): Likewise (except SIGPIPE was already caught).
Note that ls.c is special, as it also catches SIGTSTP.
* src/sort.c (main): Likewise. Also catch SIGQUIT. More details in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9510>.
2007-01-19 Dan Hipschman <dsh@linux.ucla.edu>
and Paul Eggert <eggert@cs.ucla.edu>
* src/sort.c (cleanup): Clear temphead at the end.
(exit_cleanup): New function.
(main): Don't invoke atexit until we're ready.
Invoke it with exit_cleanup, not with cleanup and close_stdout,
to avoid a race condition with cleanup and signal handling. More
details: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9508
2007-01-18 Jim Meyering <jim@meyering.net>
* src/c99-to-c89.diff: Adjust remove.c offsets.
2007-01-17 Jim Meyering <jim@meyering.net>
Make "rm --interactive=never ..." never prompt.
* NEWS: Mention this.
* src/remove.h (enum rm_interactive): New ternary type.
(struct rm_options) [interactive]: Use it, here -- rather than bool.
* src/remove.c (prompt): Reflect type change.
* src/mv.c (rm_option_init): Initialize to RMI_NEVER now.
* src/rm.c (main): Add a FIXME comment for '-d' option.
Adapt to type change of rm_options.interactive.
* tests/rm/i-never: New file. Test for the above fix.
* tests/rm/Makefile.am (TESTS): Add i-never.
2007-01-15 Jim Meyering <jim@meyering.net>
* bootstrap (gnulib_tool): When adding to .cvsignore and .gitignore,
emit foo.h, for each foo_.h. This yields one false-positive, fts.h,
but that's ok, since fts_.h will eventually be renamed.
* src/remove.c (remove_dir): Don't use errno in diagnostic.
Root-only test failure reported by Alex van Hout and Jon Grosshart in
<http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9415/focus=9415>.
* bootstrap.conf (avoided_gnulib_modules): Fix my typo:
s/--avoid=canonicalize-lgpl/--avoid=canonicalize-gpl/
2007-01-14 Bruno Haible <bruno@clisp.org>
Enable use of gnulib's new fchdir module.
* bootstrap.conf (avoided_gnulib_modules): Avoid canonicalize-lgpl,
since we use canonicalize.
(gnulib_modules): Add fchdir.
* m4/jm-macros.m4 (coreutils_MACROS): Remove fchdir-stub.
2007-01-13 Jim Meyering <jim@meyering.net>
* Transform all Makefile.am files so that when running "make check",
CU_TEST_NAME is set to the name of the test. This is so that when I
run valgrind-enabled (--log-file-qualifier=CU_TEST_NAME) "make check"
on the entire package it is more convenient to map a leak or error
found in a valgrind log file back to the offending test.
Use this command:
(echo tests/Makefile.am.in; find tests -name Makefile.am) \
|xargs perl -pi -e '/^(\s*)PATH=...VG_PATH_PREFIX/ and ' \
-e 'print $1,q|CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst |,"\\\n"'
2007-01-11 Jim Meyering <jim@meyering.net>
Avoid a leak in expr's implementation of the ":" (match) operator.
* src/expr.c (docolon): Free the regexp buffer using regfree, rather
than doing it manually, being careful to set fastmap to NULL first.
Free any re_regs.start and .end members, if necessary.
* tests/misc/test-diag: Work also when libc's error function
reports the entire program name ("../../src/test"), rather than
just the final component.
2007-01-10 Jim Meyering <jim@meyering.net>
Don't use fts_statp uninitialized for "chown -RLh --preserve-root ...".
* src/chown-core.c (FTSENT_IS_DIRECTORY): New macro.
(change_file_owner): Perform the ROOT_DEV_INO_CHECK only for a
directory. Non-directory entries lack fts_statp data when using
the FTS_NOSTAT option.
2007-01-07 Jim Meyering <jim@meyering.net>
* tests/sample-test: Update copyright date to 2007.
* Makefile.maint (copyright-check): Also check the copyright date
in tests/sample-test.
2007-01-06 Jim Meyering <jim@meyering.net>
* tests/fmt/basic (pfx-only, pfx-of-pfx): New tests,
based on examples from G.P. Halkes in
<http://article.gmane.org/gmane.comp.gnu.core-utils.bugs/9388>.
2007-01-06 G.P. Halkes <buscom@ghalkes.nl>
* src/fmt.c (copy_rest): Correct prefix handling.
Don't elide a line with the prefix followed by only white space.
(get_line): Move EOF-check to loop-termination condition.
* tests/fmt/basic (pfx-1): Adjust test to expect desired result.
(pfx-2): Remove test; its premise was contrary to the documentation.
2007-01-05 Jim Meyering <jim@meyering.net>
Avoid a used-uninitialized bug for invalid input, i.e., when the size
of the input, not counting newlines, is 1 % 4.
* gl/lib/base64.c (base64_decode): Don't hard-code inlen==4.
It may be smaller when flushing.
2007-01-05 Mike Frysinger <vapier@gentoo.org>
* src/dircolors.hin: Add a TERM directive for cons25.
2007-01-04 Jim Meyering <jim@meyering.net>
* Makefile.cfg (local-checks-to-skip): Skip strftime-check, in
case you don't have convenient access to glibc info documentation.
Use the release year, not the current year.
* src/groups.sh (version): Use a better name: @RELEASE_YEAR@.
* src/Makefile.am (RELEASE_YEAR): Define it.
(.sh): Use it.
Thanks to a prod from Eric Blake.
Ensure that "group --version" always prints the current year.
* src/groups.sh (version): Use @CURRENT_YEAR@, rather than 2006.
* src/Makefile.am (.sh): Also substitute for @CURRENT_YEAR@.
Suggestion from Eric Blake.
When decoding, always allow newlines in input, with almost no
performance impact.
* src/base64.c (do_decode): Initialize decode context.
Call base64_decode one more time, after all input is processed.
(usage): When decoding, newlines are always accepted.
* tests/misc/base64: Add a bunch of tests, for the above.
* gl/lib/base64.c: Include <string.h>.
(base64_decode_ctx_init, get_4, decode_4): New functions.
(base64_decode): Efficiently handle interspersed newlines.
(base64_decode_alloc): Update signature.
* gl/lib/base64.h (struct base64_decode_context): Define.
(base64_decode_ctx_init): Add prototype.
(base64_decode, base64_decode_alloc): Update prototypes.
* gl/lib/base64.c: Copied from gnulib.
* gl/lib/base64.h: Likewise.
2007-01-03 Jim Meyering <jim@meyering.net>
* THANKS: Add Evan Hunt.
2007-01-03 Bruno Haible <bruno@clisp.org>
Avoid spurious test failures on MacOS X 10.3.9, in a German locale.
* tests/chown/deref: Apply lang-default.
* tests/misc/split-a: Likewise.
* tests/mv/reply-no: Likewise.
* src/copy.c (copy_internal): Use mkfifo as a fallback if mknod fails.
Needed on MacOS X.
2007-01-02 Paul Eggert <eggert@cs.ucla.edu>
Now, "ls -FRL" always follows symbolic links on Linux.
* NEWS: Mention this bug fix.
* src/ls.c (gobble_file): Fix bug reported by
Nobuyuki Tsuchimura in
http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00152.html
where "ls -FRL" didn't follow a symbolic link in some cases on Linux.
* tests/ls/follow-slink: Add a test for this case.
2007-01-01 Jim Meyering <jim@meyering.net>
* tests/rm/fail-eperm: Revert last change. The PATH=... setting
is not honored at least on HP-UX 11.23 systems.
Instead, simply transform the actual output diagnostic.
Test failure reported by Bob Proulx.
2006-12-30 Jim Meyering <jim@meyering.net>
* bootstrap (gnulib_extra_files): Remove announce-gen.
* bootstrap.conf (gnulib_modules): Add it here instead, now that
it's a module.
* tests/misc/base64: Factor a long, repetitive string.
* src/c99-to-c89.diff: Adjust remove.c offsets.
Clean up after the change of 2006-12-28.
* src/remove.c (AD_pop_and_chdir): Change **DIRP parameter to *DIRP,
now that this function never modifies the pointer. Adjust comments
and code accordingly.
(remove_dir): Set "dirp" to NULL right after AD_pop_and_chdir call,
now that AD_pop_and_chdir no longer does that.
* tests/rm/fail-eperm: Avoid spurious differences (the error function
from latest glibc no longer prints the full program_name): so don't
invoke rm via ../../src/rm. Instead, invoke it via "PATH=../../src rm".
* tests/mv/acl (skip): Skip this test also if the destination
directory, which is on a different file system, lacks ACL support.
* src/copy.c (copy_reg): Rewrite a comment that was rendered
inaccurate by the 2006-10-18 change.
2006-12-28 Jim Meyering <jim@meyering.net>
When moving "up" the hierarchy, be careful to remove a just-emptied
directory before opening ".", to avoid trouble with file system
implementations that cache readdir results at opendir-time.
* src/remove.c (AD_pop_and_chdir): Add a file descriptor parameter.
Don't update **DIRP. Don't call fdopendir here.
(remove_dir): Call fdopendir here instead.
Report and patch from Mikulas Patocka:
<http://lists.gnu.org/archive/html/bug-coreutils/2006-12/msg00170.html>
2006-12-27 Jim Meyering <jim@meyering.net>
* src/tail.c (usage): Mention +N for --bytes and --lines.
Suggestion from Evan Hunt.
2006-12-26 Jim Meyering <jim@meyering.net>
* configure.ac: Require autoconf-2.61 and automake-1.10.
Without the former (even with autoconf-2.60), "make distcheck"
would fail (without the 2006-09-26 autoconf AC_CHECK_DECL fix),
due to an inttypes.h generated with CFLAGS including -pedantic.
With the old decl check, @HAVE_DECL_STRTOUMAX@ would be 0.
* Makefile.maint (VC-tag): Define, so as to gpg-sign each release
tag, using the release version number as the message.
(vc-dist): Use $(VC-tag), rather than "$(VC) tag".
2006-12-21 Paul Eggert <eggert@cs.ucla.edu>
* NEWS: dd bs= operands now silently override later ibs= and obs=,
as POSIX requires.
* src/dd.c (scanargs): Implement it.
* tests/dd/misc (outbytes): Test it.
* doc/coreutils.texi (dd invocation): Specify that bs=N
overrides later ibs and obs, undoing part of the
previous change. (The behavior was wrong.)
2006-12-20 Jim Meyering <jim@meyering.net>
"rm -rf /etc/motd" (run by non-root) now prints a diagnostic.
* src/remove.c (remove_entry): Handle EACCES for a non-directory, too.
Don't let a non-directory get by with errno == EPERM, either.
Check the file type directly (using cached stat value), rather
than trying to guess it from errno values.
Karl Berry reported that a cross-partition "mv /etc/issue ~"
failed with the um,... suboptimal diagnostic,
"mv: cannot remove `/etc/issue': Not a directory".
* tests/rm/Makefile.am (TESTS): Add fail-eacces.
* tests/rm/fail-eacces: New file.
* NEWS: Mention that both mv and rm are affected.
"cut -f 2- A B" no longer triggers a double-free bug
* src/cut.c (cut_fields): Set file-scoped global to NULL after
freeing it. This avoids a double-free (and core dump on some systems)
for this usage: "echo 1>a; echo 2>b; cut -f2- a b". Reported by
James Hunt in <http://bugzilla.redhat.com/220312>.
* NEWS: List this bug fix.
* THANKS: Mention him.
* tests/misc/cut: New file.
* tests/misc/Makefile.am (TESTS): Add cut.
2006-12-15 Jim Meyering <jim@meyering.net>
* tests/cp/open-perm-race: Correct the gdb-existence check.
Don't run either subsequent gdb command in a sub-shell.
Reported by Thomas Schwinge.
* THANKS: bring up to date.
2006-12-14 Paul Eggert <eggert@cs.ucla.edu>
Make sure cp -p isn't too generous with file permissions.
* tests/cp/Makefile.am (TESTS): Add file-perm-race.
* tests/cp/file-perm-race: New file.
Ensure cp -pR --parents isn't too generous with parent permissions.
* tests/cp/Makefile.am (TESTS): Add parent-perm-race.
* tests/cp/parent-perm-race: New file.
2006-12-14 Jim Meyering <jim@meyering.net>
* tests/chgrp/default-no-deref: Don't assume that files are created
with the primary group by default. That's not true in a directory
with the set-GID bit set.
Don't hang when there's no input tty.
* tests/cp/open-perm-race: Skip this test if there is no
controlling input `terminal'.
Test for a hard-to-detect race fix, using gdb.
* tests/cp/open-perm-race: New file, to test for the
cp --preserve=ownership fix of 2006-12-06.
* tests/cp/Makefile.am (TESTS_ENVIRONMENT): Define abs_top_builddir.
(TESTS): Add open-perm-race.
* src/chgrp.c (main): Don't prohibit -RLh, aka -RL with --no-dereference.
* src/chown.c (main): Likewise.
* src/chown-core.c (change_file_owner): Add to a comment.
* tests/chown/preserve-root: Add tests.
* NEWS: --preserve-root now works with chgrp, chmod, and chown.
* src/chmod.c (process_file): Do honor the --preserve-root option.
* src/chown-core.c (change_file_owner): Likewise, but here, also
handle the case in which a traversal would go "through" a symlink
to root. Reported by Matthew M. Boedicker
* tests/chown/preserve-root: Test for the above.
* tests/chown/Makefile.am (TESTS): Add preserve-root.
* NEWS: Mention the chmod fix induced by the 2006-12-11 change
to gnulib's m4/openat.m4.
2006-12-13 Andreas Schwab <schwab@suse.de>
Don't fail if mv/acl test succeeds.
* tests/mv/acl (skip): Check for acl support in the file system.
* tests/mv/Makefile.am (XFAIL_TESTS): Remove.
(TESTS_ENVIRONMENT): Pass CONFIG_HEADER.
2006-12-13 Paul Eggert <eggert@cs.ucla.edu>
Remove some arbitrary restrictions on size fields, so that
commands like "sort -k 18446744073709551616" no longer fail merely
because 18446744073709551616 doesn't fit in uintmax_t. The trick
is that these fields can all be treated as effectively infinity;
their exact values don't matter, since no internal buffer can be
that long.
* src/join.c (string_to_join_field): Verify that SIZE_MAX <=
ULONG_MAX if the code assumes this. Silently truncate too-large
values to SIZE_MAX, as the remaining code will do the right thing
in this case.
* src/sort.c (parse_field_count): Likewise.
* src/uniq.c (size_opt, main): Likewise.
* tests/join/Test.pm (bigfield): New test.
* tests/sort/Test.pm (bigfield): New test.
* tests/uniq/Test.pm (121): New test.
2006-12-13 Jim Meyering <jim@meyering.net>
* tests/chgrp/default-no-deref: New test.
* tests/chgrp/Makefile.am (TESTS): Add default-no-deref.
2006-12-12 Jim Meyering <jim@meyering.net>
* src/system.h (SETVBUF): Remove definition, now that the
autoconf macro, AC_FUNC_SETVBUF_REVERSED, does nothing.
* src/tee.c (tee_files): s/SETVBUF/setvbuf/.
* src/od.c (open_next_file): Likewise.
2006-12-09 Jim Meyering <jim@meyering.net>
* man/Makefile.am (.x.1): Make help2man use $(PACKAGE_STRING) as the
"source". I.e. "GNU coreutils 6.7".
* NEWS: With the change from "-pre" to "-dirty" suffix, also change
from NEXT_VER-pre to CUR_VER-dirty. So, this is 6.7-dirty.
* configure.ac (AC_INIT): s/6.8-dirty/6.7-dirty/.
* tests/uniq/Test.pm (test_vector): Skip the pipe-reading test
whenever uniq is expected to fail. This should catch the other case
[test #112] in which uniq emits "cat: write error: Broken pipe" on
some systems.
2006-12-08 Jim Meyering <jim@meyering.net>
Include bootstrap tool version info in the announcement form.
* Makefile.maint (gnulib_snapshot_date): Define.
(announcement): Use two new announce-gen options,
--bootstrap-tools and --gnulib-snapshot-date.
* Makefile.cfg (gnulib_dir): Set.
Post-release version change.
* NEWS: Add a line for 6.8-dirty.
* configure.ac (AC_INIT): Set new version string.
2006-12-07 Jim Meyering jim@meyering.net
Version 6.7.

View File

@@ -1,7 +1,6 @@
# Make coreutils. -*-Makefile-*-
# Copyright (C) 1990, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
# 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# Copyright (C) 1990, 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

View File

@@ -1,5 +1,5 @@
# Customize Makefile.maint. -*- makefile -*-
# Copyright (C) 2003-2006 Free Software Foundation, Inc.
# Copyright (C) 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
@@ -33,4 +33,8 @@ gpg_key_ID = D333CBA1
# Exclude changelog-check here so that there's less churn in ChangeLog
# files -- otherwise, you'd need to have the upcoming version number
# at the top of the file for each `make distcheck' run.
local-checks-to-skip = changelog-check
local-checks-to-skip = changelog-check strftime-check
# The local directory containing the checked-out copy of gnulib used in
# this release. Used solely to get a date for the "announcement" target.
gnulib_dir = /gnulib

View File

@@ -2,7 +2,7 @@
# This Makefile fragment is shared between the coreutils,
# CPPI, Bison, and Autoconf.
## Copyright (C) 2001-2006 Free Software Foundation, Inc.
## Copyright (C) 2001-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,6 +32,7 @@ GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
CVS = cvs
GIT = git
VC = $(GIT)
VC-tag = git-tag -s -m '$(VERSION)'
CVS_LIST = build-aux/vc-list-files
@@ -97,7 +98,7 @@ syntax-check: $(syntax-check-rules)
# FIXME: don't allow `#include .strings\.h' anywhere
sc_cast_of_argument_to_free:
@grep -nE '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
@grep -nE '\<free \(\(' $$($(CVS_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
exit 1; } || :
@@ -300,7 +301,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)) && \
@@ -328,7 +329,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
@@ -338,8 +339,8 @@ patch-check:
$(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
|| msg='compile failure with extra options'; \
rm -rf src-c89 $@.1 $@.2; \
test $$msg = ok && : || echo "$$msg" 1>&2; \
test $$msg = ok
test "$$msg" = ok && : || echo "$$msg" 1>&2; \
test "$$msg" = ok
# Ensure that date's --help output stays in sync with the info
# documentation for GNU strftime. The only exception is %N,
@@ -448,6 +449,7 @@ writable-files:
test "$$fail" && exit 1 || :
v_etc_file = lib/version-etc.c
sample-test = tests/sample-test
# Make sure that the copyright date in $(v_etc_file) is up to date.
copyright-check:
@if test -f $(v_etc_file); then \
@@ -456,6 +458,12 @@ copyright-check:
|| { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
exit 1; }; \
fi
@if test -f $(sample-test); then \
grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
>/dev/null \
|| { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
exit 1; }; \
fi
# Sanity checks with the repository.
@@ -494,7 +502,7 @@ maintainer-distcheck:
# checks fail. Also, make sure the NEWS file is up-to-date.
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
vc-dist: $(local-check) cvs-check maintainer-distcheck
$(VC) tag $(this-vc-tag)
$(VC-tag) $(this-vc-tag)
$(MAKE) dist
# Use this to make sure we don't run these programs when building
@@ -532,7 +540,7 @@ my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
cd $(t)/$(distdir) \
&& (cd src && patch -V never --fuzz=0 <c99-to-c89.diff) \
&& ./configure --disable-largefile \
CFLAGS='-Werror -ansi -pedantic -Wno-long-long' \
CFLAGS='-Werror -ansi -pedantic -Wno-long-long' \
&& $(MAKE)
-rm -rf $(t)
@echo "========================"; \
@@ -555,6 +563,11 @@ prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
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')
announcement: NEWS ChangeLog $(rel-files)
@./build-aux/announce-gen \
--release-type=$(RELEASE_TYPE) \
@@ -563,8 +576,9 @@ announcement: NEWS ChangeLog $(rel-files)
--curr=$(VERSION) \
--gpg-key-id=$(gpg_key_ID) \
--news=NEWS \
$(addprefix --url-dir=, $(url_dir_list)) \
--bootstrap-tools=autoconf,automake,bison,gnulib \
--gnulib-snapshot-date=$(gnulib_snapshot_date) \
$(addprefix --url-dir=, $(url_dir_list))
## ---------------- ##
## Updating files. ##

56
NEWS
View File

@@ -1,5 +1,61 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 6.8 (2007-02-24) [not-unstable]
** Bug fixes
chgrp, chmod, and chown now honor the --preserve-root option.
Before, they would warn, yet continuing traversing and operating on /.
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.
dd bs= operands now silently override any later ibs= and obs=
operands, as POSIX and tradition require.
"ls -FRL" always follows symbolic links on Linux. Introduced in
coreutils-6.0.
A cross-partition "mv /etc/passwd ~" (by non-root) now prints
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.
"rm --interactive=never F" no longer prompts for an unwritable F
** 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.
** New features
sort accepts the new option -C, which acts like -c except no diagnostic
is printed. Its --check option now accepts an optional argument, and
--check=quiet and --check=silent are now aliases for -C, while
--check=diagnose-first is an alias for -c or plain --check.
* Noteworthy changes in release 6.7 (2006-12-08) [stable]
** Bug fixes

12
README
View File

@@ -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:
----------------------

View File

@@ -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

6
THANKS
View File

@@ -150,6 +150,7 @@ Eric Pemente pemente@northpark.edu
Eric S. Raymond esr@snark.thyrsus.com
Erik Bennett bennett@cvo.oneworld.com
Erik Corry erik@kroete2.freinet.de
Evan Hunt ethanol@armory.com
Felix Lee flee@teleport.com
Felix Rauch Valenti frauch@cse.unsw.edu.au
Ferdinand fw@scenic.mine.nu
@@ -192,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
@@ -208,6 +210,7 @@ Ivo Timmermans ivo@debian.org
James james@albion.glarp.com
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
James Lemley James.Lemley@acxiom.com
James Hunt jamesodhunt@hotmail.com
James Sneeringer jvs@ocslink.com
James Tanis jtt@soscorp.com
James Youngman james+usenet@free-lunch.demon.co.uk
@@ -323,11 +326,13 @@ Matt Perry matt@primefactor.com
Matt Schalit mschalit@pacbell.net
Matt Swift swift@alum.mit.edu
Matthew Arnison maffew@cat.org.au
Matthew M. Boedicker matthewm@boedicker.org
Matthew Braun matthew@ans.net
Matthew Clarke Matthew_Clarke@mindlink.bc.ca
Matthew S. Levine mslevine@theory.lcs.mit.edu
Matthew Smith matts@bluesguitar.org
Matthew Swift swift@alum.mit.edu
Matthew Woehlke mw_triad@users.sourceforge.net
Matthias Urlichs smurf@noris.de
Matti Aarnio matti.aarnio@zmailer.org
Mattias Wadenstein maswan@acc.umu.se
@@ -471,6 +476,7 @@ Thomas Hood jdthood@yahoo.co.uk
Thomas Luzat thomas@luzat.com
Thomas M.Ott thmo-13@gmx.de
Thomas Quinot thomas@Cuivre.FR.EU.ORG
Thomas Schwinge tschwinge@gnu.org
Thomas Wolff mined@towo.net
Tim J. Robbins tjr@FreeBSD.org
Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu

View File

@@ -2,7 +2,7 @@
# Bootstrap this package from CVS.
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# Copyright (C) 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
@@ -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,7 +43,7 @@ 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
@@ -87,7 +92,6 @@ package=`sed -n "$extract_package_name" configure.ac` || exit
# Extra files from gnulib, which override files from other sources.
gnulib_extra_files='
build-aux/announce-gen
build-aux/install-sh
build-aux/missing
build-aux/mdate-sh
@@ -113,7 +117,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
CVS_only_file=README-hacking
# Whether to use copies instead of symlinks.
copy=false
@@ -246,7 +250,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
@@ -315,7 +321,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
@@ -324,7 +331,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"
@@ -351,6 +358,16 @@ 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=
@@ -362,7 +379,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 &&
@@ -393,8 +410,12 @@ slurp() {
for dot_ig in .cvsignore .gitignore; do
ig=$dir/$dot_ig
if test -n "$copied" && test -f $ig; then
echo "$copied" | sort -u - $ig | cmp -s - $ig ||
echo "$copied" | sort -u - $ig -o $ig || exit
insert_sorted_if_absent $ig "$copied"
# If an ignored file name ends with _.h, then also add
# the name with just ".h". Many gnulib headers are generated,
# e.g., stdint_.h -> stdint.h, dirent_.h ->..., etc.
f=`echo "$copied"|sed 's/_\.h$/.h/'`
insert_sorted_if_absent $ig "$f"
fi
done
done
@@ -402,9 +423,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

View File

@@ -1,6 +1,6 @@
# Bootstrap configuration.
# 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
@@ -19,11 +19,12 @@
# We don't need these modules, even though gnulib-tool mistakenly
# includes them because of gettext dependencies.
# includes them because of gettext and fchdir dependencies.
avoided_gnulib_modules='
--avoid=lock
--avoid=size_max
--avoid=xsize
--avoid=canonicalize-lgpl
'
# These modules are obsolete and can probably be removed soon,
@@ -37,12 +38,14 @@ obsolete_gnulib_modules='
gnulib_modules="
$avoided_gnulib_modules
$obsolete_gnulib_modules
acl alloca 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 fcntl fcntl-safer fdl file-type
fileblocks filemode filenamecat fnmatch-gnu fopen-safer
error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl
file-type fileblocks filemode filenamecat fnmatch-gnu
fopen-safer
fprintftime fsusage ftruncate fts getdate getgroups gethrxtime
getline getloadavg getndelim2 getopt getpagesize getpass-gnu
gettext gettime gettimeofday getugroups getusershell gnupload
@@ -51,14 +54,14 @@ gnulib_modules="
lchmod lchown lib-ignore linebuffer link-follow
long-options lstat malloc mbswidth md5 memcasecmp mempcpy
memrchr mkancesdirs mkdir mkdir-p mkstemp mktime modechange
mountlist obstack pathmax perl physmem posixtm posixver putenv
mountlist mpsort obstack pathmax perl physmem posixtm posixver putenv
quote quotearg raise readlink readtokens readtokens0 readutmp
realloc regex rename-dest-slash rmdir rmdir-errno
root-dev-ino
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

View File

@@ -6,6 +6,7 @@ config.sub
depcomp
gnupload
install-sh
link-warning.h
mdate-sh
missing
mkinstalldirs

View File

@@ -6,6 +6,7 @@ config.sub
depcomp
gnupload
install-sh
link-warning.h
mdate-sh
missing
texinfo.tex

View File

@@ -1,3 +1,8 @@
2007-01-30 Jim Meyering <jim@meyering.net>
* vc-list-files: Select column 2, not 3 (hg-0.9.3's manifest format
now has only two columns).
2006-10-14 Jim Meyering <jim@meyering.net>
* vc-list-files: Don't filter git-ls-files output through cut.

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# List the specified version-controlled files.
# 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
@@ -43,9 +43,9 @@ if test -d .git; then
fi
elif test -d .hg; then
if test "x$include_prefix" = x; then
hg manifest | cut -d ' ' -f 3
hg manifest | cut -d ' ' -f 2
else
hg manifest | cut -d ' ' -f 3 | grep "^$include_prefix/"
hg manifest | cut -d ' ' -f 2 | grep "^$include_prefix/"
fi
elif test -x build-aux/cvsu; then
build-aux/cvsu --find --types=AFGM $include_prefix

View File

@@ -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
@@ -19,15 +19,15 @@
dnl Written by Jim Meyering.
AC_PREREQ(2.60)
AC_INIT([GNU coreutils],[6.7],[bug-coreutils@gnu.org])
AC_PREREQ(2.61)
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.9.6 gnits dist-bzip2])
AM_INIT_AUTOMAKE([1.10 dist-bzip2])
AC_PROG_CC_STDC
AM_PROG_CC_C_O
@@ -39,6 +39,8 @@ gl_EARLY
gl_INIT
coreutils_MACROS
AC_FUNC_FORK
AC_CHECK_FUNCS(uname,
OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uname\$(EXEEXT)"
MAN="$MAN uname.1")

View File

@@ -1,3 +1,52 @@
2007-01-30 Paul Eggert <eggert@cs.ucla.edu>
* coreutils.texi
(Input processing in ptx, mkdir invocation, rmdir invocation):
@item -> @itemx to fix some typos.
2007-01-30 Paul Eggert <eggert@cs.ucla.edu>
* coreutils.texi (mkdir invocation): Say how to set the file
permission bits of a parent directory with mkdir -p.
2007-01-29 Jim Meyering <jim@meyering.net>
Document new syntax: "chown +0:+287 file", "chgrp +99 file"
* coreutils.texi (Disambiguating names and IDs): New section.
(chown invocation, chgrp invocation): Mention the new syntax
with an xref to the new section.
2007-01-19 Jim Meyering <jim@meyering.net>
* coreutils.texi (ls: General output formatting): Mention the
workarounds to accommodate the Apple Terminal bug.
2007-01-04 Jim Meyering <jim@meyering.net>
* coreutils.texi (base64 invocation): When decoding, newlines
are always accepted.
2007-01-03 Jim Meyering <jim@meyering.net>
Document what the ".0" in e.g., "-k 2,3.0" means, and...
* coreutils.texi (sort invocation): ... that it can be applied to the
field-end spec, but not the field-start one. Patch from Evan Hunt.
2006-12-21 Jim Meyering <jim@meyering.net>
* coreutils.texi (dd invocation): Improve the documentation
for bs, ibs, obs, and cbs. Suggestion from Dan Jacobson.
Patch by Olivier Delhomme.
(dd invocation): Add to the description of cbs.
(dd invocation): Specify that bs=N overrides only any
_preceding_ ibs and obs settings. Spotted by Andreas Schwab.
2006-12-14 Jim Meyering <jim@meyering.net>
* coreutils.texi: Remove two doubled words.
(Treating / specially): With --preserve-root, chgrp and chown
will not modify "/", even through a symlink.
2006-11-28 Jim Meyering <jim@meyering.net>
* perm.texi (Mode Structure): Fix typo: s/setgid/setuid/.

View File

@@ -208,6 +208,7 @@ Common Options
* Exit status:: Indicating program success or failure.
* Backup options:: Backup options
* Block size:: Block size
* Disambiguating names and IDs:: chgrp and chown owner and group syntax
* Random sources:: Sources of random data
* Target directory:: Target directory
* Trailing slashes:: Trailing slashes
@@ -644,6 +645,7 @@ name.
* Exit status:: Indicating program success or failure.
* Backup options:: -b -S, in some programs.
* Block size:: BLOCK_SIZE and --block-size, in some programs.
* Disambiguating names and IDs:: chgrp and chown owner and group syntax
* Random sources:: --random-source, in some programs.
* Target directory:: Specifying a target directory, in some programs.
* Trailing slashes:: --strip-trailing-slashes, in some programs.
@@ -924,6 +926,46 @@ set. The @option{-h} or @option{--human-readable} option is equivalent to
@option{--block-size=human-readable}. The @option{--si} option is
equivalent to @option{--block-size=si}.
@node Disambiguating names and IDs
@section chown and chgrp: Disambiguating user names and IDs
@cindex user names, disambiguating
@cindex user IDs, disambiguating
@cindex group names, disambiguating
@cindex group IDs, disambiguating
@cindex disambiguating group names and IDs
Since the @var{owner} and @var{group} arguments to @command{chown} and
@command{chgrp} may be specified as names or numeric IDs, there is an
apparent ambiguity.
What if a user or group @emph{name} is a string of digits?
@footnote{Using a number as a user name is common in some environments.}
Should the command interpret it as a user name or as an ID?
@acronym{POSIX} requires that @command{chown} and @command{chgrp}
first attempt to resolve the specified string as a name, and
only once that fails, then try to interpret it as an ID.
This is troublesome when you want to specify a numeric ID, say 42,
and it must work even in a pathological situation where
@samp{42} is a user name that maps to some other user ID, say 1000.
Simply invoking @code{chown 42 F}, will set @file{F}s owner ID to
1000---not what you intended.
GNU @command{chown} and @command{chgrp} provide a way to work around this,
that at the same time may result in a significant performance improvement
by eliminating a database look-up.
Simply precede each numeric user ID and/or group ID with a @samp{+},
in order to force its interpretation as an integer:
@example
chown +42 F
chgrp +$numeric_group_id another-file
chown +0:+0 /
@end example
GNU @command{chown} and @command{chgrp}
skip the name look-up process for each @samp{+}-prefixed string,
because a string containing @samp{+} is never a valid user or group name.
This syntax is accepted on most common Unix systems, but not on Solaris 10.
@node Random sources
@section Sources of random data
@@ -1158,6 +1200,10 @@ to operate recursively on @file{/}, so they default to
option makes them safer for most purposes. For convenience you can
specify @option{--preserve-root} in an alias or in a shell function.
Note that the @option{--preserve-root} option also ensures
that @command{chgrp} and @command{chown} do not modify @file{/}
even when dereferencing a symlink pointing to @file{/}.
@node Special built-in utilities
@section Special built-in utilities
@@ -1845,7 +1891,8 @@ output will be the original data.
@opindex -i
@opindex --ignore-garbage
@cindex Ignore garbage in base64 stream
During decoding, ignore unrecognized characters (including newline),
When decoding, newlines are always accepted.
During decoding, ignore unrecognized bytes,
to permit distorted data to be decoded.
@end table
@@ -3337,12 +3384,26 @@ mode:
@item -c
@itemx --check
@itemx --check=diagnose-first
@opindex -c
@opindex --check
@cindex checking for sortedness
Check whether the given files are already sorted: if they are not all
sorted, print an error message and exit with a status of 1.
Check whether the given file is already sorted: if it is not all
sorted, print a diagnostic containing the first out-of-order line and
exit with a status of 1.
Otherwise, exit successfully.
At most one input file can be given.
@item -C
@itemx --check=quiet
@itemx --check=silent
@opindex -c
@opindex --check
@cindex checking for sortedness
Exit successfully if the given file is already sorted, and
exit with status 1 otherwise.
At most one input file can be given.
This is like @option{-c}, except it does not print a diagnostic.
@item -m
@itemx --merge
@@ -3396,7 +3457,7 @@ Exit status:
@display
0 if no error occurred
1 if invoked with @option{-c} and the input is not properly sorted
1 if invoked with @option{-c} or @option{-C} and the input is not sorted
2 if an error occurred
@end display
@@ -3406,7 +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.
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
@@ -3573,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
@@ -3580,9 +3652,21 @@ Other options are:
@cindex sort field
Specify a sort field that consists of the part of the line between
@var{pos1} and @var{pos2} (or the end of the line, if @var{pos2} is
omitted), @emph{inclusive}. Fields and character positions are numbered
starting with 1. So to sort on the second field, you'd use
@option{--key=2,2} (@option{-k 2,2}). See below for more examples.
omitted), @emph{inclusive}.
Each @var{pos} has the form @samp{@var{f}[.@var{c}][@var{opts}]},
where @var{f} is the number of the field to use, and @var{c} is the number
of the first character from the beginning of the field. Fields and character
positions are numbered starting with 1; a character position of zero in
@var{pos2} indicates the field's last character. If @samp{.@var{c}} is
omitted from @var{pos1}, it defaults to 1 (the beginning of the field);
if omitted from @var{pos2}, it defaults to 0 (the end of the field).
@var{opts} are ordering options, allowing individual keys to be sorted
according to different rules; see below for details. Keys can span
multiple fields.
Example: To sort on the second field, use @option{--key=2,2}
(@option{-k 2,2}). See below for more examples.
@item -o @var{output-file}
@itemx --output=@var{output-file}
@@ -3686,7 +3770,7 @@ disks and controllers.
@cindex uniquifying output
Normally, output only the first of a sequence of lines that compare
equal. For the @option{--check} (@option{-c}) option,
equal. For the @option{--check} (@option{-c} or @option{-C}) option,
check that no pair of consecutive lines compares equal.
This option also disables the default last-resort comparison.
@@ -3721,29 +3805,21 @@ consistency, @option{-M} has been changed in the same way. This may
affect the meaning of character positions in field specifications in
obscure cases. The only fix is to add an explicit @option{-b}.
A position in a sort field specified with the @option{-k}
option has the form @samp{@var{f}.@var{c}}, where @var{f} is the number
of the field to use and @var{c} is the number of the first character
from the beginning of the field. In a start position, an omitted
@samp{.@var{c}} stands for the field's first character. In an end
position, an omitted or zero @samp{.@var{c}} stands for the field's
last character. If the start field falls after the end of the line
or after the end field, the field is empty. If the
@option{-b} option was specified, the @samp{.@var{c}} part of a field
specification is counted from the first nonblank character of the field.
A sort key position may also have any of the option letters @samp{Mbdfinr}
appended to it, in which case the global ordering options are not used
for that particular field. The @option{-b} option may be independently
attached to either or both of the start and
end positions of a field specification, and if it is inherited
from the global options it will be attached to both.
A position in a sort field specified with @option{-k} may have any
of the option letters @samp{Mbdfinr} appended to it, in which case the
global ordering options are not used for that particular field. The
@option{-b} option may be independently attached to either or both of
the start and end positions of a field specification, and if it is
inherited from the global options it will be attached to both.
If input lines can contain leading or adjacent blanks and @option{-t}
is not used, then @option{-k} is typically combined with @option{-b},
@option{-g}, @option{-M}, or @option{-n}; otherwise the varying
numbers of leading blanks in fields can cause confusing results.
Keys can span multiple fields.
If the start position in a sort field specifier falls after the end of
the line or after the end field, the field is empty. If the @option{-b}
option was specified, the @samp{.@var{c}} part of a field specification
is counted from the first nonblank character of the field.
@vindex _POSIX2_VERSION
@vindex POSIXLY_CORRECT
@@ -4489,7 +4565,7 @@ Fold lower case letters to upper case for sorting.
@table @samp
@item -b @var{file}
@item --break-file=@var{file}
@itemx --break-file=@var{file}
This option provides an alternative (to @option{-W}) method of describing
which characters make up words. It introduces the name of a
@@ -6410,6 +6486,13 @@ Assume that each tab stop is @var{cols} columns wide. The default is 8.
@command{ls} uses tabs where possible in the output, for efficiency. If
@var{cols} is zero, do not use tabs at all.
@c FIXME: remove in 2009, if Apple Terminal has been fixed for long enough.
Some terminal emulators (at least Apple Terminal 1.5 (133) from Mac OS X 10.4.8)
do not properly align columns to the right of a TAB following a
non-@acronym{ASCII} byte. If you use such a terminal emulator, use the
@option{-T0} option or put @code{TABSIZE=0} in your environment to tell
@command{ls} to align using spaces, not tabs.
@item -w
@itemx --width=@var{cols}
@opindex -w
@@ -7151,25 +7234,33 @@ bytes (or the size specified with @samp{seek=}).
@opindex ibs
@cindex block size of input
@cindex input block size
Read @var{bytes} bytes at a time.
Set the input block size to @var{bytes}.
This makes @command{dd} read @var{bytes} per block.
@item obs=@var{bytes}
@opindex obs
@cindex block size of output
@cindex output block size
Write @var{bytes} bytes at a time.
Set the output block size to @var{bytes}.
This makes @command{dd} write @var{bytes} per block.
@item bs=@var{bytes}
@opindex bs
@cindex block size
Both read and write @var{bytes} bytes at a time. This overrides
@samp{ibs} and @samp{obs}.
Set both input and output block sizes to @var{bytes}.
This makes @command{dd} read and write @var{bytes} per block,
overriding any @samp{ibs} and @samp{obs} settings.
@item cbs=@var{bytes}
@opindex cbs
@cindex block size of conversion
@cindex conversion block size
Convert @var{bytes} bytes at a time.
@cindex fixed-length records, converting to variable-length
@cindex variable-length records, converting to fixed-length
Set the conversion block size to @var{bytes}.
When converting variable-length records to fixed-length ones
(@option{conv=block}) or the reverse (@option{conv=unblock}),
use @var{bytes} as the fixed record length.
@item skip=@var{blocks}
@opindex skip
@@ -7346,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
@@ -8353,15 +8446,23 @@ overridden in this way.
@opindex -p
@opindex --parents
@cindex parent directories, creating
Make any missing parent directories for each argument. The file permission
bits of parent directories are set to the umask modified by @samp{u+wx}.
@xref{Directory Setuid and Setgid}, for how the set-user-ID and
set-group-ID bits of parent directories are inherited.
Ignore arguments corresponding to existing directories, and do not
change their file mode bits.
Make any missing parent directories for each argument, setting their
file permission bits to the umask modified by @samp{u+wx}. Ignore
existing parent directories, and do not change their file permission
bits.
To set the file permission bits of any newly-created parent
directories to a value that includes @samp{u+wx}, you can set the
umask before invoking @command{mkdir}. For example, if the shell
command @samp{(umask u=rwx,go=rx; mkdir -p P/Q)} creates the parent
@file{P} it sets the parent's permission bits to @samp{u=rwx,go=rx}.
To set a parent's special mode bits as well, you can invoke
@command{chmod} after @command{mkdir}. @xref{Directory Setuid and
Setgid}, for how the set-user-ID and set-group-ID bits of
newly-created parent directories are inherited.
@item -v
@item --verbose
@itemx --verbose
@opindex -v
@opindex --verbose
Print a message for each created directory. This is most useful with
@@ -8608,7 +8709,7 @@ a failure does not evoke a diagnostic and does not cause @command{rmdir} to
exit unsuccessfully.
@item -v
@item --verbose
@itemx --verbose
@opindex -v
@opindex --verbose
@cindex directory deletion, reporting
@@ -8727,6 +8828,10 @@ owner nor the group is changed.
@end table
If @var{owner} or @var{group} is intended to represent a numeric user
or group ID, then you may specify it with a leading @samp{+}.
@xref{Disambiguating names and IDs}.
Some older scripts may still use @samp{.} in place of the @samp{:} separator.
@acronym{POSIX} 1003.1-2001 (@pxref{Standards conformance}) does not
require support for that, but for backward compatibility @acronym{GNU}
@@ -8902,6 +9007,10 @@ or to the group of an existing reference file. Synopsis:
chgrp [@var{option}]@dots{} @{@var{group} | --reference=@var{ref_file}@} @var{file}@dots{}
@end example
If @var{group} is intended to represent a
numeric group ID, then you may specify it with a leading @samp{+}.
@xref{Disambiguating names and IDs}.
The program accepts the following options. Also see @ref{Common options}.
@table @samp
@@ -9151,7 +9260,7 @@ operations, for a user to change the ctime field to a user-specified value.
Time stamps assume the time zone rules specified by the @env{TZ}
environment variable, or by the system default rules if @env{TZ} is
not set. @xref{TZ Variable,, Specifying the Time Zone with @env{TZ},
libc, The GNU C Library}. You can avoid avoid ambiguities during
libc, The GNU C Library}. You can avoid ambiguities during
daylight saving transitions by using @sc{utc} time stamps.
The program accepts the following options. Also see @ref{Common options}.
@@ -9799,7 +9908,7 @@ $ stat --format=%d:%i / /usr
@opindex --printf=@var{format}
@cindex output format
Use @var{format} rather than the default format.
Like like @option{--format}, but interpret backslash escapes,
Like @option{--format}, but interpret backslash escapes,
and do not output a mandatory trailing newline.
If you want a newline, include @samp{\n} in the @var{format}.
Here's how you would use @option{--printf} to print the device

559
gl/lib/base64.c Normal file
View File

@@ -0,0 +1,559 @@
/* base64.c -- Encode binary data using printable characters.
Copyright (C) 1999, 2000, 2001, 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
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 Simon Josefsson. Partially adapted from GNU MailUtils
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
*
* See also RFC 3548 <http://www.ietf.org/rfc/rfc3548.txt>.
*
* Be careful with error checking. Here is how you would typically
* use these functions:
*
* bool ok = base64_decode_alloc (in, inlen, &out, &outlen);
* if (!ok)
* FAIL: input was not valid base64
* if (out == NULL)
* FAIL: memory allocation error
* OK: data in OUT/OUTLEN
*
* size_t outlen = base64_encode_alloc (in, inlen, &out);
* if (out == NULL && outlen == 0 && inlen != 0)
* FAIL: input too long
* if (out == NULL)
* FAIL: memory allocation error
* OK: data in OUT/OUTLEN.
*
*/
#include <config.h>
/* Get prototype. */
#include "base64.h"
/* Get malloc. */
#include <stdlib.h>
/* Get UCHAR_MAX. */
#include <limits.h>
#include <string.h>
/* C89 compliant way to cast 'char' to 'unsigned char'. */
static inline unsigned char
to_uchar (char ch)
{
return ch;
}
/* Base64 encode IN array of size INLEN into OUT array of size OUTLEN.
If OUTLEN is less than BASE64_LENGTH(INLEN), write as many bytes as
possible. If OUTLEN is larger than BASE64_LENGTH(INLEN), also zero
terminate the output buffer. */
void
base64_encode (const char *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
static const char b64str[64] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
while (inlen && outlen)
{
*out++ = b64str[(to_uchar (in[0]) >> 2) & 0x3f];
if (!--outlen)
break;
*out++ = b64str[((to_uchar (in[0]) << 4)
+ (--inlen ? to_uchar (in[1]) >> 4 : 0))
& 0x3f];
if (!--outlen)
break;
*out++ =
(inlen
? b64str[((to_uchar (in[1]) << 2)
+ (--inlen ? to_uchar (in[2]) >> 6 : 0))
& 0x3f]
: '=');
if (!--outlen)
break;
*out++ = inlen ? b64str[to_uchar (in[2]) & 0x3f] : '=';
if (!--outlen)
break;
if (inlen)
inlen--;
if (inlen)
in += 3;
}
if (outlen)
*out = '\0';
}
/* Allocate a buffer and store zero terminated base64 encoded data
from array IN of size INLEN, returning BASE64_LENGTH(INLEN), i.e.,
the length of the encoded data, excluding the terminating zero. On
return, the OUT variable will hold a pointer to newly allocated
memory that must be deallocated by the caller. If output string
length would overflow, 0 is returned and OUT is set to NULL. If
memory allocation failed, OUT is set to NULL, and the return value
indicates length of the requested memory block, i.e.,
BASE64_LENGTH(inlen) + 1. */
size_t
base64_encode_alloc (const char *in, size_t inlen, char **out)
{
size_t outlen = 1 + BASE64_LENGTH (inlen);
/* Check for overflow in outlen computation.
*
* If there is no overflow, outlen >= inlen.
*
* If the operation (inlen + 2) overflows then it yields at most +1, so
* outlen is 0.
*
* If the multiplication overflows, we lose at least half of the
* correct value, so the result is < ((inlen + 2) / 3) * 2, which is
* less than (inlen + 2) * 0.66667, which is less than inlen as soon as
* (inlen > 4).
*/
if (inlen > outlen)
{
*out = NULL;
return 0;
}
*out = malloc (outlen);
if (!*out)
return outlen;
base64_encode (in, inlen, *out, outlen);
return outlen - 1;
}
/* With this approach this file works independent of the charset used
(think EBCDIC). However, it does assume that the characters in the
Base64 alphabet (A-Za-z0-9+/) are encoded in 0..255. POSIX
1003.1-2001 require that char and unsigned char are 8-bit
quantities, though, taking care of that problem. But this may be a
potential problem on non-POSIX C99 platforms.
IBM C V6 for AIX mishandles "#define B64(x) ...'x'...", so use "_"
as the formal parameter rather than "x". */
#define B64(_) \
((_) == 'A' ? 0 \
: (_) == 'B' ? 1 \
: (_) == 'C' ? 2 \
: (_) == 'D' ? 3 \
: (_) == 'E' ? 4 \
: (_) == 'F' ? 5 \
: (_) == 'G' ? 6 \
: (_) == 'H' ? 7 \
: (_) == 'I' ? 8 \
: (_) == 'J' ? 9 \
: (_) == 'K' ? 10 \
: (_) == 'L' ? 11 \
: (_) == 'M' ? 12 \
: (_) == 'N' ? 13 \
: (_) == 'O' ? 14 \
: (_) == 'P' ? 15 \
: (_) == 'Q' ? 16 \
: (_) == 'R' ? 17 \
: (_) == 'S' ? 18 \
: (_) == 'T' ? 19 \
: (_) == 'U' ? 20 \
: (_) == 'V' ? 21 \
: (_) == 'W' ? 22 \
: (_) == 'X' ? 23 \
: (_) == 'Y' ? 24 \
: (_) == 'Z' ? 25 \
: (_) == 'a' ? 26 \
: (_) == 'b' ? 27 \
: (_) == 'c' ? 28 \
: (_) == 'd' ? 29 \
: (_) == 'e' ? 30 \
: (_) == 'f' ? 31 \
: (_) == 'g' ? 32 \
: (_) == 'h' ? 33 \
: (_) == 'i' ? 34 \
: (_) == 'j' ? 35 \
: (_) == 'k' ? 36 \
: (_) == 'l' ? 37 \
: (_) == 'm' ? 38 \
: (_) == 'n' ? 39 \
: (_) == 'o' ? 40 \
: (_) == 'p' ? 41 \
: (_) == 'q' ? 42 \
: (_) == 'r' ? 43 \
: (_) == 's' ? 44 \
: (_) == 't' ? 45 \
: (_) == 'u' ? 46 \
: (_) == 'v' ? 47 \
: (_) == 'w' ? 48 \
: (_) == 'x' ? 49 \
: (_) == 'y' ? 50 \
: (_) == 'z' ? 51 \
: (_) == '0' ? 52 \
: (_) == '1' ? 53 \
: (_) == '2' ? 54 \
: (_) == '3' ? 55 \
: (_) == '4' ? 56 \
: (_) == '5' ? 57 \
: (_) == '6' ? 58 \
: (_) == '7' ? 59 \
: (_) == '8' ? 60 \
: (_) == '9' ? 61 \
: (_) == '+' ? 62 \
: (_) == '/' ? 63 \
: -1)
static const signed char b64[0x100] = {
B64 (0), B64 (1), B64 (2), B64 (3),
B64 (4), B64 (5), B64 (6), B64 (7),
B64 (8), B64 (9), B64 (10), B64 (11),
B64 (12), B64 (13), B64 (14), B64 (15),
B64 (16), B64 (17), B64 (18), B64 (19),
B64 (20), B64 (21), B64 (22), B64 (23),
B64 (24), B64 (25), B64 (26), B64 (27),
B64 (28), B64 (29), B64 (30), B64 (31),
B64 (32), B64 (33), B64 (34), B64 (35),
B64 (36), B64 (37), B64 (38), B64 (39),
B64 (40), B64 (41), B64 (42), B64 (43),
B64 (44), B64 (45), B64 (46), B64 (47),
B64 (48), B64 (49), B64 (50), B64 (51),
B64 (52), B64 (53), B64 (54), B64 (55),
B64 (56), B64 (57), B64 (58), B64 (59),
B64 (60), B64 (61), B64 (62), B64 (63),
B64 (64), B64 (65), B64 (66), B64 (67),
B64 (68), B64 (69), B64 (70), B64 (71),
B64 (72), B64 (73), B64 (74), B64 (75),
B64 (76), B64 (77), B64 (78), B64 (79),
B64 (80), B64 (81), B64 (82), B64 (83),
B64 (84), B64 (85), B64 (86), B64 (87),
B64 (88), B64 (89), B64 (90), B64 (91),
B64 (92), B64 (93), B64 (94), B64 (95),
B64 (96), B64 (97), B64 (98), B64 (99),
B64 (100), B64 (101), B64 (102), B64 (103),
B64 (104), B64 (105), B64 (106), B64 (107),
B64 (108), B64 (109), B64 (110), B64 (111),
B64 (112), B64 (113), B64 (114), B64 (115),
B64 (116), B64 (117), B64 (118), B64 (119),
B64 (120), B64 (121), B64 (122), B64 (123),
B64 (124), B64 (125), B64 (126), B64 (127),
B64 (128), B64 (129), B64 (130), B64 (131),
B64 (132), B64 (133), B64 (134), B64 (135),
B64 (136), B64 (137), B64 (138), B64 (139),
B64 (140), B64 (141), B64 (142), B64 (143),
B64 (144), B64 (145), B64 (146), B64 (147),
B64 (148), B64 (149), B64 (150), B64 (151),
B64 (152), B64 (153), B64 (154), B64 (155),
B64 (156), B64 (157), B64 (158), B64 (159),
B64 (160), B64 (161), B64 (162), B64 (163),
B64 (164), B64 (165), B64 (166), B64 (167),
B64 (168), B64 (169), B64 (170), B64 (171),
B64 (172), B64 (173), B64 (174), B64 (175),
B64 (176), B64 (177), B64 (178), B64 (179),
B64 (180), B64 (181), B64 (182), B64 (183),
B64 (184), B64 (185), B64 (186), B64 (187),
B64 (188), B64 (189), B64 (190), B64 (191),
B64 (192), B64 (193), B64 (194), B64 (195),
B64 (196), B64 (197), B64 (198), B64 (199),
B64 (200), B64 (201), B64 (202), B64 (203),
B64 (204), B64 (205), B64 (206), B64 (207),
B64 (208), B64 (209), B64 (210), B64 (211),
B64 (212), B64 (213), B64 (214), B64 (215),
B64 (216), B64 (217), B64 (218), B64 (219),
B64 (220), B64 (221), B64 (222), B64 (223),
B64 (224), B64 (225), B64 (226), B64 (227),
B64 (228), B64 (229), B64 (230), B64 (231),
B64 (232), B64 (233), B64 (234), B64 (235),
B64 (236), B64 (237), B64 (238), B64 (239),
B64 (240), B64 (241), B64 (242), B64 (243),
B64 (244), B64 (245), B64 (246), B64 (247),
B64 (248), B64 (249), B64 (250), B64 (251),
B64 (252), B64 (253), B64 (254), B64 (255)
};
#if UCHAR_MAX == 255
# define uchar_in_range(c) true
#else
# define uchar_in_range(c) ((c) <= 255)
#endif
/* Return true if CH is a character from the Base64 alphabet, and
false otherwise. Note that '=' is padding and not considered to be
part of the alphabet. */
bool
isbase64 (char ch)
{
return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
}
/* Initialize decode-context buffer, CTX. */
void
base64_decode_ctx_init (struct base64_decode_context *ctx)
{
ctx->i = 0;
}
/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and
none of those four is a newline, then return *IN. Otherwise, copy up to
4 - CTX->i non-newline bytes from that range into CTX->buf, starting at
index CTX->i and setting CTX->i to reflect the number of bytes copied,
and return CTX->buf. In either case, advance *IN to point to the byte
after the last one processed, and set *N_NON_NEWLINE to the number of
verified non-newline bytes accessible through the returned pointer. */
static inline char *
get_4 (struct base64_decode_context *ctx,
char const *restrict *in, char const *restrict in_end,
size_t *n_non_newline)
{
if (ctx->i == 4)
ctx->i = 0;
if (ctx->i == 0)
{
char const *t = *in;
if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL)
{
/* This is the common case: no newline. */
*in += 4;
*n_non_newline = 4;
return (char *) t;
}
}
{
/* Copy non-newline bytes into BUF. */
char const *p = *in;
while (p < in_end)
{
char c = *p++;
if (c != '\n')
{
ctx->buf[ctx->i++] = c;
if (ctx->i == 4)
break;
}
}
*in = p;
*n_non_newline = ctx->i;
return ctx->buf;
}
}
#define return_false \
do \
{ \
*outp = out; \
return false; \
} \
while (false)
/* Decode up to four bytes of base64-encoded data, IN, of length INLEN
into the output buffer, *OUT, of size *OUTLEN bytes. Return true if
decoding is successful, false otherwise. If *OUTLEN is too small,
as many bytes as possible are written to *OUT. On return, advance
*OUT to point to the byte after the last one written, and decrement
*OUTLEN to reflect the number of bytes remaining in *OUT. */
static inline bool
decode_4 (char const *restrict in, size_t inlen,
char *restrict *outp, size_t *outleft)
{
char *out = *outp;
if (inlen < 2)
return false;
if (!isbase64 (in[0]) || !isbase64 (in[1]))
return false;
if (*outleft)
{
*out++ = ((b64[to_uchar (in[0])] << 2)
| (b64[to_uchar (in[1])] >> 4));
--*outleft;
}
if (inlen == 2)
return_false;
if (in[2] == '=')
{
if (inlen != 4)
return_false;
if (in[3] != '=')
return_false;
}
else
{
if (!isbase64 (in[2]))
return_false;
if (*outleft)
{
*out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
| (b64[to_uchar (in[2])] >> 2));
--*outleft;
}
if (inlen == 3)
return_false;
if (in[3] == '=')
{
if (inlen != 4)
return_false;
}
else
{
if (!isbase64 (in[3]))
return_false;
if (*outleft)
{
*out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
| b64[to_uchar (in[3])]);
--*outleft;
}
}
}
*outp = out;
return true;
}
/* Decode base64-encoded input array IN of length INLEN to output array
OUT that can hold *OUTLEN bytes. The input data may be interspersed
with newlines. Return true if decoding was successful, i.e. if the
input was valid base64 data, false otherwise. If *OUTLEN is too
small, as many bytes as possible will be written to OUT. On return,
*OUTLEN holds the length of decoded bytes in OUT. Note that as soon
as any non-alphabet, non-newline character is encountered, decoding
is stopped and false is returned. If INLEN is zero, then process
only whatever data is stored in CTX.
Initially, CTX must have been initialized via base64_decode_ctx_init.
Subsequent calls to this function must reuse whatever state is recorded
in that buffer. It is necessary for when a quadruple of base64 input
bytes spans two input buffers. */
bool
base64_decode (struct base64_decode_context *ctx,
const char *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
size_t outleft = *outlen;
bool flush_ctx = inlen == 0;
while (true)
{
size_t outleft_save = outleft;
if (ctx->i == 0 && !flush_ctx)
{
while (true)
{
/* Save a copy of outleft, in case we need to re-parse this
block of four bytes. */
outleft_save = outleft;
if (!decode_4 (in, inlen, &out, &outleft))
break;
in += 4;
inlen -= 4;
}
}
if (inlen == 0 && !flush_ctx)
break;
/* Handle the common case of 72-byte wrapped lines.
This also handles any other multiple-of-4-byte wrapping. */
if (inlen && *in == '\n')
{
++in;
--inlen;
continue;
}
/* Restore OUT and OUTLEFT. */
out -= outleft_save - outleft;
outleft = outleft_save;
{
char const *in_end = in + inlen;
char const *non_nl = get_4 (ctx, &in, in_end, &inlen);
/* If the input is empty or consists solely of newlines (0 non-newlines),
then we're done. Likewise if there are fewer than 4 bytes when not
flushing context. */
if (inlen == 0 || (inlen < 4 && !flush_ctx))
{
inlen = 0;
break;
}
if (!decode_4 (non_nl, inlen, &out, &outleft))
break;
inlen = in_end - in;
}
}
*outlen -= outleft;
return inlen == 0;
}
/* Allocate an output buffer in *OUT, and decode the base64 encoded
data stored in IN of size INLEN to the *OUT buffer. On return, the
size of the decoded data is stored in *OUTLEN. OUTLEN may be NULL,
if the caller is not interested in the decoded length. *OUT may be
NULL to indicate an out of memory error, in which case *OUTLEN
contains the size of the memory block needed. The function returns
true on successful decoding and memory allocation errors. (Use the
*OUT and *OUTLEN parameters to differentiate between successful
decoding and memory error.) The function returns false if the
input was invalid, in which case *OUT is NULL and *OUTLEN is
undefined. */
bool
base64_decode_alloc (struct base64_decode_context *ctx,
const char *in, size_t inlen, char **out,
size_t *outlen)
{
/* This may allocate a few bytes too many, depending on input,
but it's not worth the extra CPU time to compute the exact size.
The exact size is 3 * inlen / 4, minus 1 if the input ends
with "=" and minus another 1 if the input ends with "==".
Dividing before multiplying avoids the possibility of overflow. */
size_t needlen = 3 * (inlen / 4) + 2;
*out = malloc (needlen);
if (!*out)
return true;
if (!base64_decode (ctx, in, inlen, *out, &needlen))
{
free (*out);
*out = NULL;
return false;
}
if (outlen)
*outlen = needlen;
return true;
}

54
gl/lib/base64.h Normal file
View File

@@ -0,0 +1,54 @@
/* base64.h -- Encode binary data using printable characters.
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
Written by Simon Josefsson.
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. */
#ifndef BASE64_H
# define BASE64_H
/* Get size_t. */
# include <stddef.h>
/* Get bool. */
# include <stdbool.h>
/* This uses that the expression (n+(k-1))/k means the smallest
integer >= n/k, i.e., the ceiling of n/k. */
# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
struct base64_decode_context
{
unsigned int i;
char buf[4];
};
extern bool isbase64 (char ch);
extern void base64_encode (const char *restrict in, size_t inlen,
char *restrict out, size_t outlen);
extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
extern bool base64_decode (struct base64_decode_context *ctx,
const char *restrict in, size_t inlen,
char *restrict out, size_t *outlen);
extern bool base64_decode_alloc (struct base64_decode_context *ctx,
const char *in, size_t inlen,
char **out, size_t *outlen);
#endif /* BASE64_H */

View File

@@ -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
@@ -40,6 +45,7 @@ close-stream.c
close-stream.h
closeout.c
closeout.h
concatpath.c
config.charset
config.h
config.hin
@@ -52,6 +58,8 @@ diacrit.c
diacrit.h
dirchownmod.c
dirchownmod.h
dirent.h
dirent_.h
dirfd.c
dirfd.h
dirname.c
@@ -67,8 +75,10 @@ exclude.h
exit.h
exitfail.c
exitfail.h
fchdir.c
fchmodat.c
fchown-stub.c
fchownat.c
fcntl--.h
fcntl-safer.h
fcntl.h
@@ -81,6 +91,8 @@ filemode.c
filemode.h
filenamecat.c
filenamecat.h
findprog.c
findprog.h
fnmatch.c
fnmatch.h
fnmatch_.h
@@ -173,6 +185,7 @@ lstat.h
malloc.c
mbchar.c
mbchar.h
mbscasecmp.c
mbswidth.c
mbswidth.h
mbuiter.h
@@ -187,9 +200,7 @@ memcoll.h
memcpy.c
memmove.c
mempcpy.c
mempcpy.h
memrchr.c
memrchr.h
memset.c
mkancesdirs.c
mkancesdirs.h
@@ -205,6 +216,8 @@ modechange.c
modechange.h
mountlist.c
mountlist.h
mpsort.c
mpsort.h
nanosleep.c
obstack.c
obstack.h
@@ -216,6 +229,7 @@ openat-proc.c
openat.c
openat.h
pathmax.h
pathname.h
physmem.c
physmem.h
pipe-safer.c
@@ -280,10 +294,12 @@ sig2str.c
sig2str.h
snprintf.c
snprintf.h
socket.h
socket_.h
stamp-h1
stat-macros.h
stat-time.h
stat.h
stat_.h
stdbool.h
stdbool_.h
@@ -291,27 +307,27 @@ stdint.h
stdint_.h
stdio--.h
stdio-safer.h
stdio.h
stdio_.h
stdlib--.h
stdlib-safer.h
stdlib.h
stdlib_.h
stpcpy.c
stpcpy.h
strcase.h
strcasecmp.c
strcspn.c
strdup.c
strdup.h
strftime.c
strftime.h
string.h
string_.h
stripslash.c
strncasecmp.c
strndup.c
strndup.h
strnlen.c
strnlen.h
strnlen1.c
strnlen1.h
strpbrk.c
strpbrk.h
strtod.c
strtoimax.c
strtol.c
@@ -321,9 +337,14 @@ strtoull.c
strtoumax.c
strverscmp.c
strverscmp.h
sys
sys_time.h
sys_time_.h
t-fpending
tempname.c
tempname.h
time.h
time_.h
time_r.c
time_r.h
timespec.h
@@ -332,6 +353,8 @@ umaxtostr.c
unicodeio.h
unistd--.h
unistd-safer.h
unistd.h
unistd_.h
unlinkdir.c
unlinkdir.h
unlocked-io.h
@@ -350,6 +373,10 @@ verify.h
version-etc-fsf.c
version-etc.c
version-etc.h
wchar.h
wchar_.h
wctype.h
wctype_.h
wcwidth.h
xalloc-die.c
xalloc.h

47
lib/.gitignore vendored
View File

@@ -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
@@ -37,6 +42,7 @@ close-stream.c
close-stream.h
closeout.c
closeout.h
concatpath.c
config.charset
configmake.h
creat-safer.c
@@ -47,6 +53,8 @@ diacrit.c
diacrit.h
dirchownmod.c
dirchownmod.h
dirent.h
dirent_.h
dirfd.c
dirfd.h
dirname.c
@@ -62,8 +70,10 @@ exclude.h
exit.h
exitfail.c
exitfail.h
fchdir.c
fchmodat.c
fchown-stub.c
fchownat.c
fcntl--.h
fcntl-safer.h
fcntl.h
@@ -76,7 +86,10 @@ filemode.c
filemode.h
filenamecat.c
filenamecat.h
findprog.c
findprog.h
fnmatch.c
fnmatch.h
fnmatch_.h
fnmatch_loop.c
fopen-safer.c
@@ -89,6 +102,7 @@ fsusage.h
ftruncate.c
fts-cycle.c
fts.c
fts.h
fts_.h
full-read.c
full-read.h
@@ -114,6 +128,7 @@ getloadavg.c
getndelim2.c
getndelim2.h
getopt.c
getopt.h
getopt1.c
getopt_.h
getopt_int.h
@@ -164,6 +179,7 @@ lstat.h
malloc.c
mbchar.c
mbchar.h
mbscasecmp.c
mbswidth.c
mbswidth.h
mbuiter.h
@@ -178,9 +194,7 @@ memcoll.h
memcpy.c
memmove.c
mempcpy.c
mempcpy.h
memrchr.c
memrchr.h
memset.c
mkancesdirs.c
mkancesdirs.h
@@ -196,6 +210,8 @@ modechange.c
modechange.h
mountlist.c
mountlist.h
mpsort.c
mpsort.h
nanosleep.c
obstack.c
obstack.h
@@ -207,6 +223,7 @@ openat-proc.c
openat.c
openat.h
pathmax.h
pathname.h
physmem.c
physmem.h
pipe-safer.c
@@ -269,36 +286,39 @@ sig2str.c
sig2str.h
snprintf.c
snprintf.h
socket.h
socket_.h
stat-macros.h
stat-time.h
stat.h
stat_.h
stdbool.h
stdbool_.h
stdint.h
stdint_.h
stdio--.h
stdio-safer.h
stdio.h
stdio_.h
stdlib--.h
stdlib-safer.h
stdlib.h
stdlib_.h
stpcpy.c
stpcpy.h
strcase.h
strcasecmp.c
strcspn.c
strdup.c
strdup.h
strftime.c
strftime.h
string.h
string_.h
stripslash.c
strncasecmp.c
strndup.c
strndup.h
strnlen.c
strnlen.h
strnlen1.c
strnlen1.h
strpbrk.c
strpbrk.h
strtod.c
strtoimax.c
strtol.c
@@ -308,9 +328,14 @@ strtoull.c
strtoumax.c
strverscmp.c
strverscmp.h
sys
sys_time.h
sys_time_.h
t-fpending
tempname.c
tempname.h
time.h
time_.h
time_r.c
time_r.h
timespec.h
@@ -319,6 +344,8 @@ umaxtostr.c
unicodeio.h
unistd--.h
unistd-safer.h
unistd.h
unistd_.h
unlinkdir.c
unlinkdir.h
unlocked-io.h
@@ -337,6 +364,10 @@ verify.h
version-etc-fsf.c
version-etc.c
version-etc.h
wchar.h
wchar_.h
wctype.h
wctype_.h
wcwidth.h
xalloc-die.c
xalloc.h

View File

@@ -1,3 +1,22 @@
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
bootstrap-inserted file names.
2007-01-14 Jim Meyering <jim@meyering.net>
* fchdir-stub.c: Remove file. No longer needed.
2006-12-03 Jim Meyering <jim@meyering.net>
* Makefile.am (libcoreutils_a_SOURCES): Remove xmemcoll.c and

View File

@@ -1,14 +0,0 @@
#include <config.h>
#include <sys/types.h>
#include <errno.h>
/* A trivial substitute for `fchdir'.
DJGPP 2.03 and earlier don't have `fchdir'. */
int
fchdir (int fd)
{
errno = ENOSYS;
return -1;
}

View File

@@ -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)

View File

@@ -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"

View File

@@ -30,6 +30,7 @@ dirname.m4
dos.m4
double-slash-root.m4
dup2.m4
eaccess.m4
eealloc.m4
eoverflow.m4
error.m4
@@ -37,12 +38,14 @@ euidaccess.m4
exclude.m4
exitfail.m4
extensions.m4
fchdir.m4
fcntl-safer.m4
fcntl_h.m4
file-type.m4
fileblocks.m4
filemode.m4
filenamecat.m4
findprog.m4
flexmember.m4
fnmatch.m4
fpending.m4
@@ -75,6 +78,7 @@ getusershell.m4
glibc2.m4
glibc21.m4
gnulib-cache.m4
gnulib-common.m4
gnulib-comp.m4
gnulib-tool.m4
group-member.m4
@@ -119,6 +123,7 @@ lstat.m4
mbchar.m4
mbiter.m4
mbrtowc.m4
mbscasecmp.m4
mbstate_t.m4
mbswidth.m4
md5.m4
@@ -138,6 +143,7 @@ mkstemp.m4
mktime.m4
modechange.m4
mountlist.m4
mpsort.m4
nanosleep.m4
netinet_in_h.m4
nls.m4
@@ -187,12 +193,15 @@ 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
strdup.m4
strftime.m4
string_h.m4
strndup.m4
strnlen.m4
strpbrk.m4
@@ -206,7 +215,9 @@ strtoumax.m4
strverscmp.m4
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
@@ -230,7 +241,9 @@ utimes.m4
vasnprintf.m4
vasprintf.m4
visibility.m4
wchar.m4
wchar_t.m4
wctype.m4
wcwidth.m4
wint_t.m4
xalloc.m4

13
m4/.gitignore vendored
View File

@@ -29,6 +29,7 @@ dirname.m4
dos.m4
double-slash-root.m4
dup2.m4
eaccess.m4
eealloc.m4
eoverflow.m4
error.m4
@@ -36,12 +37,14 @@ euidaccess.m4
exclude.m4
exitfail.m4
extensions.m4
fchdir.m4
fcntl-safer.m4
fcntl_h.m4
file-type.m4
fileblocks.m4
filemode.m4
filenamecat.m4
findprog.m4
flexmember.m4
fnmatch.m4
fpending.m4
@@ -73,6 +76,7 @@ getugroups.m4
getusershell.m4
glibc21.m4
gnulib-cache.m4
gnulib-common.m4
gnulib-comp.m4
gnulib-tool.m4
group-member.m4
@@ -113,6 +117,7 @@ lstat.m4
mbchar.m4
mbiter.m4
mbrtowc.m4
mbscasecmp.m4
mbstate_t.m4
mbswidth.m4
md5.m4
@@ -132,6 +137,7 @@ mkstemp.m4
mktime.m4
modechange.m4
mountlist.m4
mpsort.m4
nanosleep.m4
netinet_in_h.m4
nls.m4
@@ -179,12 +185,15 @@ 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
strdup.m4
strftime.m4
string_h.m4
strndup.m4
strnlen.m4
strpbrk.m4
@@ -198,7 +207,9 @@ strtoumax.m4
strverscmp.m4
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
@@ -219,7 +230,9 @@ utimes-null.m4
utimes.m4
vasnprintf.m4
vasprintf.m4
wchar.m4
wchar_t.m4
wctype.m4
wcwidth.m4
wint_t.m4
xalloc.m4

View File

@@ -1,3 +1,11 @@
2007-01-19 Jim Meyering <jim@meyering.net>
* .cvsignore, .gitignore: Add more bootstrap-inserted file names.
2006-12-12 Jim Meyering <jim@meyering.net>
* jm-macros.m4: Remove AC_FUNC_SETVBUF_REVERSED, now that it's a no-op.
2006-10-14 Paul Eggert <eggert@cs.ucla.edu>
* sha512.m4 (gl_SHA512): Add u64.h to AC_LIBSOURCES.

View File

@@ -1,4 +1,4 @@
#serial 104 -*- autoconf -*-
#serial 105 -*- autoconf -*-
dnl Misc type-related macros for coreutils.
@@ -50,9 +50,6 @@ AC_DEFUN([coreutils_MACROS],
AC_DEFINE(ARGMATCH_DIE_DECL, [extern void usage ()],
[Define to the declaration of the xargmatch failure function.])
dnl Used to define SETVBUF in ../src/system.h.
AC_FUNC_SETVBUF_REVERSED
# used by ls
AC_REQUIRE([gl_CLOCK_TIME])
# used by shred
@@ -112,10 +109,6 @@ AC_DEFUN([coreutils_MACROS],
if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
DF_PROG='df$(EXEEXT)'
fi
# If any of these functions don't exist (e.g. DJGPP 2.03),
# use the corresponding stub.
AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)])
])
AC_DEFUN([gl_CHECK_ALL_HEADERS],

View File

@@ -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,17 +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 \
--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

View File

@@ -1,7 +1,6 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-
## Copyright (C) 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
## 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
## Copyright (C) 1990, 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
@@ -116,10 +115,16 @@ $(PROGRAMS): ../lib/libcoreutils.a
SUFFIXES = .sh
# Get the release year from ../lib/version-etc.c.
RELEASE_YEAR = \
`sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
$(top_srcdir)/lib/version-etc.c`
.sh:
rm -f $@ $@-t
sed \
-e 's!@''bindir''@!$(bindir)!' \
-e 's/@''RELEASE_YEAR'@/$(RELEASE_YEAR)/ \
-e 's/@''GNU_PACKAGE''@/$(GNU_PACKAGE)/' \
-e 's/@''PACKAGE_BUGREPORT''@/$(PACKAGE_BUGREPORT)/' \
-e 's/@''VERSION''@/$(VERSION)/' $< > $@-t

View File

@@ -1,5 +1,5 @@
/* Base64 encode/decode strings or files.
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of Base64.
@@ -83,9 +83,10 @@ With no FILE, or when FILE is -, read standard input.\n"), stdout);
fputs (_("\
\n\
The data are encoded as described for the base64 alphabet in RFC 3548.\n\
Decoding require compliant input by default, use --ignore-garbage to\n\
attempt to recover from non-alphabet characters (such as newlines) in\n\
the encoded stream.\n"), stdout);
When decoding, the input may contain newlines in addition to the bytes of\n\
the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\
from any other non-alphabet bytes in the encoded stream.\n"),
stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
@@ -183,11 +184,15 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
char inbuf[B64BLOCKSIZE];
char outbuf[BLOCKSIZE];
size_t sum;
struct base64_decode_context ctx;
base64_decode_ctx_init (&ctx);
do
{
bool ok;
size_t n;
unsigned int k;
sum = 0;
do
@@ -211,14 +216,23 @@ do_decode (FILE *in, FILE *out, bool ignore_garbage)
}
while (sum < B64BLOCKSIZE && !feof (in));
n = BLOCKSIZE;
ok = base64_decode (inbuf, sum, outbuf, &n);
/* The following "loop" is usually iterated just once.
However, when it processes the final input buffer, we want
to iterate it one additional time, but with an indicator
telling it to flush what is in CTX. */
for (k = 0; k < 1 + feof (in); k++)
{
if (k == 1 && ctx.i == 0)
break;
n = BLOCKSIZE;
ok = base64_decode (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);
if (fwrite (outbuf, 1, n, out) < n)
error (EXIT_FAILURE, errno, _("write error"));
if (fwrite (outbuf, 1, n, out) < n)
error (EXIT_FAILURE, errno, _("write error"));
if (!ok)
error (EXIT_FAILURE, 0, _("invalid input"));
if (!ok)
error (EXIT_FAILURE, 0, _("invalid input"));
}
}
while (!feof (in));
}

View File

@@ -31,7 +31,7 @@ index 4728bdd..7477da5 100644
if (top->unremovable)
hash_free (top->unremovable);
obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent));
@@ -1463,6 +1465,7 @@ rm_1 (Dirstack_state *ds, char const *fi
@@ -1481,6 +1483,7 @@ rm_1 (Dirstack_state *ds, char const *fi
return RM_ERROR;
}
@@ -39,7 +39,7 @@ index 4728bdd..7477da5 100644
struct stat st;
cache_stat_init (&st);
cycle_check_init (&ds->cycle_check_state);
@@ -1485,6 +1488,7 @@ rm_1 (Dirstack_state *ds, char const *fi
@@ -1503,6 +1506,7 @@ rm_1 (Dirstack_state *ds, char const *fi
AD_push_initial (ds);
AD_INIT_OTHER_MEMBERS ();
@@ -47,7 +47,7 @@ index 4728bdd..7477da5 100644
enum RM_status status = remove_entry (AT_FDCWD, ds, filename, &st, x, NULL);
if (status == RM_NONEMPTY_DIR)
{
@@ -1501,6 +1505,8 @@ rm_1 (Dirstack_state *ds, char const *fi
@@ -1519,6 +1523,8 @@ rm_1 (Dirstack_state *ds, char const *fi
ds_clear (ds);
return status;
@@ -83,13 +83,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

View File

@@ -260,20 +260,14 @@ main (int argc, char **argv)
if (dereference == 1)
error (EXIT_FAILURE, 0,
_("-R --dereference requires either -H or -L"));
chopt.affect_symlink_referent = false;
}
else
{
if (dereference == 0)
error (EXIT_FAILURE, 0, _("-R -h requires -P"));
chopt.affect_symlink_referent = true;
dereference = 0;
}
}
else
{
bit_flags = FTS_PHYSICAL;
chopt.affect_symlink_referent = (dereference != 0);
}
chopt.affect_symlink_referent = (dereference != 0);
if (argc - optind < (reference_file ? 1 : 2))
{

View File

@@ -228,6 +228,10 @@ process_file (FTS *fts, FTSENT *ent)
if (ok && ROOT_DEV_INO_CHECK (root_dev_ino, file_stats))
{
ROOT_DEV_INO_WARN (file_full_name);
/* Tell fts not to traverse into this hierarchy. */
fts_set (fts, ent, FTS_SKIP);
/* Ensure that we do not process "/" on the second visit. */
ent = fts_read (fts);
ok = false;
}

View File

@@ -1,5 +1,5 @@
/* chown-core.c -- core functions for changing ownership.
Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 Free Software Foundation.
Copyright (C) 2000, 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
@@ -32,6 +32,12 @@
#include "root-dev-ino.h"
#include "xfts.h"
#define FTSENT_IS_DIRECTORY(E) \
((E)->fts_info == FTS_D \
|| (E)->fts_info == FTS_DC \
|| (E)->fts_info == FTS_DP \
|| (E)->fts_info == FTS_DNR)
enum RCH_status
{
/* we called fchown and close, and both succeeded */
@@ -258,7 +264,20 @@ change_file_owner (FTS *fts, FTSENT *ent,
{
case FTS_D:
if (chopt->recurse)
return true;
{
if (ROOT_DEV_INO_CHECK (chopt->root_dev_ino, ent->fts_statp))
{
/* This happens e.g., with "chown -R --preserve-root 0 /"
and with "chown -RH --preserve-root 0 symlink-to-root". */
ROOT_DEV_INO_WARN (file_full_name);
/* Tell fts not to traverse into this hierarchy. */
fts_set (fts, ent, FTS_SKIP);
/* Ensure that we do not process "/" on the second visit. */
ent = fts_read (fts);
return false;
}
return true;
}
break;
case FTS_DP:
@@ -337,15 +356,13 @@ change_file_owner (FTS *fts, FTSENT *ent,
|| required_gid == file_stats->st_gid));
}
if (do_chown
/* With FTS_NOSTAT, file_stats is valid only for directories.
Don't need to check for FTS_D, since it is handled above,
and same for FTS_DNR, since then do_chown is false. */
&& (ent->fts_info == FTS_DP || ent->fts_info == FTS_DC)
/* This happens when chown -LR --preserve-root encounters a symlink-to-/. */
if (ok
&& FTSENT_IS_DIRECTORY (ent)
&& ROOT_DEV_INO_CHECK (chopt->root_dev_ino, file_stats))
{
ROOT_DEV_INO_WARN (file_full_name);
ok = do_chown = false;
return false;
}
if (do_chown)

View File

@@ -273,20 +273,14 @@ main (int argc, char **argv)
if (dereference == 1)
error (EXIT_FAILURE, 0,
_("-R --dereference requires either -H or -L"));
chopt.affect_symlink_referent = false;
}
else
{
if (dereference == 0)
error (EXIT_FAILURE, 0, _("-R -h requires -P"));
chopt.affect_symlink_referent = true;
dereference = 0;
}
}
else
{
bit_flags = FTS_PHYSICAL;
chopt.affect_symlink_referent = (dereference != 0);
}
chopt.affect_symlink_referent = (dereference != 0);
if (argc - optind < (reference_file ? 1 : 2))
{

View File

@@ -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
@@ -295,8 +295,8 @@ copy_reg (char const *src_name, char const *dst_name,
goto close_src_desc;
}
/* These semantics are required for cp.
The if-block will be taken in move_mode. */
/* The semantics of the following open calls are mandated
by the specs for both cp and mv. */
if (! *new_dst)
{
dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY);
@@ -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));
@@ -1686,12 +1697,16 @@ copy_internal (char const *src_name, char const *dst_name,
{
/* Use mknod, rather than mkfifo, because the former preserves
the special mode bits of a fifo on Solaris 10, while mkfifo
does not. */
does not. But fall back on mkfifo, because on some BSD systems,
mknod always fails when asked to create a FIFO. */
if (mknod (dst_name, src_mode & ~omitted_permissions, 0) != 0)
{
error (0, errno, _("cannot create fifo %s"), quote (dst_name));
goto un_backup;
}
#if HAVE_MKFIFO
if (mkfifo (dst_name, src_mode & ~S_IFIFO & ~omitted_permissions) != 0)
#endif
{
error (0, errno, _("cannot create fifo %s"), quote (dst_name));
goto un_backup;
}
}
else if (S_ISBLK (src_mode) || S_ISCHR (src_mode) || S_ISSOCK (src_mode))
{
@@ -1975,7 +1990,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);

View File

@@ -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

View File

@@ -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
@@ -1402,7 +1402,26 @@ main (int argc, char **argv)
{
int i;
static int const sig[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM };
static int const sig[] =
{
/* The usual suspects. */
SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM,
#ifdef SIGPOLL
SIGPOLL,
#endif
#ifdef SIGPROF
SIGPROF,
#endif
#ifdef SIGVTALRM
SIGVTALRM,
#endif
#ifdef SIGXCPU
SIGXCPU,
#endif
#ifdef SIGXFSZ
SIGXFSZ,
#endif
};
enum { nsigs = sizeof sig / sizeof sig[0] };
#if SA_NOCLDSTOP
@@ -1465,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);

View File

@@ -606,6 +606,7 @@ cut_fields (FILE *stream)
if (len < 0)
{
free (field_1_buffer);
field_1_buffer = NULL;
if (ferror (stream) || feof (stream))
break;
xalloc_die ();

View File

@@ -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\

View File

@@ -1,5 +1,5 @@
/* dd -- convert a file while copying it.
Copyright (C) 85, 90, 91, 1995-2006 Free Software Foundation, Inc.
Copyright (C) 85, 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
@@ -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"),
@@ -873,6 +873,7 @@ static void
scanargs (int argc, char **argv)
{
int i;
size_t blocksize = 0;
for (i = optind; i < argc; i++)
{
@@ -923,7 +924,7 @@ scanargs (int argc, char **argv)
else if (STREQ (name, "bs"))
{
invalid |= ! (0 < n && n <= MAX_BLOCKSIZE (INPUT_BLOCK_SLOP));
output_blocksize = input_blocksize = n;
blocksize = n;
}
else if (STREQ (name, "cbs"))
{
@@ -948,6 +949,9 @@ scanargs (int argc, char **argv)
}
}
if (blocksize)
input_blocksize = output_blocksize = blocksize;
/* If bs= was given, both `input_blocksize' and `output_blocksize' will
have been set to positive values. If either has not been set,
bs= was not given, so make sure two buffers are used. */
@@ -1222,7 +1226,7 @@ advance_input_after_read_error (size_t nbytes)
return true;
diff = input_offset - offset;
if (! (0 <= diff && diff <= nbytes))
error (0, 0, _("warning: screwy file offset after failed read"));
error (0, 0, _("warning: invalid file offset after failed read"));
if (0 <= skip_via_lseek (input_file, STDIN_FILENO, diff, SEEK_CUR))
return true;
if (errno == 0)

View File

@@ -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);

View File

@@ -1,5 +1,5 @@
/* dircolors - output commands to set the LS_COLOR environment variable
Copyright (C) 1996-2006 Free Software Foundation, Inc.
Copyright (C) 1996-2007 Free Software Foundation, Inc.
Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin
This program is free software; you can redistribute it and/or modify
@@ -24,11 +24,11 @@
#include "system.h"
#include "dircolors.h"
#include "c-strcase.h"
#include "error.h"
#include "getline.h"
#include "obstack.h"
#include "quote.h"
#include "strcase.h"
#include "xstrndup.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -296,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;
@@ -325,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. */
}
@@ -336,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)

View File

@@ -23,6 +23,7 @@ TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM console
TERM cygwin
TERM dtterm

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -427,6 +427,10 @@ docolon (VALUE *sv, VALUE *pv)
tostring (sv);
tostring (pv);
re_regs.num_regs = 0;
re_regs.start = NULL;
re_regs.end = NULL;
re_buffer.buffer = NULL;
re_buffer.allocated = 0;
re_buffer.fastmap = fastmap;
@@ -463,7 +467,13 @@ docolon (VALUE *sv, VALUE *pv)
(matchlen == -2 ? errno : EOVERFLOW),
_("error in regular expression matcher"));
free (re_buffer.buffer);
if (0 < re_regs.num_regs)
{
free (re_regs.start);
free (re_regs.end);
}
re_buffer.fastmap = NULL;
regfree (&re_buffer);
return v;
}

View File

@@ -607,12 +607,15 @@ copy_rest (FILE *f, int c)
const char *s;
out_column = 0;
if (in_column > next_prefix_indent && c != '\n' && c != EOF)
if (in_column > next_prefix_indent || (c != '\n' && c != EOF))
{
put_space (next_prefix_indent);
for (s = prefix; out_column != in_column && *s; out_column++)
putchar (*s++);
put_space (in_column - out_column);
if (c != EOF && c != '\n')
put_space (in_column - out_column);
if (c == EOF && in_column >= next_prefix_indent + prefix_length)
putchar ('\n');
}
while (c != '\n' && c != EOF)
{
@@ -688,10 +691,8 @@ get_line (FILE *f, int c)
flush_paragraph ();
}
word_limit++;
if (c == EOF)
return EOF;
}
while (c != '\n');
while (c != '\n' && c != EOF);
return get_prefix (f);
}

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# groups -- print the groups a user is in
# Copyright (C) 1991, 1997, 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
# Copyright (C) 1991, 1997, 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
@@ -32,7 +32,7 @@ Same as id -Gn. If no USERNAME, use current process.
Report bugs to <@PACKAGE_BUGREPORT@>."
version='groups (@GNU_PACKAGE@) @VERSION@
Copyright (C) 2006 Free Software Foundation, Inc.
Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

View File

@@ -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\

View File

@@ -599,7 +599,8 @@ add_field (int file, size_t field)
/* Convert a string of decimal digits, STR (the 1-based join field number),
to an integral value. Upon successful conversion, return one less
(the zero-based field number). If it cannot be converted, give a
(the zero-based field number). Silently convert too-large values
to SIZE_MAX - 1. Otherwise, if a value cannot be converted, give a
diagnostic and exit. */
static size_t
@@ -607,16 +608,12 @@ string_to_join_field (char const *str)
{
size_t result;
unsigned long int val;
verify (SIZE_MAX <= ULONG_MAX);
strtol_error s_err = xstrtoul (str, NULL, 10, &val, "");
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
{
error (EXIT_FAILURE, 0,
_("value %s is so large that it is not representable"),
quote (str));
}
if (s_err != LONGINT_OK || val == 0)
val = SIZE_MAX;
else if (s_err != LONGINT_OK || val == 0)
error (EXIT_FAILURE, 0, _("invalid field number: %s"), quote (str));
result = val - 1;

250
src/ls.c
View File

@@ -1,5 +1,5 @@
/* `dir', `vdir' and `ls' directory listing programs for GNU.
Copyright (C) 85, 88, 90, 91, 1995-2006 Free Software Foundation, Inc.
Copyright (C) 85, 88, 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
@@ -93,6 +93,7 @@
#include "ls.h"
#include "lstat.h"
#include "mbswidth.h"
#include "mpsort.h"
#include "obstack.h"
#include "quote.h"
#include "quotearg.h"
@@ -155,22 +156,23 @@ struct fileinfo
/* The file name. */
char *name;
struct stat stat;
bool stat_ok;
/* For symbolic link, name of the file linked to, otherwise zero. */
char *linkname;
struct stat stat;
enum filetype filetype;
/* For symbolic link and long listing, st_mode of file linked to, otherwise
zero. */
mode_t linkmode;
bool stat_ok;
/* For symbolic link and color printing, true if linked-to file
exists, otherwise false. */
bool linkok;
enum filetype filetype;
#if USE_ACL
/* For long listings, true if the file has an access control list. */
bool have_acl;
@@ -266,18 +268,23 @@ static Hash_table *active_dir_set;
/* The table of files in the current directory:
`files' points to a vector of `struct fileinfo', one per file.
`nfiles' is the number of elements space has been allocated for.
`files_index' is the number actually in use. */
`cwd_file' points to a vector of `struct fileinfo', one per file.
`cwd_n_alloc' is the number of elements space has been allocated for.
`cwd_n_used' is the number actually in use. */
/* Address of block containing the files that are described. */
static struct fileinfo *files; /* FIXME: rename this to e.g. cwd_file */
static struct fileinfo *cwd_file;
/* Length of block that `files' points to, measured in files. */
static size_t nfiles; /* FIXME: rename this to e.g. cwd_n_alloc */
/* Length of block that `cwd_file' points to, measured in files. */
static size_t cwd_n_alloc;
/* Index of first unused in `files'. */
static size_t files_index; /* FIXME: rename this to e.g. cwd_n_used */
/* Index of first unused slot in `cwd_file'. */
static size_t cwd_n_used;
/* Vector of pointers to files, in proper sorted order, and the number
of entries allocated for it. */
static void **sorted_file;
static size_t sorted_file_alloc;
/* When true, in a color listing, color each symlink name according to the
type of file it points to. Otherwise, color them according to the `ln'
@@ -1113,8 +1120,29 @@ main (int argc, char **argv)
int n_files;
/* The signals that are trapped, and the number of such signals. */
static int const sig[] = { SIGHUP, SIGINT, SIGPIPE,
SIGQUIT, SIGTERM, SIGTSTP };
static int const sig[] =
{
/* This one is handled specially. */
SIGTSTP,
/* The usual suspects. */
SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM,
#ifdef SIGPOLL
SIGPOLL,
#endif
#ifdef SIGPROF
SIGPROF,
#endif
#ifdef SIGVTALRM
SIGVTALRM,
#endif
#ifdef SIGXCPU
SIGXCPU,
#endif
#ifdef SIGXFSZ
SIGXFSZ,
#endif
};
enum { nsigs = sizeof sig / sizeof sig[0] };
#if ! SA_NOCLDSTOP
@@ -1231,9 +1259,9 @@ main (int argc, char **argv)
obstack_init (&subdired_obstack);
}
nfiles = 100;
files = xnmalloc (nfiles, sizeof *files);
files_index = 0;
cwd_n_alloc = 100;
cwd_file = xnmalloc (cwd_n_alloc, sizeof *cwd_file);
cwd_n_used = 0;
clear_files ();
@@ -1251,19 +1279,19 @@ main (int argc, char **argv)
gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, "");
while (i < argc);
if (files_index)
if (cwd_n_used)
{
sort_files ();
if (!immediate_dirs)
extract_dirs_from_files (NULL, true);
/* `files_index' might be zero now. */
/* `cwd_n_used' might be zero now. */
}
/* In the following if/else blocks, it is sufficient to test `pending_dirs'
(and not pending_dirs->name) because there may be no markers in the queue
at this point. A marker may be enqueued when extract_dirs_from_files is
called with a non-empty string or via print_dir. */
if (files_index)
if (cwd_n_used)
{
print_current_files ();
if (pending_dirs)
@@ -2314,6 +2342,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
{
file_failure (command_line_arg,
_("cannot determine device and inode of %s"), name);
closedir (dirp);
return;
}
@@ -2323,13 +2352,14 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
{
error (0, 0, _("%s: not listing already-listed directory"),
quotearg_colon (name));
closedir (dirp);
return;
}
DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
}
/* Read the directory entries, and insert the subfiles into the `files'
/* Read the directory entries, and insert the subfiles into the `cwd_file'
table. */
clear_files ();
@@ -2418,7 +2448,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
DIRED_PUTCHAR ('\n');
}
if (files_index)
if (cwd_n_used)
print_current_files ();
}
@@ -2472,7 +2502,7 @@ unsigned_file_size (off_t size)
return size + (size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
}
/* Enter and remove entries in the table `files'. */
/* Enter and remove entries in the table `cwd_file'. */
/* Empty the table of files. */
@@ -2481,13 +2511,14 @@ clear_files (void)
{
size_t i;
for (i = 0; i < files_index; i++)
for (i = 0; i < cwd_n_used; i++)
{
free (files[i].name);
free (files[i].linkname);
struct fileinfo *f = sorted_file[i];
free (f->name);
free (f->linkname);
}
files_index = 0;
cwd_n_used = 0;
#if USE_ACL
any_has_acl = false;
#endif
@@ -2517,13 +2548,13 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
which is not used for command line arguments. */
assert (! command_line_arg || inode == NOT_AN_INODE_NUMBER);
if (files_index == nfiles)
if (cwd_n_used == cwd_n_alloc)
{
files = xnrealloc (files, nfiles, 2 * sizeof *files);
nfiles *= 2;
cwd_file = xnrealloc (cwd_file, cwd_n_alloc, 2 * sizeof *cwd_file);
cwd_n_alloc *= 2;
}
f = &files[files_index];
f = &cwd_file[cwd_n_used];
memset (f, '\0', sizeof *f);
f->stat.st_ino = inode;
f->filetype = type;
@@ -2534,14 +2565,15 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
direct.d_type), we have to stat it in order to indicate
sticky and/or other-writable attributes. */
|| (type == directory && print_with_color)
|| (print_inode
&& (inode == NOT_AN_INODE_NUMBER
/* When dereferencing symlinks, the inode must come from
stat, but readdir provides the inode of lstat. Command
line dereferences are already taken care of by the above
assertion that the inode number is not yet known. */
|| (dereference == DEREF_ALWAYS
&& (type == symbolic_link || type == unknown))))
/* When dereferencing symlinks, the inode and type must come from
stat, but readdir provides the inode and type of lstat. */
|| ((print_inode || format_needs_type)
&& (type == symbolic_link || type == unknown)
&& (dereference == DEREF_ALWAYS
|| (command_line_arg && dereference != DEREF_NEVER)))
/* Command line dereferences are already taken care of by the above
assertion that the inode number is not yet known. */
|| (print_inode && inode == NOT_AN_INODE_NUMBER)
|| (format_needs_type
&& (type == unknown || command_line_arg
/* --indicator-style=classify (aka -F)
@@ -2614,7 +2646,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
return 0;
f->name = xstrdup (name);
files_index++;
cwd_n_used++;
return 0;
}
@@ -2747,7 +2779,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
}
f->name = xstrdup (name);
files_index++;
cwd_n_used++;
return blocks;
}
@@ -2812,7 +2844,7 @@ basename_is_dot_or_dotdot (const char *name)
return dot_or_dotdot (base);
}
/* Remove any entries from FILES that are for directories,
/* Remove any entries from CWD_FILE that are for directories,
and queue them to be listed as directories instead.
DIRNAME is the prefix to prepend to each dirname
to make it correct relative to ls's working dir;
@@ -2837,39 +2869,37 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg)
/* Queue the directories last one first, because queueing reverses the
order. */
for (i = files_index; i-- != 0; )
if (is_directory (&files[i])
&& (! ignore_dot_and_dot_dot
|| ! basename_is_dot_or_dotdot (files[i].name)))
{
if (!dirname || files[i].name[0] == '/')
{
queue_directory (files[i].name, files[i].linkname,
command_line_arg);
}
else
{
char *name = file_name_concat (dirname, files[i].name, NULL);
queue_directory (name, files[i].linkname, command_line_arg);
free (name);
}
if (files[i].filetype == arg_directory)
free (files[i].name);
}
for (i = cwd_n_used; i-- != 0; )
{
struct fileinfo *f = sorted_file[i];
if (is_directory (f)
&& (! ignore_dot_and_dot_dot
|| ! basename_is_dot_or_dotdot (f->name)))
{
if (!dirname || f->name[0] == '/')
queue_directory (f->name, f->linkname, command_line_arg);
else
{
char *name = file_name_concat (dirname, f->name, NULL);
queue_directory (name, f->linkname, command_line_arg);
free (name);
}
if (f->filetype == arg_directory)
free (f->name);
}
}
/* Now delete the directories from the table, compacting all the remaining
entries. */
for (i = 0, j = 0; i < files_index; i++)
for (i = 0, j = 0; i < cwd_n_used; i++)
{
if (files[i].filetype != arg_directory)
{
if (j < i)
files[j] = files[i];
++j;
}
struct fileinfo *f = sorted_file[i];
sorted_file[j] = f;
j += (f->filetype != arg_directory);
}
files_index = j;
cwd_n_used = j;
}
/* Use strcoll to compare strings in this locale. If an error occurs,
@@ -3091,6 +3121,15 @@ static qsortFunc sort_functions[][2][2][2] =
verify (ARRAY_CARDINALITY (sort_functions)
== sort_numtypes + time_numtypes - 1 );
/* Set up SORTED_FILE to point to the in-use entries in CWD_FILE, in order. */
static void
initialize_ordering_vector (void)
{
size_t i;
for (i = 0; i < cwd_n_used; i++)
sorted_file[i] = &cwd_file[i];
}
/* Sort the files now in the table. */
@@ -3099,6 +3138,15 @@ sort_files (void)
{
bool use_strcmp;
if (sorted_file_alloc < cwd_n_used + cwd_n_used / 2)
{
free (sorted_file);
sorted_file = xnmalloc (cwd_n_used, 3 * sizeof *sorted_file);
sorted_file_alloc = 3 * cwd_n_used;
}
initialize_ordering_vector ();
if (sort_type == sort_none)
return;
@@ -3113,13 +3161,14 @@ sort_files (void)
{
use_strcmp = true;
assert (sort_type != sort_version);
initialize_ordering_vector ();
}
/* When sort_type == sort_time, use time_type as subindex. */
qsort (files, files_index, sizeof *files,
sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)]
[use_strcmp][sort_reverse]
[directories_first]);
mpsort ((void const **) sorted_file, cwd_n_used,
sort_functions[sort_type + (sort_type == sort_time ? time_type : 0)]
[use_strcmp][sort_reverse]
[directories_first]);
}
/* List all the files now in the table. */
@@ -3132,9 +3181,9 @@ print_current_files (void)
switch (format)
{
case one_per_line:
for (i = 0; i < files_index; i++)
for (i = 0; i < cwd_n_used; i++)
{
print_file_name_and_frills (files + i);
print_file_name_and_frills (sorted_file[i]);
putchar ('\n');
}
break;
@@ -3152,9 +3201,9 @@ print_current_files (void)
break;
case long_format:
for (i = 0; i < files_index; i++)
for (i = 0; i < cwd_n_used; i++)
{
print_long_format (files + i);
print_long_format (sorted_file[i]);
DIRED_PUTCHAR ('\n');
}
break;
@@ -3947,7 +3996,7 @@ print_many_per_line (void)
/* Calculate the number of rows that will be in each column except possibly
for a short column on the right. */
size_t rows = files_index / cols + (files_index % cols != 0);
size_t rows = cwd_n_used / cols + (cwd_n_used % cols != 0);
for (row = 0; row < rows; row++)
{
@@ -3958,12 +4007,13 @@ print_many_per_line (void)
/* Print the next row. */
while (1)
{
size_t name_length = length_of_file_name_and_frills (files + filesno);
struct fileinfo const *f = sorted_file[filesno];
size_t name_length = length_of_file_name_and_frills (f);
size_t max_name_length = line_fmt->col_arr[col++];
print_file_name_and_frills (files + filesno);
print_file_name_and_frills (f);
filesno += rows;
if (filesno >= files_index)
if (filesno >= cwd_n_used)
break;
indent (pos + name_length, pos + max_name_length);
@@ -3980,15 +4030,16 @@ print_horizontal (void)
size_t pos = 0;
size_t cols = calculate_columns (false);
struct column_info const *line_fmt = &column_info[cols - 1];
size_t name_length = length_of_file_name_and_frills (files);
size_t name_length = length_of_file_name_and_frills (cwd_file);
size_t max_name_length = line_fmt->col_arr[0];
/* Print first entry. */
print_file_name_and_frills (files);
print_file_name_and_frills (cwd_file);
/* Now the rest. */
for (filesno = 1; filesno < files_index; ++filesno)
for (filesno = 1; filesno < cwd_n_used; ++filesno)
{
struct fileinfo const *f;
size_t col = filesno % cols;
if (col == 0)
@@ -4002,9 +4053,10 @@ print_horizontal (void)
pos += max_name_length;
}
print_file_name_and_frills (files + filesno);
f = sorted_file[filesno];
print_file_name_and_frills (f);
name_length = length_of_file_name_and_frills (files + filesno);
name_length = length_of_file_name_and_frills (f);
max_name_length = line_fmt->col_arr[col];
}
putchar ('\n');
@@ -4016,9 +4068,10 @@ print_with_commas (void)
size_t filesno;
size_t pos = 0;
for (filesno = 0; filesno < files_index; filesno++)
for (filesno = 0; filesno < cwd_n_used; filesno++)
{
size_t len = length_of_file_name_and_frills (files + filesno);
struct fileinfo const *f = sorted_file[filesno];
size_t len = length_of_file_name_and_frills (f);
if (filesno != 0)
{
@@ -4039,7 +4092,7 @@ print_with_commas (void)
putchar (separator);
}
print_file_name_and_frills (files + filesno);
print_file_name_and_frills (f);
pos += len;
}
putchar ('\n');
@@ -4097,7 +4150,7 @@ static void
init_column_info (void)
{
size_t i;
size_t max_cols = MIN (max_idx, files_index);
size_t max_cols = MIN (max_idx, cwd_n_used);
/* Currently allocated columns in column_info. */
static size_t column_info_alloc;
@@ -4164,20 +4217,21 @@ init_column_info (void)
static size_t
calculate_columns (bool by_columns)
{
size_t filesno; /* Index into files. */
size_t filesno; /* Index into cwd_file. */
size_t cols; /* Number of files across. */
/* Normally the maximum number of columns is determined by the
screen width. But if few files are available this might limit it
as well. */
size_t max_cols = MIN (max_idx, files_index);
size_t max_cols = MIN (max_idx, cwd_n_used);
init_column_info ();
/* Compute the maximum number of possible columns. */
for (filesno = 0; filesno < files_index; ++filesno)
for (filesno = 0; filesno < cwd_n_used; ++filesno)
{
size_t name_length = length_of_file_name_and_frills (files + filesno);
struct fileinfo const *f = sorted_file[filesno];
size_t name_length = length_of_file_name_and_frills (f);
size_t i;
for (i = 0; i < max_cols; ++i)
@@ -4185,7 +4239,7 @@ calculate_columns (bool by_columns)
if (column_info[i].valid_len)
{
size_t idx = (by_columns
? filesno / ((files_index + i) / (i + 1))
? filesno / ((cwd_n_used + i) / (i + 1))
: filesno % (i + 1));
size_t real_length = name_length + (idx == i ? 0 : 2);
@@ -4281,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\

View File

@@ -1,5 +1,5 @@
/* mv -- move or rename files
Copyright (C) 86, 89, 90, 91, 1995-2006 Free Software Foundation, Inc.
Copyright (C) 86, 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
@@ -98,7 +98,7 @@ rm_option_init (struct rm_options *x)
/* Should we prompt for removal, too? No. Prompting for the `move'
part is enough. It implies removal. */
x->interactive = 0;
x->interactive = RMI_NEVER;
x->stdin_tty = false;
x->verbose = false;

View File

@@ -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"));

View File

@@ -928,7 +928,7 @@ open_next_file (void)
while (in_stream == NULL);
if (limit_bytes_to_format & !flag_dump_strings)
SETVBUF (in_stream, NULL, _IONBF, 0);
setvbuf (in_stream, NULL, _IONBF, 0);
return ok;
}

View File

@@ -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\

View File

@@ -1,5 +1,5 @@
/* remove.c -- core functions for removing files and directories
Copyright (C) 88, 90, 91, 1994-2006 Free Software Foundation, Inc.
Copyright (C) 88, 90, 91, 1994-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
@@ -417,22 +417,32 @@ ds_free (Dirstack_state *ds)
free (ds);
}
/* Pop the active directory (AD) stack and move *DIRP `up' one level,
/* Pop the active directory (AD) stack and prepare to move `up' one level,
safely. Moving `up' usually means opening `..', but when we've just
finished recursively processing a command-line directory argument,
there's nothing left on the stack, so set *DIRP to NULL in that case.
The idea is to return with *DIRP opened on the parent directory,
there's nothing left on the stack, so set *FDP to AT_FDCWD in that case.
The idea is to return with *FDP opened on the parent directory,
assuming there are entries in that directory that we need to remove.
Note that we must not call opendir (or fdopendir) just yet, since
the caller must first remove the directory we're coming from.
That is because some file system implementations cache readdir
results at opendir time; so calling opendir, rmdir, readdir would
return an entry for the just-removed directory.
Whenever using chdir '..' (virtually, now, via openat), verify
that the post-chdir dev/ino numbers for `.' match the saved ones.
If any system call fails or if dev/ino don't match then give a
If any system call fails or if dev/ino don't match, then give a
diagnostic and longjump out.
Return the name (in malloc'd storage) of the
directory (usually now empty) from which we're coming, and which
corresponds to the input value of *DIRP. */
corresponds to the input value of DIRP.
Finally, note that while this function's name is no longer as
accurate as it once was (it no longer calls chdir), it does open
the destination directory. */
static char *
AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds)
AD_pop_and_chdir (DIR *dirp, int *fdp, Dirstack_state *ds)
{
struct AD_ent *leaf_dir_ent = AD_stack_top(ds);
struct dev_ino leaf_dev_ino = leaf_dir_ent->dev_ino;
@@ -465,15 +475,15 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds)
if (1 < AD_stack_height (ds))
{
struct stat sb;
int fd = openat (dirfd (*dirp), "..", O_RDONLY);
if (closedir (*dirp) != 0)
int fd = openat (dirfd (dirp), "..", O_RDONLY);
if (closedir (dirp) != 0)
{
error (0, errno, _("FATAL: failed to close directory %s"),
quote (full_filename (prev_dir)));
goto next_cmdline_arg;
}
/* The above fails with EACCES when *DIRP is readable but not
/* The above fails with EACCES when DIRP is readable but not
searchable, when using Solaris' openat. Without this openat
call, tests/rm2 would fail to remove directories a/2 and a/3. */
if (fd < 0)
@@ -499,15 +509,6 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds)
{
error (0, 0, _("FATAL: directory %s changed dev/ino"),
quote (full_filename (".")));
goto close_and_next;
}
*dirp = fdopendir (fd);
if (*dirp == NULL)
{
error (0, errno, _("FATAL: cannot return to .. from %s"),
quote (full_filename (".")));
close_and_next:;
close (fd);
@@ -515,16 +516,17 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds)
free (prev_dir);
longjmp (ds->current_arg_jumpbuf, 1);
}
*fdp = fd;
}
else
{
if (closedir (*dirp) != 0)
if (closedir (dirp) != 0)
{
error (0, errno, _("FATAL: failed to close directory %s"),
quote (full_filename (prev_dir)));
goto next_cmdline_arg;
}
*dirp = NULL;
*fdp = AT_FDCWD;
}
return prev_dir;
@@ -796,10 +798,14 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
*is_empty = T_UNKNOWN;
if (((!x->ignore_missing_files & (x->interactive | x->stdin_tty))
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)
|| x->interactive == RMI_ALWAYS)
{
if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0)
{
@@ -819,7 +825,7 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
/* Using permissions doesn't make sense for symlinks. */
if (S_ISLNK (sbuf->st_mode))
{
if ( ! x->interactive)
if (x->interactive != RMI_ALWAYS)
return RM_OK;
write_protected = false;
}
@@ -1016,8 +1022,7 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename,
errno = EISDIR;
if (! x->recursive
|| errno == ENOENT || errno == ENOTDIR
|| errno == ELOOP || errno == ENAMETOOLONG)
|| (cache_stat_ok (st) && !S_ISDIR (st->st_mode)))
{
if (ignorable_missing (x, errno))
return RM_OK;
@@ -1028,6 +1033,7 @@ remove_entry (int fd_cwd, Dirstack_state const *ds, char const *filename,
quote (full_filename (filename)));
return RM_ERROR;
}
assert (!cache_stat_ok (st) || S_ISDIR (st->st_mode));
}
else
{
@@ -1369,7 +1375,7 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir,
traversal into the current directory, (known as SUBDIR, from ..),
DIRP's device number is different from CURRENT_DEV. Arrange not
to do anything more with this hierarchy. */
error (0, errno, _("skipping %s, since it's on a different device"),
error (0, 0, _("skipping %s, since it's on a different device"),
quote (full_filename (subdir)));
free (subdir);
AD_mark_current_as_unremovable (ds);
@@ -1382,11 +1388,12 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir,
--one-file-system, when the current directory is on a
different file system. */
{
int fd;
/* The name of the directory that we have just processed,
nominally removing all of its contents. */
char *empty_dir = AD_pop_and_chdir (&dirp, ds);
int fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
assert (dirp != NULL || AD_stack_height (ds) == 1);
char *empty_dir = AD_pop_and_chdir (dirp, &fd, ds);
dirp = NULL;
assert (fd != AT_FDCWD || AD_stack_height (ds) == 1);
/* Try to remove EMPTY_DIR only if remove_cwd_entries succeeded. */
if (tmp_status == RM_OK)
@@ -1405,6 +1412,8 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir,
{
free (empty_dir);
status = s;
if (fd != AT_FDCWD)
close (fd);
goto closedir_and_return;
}
@@ -1426,8 +1435,17 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir,
free (empty_dir);
if (AD_stack_height (ds) == 1)
if (fd == AT_FDCWD)
break;
dirp = fdopendir (fd);
if (dirp == NULL)
{
error (0, errno, _("FATAL: cannot return to .. from %s"),
quote (full_filename (".")));
close (fd);
longjmp (ds->current_arg_jumpbuf, 1);
}
}
}

View File

@@ -1,6 +1,6 @@
/* Remove directory entries.
Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005, 2006 Free
Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -22,13 +22,22 @@
# include "dev-ino.h"
enum rm_interactive
{
/* Start with any number larger than 1, so that any legacy tests
against values of 0 or 1 will fail. */
RMI_ALWAYS = 3,
RMI_SOMETIMES,
RMI_NEVER
};
struct rm_options
{
/* If true, ignore nonexistent files. */
bool ignore_missing_files;
/* If true, query the user about whether to remove each file. */
bool interactive;
enum rm_interactive interactive;
/* If true, do not traverse into (or remove) any directory that is
on a file system (i.e., that has a different device number) other

View File

@@ -1,5 +1,5 @@
/* `rm' file deletion utility for GNU.
Copyright (C) 88, 90, 91, 1994-2006 Free Software Foundation, Inc.
Copyright (C) 88, 90, 91, 1994-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
@@ -213,7 +213,7 @@ static void
rm_option_init (struct rm_options *x)
{
x->ignore_missing_files = false;
x->interactive = false;
x->interactive = RMI_SOMETIMES;
x->one_file_system = false;
x->recursive = false;
x->root_dev_ino = NULL;
@@ -249,25 +249,25 @@ main (int argc, char **argv)
{
case 'd':
/* Ignore this option, for backward compatibility with
coreutils 5.92. Some time after 2005, we'll change this
coreutils 5.92. FIXME: Some time after 2005, change this
to report an error (or perhaps behave like FreeBSD does)
instead of ignoring the option. */
break;
case 'f':
x.interactive = false;
x.interactive = RMI_NEVER;
x.ignore_missing_files = true;
prompt_once = false;
break;
case 'i':
x.interactive = true;
x.interactive = RMI_ALWAYS;
x.ignore_missing_files = false;
prompt_once = false;
break;
case 'I':
x.interactive = false;
x.interactive = RMI_NEVER;
x.ignore_missing_files = false;
prompt_once = true;
break;
@@ -288,18 +288,18 @@ main (int argc, char **argv)
switch (i)
{
case interactive_never:
x.interactive = false;
x.interactive = RMI_NEVER;
prompt_once = false;
break;
case interactive_once:
x.interactive = false;
x.interactive = RMI_SOMETIMES;
x.ignore_missing_files = false;
prompt_once = true;
break;
case interactive_always:
x.interactive = true;
x.interactive = RMI_ALWAYS;
x.ignore_missing_files = false;
prompt_once = false;
break;

View File

@@ -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;
}

View File

@@ -1,5 +1,5 @@
/* sort - sort lines of text (with all kinds of options).
Copyright (C) 1988, 1991-2006 Free Software Foundation, Inc.
Copyright (C) 1988, 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
@@ -25,10 +25,13 @@
#include <getopt.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "system.h"
#include "argmatch.h"
#include "error.h"
#include "hard-locale.h"
#include "hash.h"
#include "inttostr.h"
#include "md5.h"
#include "physmem.h"
@@ -63,7 +66,8 @@ struct rlimit { size_t rlim_cur; };
present. */
#ifndef SA_NOCLDSTOP
# define SA_NOCLDSTOP 0
# define sigprocmask(How, Set, Oset) /* empty */
/* No sigprocmask. Always 'return' zero. */
# define sigprocmask(How, Set, Oset) (0)
# define sigset_t int
# if ! HAVE_SIGINTERRUPT
# define siginterrupt(sig, flag) /* empty */
@@ -92,6 +96,20 @@ enum
SORT_FAILURE = 2
};
enum
{
/* The number of times we should try to fork a compression process
(we retry if the fork call fails). We don't _need_ to compress
temp files, this is just to reduce disk access, so this number
can be small. */
MAX_FORK_TRIES_COMPRESS = 2,
/* The number of times we should try to fork a decompression process.
If we can't fork a decompression process, we can't sort, so this
number should be big. */
MAX_FORK_TRIES_DECOMPRESS = 8
};
/* The representation of the decimal point in the current locale. */
static int decimal_point;
@@ -261,6 +279,9 @@ static bool have_read_stdin;
/* List of key field comparisons to be tried. */
static struct keyfield *keylist;
/* Program used to (de)compress temp files. Must accept -d. */
static char const *compress_program;
static void sortlines_temp (struct line *, size_t, struct line *);
/* Report MESSAGE for FILE, then clean up and exit.
@@ -315,9 +336,14 @@ Ordering options:\n\
fputs (_("\
Other options:\n\
\n\
-c, --check check whether input is sorted; do not sort\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);
fputs (_("\
-o, --output=FILE write result to FILE instead of standard output\n\
-s, --stable stabilize sort by disabling last-resort comparison\n\
-S, --buffer-size=SIZE use SIZE for main memory buffer\n\
@@ -364,15 +390,18 @@ native byte values.\n\
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
RANDOM_SOURCE_OPTION = CHAR_MAX + 1
CHECK_OPTION = CHAR_MAX + 1,
COMPRESS_PROGRAM_OPTION,
RANDOM_SOURCE_OPTION
};
static char const short_options[] = "-bcdfgik:mMno:rRsS:t:T:uy:z";
static char const short_options[] = "-bcCdfgik:mMno:rRsS:t:T:uy:z";
static struct option const long_options[] =
{
{"ignore-leading-blanks", no_argument, NULL, 'b'},
{"check", no_argument, NULL, 'c'},
{"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'},
@@ -396,18 +425,220 @@ static struct option const long_options[] =
{NULL, 0, NULL, 0},
};
static char const *const check_args[] =
{
"quiet", "silent", "diagnose-first", NULL
};
static char const check_types[] =
{
'C', 'C', 'c'
};
ARGMATCH_VERIFY (check_args, check_types);
/* The set of signals that are caught. */
static sigset_t caught_signals;
/* Critical section status. */
struct cs_status
{
bool valid;
sigset_t sigs;
};
/* Enter a critical section. */
static struct cs_status
cs_enter (void)
{
struct cs_status status;
status.valid = (sigprocmask (SIG_BLOCK, &caught_signals, &status.sigs) == 0);
return status;
}
/* Leave a critical section. */
static void
cs_leave (struct cs_status status)
{
if (status.valid)
{
/* Ignore failure when restoring the signal mask. */
sigprocmask (SIG_SETMASK, &status.sigs, NULL);
}
}
/* The list of temporary files. */
struct tempnode
{
struct tempnode *volatile next;
pid_t pid; /* If compressed, the pid of compressor, else zero */
char name[1]; /* Actual size is 1 + file name length. */
};
static struct tempnode *volatile temphead;
static struct tempnode *volatile *temptail = &temphead;
struct sortfile
{
char const *name;
pid_t pid; /* If compressed, the pid of compressor, else zero */
};
/* A table where we store compression process states. We clean up all
processes in a timely manner so as not to exhaust system resources,
so we store the info on whether the process is still running, or has
been reaped here. */
static Hash_table *proctab;
enum { INIT_PROCTAB_SIZE = 47 };
enum procstate { ALIVE, ZOMBIE };
/* A proctab entry. The COUNT field is there in case we fork a new
compression process that has the same PID as an old zombie process
that is still in the table (because the process to decompress the
temp file it was associated with hasn't started yet). */
struct procnode
{
pid_t pid;
enum procstate state;
size_t count;
};
static size_t
proctab_hasher (const void *entry, size_t tabsize)
{
const struct procnode *node = entry;
return node->pid % tabsize;
}
static bool
proctab_comparator (const void *e1, const void *e2)
{
const struct procnode *n1 = e1, *n2 = e2;
return n1->pid == n2->pid;
}
/* The total number of forked processes (compressors and decompressors)
that have not been reaped yet. */
static size_t nprocs;
/* The number of child processes we'll allow before we try to reap some. */
enum { MAX_PROCS_BEFORE_REAP = 2 };
/* If 0 < PID, wait for the child process with that PID to exit.
If PID is -1, clean up a random child process which has finished and
return the process ID of that child. If PID is -1 and no processes
have quit yet, return 0 without waiting. */
static pid_t
reap (pid_t pid)
{
int status;
pid_t cpid = waitpid (pid, &status, pid < 0 ? WNOHANG : 0);
if (cpid < 0)
error (SORT_FAILURE, errno, _("waiting for %s [-d]"),
compress_program);
else if (0 < cpid)
{
if (! WIFEXITED (status) || WEXITSTATUS (status))
error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"),
compress_program);
--nprocs;
}
return cpid;
}
/* Add the PID of a running compression process to proctab, or update
the entry COUNT and STATE fields if it's already there. This also
creates the table for us the first time it's called. */
static void
register_proc (pid_t pid)
{
struct procnode test, *node;
if (! proctab)
{
proctab = hash_initialize (INIT_PROCTAB_SIZE, NULL,
proctab_hasher,
proctab_comparator,
free);
if (! proctab)
xalloc_die ();
}
test.pid = pid;
node = hash_lookup (proctab, &test);
if (node)
{
node->state = ALIVE;
++node->count;
}
else
{
node = xmalloc (sizeof *node);
node->pid = pid;
node->state = ALIVE;
node->count = 1;
hash_insert (proctab, node);
}
}
/* This is called when we reap a random process. We don't know
whether we have reaped a compression process or a decompression
process until we look in the table. If there's an ALIVE entry for
it, then we have reaped a compression process, so change the state
to ZOMBIE. Otherwise, it's a decompression processes, so ignore it. */
static void
update_proc (pid_t pid)
{
struct procnode test, *node;
test.pid = pid;
node = hash_lookup (proctab, &test);
if (node)
node->state = ZOMBIE;
}
/* This is for when we need to wait for a compression process to exit.
If it has a ZOMBIE entry in the table then it's already dead and has
been reaped. Note that if there's an ALIVE entry for it, it still may
already have died and been reaped if a second process was created with
the same PID. This is probably exceedingly rare, but to be on the safe
side we will have to wait for any compression process with this PID. */
static void
wait_proc (pid_t pid)
{
struct procnode test, *node;
test.pid = pid;
node = hash_lookup (proctab, &test);
if (node->state == ALIVE)
reap (pid);
node->state = ZOMBIE;
if (! --node->count)
{
hash_delete (proctab, node);
free (node);
}
}
/* Keep reaping finished children as long as there are more to reap.
This doesn't block waiting for any of them, it only reaps those
that are already dead. */
static void
reap_some (void)
{
pid_t pid;
while (0 < nprocs && (pid = reap (-1)))
update_proc (pid);
}
/* Clean up any remaining temporary files. */
static void
@@ -417,17 +648,34 @@ cleanup (void)
for (node = temphead; node; node = node->next)
unlink (node->name);
temphead = NULL;
}
/* Create a new temporary file, returning its newly allocated name.
Store into *PFP a stream open for writing. */
/* Cleanup actions to take when exiting. */
static char *
create_temp_file (FILE **pfp)
static void
exit_cleanup (void)
{
if (temphead)
{
/* Clean up any remaining temporary files in a critical section so
that a signal handler does not try to clean them too. */
struct cs_status cs = cs_enter ();
cleanup ();
cs_leave (cs);
}
close_stdout ();
}
/* Create a new temporary file, returning its newly allocated tempnode.
Store into *PFD the file descriptor open for writing. */
static struct tempnode *
create_temp_file (int *pfd)
{
static char const slashbase[] = "/sortXXXXXX";
static size_t temp_dir_index;
sigset_t oldset;
int fd;
int saved_errno;
char const *temp_dir = temp_dirs[temp_dir_index];
@@ -435,15 +683,17 @@ create_temp_file (FILE **pfp)
struct tempnode *node =
xmalloc (offsetof (struct tempnode, name) + len + sizeof slashbase);
char *file = node->name;
struct cs_status cs;
memcpy (file, temp_dir, len);
memcpy (file + len, slashbase, sizeof slashbase);
node->next = NULL;
node->pid = 0;
if (++temp_dir_index == temp_dir_count)
temp_dir_index = 0;
/* Create the temporary file in a critical section, to avoid races. */
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
cs = cs_enter ();
fd = mkstemp (file);
if (0 <= fd)
{
@@ -451,13 +701,14 @@ create_temp_file (FILE **pfp)
temptail = &node->next;
}
saved_errno = errno;
sigprocmask (SIG_SETMASK, &oldset, NULL);
cs_leave (cs);
errno = saved_errno;
if (fd < 0 || (*pfp = fdopen (fd, "w")) == NULL)
if (fd < 0)
die (_("cannot create temporary file"), file);
return file;
*pfd = fd;
return node;
}
/* Return a stream for FILE, opened with mode HOW. A null FILE means
@@ -514,6 +765,172 @@ xfclose (FILE *fp, char const *file)
}
}
static void
dup2_or_die (int oldfd, int newfd)
{
if (dup2 (oldfd, newfd) < 0)
error (SORT_FAILURE, errno, _("dup2 failed"));
}
/* Fork a child process for piping to and do common cleanup. The
TRIES parameter tells us how many times to try to fork before
giving up. Return the PID of the child or -1 if fork failed. */
static pid_t
pipe_fork (int pipefds[2], size_t tries)
{
#if HAVE_WORKING_FORK
struct tempnode *saved_temphead;
int saved_errno;
unsigned int wait_retry = 1;
pid_t pid IF_LINT (= -1);
struct cs_status cs;
if (pipe (pipefds) < 0)
return -1;
while (tries--)
{
/* This is so the child process won't delete our temp files
if it receives a signal before exec-ing. */
cs = cs_enter ();
saved_temphead = temphead;
temphead = NULL;
pid = fork ();
saved_errno = errno;
if (pid)
temphead = saved_temphead;
cs_leave (cs);
errno = saved_errno;
if (0 <= pid || errno != EAGAIN)
break;
else
{
sleep (wait_retry);
wait_retry *= 2;
reap_some ();
}
}
if (pid < 0)
{
close (pipefds[0]);
close (pipefds[1]);
}
else if (pid == 0)
{
close (STDIN_FILENO);
close (STDOUT_FILENO);
}
else
++nprocs;
return pid;
#else /* ! HAVE_WORKING_FORK */
return -1;
#endif
}
/* Create a temporary file and start a compression program to filter output
to that file. Set *PFP to the file handle and if *PPID is non-NULL,
set it to the PID of the newly-created process. */
static char *
create_temp (FILE **pfp, pid_t *ppid)
{
int tempfd;
struct tempnode *node = create_temp_file (&tempfd);
char *name = node->name;
if (compress_program)
{
int pipefds[2];
node->pid = pipe_fork (pipefds, MAX_FORK_TRIES_COMPRESS);
if (0 < node->pid)
{
close (tempfd);
close (pipefds[0]);
tempfd = pipefds[1];
register_proc (node->pid);
}
else if (node->pid == 0)
{
close (pipefds[1]);
dup2_or_die (tempfd, STDOUT_FILENO);
close (tempfd);
dup2_or_die (pipefds[0], STDIN_FILENO);
close (pipefds[0]);
if (execlp (compress_program, compress_program, (char *) NULL) < 0)
error (SORT_FAILURE, errno, _("couldn't execute %s"),
compress_program);
}
else
node->pid = 0;
}
*pfp = fdopen (tempfd, "w");
if (! *pfp)
die (_("couldn't create temporary file"), name);
if (ppid)
*ppid = node->pid;
return name;
}
/* Open a compressed temp file and start a decompression process through
which to filter the input. PID must be the valid processes ID of the
process used to compress the file. */
static FILE *
open_temp (const char *name, pid_t pid)
{
int tempfd, pipefds[2];
pid_t child_pid;
FILE *fp;
wait_proc (pid);
tempfd = open (name, O_RDONLY);
if (tempfd < 0)
die (_("couldn't open temporary file"), name);
child_pid = pipe_fork (pipefds, MAX_FORK_TRIES_DECOMPRESS);
if (0 < child_pid)
{
close (tempfd);
close (pipefds[1]);
}
else if (child_pid == 0)
{
close (pipefds[0]);
dup2_or_die (tempfd, STDIN_FILENO);
close (tempfd);
dup2_or_die (pipefds[1], STDOUT_FILENO);
close (pipefds[1]);
if (execlp (compress_program, compress_program, "-d", (char *) NULL) < 0)
error (SORT_FAILURE, errno, _("couldn't execute %s -d"),
compress_program);
}
else
error (SORT_FAILURE, errno, _("couldn't create process for %s -d"),
compress_program);
fp = fdopen (pipefds[0], "r");
if (! fp)
die (_("couldn't create temporary file"), name);
return fp;
}
static void
write_bytes (const char *buf, size_t n_bytes, FILE *fp, const char *output_file)
{
@@ -539,20 +956,20 @@ zaptemp (const char *name)
struct tempnode *volatile *pnode;
struct tempnode *node;
struct tempnode *next;
sigset_t oldset;
int unlink_status;
int unlink_errno = 0;
struct cs_status cs;
for (pnode = &temphead; (node = *pnode)->name != name; pnode = &node->next)
continue;
/* Unlink the temporary file in a critical section to avoid races. */
next = node->next;
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
cs = cs_enter ();
unlink_status = unlink (name);
unlink_errno = errno;
*pnode = next;
sigprocmask (SIG_SETMASK, &oldset, NULL);
cs_leave (cs);
if (unlink_status != 0)
error (0, unlink_errno, _("warning: cannot remove: %s"), name);
@@ -1493,13 +1910,13 @@ compare (const struct line *a, const struct line *b)
return reverse ? -diff : diff;
}
/* Check that the lines read from FILE_NAME come in order. Print a
diagnostic (FILE_NAME, line number, contents of line) to stderr and return
false if they are not in order. Otherwise, print no diagnostic
and return true. */
/* Check that the lines read from FILE_NAME come in order. Return
true if they are in order. If CHECKONLY == 'c', also print a
diagnostic (FILE_NAME, line number, contents of line) to stderr if
they are not in order. */
static bool
check (char const *file_name)
check (char const *file_name, char checkonly)
{
FILE *fp = xfopen (file_name, "r");
struct buffer buf; /* Input buffer. */
@@ -1525,15 +1942,19 @@ check (char const *file_name)
{
found_disorder:
{
struct line const *disorder_line = line - 1;
uintmax_t disorder_line_number =
buffer_linelim (&buf) - disorder_line + line_number;
char hr_buf[INT_BUFSIZE_BOUND (uintmax_t)];
fprintf (stderr, _("%s: %s:%s: disorder: "),
program_name, file_name,
umaxtostr (disorder_line_number, hr_buf));
write_bytes (disorder_line->text, disorder_line->length, stderr,
_("standard error"));
if (checkonly == 'c')
{
struct line const *disorder_line = line - 1;
uintmax_t disorder_line_number =
buffer_linelim (&buf) - disorder_line + line_number;
char hr_buf[INT_BUFSIZE_BOUND (uintmax_t)];
fprintf (stderr, _("%s: %s:%s: disorder: "),
program_name, file_name,
umaxtostr (disorder_line_number, hr_buf));
write_bytes (disorder_line->text, disorder_line->length,
stderr, _("standard error"));
}
ordered = false;
break;
}
@@ -1586,7 +2007,7 @@ check (char const *file_name)
file has not been opened yet (or written to, if standard output). */
static void
mergefps (char **files, size_t ntemps, size_t nfiles,
mergefps (struct sortfile *files, size_t ntemps, size_t nfiles,
FILE *ofp, char const *output_file)
{
FILE *fps[NMERGE]; /* Input streams for each file. */
@@ -1609,10 +2030,12 @@ mergefps (char **files, size_t ntemps, size_t nfiles,
/* Read initial lines from each input file. */
for (i = 0; i < nfiles; )
{
fps[i] = xfopen (files[i], "r");
fps[i] = (files[i].pid
? open_temp (files[i].name, files[i].pid)
: xfopen (files[i].name, "r"));
initbuf (&buffer[i], sizeof (struct line),
MAX (merge_buffer_size, sort_size / nfiles));
if (fillbuf (&buffer[i], fps[i], files[i]))
if (fillbuf (&buffer[i], fps[i], files[i].name))
{
struct line const *linelim = buffer_linelim (&buffer[i]);
cur[i] = linelim - 1;
@@ -1622,11 +2045,11 @@ mergefps (char **files, size_t ntemps, size_t nfiles,
else
{
/* fps[i] is empty; eliminate it from future consideration. */
xfclose (fps[i], files[i]);
xfclose (fps[i], files[i].name);
if (i < ntemps)
{
ntemps--;
zaptemp (files[i]);
zaptemp (files[i].name);
}
free (buffer[i].buf);
--nfiles;
@@ -1695,7 +2118,7 @@ mergefps (char **files, size_t ntemps, size_t nfiles,
cur[ord[0]] = smallest - 1;
else
{
if (fillbuf (&buffer[ord[0]], fps[ord[0]], files[ord[0]]))
if (fillbuf (&buffer[ord[0]], fps[ord[0]], files[ord[0]].name))
{
struct line const *linelim = buffer_linelim (&buffer[ord[0]]);
cur[ord[0]] = linelim - 1;
@@ -1708,11 +2131,11 @@ mergefps (char **files, size_t ntemps, size_t nfiles,
if (ord[i] > ord[0])
--ord[i];
--nfiles;
xfclose (fps[ord[0]], files[ord[0]]);
xfclose (fps[ord[0]], files[ord[0]].name);
if (ord[0] < ntemps)
{
ntemps--;
zaptemp (files[ord[0]]);
zaptemp (files[ord[0]].name);
}
free (buffer[ord[0]].buf);
for (i = ord[0]; i < nfiles; ++i)
@@ -1755,6 +2178,10 @@ mergefps (char **files, size_t ntemps, size_t nfiles,
ord[j] = ord[j + 1];
ord[count_of_smaller_lines] = ord0;
}
/* Free up some resources every once in a while. */
if (MAX_PROCS_BEFORE_REAP < nprocs)
reap_some ();
}
if (unique && savedline)
@@ -1893,8 +2320,8 @@ sortlines_temp (struct line *lines, size_t nlines, struct line *temp)
common cases. */
static size_t
avoid_trashing_input (char **files, size_t ntemps, size_t nfiles,
char const *outfile)
avoid_trashing_input (struct sortfile *files, size_t ntemps,
size_t nfiles, char const *outfile)
{
size_t i;
bool got_outstat = false;
@@ -1902,11 +2329,11 @@ avoid_trashing_input (char **files, size_t ntemps, size_t nfiles,
for (i = ntemps; i < nfiles; i++)
{
bool is_stdin = STREQ (files[i], "-");
bool is_stdin = STREQ (files[i].name, "-");
bool same;
struct stat instat;
if (outfile && STREQ (outfile, files[i]) && !is_stdin)
if (outfile && STREQ (outfile, files[i].name) && !is_stdin)
same = true;
else
{
@@ -1922,7 +2349,7 @@ avoid_trashing_input (char **files, size_t ntemps, size_t nfiles,
same = (((is_stdin
? fstat (STDIN_FILENO, &instat)
: stat (files[i], &instat))
: stat (files[i].name, &instat))
== 0)
&& SAME_INODE (instat, outstat));
}
@@ -1930,9 +2357,11 @@ avoid_trashing_input (char **files, size_t ntemps, size_t nfiles,
if (same)
{
FILE *tftp;
char *temp = create_temp_file (&tftp);
mergefps (&files[i], 0, nfiles - i, tftp, temp);
files[i] = temp;
pid_t pid;
char *temp = create_temp (&tftp, &pid);
mergefps (&files[i],0, nfiles - i, tftp, temp);
files[i].name = temp;
files[i].pid = pid;
return i + 1;
}
}
@@ -1946,7 +2375,8 @@ avoid_trashing_input (char **files, size_t ntemps, size_t nfiles,
OUTPUT_FILE; a null OUTPUT_FILE stands for standard output. */
static void
merge (char **files, size_t ntemps, size_t nfiles, char const *output_file)
merge (struct sortfile *files, size_t ntemps, size_t nfiles,
char const *output_file)
{
while (NMERGE < nfiles)
{
@@ -1967,11 +2397,13 @@ merge (char **files, size_t ntemps, size_t nfiles, char const *output_file)
for (out = in = 0; out < nfiles / NMERGE; out++, in += NMERGE)
{
FILE *tfp;
char *temp = create_temp_file (&tfp);
pid_t pid;
char *temp = create_temp (&tfp, &pid);
size_t nt = MIN (ntemps, NMERGE);
ntemps -= nt;
mergefps (&files[in], nt, NMERGE, tfp, temp);
files[out] = temp;
files[out].name = temp;
files[out].pid = pid;
}
remainder = nfiles - in;
@@ -1984,11 +2416,13 @@ merge (char **files, size_t ntemps, size_t nfiles, char const *output_file)
files as possible, to avoid needless I/O. */
size_t nshortmerge = remainder - cheap_slots + 1;
FILE *tfp;
char *temp = create_temp_file (&tfp);
pid_t pid;
char *temp = create_temp (&tfp, &pid);
size_t nt = MIN (ntemps, nshortmerge);
ntemps -= nt;
mergefps (&files[in], nt, nshortmerge, tfp, temp);
files[out++] = temp;
files[out].name = temp;
files[out++].pid = pid;
in += nshortmerge;
}
@@ -2060,7 +2494,7 @@ sort (char * const *files, size_t nfiles, char const *output_file)
else
{
++ntemps;
temp_output = create_temp_file (&tfp);
temp_output = create_temp (&tfp, NULL);
}
do
@@ -2075,6 +2509,10 @@ sort (char * const *files, size_t nfiles, char const *output_file)
xfclose (tfp, temp_output);
/* Free up some resources every once in a while. */
if (MAX_PROCS_BEFORE_REAP < nprocs)
reap_some ();
if (output_file_created)
goto finish;
}
@@ -2088,10 +2526,11 @@ sort (char * const *files, size_t nfiles, char const *output_file)
{
size_t i;
struct tempnode *node = temphead;
char **tempfiles = xnmalloc (ntemps, sizeof *tempfiles);
struct sortfile *tempfiles = xnmalloc (ntemps, sizeof *tempfiles);
for (i = 0; node; i++)
{
tempfiles[i] = node->name;
tempfiles[i].name = node->name;
tempfiles[i].pid = node->pid;
node = node->next;
}
merge (tempfiles, ntemps, ntemps, output_file);
@@ -2170,7 +2609,8 @@ check_ordering_compatibility (void)
/* Parse the leading integer in STRING and store the resulting value
(which must fit into size_t) into *VAL. Return the address of the
suffix after the integer. If MSGID is NULL, return NULL after
suffix after the integer. If the value is too large, silently
substitute SIZE_MAX. If MSGID is NULL, return NULL after
failure; otherwise, report MSGID and exit on failure. */
static char const *
@@ -2189,10 +2629,8 @@ parse_field_count (char const *string, size_t *val, char const *msgid)
/* Fall through. */
case LONGINT_OVERFLOW:
case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR:
if (msgid)
error (SORT_FAILURE, 0, _("%s: count `%.*s' too large"),
_(msgid), (int) (suffix - string), string);
return NULL;
*val = SIZE_MAX;
break;
case LONGINT_INVALID:
if (msgid)
@@ -2287,7 +2725,7 @@ main (int argc, char **argv)
struct keyfield gkey;
char const *s;
int c = 0;
bool checkonly = false;
char checkonly = 0;
bool mergeonly = false;
char *random_source = NULL;
bool need_random = false;
@@ -2303,10 +2741,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
atexit (cleanup);
initialize_exit_failure (SORT_FAILURE);
atexit (close_stdout);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
#if HAVE_NL_LANGINFO
@@ -2335,7 +2770,26 @@ main (int argc, char **argv)
{
size_t i;
static int const sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM };
static int const sig[] =
{
/* The usual suspects. */
SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM,
#ifdef SIGPOLL
SIGPOLL,
#endif
#ifdef SIGPROF
SIGPROF,
#endif
#ifdef SIGVTALRM
SIGVTALRM,
#endif
#ifdef SIGXCPU
SIGXCPU,
#endif
#ifdef SIGXFSZ
SIGXFSZ,
#endif
};
enum { nsigs = sizeof sig / sizeof sig[0] };
#if SA_NOCLDSTOP
@@ -2366,6 +2820,9 @@ main (int argc, char **argv)
#endif
}
/* The signal mask is known, so it is safe to invoke exit_cleanup. */
atexit (exit_cleanup);
gkey.sword = gkey.eword = SIZE_MAX;
gkey.ignore = NULL;
gkey.translate = NULL;
@@ -2460,8 +2917,22 @@ main (int argc, char **argv)
}
break;
case CHECK_OPTION:
c = (optarg
? XARGMATCH ("--check", optarg, check_args, check_types)
: 'c');
/* Fall through. */
case 'c':
checkonly = true;
case 'C':
if (checkonly && checkonly != c)
incompatible_options ("cC");
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':
@@ -2668,19 +3139,31 @@ main (int argc, char **argv)
if (checkonly)
{
if (nfiles > 1)
error (SORT_FAILURE, 0, _("extra operand %s not allowed with -c"),
quote (files[1]));
error (SORT_FAILURE, 0, _("extra operand %s not allowed with -%c"),
quote (files[1]), checkonly);
if (outfile)
incompatible_options ("co");
{
static char opts[] = {0, 'o', 0};
opts[0] = checkonly;
incompatible_options (opts);
}
/* POSIX requires that sort return 1 IFF invoked with -c and the
/* POSIX requires that sort return 1 IFF invoked with -c or -C and the
input is not properly sorted. */
exit (check (files[0]) ? EXIT_SUCCESS : SORT_OUT_OF_ORDER);
exit (check (files[0], checkonly) ? EXIT_SUCCESS : SORT_OUT_OF_ORDER);
}
if (mergeonly)
merge (files, 0, nfiles, outfile);
{
struct sortfile *sortfiles = xcalloc (nfiles, sizeof *sortfiles);
size_t i;
for (i = 0; i < nfiles; ++i)
sortfiles[i].name = files[i];
merge (sortfiles, 0, nfiles, outfile);
}
else
sort (files, nfiles, outfile);

View File

@@ -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
@@ -97,10 +97,6 @@ you must include <sys/types.h> before including this file
memcpy otherwise. */
#include <string.h>
#include "mempcpy.h"
#include "memrchr.h"
#include "stpcpy.h"
#include "strpbrk.h"
#include <errno.h>
@@ -117,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. */
@@ -389,14 +384,6 @@ readdir_ignoring_dot_and_dotdot (DIR *dirp)
}
}
#if SETVBUF_REVERSED
# define SETVBUF(Stream, Buffer, Type, Size) \
setvbuf (Stream, Type, Buffer, Size)
#else
# define SETVBUF(Stream, Buffer, Type, Size) \
setvbuf (Stream, Buffer, Type, Size)
#endif
/* Factor out some of the common --help and --version processing code. */
/* These enum values cannot possibly conflict with the option values

View File

@@ -231,7 +231,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
inaccessible when tail starts or if it becomes\n\
inaccessible later; useful when following by name,\n\
i.e., with --follow=name\n\
-c, --bytes=N output the last N bytes\n\
-c, --bytes=N output the last N bytes; alternatively, use +N to\n\
output bytes starting with the Nth of each file\n\
"), stdout);
fputs (_("\
-f, --follow[={name|descriptor}]\n\
@@ -241,7 +242,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-F same as --follow=name --retry\n\
"), stdout);
printf (_("\
-n, --lines=N output the last N lines, instead of the last %d\n\
-n, --lines=N output the last N lines, instead of the last %d;\n\
or use +N to output lines starting with the Nth\n\
--max-unchanged-stats=N\n\
with --follow=name, reopen a FILE which has not\n\
changed size after N (default %d) iterations\n\

View File

@@ -161,7 +161,7 @@ tee_files (int nfiles, const char **files)
the first one correspond to standard output. */
descriptors[0] = stdout;
files[0] = _("standard output");
SETVBUF (stdout, NULL, _IONBF, 0);
setvbuf (stdout, NULL, _IONBF, 0);
for (i = 1; i <= nfiles; i++)
{
@@ -174,7 +174,7 @@ tee_files (int nfiles, const char **files)
ok = false;
}
else
SETVBUF (descriptors[i], NULL, _IONBF, 0);
setvbuf (descriptors[i], NULL, _IONBF, 0);
}
while (1)

View File

@@ -172,17 +172,26 @@ Fields are skipped before chars.\n\
exit (status);
}
/* Convert OPT to size_t, reporting an error using MSGID if it does
not fit. */
/* Convert OPT to size_t, reporting an error using MSGID if OPT is
invalid. Silently convert too-large values to SIZE_MAX. */
static size_t
size_opt (char const *opt, char const *msgid)
{
unsigned long int size;
if (xstrtoul (opt, NULL, 10, &size, "") != LONGINT_OK
|| SIZE_MAX < size)
error (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
return size;
verify (SIZE_MAX <= ULONG_MAX);
switch (xstrtoul (opt, NULL, 10, &size, ""))
{
case LONGINT_OK:
case LONGINT_OVERFLOW:
break;
default:
error (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
}
return MIN (size, SIZE_MAX);
}
/* Given a linebuffer LINE,
@@ -472,8 +481,8 @@ main (int argc, char **argv)
skip_fields = 0;
if (!DECIMAL_DIGIT_ACCUMULATE (skip_fields, optc - '0', size_t))
error (EXIT_FAILURE, 0, "%s",
_("invalid number of fields to skip"));
skip_fields = SIZE_MAX;
skip_field_option_type = SFO_OBSOLETE;
}
break;

View File

@@ -11,6 +11,7 @@ TESTS = help-version
TESTS_ENVIRONMENT = \
all_programs="`$(all_programs)`" \
PACKAGE_BUGREPORT=$(PACKAGE_BUGREPORT) \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../src$(PATH_SEPARATOR)$$PATH"
EXTRA_DIST = \

View File

@@ -24,6 +24,7 @@
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,$(srcdir),g'

View File

@@ -1,8 +1,14 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.4 gnits
TESTS = \
default-no-deref \
basic \
deref \
no-x \
posix-H \
recurse
TESTS = no-x posix-H basic deref recurse
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
host_triplet=$(host_triplet) \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

51
tests/chgrp/default-no-deref Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
# Ensure that chgrp -R does not dereference symlinks.
# Copyright (C) 2006 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
chgrp --version
fi
. $srcdir/../group-names
set _ $groups; shift
g2=$2
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 d && touch f && ln -s ../f d/s || framework_failure=1
if test $framework_failure = 1; then
echo "$0: failure in testing framework" 1>&2
(exit 1); exit 1
fi
fail=0
g_init=`stat --printf=%g f`
chgrp -R $g2 d || fail=1
test `stat --printf=%g f` = $g_init || fail=1
(exit $fail); exit $fail

View File

@@ -1,6 +1,4 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.4 gnits
TESTS = \
inaccessible \
c-option \
@@ -14,4 +12,5 @@ TESTS = \
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

View File

@@ -1,10 +1,10 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.4 gnits
TESTS = \
preserve-root \
basic \
deref \
separator
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

View File

@@ -25,6 +25,7 @@ if test "$VERBOSE" = yes; then
fi
. $srcdir/../envvar-check
. $srcdir/../lang-default
pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$

88
tests/chown/preserve-root Executable file
View File

@@ -0,0 +1,88 @@
#!/bin/sh
# Verify that --preserve-root works.
# Copyright (C) 2006 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
chown --version
fi
. $srcdir/../envvar-check
. $srcdir/../lang-default
PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
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 d && ln -s / d/slink-to-root
if test $framework_failure = 1; then
echo "$0: failure in testing framework" 1>&2
(exit 1); exit 1
fi
fail=0
# Even if --preserve-root were to malfunction, allowing the chown or
# chgrp to traverse through "/", since we're running as non-root,
# they would be very unlikely to cause any changes.
chown -R --preserve-root 0 / > out 2>&1 && fail=1
chgrp -R --preserve-root 0 / >> out 2>&1 && fail=1
# Here, if --preserve-root were to malfunction, chmod could make changes,
# but only to files owned and unreadable by the user running this test,
# and then, only to make them readable by owner.
chmod -R --preserve-root u+r / >> out 2>&1 && fail=1
# With -RHh, --preserve-root should trigger nothing,
# since the symlink in question is not a command line argument.
# Contrary to the above commands, these two should succeed.
echo '==== test -RHh' >> out
chown -RHh --preserve-root `id -u` d >> out 2>&1 || fail=1
chgrp -RHh --preserve-root `id -g` d >> out 2>&1 || fail=1
# These must fail.
echo '==== test -RLh' >> out
chown -RLh --preserve-root `id -u` d >> out 2>&1 && fail=1
chgrp -RLh --preserve-root `id -g` d >> out 2>&1 && fail=1
cat <<\EOF > exp || fail=1
chown: it is dangerous to operate recursively on `/'
chown: use --no-preserve-root to override this failsafe
chgrp: it is dangerous to operate recursively on `/'
chgrp: use --no-preserve-root to override this failsafe
chmod: it is dangerous to operate recursively on `/'
chmod: use --no-preserve-root to override this failsafe
==== test -RHh
==== test -RLh
chown: it is dangerous to operate recursively on `d/slink-to-root' (same as `/')
chown: use --no-preserve-root to override this failsafe
chgrp: it is dangerous to operate recursively on `d/slink-to-root' (same as `/')
chgrp: use --no-preserve-root to override this failsafe
EOF
cmp out exp || fail=1
test $fail = 1 && diff out exp 2> /dev/null
(exit $fail); exit $fail

View File

@@ -1,7 +1,6 @@
# Make coreutils tests for cp. -*-Makefile-*-
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free
# Software Foundation, Inc.
# Copyright (C) 1997-2001, 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
@@ -18,9 +17,8 @@
# 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 \
src-base-dot \
sparse \
@@ -33,7 +31,9 @@ TESTS = \
perm cp-HL cp-i special-bits link dir-rm-dest cp-parents deref-slink \
dir-vs-file into-self
EXTRA_DIST = $(TESTS) trailing-slash
TESTS_ENVIRONMENT = \
MAKE=$(MAKE) \
CONFIG_HEADER=$(CONFIG_HEADER) \
TESTS_ENVIRONMENT = \
MAKE=$(MAKE) \
abs_top_builddir=$(abs_top_builddir) \
CONFIG_HEADER=$(CONFIG_HEADER) \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

View File

@@ -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

71
tests/cp/file-perm-race Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/sh
# Make sure cp -p isn't too generous with file permissions.
# Copyright (C) 2006 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
cp --version
fi
pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
trap 'status=$?; cd "$pwd" && 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
umask 022
mkfifo 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 the
# destination permissions before they're finalized.
cp -p --copy-contents fifo fifo-copy &
cp_pid=$!
(
# Now 'cp' is reading the fifo. Wait for the destination file to
# be created, encouraging things along by echoing to the fifo.
while test ! -f fifo-copy; do
echo foo
done
# Check the permissions of the destination.
ls -l fifo-copy >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
) >fifo
case `cat ls.out` in
-???------*)
fail=0;;
*)
fail=1;;
esac
wait $cp_pid || fail=1
(exit $fail); exit $fail

78
tests/cp/parent-perm-race Executable file
View File

@@ -0,0 +1,78 @@
#!/bin/sh
# Make sure cp -pR --parents isn't too generous with parent permissions.
# 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 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
cp --version
fi
pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
trap 'status=$?; cd "$pwd" && 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
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

View File

@@ -52,6 +52,7 @@ od-overlap4.E od-overlap5.O od-overlap5.E
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,$(srcdir),g'

View File

@@ -6,6 +6,7 @@ TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=dd

View File

@@ -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
@@ -74,6 +83,10 @@ if dd oflag=nolinks if=$tmp_in of=$tmp_out 2> /dev/null; then
dd oflag=nolinks < $tmp_in > $tmp_out 2>&1 || fail=1
fi
rm -f $tmp_in $tmp_in2 $tmp_sym $tmp_out
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 || fail=1
test $fail -eq 0 && fail=$warn
exit $fail

View File

@@ -6,6 +6,7 @@ TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=dircolors

View File

@@ -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 \
@@ -36,4 +33,5 @@ TESTS = \
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

View File

@@ -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

View File

@@ -1,11 +1,10 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.3b gnits
TESTS = basic
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=expr

View File

@@ -1,11 +1,10 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*-.
AUTOMAKE_OPTIONS = 1.3b gnits
TESTS = basic
EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=factor

View File

@@ -6,6 +6,7 @@ TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=fmt

View File

@@ -2,7 +2,7 @@
# -*- perl -*-
# Basic tests for "fmt".
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -60,23 +60,23 @@ my @Tests =
. " is the first\noption; use -w N instead\n"
. "Try `fmt --help' for more information.\n" }, {EXIT => 1}],
# With --prefix=P, Do not remove leading on lines without the prefix.
# With --prefix=P, do not remove leading space on lines without the prefix.
['pfx-1', qw (-p '>'),
{IN=> " 1\n 2\n\t3\n\t\t4\n> quoted\n> text\n"},
# This is the buggy output (leading white space removed),
# from coreutils-5.93.
{OUT=> "1\n2\n3\n4\n> quoted text\n"}],
# FIXME: this is the desired output
# {OUT=> " 1\n 2\n\t3\n\t\t4\n> quoted text\n"}],
{OUT=> " 1\n 2\n\t3\n\t\t4\n> quoted text\n"}],
# Like the above, but when two adjacent, non-prefixed lines have
# the same indentation, ensure that they are formatted.
['pfx-2', qw (-p '>'),
{IN=> " 1\n 2\n\t3\n\t4\n"},
{OUT=> "1\n2\n3\n4\n"}],
# FIXME: this is the desired output
# {OUT=> " 1 2\n\t3 4\n"}],
);
# Don't remove prefix from a prefix-only line.
['pfx-only', qw (-p '>'),
{IN=> ">\n"},
{OUT=> ">\n"}],
# With a multi-byte prefix, say, "foo", don't empty a line that
# starts with a strict prefix (e.g. "fo") of that prefix.
# With fmt from coreutils-6.7, it would mistakenly output an empty line.
['pfx-of-pfx', qw (-p 'foo'),
{IN=> "fo\n"},
{OUT=> "fo\n"}],
);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};

View File

@@ -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,13 +18,12 @@
## 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
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
TESTS = testsuite

View File

@@ -39,6 +39,7 @@ posix-3.O posix-3.E posix-4.O posix-4.E posix-5.O posix-5.E
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,$(srcdir),g'

View File

@@ -1,8 +1,7 @@
## 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 = \
EXEEXT='$(EXEEXT)' \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

View File

@@ -30,19 +30,21 @@ maint_gen = 1a.I1 1a.I2 1a.X 1b.I1 1b.I2 1b.X 1c.I1 1c.I2 1c.X 1d.I1 1d.I2 \
5k.I2 5k.X 5l.I1 5l.I2 5l.X 5m.I1 5m.I2 5m.X 6a.I1 6a.I2 6a.X 6b.I1 6b.I2 \
6b.X 6c.I1 6c.I2 6c.X 7a.I1 7a.I2 7a.X 8a.I1 8a.I2 8a.X 8b.I1 8b.I2 8b.X \
9a.I1 9a.I2 9a.X trailing-sp.I1 trailing-sp.I2 trailing-sp.X sp-vs-blank.I1 \
sp-vs-blank.I2 sp-vs-blank.X 8-bit-t.I1 8-bit-t.I2 8-bit-t.X invalid-j.X
sp-vs-blank.I2 sp-vs-blank.X 8-bit-t.I1 8-bit-t.I2 8-bit-t.X bigfield.I1 \
bigfield.I2 bigfield.X invalid-j.X
run_gen = 1a.O 1a.E 1b.O 1b.E 1c.O 1c.E 1d.O 1d.E 1e.O 1e.E 1f.O 1f.E 2a.O \
2a.E 2b.O 2b.E 2c.O 2c.E 3a.O 3a.E 4a.O 4a.E 4b.O 4b.E 4c.O 4c.E 4d.O 4d.E \
4e.O 4e.E 5a.O 5a.E 5b.O 5b.E 5c.O 5c.E 5d.O 5d.E 5e.O 5e.E 5f.O 5f.E 5g.O \
5g.E 5h.O 5h.E 5i.O 5i.E 5j.O 5j.E 5k.O 5k.E 5l.O 5l.E 5m.O 5m.E 6a.O 6a.E \
6b.O 6b.E 6c.O 6c.E 7a.O 7a.E 8a.O 8a.E 8b.O 8b.E 9a.O 9a.E trailing-sp.O \
trailing-sp.E sp-vs-blank.O sp-vs-blank.E 8-bit-t.O 8-bit-t.E invalid-j.O \
invalid-j.E
trailing-sp.E sp-vs-blank.O sp-vs-blank.E 8-bit-t.O 8-bit-t.E bigfield.O \
bigfield.E invalid-j.O invalid-j.E
##test-files-end
EXTRA_DIST = Test.pm $x-tests $(explicit) $(maint_gen)
noinst_SCRIPTS = $x-tests
TESTS_ENVIRONMENT = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"
editpl = sed -e 's,@''PERL''@,$(PERL),g' -e 's,@''srcdir''@,$(srcdir),g'

View File

@@ -136,6 +136,9 @@ my @tv = (
[t_subst "a:1\nb:1\n", t_subst "a:2:\nb:2:\n"],
t_subst "a:1:2:\nb:1:2:\n", 0],
['bigfield', '-1 340282366920938463463374607431768211456 -2 2',
["a\n", "b\n"], " a b\n", 0],
# FIXME: change this to ensure the diagnostic makes sense
['invalid-j', '-j x', {}, "", 1],

View File

@@ -1,7 +1,6 @@
## 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 = \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH"

View File

@@ -6,6 +6,7 @@ TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
PERL="$(PERL)" \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PROG=ls

View File

@@ -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 \
@@ -33,6 +30,7 @@ EXTRA_DIST = $(TESTS)
TESTS_ENVIRONMENT = \
top_srcdir=$(top_srcdir) \
srcdir=$(srcdir) \
CU_TEST_NAME=`basename $(abs_srcdir)`,$$tst \
PATH="$(VG_PATH_PREFIX)`pwd`/../../src$(PATH_SEPARATOR)$$PATH" \
PERL="$(PERL)" \
PROG=ls

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# make sure ls -L always follows symlinks
# Copyright (C) 2000, 2002, 2004, 2006 Free Software Foundation, Inc.
# Copyright (C) 2000, 2002, 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
@@ -33,9 +33,10 @@ mkdir $tmp || framework_failure=1
cd $tmp || framework_failure=1
# Isolate output files from directory being listed
mkdir dir || framework_failure=1
mkdir dir dir/sub dir1 || framework_failure=1
cd dir || framework_failure=1
ln -s link link || framework_failure=1
ln -s ../../dir1 sub/link-to-dir || framework_failure=1
# Make sure the symlink was created.
# `ln -s link link' succeeds, but creates no file on
@@ -56,15 +57,30 @@ ls -L link 2> /dev/null && fail=1
# list the link, provided no further information about the link needed
# to be printed. Since POSIX does not specify one way or the other, we
# opt for compatibility (this was broken in 5.3.0 through 5.94).
ls -L > ../out || fail=1
LC_ALL=C ls -L > ../out-L || fail=1
LC_ALL=C ls -FLR sub > ../out-FLR-sub || fail=1
cd .. || fail=1
cat <<\EOF > exp
cat <<\EOF > exp-L
link
sub
EOF
cmp out exp || fail=1
test $fail = 1 && diff out exp 2> /dev/null
cat <<\EOF > exp-FLR-sub
sub:
link-to-dir/
sub/link-to-dir:
EOF
cmp out-L exp-L || {
fail=1
diff out-L exp-L
}
cmp out-FLR-sub exp-FLR-sub || {
fail=1
diff out-FLR-sub exp-FLR-sub
}
(exit $fail); exit $fail

Some files were not shown because too many files have changed in this diff Show More