Compare commits

..

198 Commits
v8.12 ... v8.13

Author SHA1 Message Date
Jim Meyering
c7fca77515 version 8.13
* NEWS: Record release date.
2011-09-08 17:04:42 +02:00
Jim Meyering
032bbff2da build: update gnulib submodule to latest 2011-09-08 15:49:42 +02:00
Jim Meyering
5581bf28e3 stat: avoid compilation failure on AIX 7.x
* src/stat.c (USE_STATVFS): Adjust definition so that it is enabled
also on AIX 7.x systems that provide statvfs64 and no statvfs.
[USE_STATVFS && ! STAT_STATVFS && STAT_STATVFS64] (STATFS): Define
to statvfs64 in that precise case.
* m4/stat-prog.m4 (cu_PREREQ_STAT_PROG): Adjust the condition
here to match the new one in stat.c, to keep them in sync.
Reported by Bruno Haible.  For details, see
http://article.gmane.org/gmane.comp.gnu.coreutils.general/1668
2011-09-08 12:16:17 +02:00
Bernhard Voelker
5eeaca942a tests: adjust PATH to include /sbin for mkfs-using tests
* tests/init.cfg (require_mkfs_PATH_): New function to test whether mkfs
is in PATH, otherwise adding /sbin to PATH.  Needed for distributions
(OpenSuSE, Solaris) in which sudo does not include /sbin in PATH.
* tests/cp/cp-a-selinux: Use require_mkfs_PATH_.
* tests/cp/cp-mv-enotsup-xattr: Likewise.
* tests/cp/sparse-fiemap: Likewise.
* tests/mkdir/writable-under-readonly: Likewise.
* tests/rm/read-only: Likewise.
2011-09-07 18:00:55 +02:00
Jim Meyering
f85ca2c876 tests: avoid false-positive "make check" failure when perl is missing
* doc/Makefile.am (sc-lower-case-var): Skip this test when $(PERL)
is not usable.  Reported by Bruno Haible.
2011-09-07 18:00:55 +02:00
Jim Meyering
ac5739d317 cp: update gnulib to get support for NFSv4 ACLs
* NEWS (Improvements): Mention the cp-vs-NFSv4-ACL improvement we
have inherited via gnulib.  For details, see
http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28100
and the following messages in that thread.
* gnulib: Update to latest, for numerous ACL-related improvements.
2011-09-07 17:59:46 +02:00
Bruno Haible
0cefe58092 tests: init.sh: work also with any non-GNU diff that supports -u
* tests/init.sh: Relax check for diff -u support.
Rather than checking for GNU diff via --version, simply check
for support for -u itself.  Useful at least on OpenBSD 4.9.
2011-09-02 14:08:40 +02:00
Jim Meyering
7490145dd0 tests: remove require-perl script; use function instead
* tests/require-perl: Remove file.
* tests/Makefile.am (EXTRA_DIST): Remove it from this list.
* tests/init.cfg (require_perl_): New function.
* tests/misc/pwd-long: Use the new function, not the file.
* tests/ls/nameless-uid: Likewise.
* tests/misc/sum-sysv: Likewise.
2011-09-02 14:08:40 +02:00
Jim Meyering
d8945c8d8f tests: cut: exercise distro-added multibyte code paths
* tests/misc/cut: Repeat each test using a multibyte locale,
if the configure-time test found such a locale.
Adjust the tests so that they also accept a slightly
different diagnostic that is specific to the MB-patched cut.
2011-09-02 14:08:40 +02:00
Pádraig Brady
832c85e3f7 doc: describe test control variables
* HACKING (Add tests): Mention the variables and default values.
* README-release (Pre-release testing): Mention that setting
the SHELL variable may be required.
Suggested by Bruno Haible.
2011-09-02 11:41:23 +01:00
Pádraig Brady
3d2e55d508 timeout: fixup previous warning fix
* src/timeout.c (settimeout): Fix the previous commit
to test errno rather than the return value.
2011-09-01 15:50:08 +01:00
Pádraig Brady
37784220dd tests: split/l-chunk: avoid a portability issue
* tests/split/l-chunk: Don't use the `test "$var"`
idiom to test that var is set to something as
that's not supported by all shells.
The new style matches the usage is the rest of
the test in any case.
Reported by Bruno Haible on AIX 6.1 and 7.1
2011-09-01 15:43:25 +01:00
Jim Meyering
551cbda027 tests: pwd-long: diagnose failure earlier
Without this change, we'd get use-of-uninit value warnings
and harder-to-diagnose failure down the road.
* tests/misc/pwd-long (normalize_to_cwd_relative): Diagnose stat
failure.  This failed on AIX 6.1 and 7.1.  Reported by Bruno Haible.
2011-09-01 16:36:23 +02:00
Jim Meyering
af5f2d741b tests: printf-surprise: avoid false-positive failure
* tests/misc/printf-surprise: Also accept a strerror-style string
after the usual 'printf: write error:' diagnostic prefix.
Otherwise, this test would fail on HP-UX 11.
Reported by Bruno Haible.
2011-09-01 16:36:23 +02:00
Bernhard Voelker
44f7444987 tests: improve message in 'require_membership_in_two_groups_' function
* tests/init.cfg (require_membership_in_two_groups_): Add quotes
around the suggested groups for the COREUTILS_GROUPS variable.
2011-09-01 16:36:23 +02:00
Jim Meyering
ac54e1e4d2 tests: misc/printf: accommodate alternate behavior
* tests/misc/printf: Avoid false positive failure on MacOS X 10.5
due to a slightly differing diagnostic.  Reported by Bruno Haible.
2011-09-01 16:36:23 +02:00
Jim Meyering
a8c7983629 tests: invoke via "env printf", rather than using an absolute name
* tests/misc/printf: This results in more concise diagnostics.
2011-09-01 16:36:23 +02:00
Pádraig Brady
38e3a90e4b timeout: suppress a redundant warning on some systems
* src/timeout.c (settimeout): Don't warn about ENOSYS
which is returned on OpenBSD 4.9 at least.
Reported by Bruno Haible
2011-09-01 15:30:18 +01:00
Pádraig Brady
197cd0994d stdbuf: fix helper lib identification on some platforms
* src/stdbuf.c (main): Pass the path of `stdbuf` rather than
the command it's running to the search function.  This is
significant on platforms without /proc/self/exe
Reported by Bruno Haible
2011-09-01 15:27:58 +01:00
Pádraig Brady
0d89a42bff build: avoid the use of strsignal() in split
... which is not available on some platforms,
and the replacement currently requires linking
with threading libraries.
* src/split.c (closeout): Remove the call to strsignal()
which is largely redundant anyway as sig2str()
is already used to map number to name in the error.
Reported by Bruno Haible on AIX 6.1 and 7.1
2011-09-01 15:20:55 +01:00
Jim Meyering
df9cd0a426 date: support parsing of ISO-8601-with-"T" dates
Thanks to an improvement in gnulib's parse-datetime module,
commands like this now succeed (output manually indented):
    $ ./date -u -d 2004-02-29T16:21:42.33+07:00 +%FT%T.%N%z
		   2004-02-29T09:21:42.330000000+0000
* tests/misc/date: Add a test to exercise the new-in-gnulib
parsing of ISO8601-with-"T" dates.
* NEWS (New features): Mention it.
* gnulib: Update, to pull in this parse-datetime improvement.
2011-08-31 20:00:19 +02:00
Pádraig Brady
683ee76ad2 build: heap.c: make possible gnulib candidate c89 compatible
* gl/lib/heap.c: Move declaration to the top of scope.
Reported by Rob McMahon and Wolfgang Steinwender
in relation to "Sun WorkShop 6 update 2 C 5.3 Patch 111679-12
2003/05/18" and "GCC 2.95.3" respectively.
2011-08-30 15:09:23 +01:00
Pádraig Brady
24a1a8c473 timeout: revert signal propagation enhancement
This effectively reverts the unreleased commit 5a647a05

* src/timeout.c (main): Don't propagate signals from the monitored
process, as on Linux /proc/sys/kernel/core_pattern could still
handle them and cause false reports against `timeout`
2011-08-25 11:35:31 +01:00
Jim Meyering
6a2751d59d maint: rename a test
Lesson: do not include details like "4 million" in a file name.
* tests/rm/many-dir-entries-vs-OOM: Renamed from ...
* tests/rm/4-million-entry-dir: ...this.
* tests/Makefile.am (TESTS): Reflect renaming.
2011-08-24 10:50:28 +02:00
Jim Meyering
ebc63d33ea tests: adjust the new, very expensive rm test to be less expensive
* tests/rm/4-million-entry-dir: Create only 200,000 files, rather
than 4 million.  The latter was overkill, and was too likely to
fail due to inode exhaustion.  Not everyone is using btrfs yet.
Now that this test doesn't take so long, label it as merely
"expensive", rather than "very expensive".  Thanks to
Bernhard Voelker for pointing out the risk of inode exhaustion.
2011-08-24 10:50:15 +02:00
Pádraig Brady
1f93c96339 pr: fix so that LAST_PAGE is honored with -T
Ever since the LAST_PAGE functionality was added
in commit ed0923a1, 1996-12-05,
"Apply big patch (patch-20) from Roland Huebner"
it was ignored when -t or -T were specified or
when -l <= 10.

* src/pr.c (print_page): Increment the current page here.
(print_header): Don't increment the current page here.
* tests/pr/pr-tests: Add a test case.
* NEWS: Mention the fix

Reported at http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9347
2011-08-24 00:21:17 +01:00
Erik Auerswald
423b079f53 doc: correct typo in yesterday's NEWS entry: 30GB -> 30MB
* NEWS: s/30GB/30MB/
2011-08-20 08:12:31 +02:00
Jim Meyering
0ba576979a rm, du, chmod, chown, chgrp: use much less memory for large directories
For details, see the gnulib commit,
http://git.sv.gnu.org/cgit/gnulib.git/commit/?id=47cb657e
* tests/rm/4-million-entry-dir: New test.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
* gnulib: Update to latest to get the required fts fixes.
2011-08-19 18:21:06 +02:00
Bernhard Voelker
036a9c6909 maint: remove empty statement after jump label
* src/head.c (elide_tail_bytes_pipe): Remove the empty statement, ";"
after a jump label; it is needed only when a declaration follows.
* src/kill.c (main): Likewise.
* src/od.c (main): Likewise.
* src/paste.c (collapse_escapes): Likewise.
* src/printf.c (print_formatted): Likewise.
2011-08-13 11:21:01 +02:00
Paul Eggert
faf5fbeb36 pathchk: port to hosts where mbstate_t is replaced
This problem was discovered when trying to build git coreutils on
Solaris 8 sparcv9 with Sun C 5.8: the 3rd argument to mbrlen was
of type int * (a pointer to the gnulib replacement mbstate_t) but
the system mbrlen wants the system mbstate_t *.
* bootstrap.conf (gnulib_modules): Add mbrlen.
* src/pathchk.c (mbrlen, mbstate_t) [!(HAVE_MBRLEN && HAVE_MBSTATE_T)]:
Remove macros, which are wrong now that gnulib supplies
replacements for mbstate_t and mbrlen.
2011-08-12 01:15:37 -07:00
Paul Eggert
4a1527908b bootstrap: use latest gnulib bootstrap, gettext
* bootstrap: Sync from gnulib.  This removes an obsolescent
gettext.m4 patch, along with some other changes that do not
seem to affect coreutils.
* bootstrap.conf (gnulib_modules): Use gettext, not gettext-h.
Current gnulib gettext seems to work without needing special hacking.
* configure.ac (AM_GNU_GETTEXT_VERSION): Now 0.18.1, not 0.17.
* gnulib: Update to latest.
2011-08-11 18:38:19 -07:00
Jim Meyering
dce1da2b57 maint: use gnulib's new largefile modulue
* bootstrap.conf (gnulib_modules): Add largefile.
This is useful to Mac OS X 10.5 users if/when configure
is generated using autoconf prior to v2.68-80-gdb2f2e0.
* gnulib: Update to latest.
2011-08-11 15:27:21 +02:00
Jim Meyering
4cf9eb5282 tests: avoid lack-of-support du test failure on HP-UX 11.31
* tests/du/inaccessible-cwd: Skip this test on systems like HP-UX 11.31
that lack both the *at functions and the /proc/self/fd-based support
we might have used to emulate them.  Reported by Bruno Haible in
http://debbugs.gnu.org/8846
2011-08-08 10:12:38 +02:00
Jim Meyering
7055579067 join: with --check-order print offending file name, line number and data
* src/join (g_names): New global (was main's "names").
(main): Update all uses of "names".
(line_no[2]): New globals.
(get_line): Increment after reading each line.
(check_order): Print the standard "file name:line_no: " prefix
as well as the offending line when reporting disorder.
Here is a sample old/new comparison:
  -join: file 1 is not in sorted order
  +join: in:4: is not sorted: contents-of-line-4
* tests/misc/join: Change the two affected tests to expect
the new diagnostic.
Add new tests for more coverage: mismatch in file 2,
two diagnostics, zero-length out-of-order line.
* NEWS (Improvements): Mention it.
Suggested by David Gast in http://debbugs.gnu.org/9236
2011-08-08 10:12:38 +02:00
Jim Meyering
005534907c maint: use xcalloc rather than xmalloc+memset (no semantic change)
* src/join.c (init_linep): Use xcalloc, not xmalloc+memset.
2011-08-08 10:12:38 +02:00
Jim Meyering
149499925e maint: add copyright notice to init.cfg
* tests/init.cfg: Add copyright.  Suggested by Stefano Lattarini.
2011-08-08 10:11:48 +02:00
Jim Meyering
0b27edfe1d maint: prevent accidental future use of the old shell function name
This is especially important for an error-handling shell function
like this that is actually called only rarely.
* cfg.mk (sc_prohibit_framework_failure): New rule, to prevent
use of the old name.
2011-08-08 10:11:48 +02:00
Stefano Lattarini
554caaf6ff tests: complete the renaming framework_failure -> framework_failure_
These changes were mostly mechanical, made by running the
following command:

  git grep -lw framework_failure | grep -v ChangeLog \
    | xargs perl -pi -e 's/\b(framework_failure)\b/${1}_/'

and then editing init.cfg and `tests/cp/cp-a-selinux' by hand.

* tests/init.cfg (framework_failure): Remove, `framework_failure_'
from init.sh should be used instead in the tests.
Remove now-obsolete "FIXME" comment.
(is_local_dir_, require_strace_, require_membership_in_two_groups_,
require_sparse_support_, skip_if_mcstransd_is_running_,
mkfifo_or_skip_) Use `framework_failure_', not `framework_failure'.
* Many test scripts: Likewise.
2011-08-08 10:11:48 +02:00
Paul Eggert
8e2767a3f0 mktemp: stir in enough entropy (Bug#6683)
* gl/lib/tempname.c.diff (gen_tempname_len):
Use x_suffix_len bytes' worth of entropy, not 8 bytes.
2011-08-08 00:30:55 -07:00
Stefano Lattarini
bbcf3abc2c tests: remove obsolete 'error_' shell function
* tests/init.cfg (framework_failure, getlimits_): Use 'fatal_'
instead of 'error_'.
(error_): Delete, it's not used anymore (and one is anyway
advised to use 'fatal_' instead).
Update heading comments.
* tests/shell-or-perl (error_): Renamed ...
(fatal_): ... to this, for consistency.  Also, add a useful
comment.
2011-08-04 18:07:52 +02:00
Pádraig Brady
7eaff0fea3 doc: mention the new mirroring behavior of cp -au
* NEWS: Mention the change in behavior.
* doc/coreutils.texi (cp invocation): Likewise.
2011-07-31 13:08:47 +01:00
Jim Meyering
e24c711cbc maint: accommodate old-NEWS update
* cfg.mk (old_NEWS_hash): Update, to accommodate 6.12 addition.
Without this change, "make syntax-check" would fail.
2011-07-31 11:23:58 +02:00
Paul Eggert
c88f6f22c7 * NEWS: Say that 6.12 preserved ns-resolution timestamps. 2011-07-31 00:27:38 -07:00
Jim Meyering
e9ced81139 build: require gnulib's fclose module
* bootstrap.conf (gnulib_modules): Explicitly use the fclose module.
This is required, now that gnulib's close module no longer depends
on fclose.  Without this module, we would be exposed to fclose bugs
affecting at least glibc 2.13 and FreeBSD.
Reported by Bernhard Voelker.  Suggested by Eric Blake.
2011-07-29 15:23:02 +02:00
Jim Meyering
0be1ae6620 build: update gnulib, for "make syntax-check" fix
Without the recent maint.mk fix, "make syntax-check"
would fail like this:

    src/dd.c:# define SA_RESETHAND 0
    src/ls.c:# define SA_RESTART 0
    src/timeout.c:# define SA_RESTART 0
    maint.mk: define the above via some gnulib .h file
    make: *** [sc_prohibit_always-defined_macros] Error 1
2011-07-29 08:07:30 +02:00
Ivan Sichmann Freitas
6ab90b53f6 doc: add a vim indentation example
HACKING: add a vim example showing how to configure it to follow GNU
indentation in coreutils source files.
2011-07-27 13:51:15 +01:00
Pádraig Brady
42300faaa9 maint: copy: refactor hard link creation
* src/copy.c (create_hard_link): A new function refactored
from existing code.
(copy_internal): Call the new function from all 3 locations
that create hard links.
* tests/cp/same-file: Amend to match the adjusted diagnostic.
2011-07-27 13:32:32 +01:00
Pádraig Brady
2aea1828a1 tests: cp/preserve-link: test all relevant paths
* tests/cp/preserve-link: Add test cases for when a missing
link in the destination tree is encountered first and second.
Also add cases for old and new separate files in the destination
tree, both to make the clobbering behavior explicit, and to
test any changes in this area in future.
2011-07-27 09:36:59 +01:00
Jim Meyering
b2bb19b4b3 doc: mention cp's dir-permissions fix
* NEWS (Bug fixes): Mention yesterday's dir-permissions fix.
2011-07-26 09:24:31 +02:00
Jim Meyering
5f35396395 maint: use consistent style in C and test scripts
* src/copy.c (copy_internal): Adjust formatting style to conform with
guidelines in HACKING: put braces around two one-line "else" blocks.
* tests/cp/existing-perm-dir: Use $(...), not `...`, and
stat rather than ls+cut to get the mode string.
mode=$(stat --p=%A dst/dir)
2011-07-26 09:01:44 +02:00
Paul Eggert
e772bddde8 cp: don't mishandle existing dir dest permissions (Bug#9170)
* src/copy.c (copy_internal): If we don't create the directory,
then we cannot have omitted permissions.  Problem and trivial
fix reported by Eric Lammerts.
* tests/Makefile.am (TESTS): Add cp/existing-perm-dir.
* tests/cp/existing-perm-dir: New file.
2011-07-25 14:04:51 -07:00
Jim Meyering
f28a09810b cp -up: preserve all hard links
* src/copy.c (copy_internal): With --update (-u), this function would
return early once it found that the destination is not older than the
source, *without* recording the source-dev/ino--to--dest_name mapping.
That mapping is required in order to preserve src hard links in the
destination tree, so when using cp with --update and --preserve=links
(perhaps via -p or -a), cp could fail to preserve one hard link
per inode when at least one of the hard-linked names already exists
in the destination tree.
Reported by Odd Harry Mannsverk in http://debbugs.gnu.org/8419.
* tests/cp/preserve-link: New file.  Exercise the flaw/fix.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
2011-07-25 14:15:44 +02:00
Pádraig Brady
aeb5222a6d timeout: support sub-second timeouts
* src/timeout.c (settimeout): A new function to convert
from a floating point duration and call alarm() or
timer_settime() if that's available.
(parse_duration): Return a double rather than unsigned int.
(usage): Mention floating point is supported.
(main): Pass the double to settimeout() rather than
calling alarm() directly with the parsed int.
(cleanup): Likewise.
* doc/coreutils.texi (timeout invocation): Say floating point timeouts
now supported, and mention the caveat with resolution.
* bootstrap.conf: Include the timer-time gnulib module.
* tests/misc/timeout-parameters: Add a test with nanoseconds.
* NEWS: Mention the improvement.
2011-07-25 12:00:26 +01:00
Jim Meyering
42c4ba6ceb build: update gnulib to fix a build warning/error in a test program 2011-07-25 08:26:21 +02:00
Jim Meyering
c29cb31b7f df: support partitions larger than 4 TiB on MacOS >= 10.5 & AIX >=5.2
This change derives from improvements to gnulib's fsusage module.
* NEWS (Improvements): df now supports disk partitions larger than
4 TiB on MacOS X 10.5 or newer and on AIX 5.2 or newer.
Alphabetize entries.
* gnulib: Update to latest.
2011-07-24 22:58:36 +02:00
Paul Eggert
339613b6bd dd, shred: use fdatasync only if declared
* m4/jm-macros.m4 (coreutils_MACROS): Use fdatasync only if declared.
MacOS X 10.7 has an fdatasync that is not declared, and is rumored to
be ineffective.  (Bug#9141)
2011-07-22 13:41:19 -07:00
Mike Frysinger
f603b2d228 dircolors: add screen.Eterm terminal type
* src/dircolors.hin: Add screen.Eterm.
Reported by Kfir Lavi
2011-07-20 14:14:25 +01:00
Pádraig Brady
f3b473c579 maint: remove a redundant call to gl_CLOCK_TIME
* m4/jm-macros.m4: Remove gl_CLOCK_TIME as it's already
done by the gettime gnulib module.
2011-07-20 11:38:50 +01:00
Pádraig Brady
65a0483fb5 unexpand: fix misalignment when spaces span a tabstop
The following dropped the space from the first field
  printf "1234567  \t1\n" | unexpand -a
Note POSIX says that spaces should not precede tabs.
Also a single trailing space should not be converted
if the next field starts with non blank characters.
So we enforce those rules too, with this change.

* src/unexpand.c (unexpand): Implement as per POSIX rules.
* tests/misc/unexpand: Add tests, and adjust existing
tests as per POSIX rules.
* NEWS: Mention the fix.
Reported by Hallvard B Furuseth
2011-07-20 10:38:46 +01:00
Paul Eggert
dc7284ef72 * NEWS: Mention fix for Bug#9098. 2011-07-17 12:52:55 -07:00
Paul Eggert
7e576fc403 timeout: add regression test (Bug#9098)
* tests/misc/timeout: Check that 'timeout' is not confused when
starting off with a child.
2011-07-17 12:52:55 -07:00
Paul Eggert
240a633756 timeout: treat seconds counts like 'sleep' does
Treat fractions as a request to round up to the next representable
value, and treat out-of-range values as maximal ones.  This is
consistent with how "sleep" works.  And this way, "timeout
999999999999999999d FOO" and "timeout 4.5 foo" are more likely to
do what the user wants.
* src/timeout.c: Include c-strtod.h and xstrtod.h, not xstrtol.h.
(apply_time_suffix): Change it to the way sleep.c's time_suffix
does things.  Maybe this function (identical in both programs,
other than its name) should be moved to a library?
(parse_duration): Return a maximal value on overflow.  Return
unsigned int, not unsigned long.  Allow fractions, which round
up to the next integer value.
* tests/misc/timeout-parameters: Adjust tests to match new behavior.
Add a very large number.
2011-07-16 12:10:45 -07:00
Paul Eggert
2d9b49789f Fix capiTalization in comments. 2011-07-16 12:10:45 -07:00
Paul Eggert
8f1629f0ad * src/timeout.c (main): Use waitpid, not wait (Bug#9098).
Reported by Andreas Schwab.

* src/timeout.c (SA_RESTART): Define to 0 if not defined.
2011-07-16 12:10:45 -07:00
Paul Eggert
8d8f5f1028 timeout: port to NonStop (Bug#9077)
* src/timeout.c (SA_RESTART): Define to	0 if not defined.
(main): Don't assume signal handling uses SA_RESTART.
2011-07-16 12:10:44 -07:00
Paul Eggert
84185eda59 ls: port to NonStop (Bug#9076)
* src/ls.c (SA_RESTART): Define to 0 if not defined.
2011-07-16 12:10:44 -07:00
Paul Eggert
efec1600c9 dd: port to NonStop (Bug#9076)
* src/dd.c (SA_RESETHAND): Define to 0 if not defined.
2011-07-16 12:10:44 -07:00
Paul Eggert
837e1f5519 csplit: don't prematurely terminate cleanup (Bug#9076)
* src/csplit.c (interrupt_handler): Reset signal to SIG_DFL
after deleting the files, so that a second interrupt won't
prematurely terminate cleanup.
(main): Don't use SA_NODEFER | SA_RESETHAND, as that might
allow premature termination of cleanup.  Also, this ports better
to platforms like NonStop, which don't ahve SA_RESETHAND.
2011-07-15 16:03:57 -07:00
Paul Eggert
750fadd5d3 * src/dd.c: Remove obsolete comments re POSIX. 2011-07-15 15:56:34 -07:00
Pádraig Brady
63613d4935 build: avoid a st_blksize compile failure on some systems
* src/stat.c (print_stat): Use ST_BLKSIZE() rather than
accessing st_blksize directly, which is not present on
NonStop at least.  Reported by Joachim Schmitz.
2011-07-15 16:23:28 +01:00
Pádraig Brady
4f71710c42 build: avoid a fiemap compile failure on some systems
* src/fiemap.h (struct fiemap): Adjust the previous change
to the fiemap_extents array, which would also require changes
to the sizeof calculations in extent_scan_read().
Instead, only declare the fiemap_extents zero length array
on linux, which is the only platform that references this member.
This avoids a compilation failure on systems that don't support
this non standard construct.  We don't use the equivalent C99
flexible array construct so as to have maximum portability.
* src/extent-scan.c: Cleanup. Remove a redundant #ifndef.
2011-07-15 10:55:04 +01:00
Paul Eggert
feb0b08c0d * src/fiemap.h (struct fiemap.fm_extents): Change size to 1.
This is for portability to non-GCC C89 and C99 compilers.
Original problem, on NonStop, reported by Joachim Schmitz in
<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9077>.
2011-07-14 22:08:04 -07:00
Bernhard Voelker
be6120b5cc maint: fix warning 'possible use of "=" where "==" was intended'
* src/mktemp.c: maint: avoid warning by using the comma operator
rather than an always-true conditional (as suggested by Eric Blake).
Reported by Joachim Schmitz in http://debbugs.gnu.org/9064.
2011-07-14 11:56:23 +01:00
Benoît Knecht
acdf4e99e6 doc: describe the file permissions set by mktemp
* src/mktemp.c (usage): As above, for --help.
Reported by Jordi Pujol in http://bugs.debian.org/551093.
Wording improvments from Eric Blake.
2011-07-13 15:12:28 +01:00
Benoît Knecht
2c558fd0d3 doc: note the order in which wc counts are printed
This information has already been added to the Texinfo manual, but was
missing from the --help output.

* src/wc.c (usage): As above, for --help.
Reported by Vincent Lefevre in http://bugs.debian.org/395430.
2011-07-13 10:16:03 +01:00
Jim Meyering
7700751c5f build: update gnulib submodule to latest 2011-07-12 15:40:53 +02:00
Eric Blake
bf0771a1c5 build: list makeinfo 4.13 as a build-from-git requirement
* bootstrap.conf (buildreq): List 4.13 as minimum makeinfo version.
Prompted by Joachim Schmitz's report in http://debbugs.gnu.org/9050.
2011-07-12 15:40:45 +02:00
Benoît Knecht
6cafe09c33 dircolors: highlight .webm multimedia files
* src/dircolors.hin: Add .webm multimedia files.
Suggested by Josh Triplett in http://bugs.debian.org/582403.
2011-07-11 10:13:29 +02:00
Jim Meyering
f8f1c8111e maint: add syntax-check rule to prohibit "."-terminated "SEE ALSO"
* cfg.mk (sc_prohibit_man_see_also_period): Prohibit a period at
the end of the first line after a "SEE ALSO" marker in man/*.x.
With this, we shouldn't have to make any more changes like those
in today's commit, f2dabd68.
2011-07-08 21:55:00 +02:00
Pádraig Brady
af1ffdff17 doc: list all new file system types recognized by stat -f
NEWS (Improvements): Mention the MQUEUE and PSTOREFS
file systems, recognized as of commit 171e1b98.
2011-07-08 16:01:27 +01:00
Benoît Knecht
f2dabd6806 doc: don't terminate SEE ALSO sections with a period
man-pages(7) explicitly says about SEE ALSO sections: "Do not terminate
this with a period." This is also in line with all the other man pages
in coreutils.

* man/cat.x: Remove period at the end of the SEE ALSO section.
* man/tac.x: Likewise.
2011-07-08 15:28:16 +01:00
Pádraig Brady
5a647a05e2 timeout: handle signals more transparently
* m4/jm-macros.m4: Define HAVE_SETRLIMIT.
* src/timeout.c: If the child exited with a signal,
raise that signal to the timeout process itself,
so that callers may also see the signal status.
Use setrlimit to disable core dumps for the timeout
process, which would be generated by some signals.
2011-07-08 15:11:27 +01:00
Pádraig Brady
4d90d29899 timeout: support cascaded timeouts
* src/timeout.c (cleanup): Send signals directly to the child
in case it has started its own process group (like a cascaded
timeout command would for example).
* test/misc/timeout-group: Add a test case.
* NEWS: Mention the fix.
2011-07-08 13:54:08 +01:00
Pádraig Brady
4496c94091 timeout: add --foreground to support interactive commands
Or more accurately, commands not started from the shell prompt,
that are interactive, or need to receive Ctrl-C etc. from the terminal.

* doc/coreutils.texi (timeout invocation): Document --foreground.
* src/timeout.c (main): Set the foreground flag and don't create
a separate group.
(cleanup): Only send a signal directly to the monitored command
when the foreground flag is set.
(usage): Describe --foreground.
* tests/misc/timeout-group: Add a new test.
* tests/Makefile.am: Reference new test.
NEWS: Mention the new option.

Reported by Shay Shimony
Analysis by Alan Curry
Fix suggested by Paul Eggert
2011-07-08 11:23:08 +01:00
Benoît Knecht
28a7fb52bc doc: note that cp -l creates _hard_ links
This fact was already noted in the Texinfo manual, but not in the
output of --help.
* src/cp.c (usage): As above, for --help.
Reported by Jari Aalto in http://bugs.debian.org/294327.
2011-07-08 12:15:00 +02:00
Jim Meyering
b358f1f2a3 tests: exercise md5sum's new --strict option
* tests/misc/md5sum: Exercise new --strict option.
2011-07-07 16:42:47 +02:00
Patrick Schoenfeld
33171d049a md5sum, sha1sum, etc: accept new option: --strict
Use this new option with --check when the input is expected to
consist solely of checksum lines.  With only --check, an invalid
line evokes a warning, but the program can still exit successfully.
With --strict, any invalid line makes the program exit non-zero.

* src/md5sum.c (strict, STRICT_OPTION): Declare/define.
(long_options): Add "strict".
(usage): Describe --strict.
(digest_check): Count improperly_formatted lines, too, and use
that number and the global "strict" to determine the return value.
(main): Handle STRICT_OPTION.
Reject --strict without --check.
* doc/coreutils.texi: Describe it.
* NEWS (New features): Mention it.
2011-07-07 16:42:47 +02:00
Benoît Knecht
88bdce982a doc: note date's %k, %l are space-padded and equivalent to %_H and %_I
* src/date.c (usage): As above, for --help.
* doc/coreutils.texi (Time conversion specifiers): Likewise.
Reported by Britton Leo Kerin in http://bugs.debian.org/115833.
2011-07-07 14:01:50 +02:00
Jim Meyering
473b4fc1e8 stat: recognize GPFS as a file system type
* src/stat.c (human_fstype) [S_MAGIC_GPFS]: Add a case,
to handle GPFS_SUPER_MAGIC/0x47504653.  Prompted by this discussion:
http://thread.gmane.org/gmane.comp.sysutils.autoconf.general/14007
* NEWS (Improvements): Mention it.
2011-07-07 13:58:22 +02:00
Jim Meyering
84d048002e maint: use "const" and "pure" function attributes where possible
* configure.ac (WARN_CFLAGS): Add -Wsuggest-attribute=const,
-Wsuggest-attribute=pure and -Wsuggest-attribute=noreturn.
(GNULIB_WARN_CFLAGS): But do not add them here... yet.
* src/chown-core.h (chopt_free, uid_to_name): Add function attribute(s).
* src/copy.c (is_ancestor, valid_options): Likewise.
* src/copy.h (chown_failure_ok): Likewise.
* src/dd.c (operand_matches, operand_is): Likewise.
* src/df.c (selected_fstype, excluded_fstype): Likewise.
* src/expr.c (null looks_like_integer): Likewise.
* src/md5sum.c (hex_digits): Likewise.
* src/od.c (get_lcm): Likewise.
* src/pathchk.c (component_start, component_len): Likewise.
* src/pinky.c (count_ampersands): Likewise.
* src/pr.c (cols_ready_to_print): Likewise.
* src/ptx.c (search_table): Likewise.
* src/sort.c (find_unit_order): Likewise.
* src/stty.c (mode_type_flag, string_to_baud, baud_to_value): Likewise.
* src/system.h (gcd, lcm): Likewise.
* src/tr.c (is_char_class_member, look_up_char_class): Likewise.
(star_digits_closebracket): Likewise.
* src/uniq.c (find_field): Likewise.
* src/wc.c (compute_number_width): Likewise.
* lib/xfts.h (cycle_warning_required): Likewise.
* gl/lib/randint.h (randint_get_source): Likewise.
* gl/lib/randperm.c (ceil_lg): Likewise.
* gl/lib/randperm.h (randperm_bound): Likewise.
* lib/strnumcmp.h (strintcmp): Likewise.
2011-07-02 12:35:06 +02:00
Jim Meyering
76d8e9abe1 buffer_lcm: declare with _GL_ATTRIBUTE_CONST
* lib/buffer-lcm.h (buffer_lcm): Use _GL_ATTRIBUTE_CONST.
* lib/buffer-lcm.c: Include <config.h>.
2011-07-02 12:35:06 +02:00
Pádraig Brady
e7734b4a66 doc: detail the effect of disabling input buffering with stdbuf
* docs/coreutils.texi (stdbuf invocation): Expand on the different
reasons for disabling buffering on input and output.
2011-07-01 22:47:54 +01:00
Bruno Haible
0c87ba4693 doc: mention the restrictions for stdbuf more prominently
* doc/coreutils.texi (stdbuf invocation): List the contraints
on the command being controlled, up front.
2011-07-01 22:44:19 +01:00
Jim Meyering
10ec91d84a doc: improve ls --help grammar
* src/ls.c (usage): Improve grammar.
Reported by Peng Yu.
2011-06-25 14:54:49 +02:00
Jim Meyering
18839ad9c1 doc: clarify an improvement from coreutils-7.0
* NEWS (7.0 Improvements): Mention the command: "ls -1U".
* cfg.mk (old_NEWS_hash): Update.
2011-06-25 07:59:13 +02:00
Jim Meyering
54cbe6e643 maint: don't use gnulib's pathmax module; define PATH_MAX if needed
* bootstrap.conf (gnulib_modules): Remove pathmax.
* src/system.h: Don't include "pathmax.h".
(PATH_MAX) [!PATH_MAX]: Define to 8192.  Defining it to a constant
is preferable to using a definition from pathmax.h that might expand
to pathconf ("/", _PC_PATH_MAX). Prompted by discussion leading to:
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/27183/focus=27269
2011-06-25 07:59:13 +02:00
Jim Meyering
5f4a1cda67 build: bootstrap: remove obsolete gettext-related file exclusions
* bootstrap.conf: Don't bother to exclude gettext/intl-related
.m4 files.  That exclusion is no longer necessary.
2011-06-25 07:59:13 +02:00
Pádraig Brady
171e1b9815 stat: recognize MQUEUE and PSTOREFS file systems
* src/stat.c (human_fstype): Add magic numbers for
PSTOREFS and MQUEUE.
2011-06-24 13:30:57 +01:00
Bernhard Voelker
376b19410e tests: stat-free-color: do not count stat calls before main
* tests/ls/stat-free-color: The system may perform additional stat
calls upon loading (seen on OpenSuSE-11.4).  Count only the number
of stat calls compared to --help.
This also reduces back to "1" the number of expected calls,
effectively reverting part of 2011-06-01 commit, ccf2d9a4.
2011-06-22 16:06:52 +02:00
Bernhard Voelker
6301c72b6f tests: cp/sparse-fiemap: use "head -n99" in place of "head -99"
* tests/cp/sparse-fiemap: Use "head -n99" in place of "head -99".
The latter is officially obsolete.
2011-06-21 14:37:53 +02:00
Jim Meyering
1d919fbb7f tests: init.sh: use "sed 1q" in place of "head -1"
* tests/init.sh (warn_): Use "sed 1q" in place of "head -1".
The latter is officially obsolete but more portable than "head -n1".
Reported by Bernhard Voelker.
2011-06-20 10:01:43 +02:00
Jim Meyering
ea7c77df7f maint: update THANKS.in
* THANKS.in: Remove Stefano's name.
2011-06-20 09:53:24 +02:00
Bernhard Voelker
b970f0a505 tests: improve init.sh by removing w2_
* tests/init.sh (w2_): Remove, moving contents into...
(warn_): ...here.  Call self from subshell when IFS must be changed.
2011-06-20 09:53:20 +02:00
Stefano Lattarini
2f60384d6a tests: avoid extra forks in the testsuite
* tests/shell-or-perl: Prefer the `read' builtin over `grep' to
look at the shebang line of test scripts.  Since `read' is a
special builtin, it might abort the whole program upon failures,
so add extra sanity checks, verifying that the test script exists
and is readable, before trying to read from it.
2011-06-19 21:57:43 +02:00
Stefano Lattarini
a51c6e0356 tests: make test runner a script, not a shell function
This change implements a more correct and idiomatic use of the
features of the Automake-provided 'parallel-tests' harness.
Moreover, this change is required in order for the testsuite to
continue to work with the new testsuite harness that is planned
to be introduced in Automake 1.12 (which, as of the writing date,
is still under development and in alpha state).

* tests/shell-or-perl: New auxiliary script.
* tests/Makefile.am (EXTRA_DIST): Distribute it.
* tests/check.mk (TESTS_ENVIRONMENT): Remove definition of the
`shell_or_perl_' shell function, whose code has been moved in
the new script above (with a few improvements and extensions).
Do not use it to run the test scripts.
(LOG_COMPILER): New, properly invoking `shell-or-perl'.
2011-06-19 21:57:43 +02:00
Jim Meyering
e23f179557 stdbuf: fix automake variable name to work with cutting edge automake
* src/Makefile.am (pkglibexec_PROGRAMS): Rename from pkglib_PROGRAMS.
The latter is invalid.  Without this change, automake
v1.11-373-g9ca6326 and newer (on master) would fail with this:
`pkglibdir' is not a legitimate directory for `PROGRAMS'
This changes the default installation directory of libstdbuf.so from
$prefix/lib/coreutils/ to
$prefix/libexec/coreutils/
* src/stdbuf.c (set_LD_PRELOAD): Search in PKGLIBEXECDIR, not PKGLIBDIR,
since that's where we install libstdbuf.so.
Do not search in "", the system default search path.
2011-06-19 21:57:43 +02:00
Pádraig Brady
24b3c8b160 maint: avoid a false positive syntax check
* cfg.mk (sc_strftime_check): Skip the check when there
is no info to compare against.
Reported by Stefano Lattarini
2011-06-19 11:49:57 +01:00
James Youngman
c8392b368e maint: typo: insert omitted word in test comment
* tests/misc/sort-spinlock-abuse: Fix typo:
s/"very expensive" are/"very expensive" tests are/
2011-06-19 09:16:20 +02:00
Stefano Lattarini
51e9f0308e maint: fix typo in comment in configure.ac
* configure.ac ($MAN): Fix typo in explanatory comment.
2011-06-18 19:37:36 +02:00
Jim Meyering
4c3c2c795e tests: sort-debug-keys: fix a bug with translated diagnostics
Ensure that English diagnostics are emitted even when using
French sorting rules.
* tests/misc/sort-debug-keys: Unset LC_ALL and set LC_COLLATE,
LC_CTYPE and LC_NUMERIC to the fr_FR.UTF-8 locale, while setting
LC_MESSAGES=C.  Reported by Stefano Lattarini.
2011-06-18 08:34:07 +02:00
Pádraig Brady
f0e8f13ead maint: remove duplicate names from THANKS
* .mailmap: Merge email addresses
* THANKS.in: Remove a duplicate name
Reported by Stefano Lattarini
2011-06-17 22:48:22 +01:00
Jim Meyering
23ddefd3d1 maint: use modules/tempname.diff file, not a replacement; update gnulib
Using a .diff is much more maintainable.  Otherwise, changes in
the gnulib module description file may not be noticed and merged
promptly and may even result in subtle errors.  Luckily, this time,
the failure to propagate gnulib's changes to modules/tempname resulted
only in an obvious link failure.
* gl/modules/tempname: Remove file.
* gl/modules/tempname.diff: Use a .diff file instead.
* gnulib: Update submodule to latest.
2011-06-17 12:11:03 +02:00
Jim Meyering
7df26ae6fe tests: avoid sort-spinlock-abuse false positive under heavy load
* tests/misc/sort-spinlock-abuse: Classify as "very expensive" to
avoid unwarranted failure once and for all.
2011-06-17 12:11:03 +02:00
Jim Meyering
2e580ca741 tests: remove skip_test_ function; use new skip_ instead
* tests/init.cfg (skip_test_): Remove function.
Use skip_ in place of skip_test_ everywhere else.
* cfg.mk (sc_prohibit_skip_): Remove rule.
* tests/**: Use skip_, not skip_test_, everywhere.
2011-06-17 09:17:37 +02:00
Jim Meyering
13672ec321 tests: make init.sh's warn_ emit to both the tty and the log file
* tests/init.sh (warn_): When $stderr_fileno_ != 2,
emit the diagnostic to both the tty and the log file.
2011-06-17 09:17:30 +02:00
Jim Meyering
7f8d9892fb tests: use printf, not echo in init.sh's warn_ function
* tests/init.sh (warn_): Use printf, not echo.  The latter would
misbehave when given strings containing a backslash or starting
with e.g., -n.  James Youngman suggested setting IFS.
2011-06-17 08:54:08 +02:00
Jim Meyering
6b687452d8 tests: accommodate HP-UX and ksh-derived shells
Running "make check" normally prints a diagnostic to the outermost
stderr (usually a tty) to explain why a test is skipped.  It did this
by redirecting FD 9 to stderr (via "exec 9>&2") before invoking the
shell script.  Shell scripts write skip-explanation to FD 9 via
init.sh's skip_ function.  However, with ksh and HP-UX's /bin/sh,
the effects of "exec 9>&2" are canceled upon fork-and-exec, so we
would get a "Bad file number" diagnostic and no skip explanation on
those systems.
* tests/check.mk (TESTS_ENVIRONMENT): Redirect more portably, via
"$(SHELL) 9>&2", rather than the prior "exec 9>&2; $(SHELL) ..."
Actually, we use "shell_or_perl_ 9>&2", to make this effective
also for the perl-based tests.
* tests/init.sh (stderr_fileno_): Update the advice in comments.
See http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22488
for lots of discussion.  Stefano Lattarini suggested the solution
of putting "9>&2" after the command.  Reported by Bruno Haible.
2011-06-14 11:05:05 +02:00
Jim Meyering
ef6e57b24b init.sh: sync from gnulib
* tests/init.sh: Sync recent changes from gnulib.
2011-06-13 18:34:03 +02:00
Jim Meyering
83e424e731 maint: revert previous commit
Revert "init.sh: accommodate shells for which 1>&$stderr_fileno_ fails"
This reverts commit 6fb9aeedd1.
That change did not solve the problem.  For details, see
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846#74
2011-06-13 18:34:03 +02:00
Jim Meyering
6fb9aeedd1 init.sh: accommodate shells for which 1>&$stderr_fileno_ fails
* tests/init.sh (warn_): Use eval to work around a bug in some shells,
like those of Solaris 10 and HP-UX 11.11.
Improved by Stefano Lattarini.
2011-06-13 12:42:18 +02:00
Jim Meyering
2f5c2a25ed doc: add NEWS items for recent gnulib fixes
* NEWS (Improvements): Mention the new HP-UX 11.11 ACL support.
(Build-related): Mention the cc/HP-UX 11.11 build fix.
2011-06-13 12:39:23 +02:00
Jim Meyering
cd94370f74 tests: avoid sort-spinlock-abuse false positive under heavy load
* tests/misc/sort-spinlock-abuse: This test would frequently fail
when run on a system under heavy load.  Increase duration and limit.
2011-06-13 12:39:22 +02:00
James Youngman
5a3879ad03 maint: use stat-size module from gnulib
* gnulib: Update to latest.
* src/system.h: Definitions of ST_* macros have moved into the
gnulib module stat-size (specifically, the header file
stat-size.h), so remove them from here.
* src/truncate.c: Include stat-size.h.
* src/stat.c: Likewise.
* src/shred.c: Likewise.
* src/ls.c: Likewise.
* src/du.c: Likewise.
* src/ioblksize.h: New file.  Move definition of io_blksize out of
system.h so that system.h does not have to include stat-size.h.
* src/cat.c: Include ioblksize.h.
* src/split.c: Likewise.
* src/copy.c: Include both stat-size.h and ioblksize.h.
* src/Makefile.am (noinst_HEADERS): Add ioblksize.h.
2011-06-13 12:39:22 +02:00
Pádraig Brady
e4feb5c03b tests: avoid a false failure on HPUX systems
* tests/dd/nocache: Relax the test, as the system
may return various errors from posix_fadvise().
HPUX 11.31 returns ENOTTY for example.
Reported by Bruno Haible
2011-06-13 11:36:06 +01:00
Jim Meyering
7c77c93dc5 tests: inotify-rotate: avoid false positive under heavy load
* tests/tail-2/inotify-rotate: Increase timeout from 10s to 40s
to avoid load-induced false positive.
2011-06-11 13:54:12 +02:00
Pádraig Brady
869202a18c maint: remove unneeded includes
Remove unneeded includes as reported by:
http://code.google.com/p/include-what-you-use/

* src/cp-hash.c: Remove unused include.
* src/dd.c: Likewise.
* src/du.c: Likewise.
* src/head.c: Likewise.
* src/kill.c: Likewise.
* src/ls.c: Likewise.
* src/stdbuf.c: Likewise.
* src/timeout.c: Likewise.
* src/truncate.c: Likewise.
2011-06-09 15:19:46 +01:00
Pádraig Brady
77d41d2e20 doc: add examples to date --help
* src/date.c (usage): Add examples for TZ handling,
and "seconds since epoch" parsing, neither of which
was mentioned in the man page until now.
* THANKS.in: Add Rick.
Suggested by Rick Stanley.
2011-06-09 15:07:42 +01:00
Jim Meyering
c2b25223c1 build: require at least 2-year old autoconf-2.64 (was 2.62)
* configure.ac: Require autoconf-2.64, which is nearly two years old.
* src/system.h (emit_ancillary_info): Use PACKAGE_URL, now that we
require autoconf-2.64.
2011-06-04 10:57:01 +02:00
Jim Meyering
b7332b889e maint: remove now-spurious curly braces
* src/chown-core.c (restricted_chown): Remove FIXME comment and
superfluous curly braces.
2011-06-04 10:56:56 +02:00
Jim Meyering
ccf2d9a482 tests: stat-free-color: accommodate stat of /selinux on rawhide
* tests/ls/stat-free-color: This test recently began to fail on
rawhide because dynamic library start-up code now stats "/selinux",
making the total number of calls 2 rather than the prior 1.
Create two more dangling symlinks, so that any erroneous stat-
or lstat-calling code will get at least those three.
2011-06-01 16:12:04 +02:00
Marek Polacek
cc8ee4d351 yes.c: do not use exit after error
I think it would be better to exit through the error() and not
to call the exit() after the error().  This way we can get rid of
one function call (and curly brackets).

* src/yes.c (main): Exit through the error(), remove exit() call
after error().
2011-06-01 08:05:29 -06:00
Jim Meyering
e7b4bf4b57 tail: fix an inconsequential bug spotted by coverity
* src/tail.c (start_bytes): Increase *READ_POS (not READ_POS)
by the number of bytes read.  This is a real bug that happens
to have no consequence in practice.  First, this code is exercised
only when tailing-forever a non-regular file by bytes, and with a
start-relative offset, e.g., "mkfifo f; tail -f -c +3 f", but even
then, the invalid READ_POS value does not influence how tail works.
It is stored in the File_spec.size member, but that member is not
used at all in tail_forever_inotify, and in tail_forever, it is
used only when the File_spec refers to a regular file.
2011-06-01 13:49:04 +02:00
Paul Eggert
c1716a1ebf * doc/coreutils.texi (sort invocation): I/0 -> I/O (sr#107504) 2011-05-31 09:59:22 -07:00
Jim Meyering
5c557690d8 maint: remove unnecessary gnulib .diff file
* gl/modules/getloadavg.diff: Remove file.  It stopped being
useful back in February.
* Makefile.am (EXTRA_DIST): Remove it.
2011-05-29 14:37:41 +02:00
Jim Meyering
d4aca64b53 maint: placate -Wsign-compare when it's non-invasive
* src/stdbuf.c: Declare loop index to be unsigned.
2011-05-29 12:16:11 +02:00
Jim Meyering
31bbcc7abf ls: placate gcc-4.7.0's -Wstrict-overflow
* src/ls.c (enum parse_state): Define.
(parse_ls_color): Use enum names in place of constants,
thus avoiding the offending -1.
2011-05-28 22:10:00 +02:00
Jim Meyering
d0a9750e08 maint: remove useless (off_t) cast of lseek arg
* src/wc.c (wc): Remove unnecessary cast.
* src/head.c (elide_tail_bytes_file, elide_tail_lines_file): Likewise.
* src/tac.c (tac_seekable, tac_file): Likewise.
2011-05-28 13:52:17 +02:00
Jim Meyering
963d809ae9 tests: move tests/misc/split-* into tests/split/...
* tests/split/suffix-length: Rename from tests/misc/split-a.
* tests/split/b-chunk: Rename from misc/split-bchunk.
* tests/split/fail: Rename from tests/misc/split-fail.
* tests/split/lines: Rename from tests/misc/split-l.
* tests/split/l-chunk: Rename from tests/misc/split-lchunk.
* tests/split/r-chunk: Rename from tests/misc/split-rchunk.
* tests/Makefile.am (TESTS): Reflect renaming.
2011-05-28 13:52:17 +02:00
Pádraig Brady
54a49f22ae chown,chgrp: output the original ownership in -v messages
* src/chown-core.c (describe_change): Output the
original owner if possible.
(user_group_str): Handle the case when neither
owner or group are passed.
* NEWS: Mention the change in behavior.
2011-05-27 23:21:46 +01:00
Pádraig Brady
6b282e7510 chown,chgrp: output the correct ownership in -v messages
* src/chown_core.c (describe_change): Accept the ownership of
the original file and output that when not changing.
This is significant when --from is specified as then
the original and specified ownership may be different.
(user_group_str): A new helper function refactored from
describe_change().
(change_file_owner): Pass the original user and group
strings to describe_change().
* test/chown/basic: Add a test case.
* NEWS: Mention the fix.
2011-05-27 22:37:46 +01:00
Pádraig Brady
8a26bccb46 maint: fix a -Wstrict-overflow build failure with gcc 4.5
* src/ls.c (print_color_indicator): Avoid the warning by
not decrementing the integer.
2011-05-27 00:39:55 +01:00
Jim Meyering
ad756440fb build: --enable-gcc-warnings: enable -Wstrict-overflow in src/
* configure.ac (WARN_CFLAGS): Don't turn off -Wstrict-overflow.
(GNULIB_WARN_CFLAGS): Remove -Wstrict-overflow from the list of
warning options used in lib/.
Normally I find that -Wstrict-overflow produces too many false
positives, but considering that it warns of the bug reported in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498, I now think
it is worthwhile.  The lesser of two evils.
Thanks to Daniel Veillard for showing me the gcc bug report.
2011-05-26 22:13:54 +02:00
Jim Meyering
419b6c9d42 maint: accommodate gcc's -Wstrict-overflow option
* src/factor.c (factor_using_pollard_rho): Change type of "i"
to unsigned to avoid warning from gcc's -Wstrict-overflow.
* src/expr.c: Use an unsigned intermediate.
* src/dircolors.c (main): Reorder operations to avoid the risk of
pointer overflow.
* src/tr.c (squeeze_filter): Change NOT_A_CHAR from an anonymous
"enum" to an "int", to avoid this warning:
tr.c:1624:10: error: assuming signed overflow does not occur when
  simplifying conditional to constant [-Werror=strict-overflow]
* src/pr.c (main): Make index "i" unsigned.
2011-05-26 22:13:37 +02:00
Jim Meyering
d7e2365203 maint: enforce cpp indentation policy
* cfg.mk (sc_preprocessor_indentation): New test, from libvirt.
Exempt 3 files from new cppi test.
* gl/lib/randread.c: Adjust cpp indentation to comply.
* src/extent-scan.c (extent_need_sync): Likewise.
2011-05-26 22:10:46 +02:00
Jim Meyering
3f98fe3155 maint: env.c: remove unnecessary use of strchr
* src/env.c (main): Remove excess (and confusing to static analyzers)
use of strchr.
2011-05-26 22:10:46 +02:00
Jim Meyering
a042bba6c7 shred: placate coverity and fix a comment
* src/shred.c (incname): Add an assertion to tell static analyzers
that we know this particular use of strchr never returns NULL.
Finish incomplete sentence in function-describing comment.
2011-05-26 22:10:46 +02:00
Pádraig Brady
41139da2e7 maint: split: remove --filter specific code from other paths
* src/split.c (lines_chunk_split): Don't use ignore_error() which
is redundant and confusing when not running with --filter.
(lines_rr): Likewise.
(ofile_open): Likewise. Add a comment to clarify that
filters aren't restarted under file descriptor pressure.
2011-05-26 00:28:14 +01:00
Pádraig Brady
bfffa90947 split: diagnose when --filter is used with a chunk number
* src/split.c (main): Exit with a diagnostic if --filter
is specified along with a specific chunk number.
* test/split/filter: Ensure this combination fails.
2011-05-26 00:23:11 +01:00
Pádraig Brady
6eec064597 split: exit when we can no longer write to a --filter
* src/split.c (bytes_split): Stop reading when we
can no longer write to a child process.
(lines_rr): Likewise.
(lines_bytes_split): No change is made here since
input is bounded by the original file size.
* test/split/filter: Add test cases.
2011-05-26 00:12:05 +01:00
Pádraig Brady
5908e29e82 split: return success even if a --filter exits
src/split.c (main): Don't unblock SIGPIPE before cleanup,
as then any pending signals will be sent and cause
the main split process to exit with a non zero status (141).
* test/split/filter: Add a test for this case.
2011-05-26 00:10:32 +01:00
Pádraig Brady
d92849fe5a split: fix an edge case where -n l/... creates an extra file
* src/split.c (lines_bytes_chunk): Handle the edge case
where the file is truncated as we read.
* tests/misc/split-lchunk: Cleanup; no functional change.
2011-05-25 23:04:58 +01:00
Bernhard Voelker
e89c998a9e chmod: output the original mode in verbose mode
* src/chmod.c (describe_change): Pass in the original mode,
and output this in the messages.
* tests/chmod/c-option: Adjust as per the new message.
* THANKS.in: Remove the now auto-generated name.
* NEWS: Mention the change in behavior.

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2011-05-25 23:04:12 +01:00
Jim Meyering
bf9d4f1317 tests: ls/stat-free-color: fix unwarranted failure on a 32-bit system
* tests/ls/stat-free-color: Also check for stat64 and lstat64 syscalls.
This fixes a test failure reported by Stefano Lattarini.
2011-05-25 08:27:34 +02:00
Jim Meyering
56a88e9522 maint: accommodate gnulib's newer tight_scope rule
* cfg.mk: Include via "-include", to accommodate new tight-scope rule.
(sc_check-AUTHORS): Change the name of the rule in src/Makefile.am
to _sc_check-AUTHORS, so it doesn't conflict with this one when
this file is included into the sub-make's context.
* src/Makefile.am (_sc_check-AUTHORS): Rename from sc_check-AUTHORS.
* gnulib: Update to latest.
2011-05-25 08:26:14 +02:00
Jim Meyering
484df12639 doc: make README-hacking slightly more generic
* README-hacking: Remove a reference to "coreutils".
2011-05-25 08:26:14 +02:00
Jim Meyering
dac67b8cc2 touch: placate static analyzers: no NULL-deref is possible
* src/touch.c (main): Avoid even the hint of possibility that
we'd dereference NULL upon localtime failure.  Coverity reported
the potential, but it appears not to be possible, since posixtime
rejects any time for which the subsequent localtime would return NULL.
See http://thread.gmane.org/gmane.comp.gnu.coreutils.general/1253
2011-05-25 08:25:54 +02:00
Pádraig Brady
7d44751f0e split: fix cases where -n l/... creates extraneous files
* src/split.c (lines_chunk_split): Ensure that data is only
written to stdout when k specified.  Also ensure that
extra files are not created when there is more data available
than reported in the file size.
* tests/misc/split-lchunk: Verify that split -n l/k/n doesn't
generate any files, and that -n l/n always generates n files.
* NEWS: Mention the fix.
2011-05-24 16:29:48 +01:00
Stéphane Raimbault
9ead32a9be doc: add a missing space in timeout --help
* src/timeout.c (usage): Add a space to be consistent
with other uses of "(the default)" in the documentation.

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2011-05-24 16:17:02 +01:00
Pádraig Brady
64ceb14984 doc: improve tail -f vs. inotify description and advice
* doc/coreutils.texi (tail invocation): Adjust, and add an example.
2011-05-24 12:04:54 +02:00
Jim Meyering
0a8d30534b maint: avoid trivial syntax-check failure
* doc/coreutils.texi (tail invocation): Use @var{n}, not @var{N}.
2011-05-23 20:03:58 +02:00
Karl Berry
ac9c5330df maint: README-hacking clarifications
* README-hacking: Small getting-started clarifications.
2011-05-23 19:07:25 +02:00
Jim Meyering
acbfebeb8d doc: describe how kernel inotify support affects tail -f
* doc/coreutils.texi (tail invocation) [-f]: Mention how inotify
kernel support makes a difference.
Prompted by http://bugzilla.redhat.com/662900
2011-05-23 16:09:52 +02:00
Jim Meyering
d61f5a1c16 tests: fix typo in tac-continue
* tests/misc/tac-continue: Fix typo in usually-skipped test:
s/mkfifo_or_skip/mkfifo_or_skip_/ (i.e., append "_").
This test is usually skipped, because I'm probably the only
one to set the FULL_PARTITION_TMPDIR envvar, and recently the
one I'd been using ceased to exist, so this test was skipped
even for me.  Good argument for making this a root-only test
and creating a full partition just for this test case.
2011-05-22 17:10:31 +02:00
Jim Meyering
12c5386a30 doc: fix a formatting nit in od's texinfo documentation
* doc/coreutils.texi (od invocation): Typesetting of "bytes" was wrong.
Fix it via s/@code/@var/ so it's consistent.
2011-05-22 09:11:19 +02:00
Ivan Sichmann Freitas
485a454576 maint: fix comment typos in df.c
* src/df.c: s/Optain/Obtain/
2011-05-21 10:39:48 +02:00
Jim Meyering
cb4a0e31e2 maint: correct typos involving misuse of "a" and "an"
* NEWS: "an misleading"
* src/expr.c: "a integer
* src/ptx.c (find_occurs_in_text): "a end"
* src/shred.c (do_wipefd): "a infinite"
* src/sort.c (SUBTHREAD_LINES_HEURISTIC): "an dual-core"
(compare_random): "an checksum"
* cfg.mk (old_NEWS_hash): Update, since the typo was in old news.
2011-05-19 21:36:33 +02:00
Pádraig Brady
beaa949313 printf: fix an out-of-bounds memory access
* src/printf.c (STRTOX): Don't access memory after a
string containing a single quote character.
* tests/misc/printf: Add tests for various combinations
of single quote characters combined with a numeric format.
* THANKS.in: Add bug reporter.
* NEWS: Mention the fix.

Reported-by: Paul Marinescu <paul.marinescu@imperial.ac.uk>
2011-05-18 07:33:04 +01:00
Pádraig Brady
50ca38e523 doc: mention that ls time ordering is newest first
* src/ls.c (usage): Add the "newest first" info to
the -t and -c options
2011-05-17 07:51:44 +01:00
Pádraig Brady
5116103826 tests: refactor more tests to use mkfifo_or_skip_
* tests/cp/existing-perm-race: s/mkfifo/mkfifo_or_skip_/
* tests/cp/file-perm-race: Likewise.
* tests/cp/parent-perm-race: Likewise.
* tests/cp/special-f: Likewise.
* tests/dd/reblock: Likewise.
* tests/ls/file-type: Likewise.
* tests/misc/cat-buf: Likewise.
* tests/misc/mknod: Likewise.
* tests/misc/printf-surprise: Likewise.
* tests/misc/selinux: Likewise.
* tests/misc/sort-spinlock-abuse: Likewise.
* tests/misc/stdbuf: Likewise.
* tests/misc/tac-continue: Likewise.
* tests/init.cfg: Improve the error message when skipping.
2011-05-14 10:41:29 +01:00
Pádraig Brady
27873f1deb shuf: use memory more efficiently when returning a subset
* gl/lib/randperm.c (randperm_new): When the number of items
to return H, is much smaller than the total number of items N,
use a hash to represent the sparse permutations of the set N.
This is currently enabled for N > 128K and N/H > 32.
* tests/misc/shuf: Ensure shuf can quickly return 2 numbers
from a large range.
* gl/modules/randperm: Depend on hash.
* NEWS: Mention the change.
2011-05-14 10:30:12 +01:00
Jim Meyering
9d152a1ed7 maint: avoid syntax-check failure due to long line
* tests/du/bigtime (future_time): Split long line.
2011-05-13 23:37:23 +02:00
Jim Meyering
76f49e601e maint: add new syntax-check rule to prohibit use of skip_
* cfg.mk (sc_prohibit_skip_): New rule.
* tests/init.cfg (skip_test_): Add a comment.
2011-05-13 18:57:31 +02:00
Jim Meyering
89d542f3d8 tests: use skip_test_, not skip_
skip_test_ emits its diagnostic both to FD 9 (tty), and to
FD 2 (usually the log file), whereas init.sh's skip_ emits
only to FD 9.  Without that, the log is slightly less useful.
* tests/cp/fiemap-2: Use skip_test_, not skip_.
* tests/cp/fiemap-perf: Likewise.
* tests/du/bigtime: Likewise.
* tests/du/files0-from-dir: Likewise.
* tests/du/move-dir-while-traversing: Likewise.
* tests/init.sh: Likewise.
* tests/misc/sort-stale-thread-mem: Likewise.
* tests/misc/stat-nanoseconds: Likewise.
* tests/mv/i-3: Likewise.
* tests/mv/sticky-to-xpart: Likewise.
* tests/split/filter: Likewise.
Prompted by a report from Pádraig Brady.
2011-05-13 18:38:52 +02:00
Jim Meyering
a085b6fc6c ls: allow stat-free use of --color
Even on a system with d_type support, the default use of --color
makes ls stat every file in order to be able to honor settings like
EXEC, STICKY, ORPHAN, SETUID, etc., because those settings require
information that is not provided by dirent.d_type.  However, if
for a potentially large performance gain, you are willing to disable
those settings, you can now make ls --color give type-related coloring
and perform no stat calls at all (other than the unavoidable call-per-
command-line argument).  Before this change, even with all of those
attributes disabled, ls --color would still stat every directory.
Now, we're down to the minimum of one stat call per command-line arg.
* src/ls.c (gobble_file): With --color, don't stat a
non-command-line-specified directory when no directory-coloring
attribute is enabled.
* tests/init.cfg (require_dirent_d_type_): New function.
* tests/d_type-check: New script, mostly from Pádraig Brady.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/ls/stat-free-color: New test.
* tests/Makefile.am (TESTS): Add it.
* doc/coreutils.texi (General output formatting): Describe how
to use dircolors to make ls --color refrain from calling stat
on a d_type-enabled file system.
Prompted by a query from Josef Bacik.
2011-05-13 18:28:43 +02:00
Jim Meyering
6bc73ee56e maint: use <unistd.h>, not "group-member.h"
gnulib's group-member module now ensures that the group_member
function is declared in <unistd.h>, just like it is glibc.
* lib/euidaccess-stat.c: Remove inclusion of "group-member.h".
* src/chgrp.c: Likewise.
2011-05-12 08:23:52 +02:00
Jim Meyering
eec0e6d2e4 build: update gnulib submodule to latest 2011-05-12 08:23:52 +02:00
Jim Meyering
9418e01abe maint: remove syntax-checking sc_tight_scope rule
* src/Makefile.am (sc_tight_scope): Remove rule.
Now it's provided via gnulib's maint.mk.
* cfg.mk (sc_tight_scope): Likewise.
2011-05-11 17:20:33 +02:00
Jim Meyering
2141543a37 maint: tail: mark a global variable as static
* src/tail.c [HAVE_INOTIFY] (inotify_wd_mask): Declare static.
2011-05-11 17:17:53 +02:00
Pádraig Brady
73fd918bd0 maint: remove -Wmissing-field-initializers workarounds
* configure.ac: Rather than disabling -Wmissing-field-initializers,
use the fact that gnulib now disables it automatically when required
(on versions of GCC older than 4.7).
* src/system.h: Remove the no longer needed DECLARE_ZEROED_AGGREGATE.
* src/ls.c: Likewise.
* src/pathchk.c: Likewise.
* src/shred.c: Likewise.
* src/stty.c: Likewise.
* src/wc.c: Likewise.
2011-05-08 17:38:37 +01:00
Jim Meyering
3c8ff029d4 tests: don't fail the split --filter=CMD test if xz is not available
* tests/split/filter: Skip if xz is not installed.
2011-05-07 07:48:00 +02:00
Jim Meyering
09baf2287e doc: document split's new --filter=CMD option
* doc/coreutils.texi (split invocation): Describe --filter=CMD.
* NEWS (New feature): Mention it.
2011-05-06 22:54:51 +02:00
Jim Meyering
2644e288e4 tests: test split's new --filter=CMD option
* tests/Makefile.am (TESTS): Add split/filter.
* tests/split/filter: New file.
2011-05-06 22:54:51 +02:00
Karl Heuer
a09d9e5bad split: accept new output --filter=CMD option
* src/split.c: Include <signal.h>, <sys/wait.h> and "sig2str.h".
(FILTER_OPTION): New anonymous enum member.
(filter_command, filter_pid): New globals.
(open_pipes, open_pipes_alloc, n_open_pipes): Likewise.
(oldblocked, newblocked): Likewise.
(longopts): Add "filter".
(usage): Document --filter.
(create): Extend to create a pipe and fork "sh -c CMD".
(closeout): Adapt to close a pipe and wait for child process.
(cwrite): Call closeout, not just close.
(lines_chunk_split): FIXME
(bytes_chunk_extract): FIXME
(opid, ofile_open, lines_rr, main): FIXME
(ignorable): New function, to encapsulate EPIPE test.
2011-05-06 22:54:51 +02:00
Jim Meyering
a1f21327eb build: update gnulib submodule to latest 2011-05-06 17:05:49 +02:00
Pádraig Brady
ebce7bfb1b sort: fix a contradictory --debug warning
* src/sort.c (key_warn): `sort -k2,1n --debug` would output
warnings about being both "zero width" and "spanning multiple fields".
Suppress the latter one.
* tests/misc/sort-debug-warn: Add a couple of test cases.
2011-05-06 08:07:46 +01:00
Pádraig Brady
9aeffd3fe5 df: fix crash in mem exhaustion edge case
* src/df.c (print_table): Don't try to output NULL
if ambsalign() can't allocate memory.  Instead just
output the unaligned text.
2011-05-05 16:32:14 +01:00
Jim Meyering
719dcc7f01 maint: remove use of gnulib's obsolete strtol module
* bootstrap.conf (gnulib_modules): Remove now-obsolete "strtol".
Remove use of $obsolete_gnulib_modules: unused since commit edc69f91.
2011-05-03 10:25:32 +02:00
Jim Meyering
73243f181d maint: remove unnecessary listing of update-copyright in Makefile.am
* Makefile.am (changelog_etc): Don't list update-copyright here.
It is automatically included via gnulib-tool-generated lib/gnulib.mk.
2011-05-03 10:25:32 +02:00
Jim Meyering
9d282141ba doc: remove a name from THANKS.in that is derived from git log
* THANKS.in: Remove a now-duplicate name.
2011-05-03 10:25:32 +02:00
Jim Meyering
47ef7504da copy: fix my typo
* src/copy.c (copy_reg): Fix my typo (mis-applied patch).
The patch by Jeff Liu was fine, but I mis-applied it
and introduced a compilation error in commit efa479c1.

2011-05-03  Jim Meyering  <meyering@redhat.com>
2011-05-03 10:24:18 +02:00
Jim Meyering
4b28ff7f32 build: avoid bootstrap failure when $GZIP is set
Running "GZIP=-9 ./bootstrap" would fail right away, because the
tool-version-checking code would treat the upper-cased program name
as an environment variable name and if that has a value use the
result as the application name.  That works fine for automake,
autoconf, etc. but not for gzip.
* bootstrap (check_versions): Do not treat $GZIP as a program name.
If defined at all, it is supposed to list gzip options.
Reported by Alan Curry in http://debbugs.gnu.org/8609
2011-05-03 10:15:13 +02:00
Jeff Liu
efa479c1e5 copy: correct misuse of quote in diagnostic
* src/copy.c (copy_reg): Multiple uses of quote (s) in an
argument list is erroneous.  Use quote_n, instead.
2011-05-03 10:15:13 +02:00
Jim Meyering
b83d289685 maint: adjust split.c formatting to conform
* src/split.c (usage): Correct indentation.
(ofile_open): Likewise.
(create): "char *name", not "char* name".
(struct of_info) [ofile]: Similar.
(parse_chunk): Add spaces around "+".
2011-04-30 12:20:56 +02:00
Eric Blake
c1effb1f2b build: update to latest gnulib
* gnulib: Update to latest.
* bootstrap.conf (gnulib_modules): Add xgetgroups.
2011-04-29 11:03:33 +02:00
Jim Meyering
d78ccd5949 tests: distribute new file, CuSkip.pm
Without this, most perl-based tests would fail in "make distcheck".
* tests/Makefile.am (EXTRA_DIST): Add CuSkip.pm
2011-04-29 11:03:33 +02:00
Jim Meyering
3ed91fc8b9 tests: remove useless test: misc/pwd-unreadable-parent
* tests/Makefile.am (TESTS): Remove misc/pwd-unreadable-parent.
This test was misleading and useless (was always skipped).
Inspired by a report from Bruno Haible: http://debbugs.gnu.org/8570
* tests/misc/pwd-unreadable-parent: Remove file.
2011-04-28 22:45:34 +02:00
Jim Meyering
1560848265 tests: write skip explanation from perl scripts also to outer stderr
* tests/CuSkip.pm (skip): New file/module/function, to help
the perl test scripts "skip" a test consistently, emitting
a diagnostic both into the log file and into the outermost
stderr stream that is more likely to be seen by a human.
* tests/check.mk (TESTS_ENVIRONMENT): Add -MCuSkip.
* tests/misc/date-next-dow: Use CuSkip::skip in place of warn+exit-77.
* tests/misc/tty-eof: Likewise.
* tests/misc/uniq: Likewise.
* tests/rm/fail-eperm: Likewise.
* tests/misc/md5sum-newline: Likewise.  Also, s/program_name/ME/.
* tests/misc/ls-misc (setuid_setup, main): Likewise.
* tests/misc/pwd-long: Likewise, and add -I"$abs_srcdir" -MCuSkip
to the $PERL invocation command.
Inspired by a request from Bruno Haible regarding misc/tty-eof:
http://debbugs.gnu.org/8570
2011-04-28 22:43:56 +02:00
Jim Meyering
e3f814a773 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2011-04-26 16:18:02 +02:00
406 changed files with 3316 additions and 1778 deletions

View File

@@ -23,6 +23,8 @@ Pádraig Brady <p@draigBrady.com> <P@draigBrady.com>
<jrv@debian.org> <jrvz@comcast.net>
<dave.anglin@nrc.ca> <dave@hiauly1.hia.nrc.ca>
<psfales@alcatel-lucent.com> <psfales@lucent.com>
<karl@gnu.org> <karl@freefriends.org>
<stephane.raimbault@gmail.com> <stephane.raimbault@makina-corpus.com>
# Prefer spelled-out middle name and its address.
Arne Henrik Juul <arnej@imf.unit.no> Arne H. Juul <arnej@solan.unit.no>

View File

@@ -1 +1 @@
8.11
8.12

31
HACKING
View File

@@ -349,10 +349,25 @@ this code enables the right mode:
(not (string-equal mode-name "Makefile")))
(setq indent-tabs-mode nil))))
[*] Makefile and ChangeLog files are exempt, of course.
If you use vim (7+ compiled with autocommands), and coreutils working
directory name also matches, add the following in ~/.vimrc:
[FIXME: suggest vim syntax to do same thing, if it can be done safely.
Most distros now "set nomodeline" by default for a good reason. ]
" Set GNU style indentation, spaces instead of TABs
function! CoreutilsIndent()
" Check if 'coreutils' is part of the current working directory
if match(getcwd(), "coreutils") > 0
" The next 3 lines below set the GNU indentation
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal shiftwidth=2
setlocal tabstop=8
" Coreutils specific, expand TABs with spaces
setlocal expandtab
endif
endfunction
autocmd BufEnter *.c,*.h call CoreutilsIndent()
[*] Makefile and ChangeLog files are exempt, of course.
Send patches to the address listed in --help output
@@ -415,6 +430,16 @@ as possible. Note to run tests/misc/new-test in isolation you can do:
(cd tests && make check TESTS=misc/new-test VERBOSE=yes)
Variables that are significant for tests with their default values are:
VERBOSE=yes
RUN_EXPENSIVE_TESTS=no
RUN_VERY_EXPENSIVE_TESTS=no
SHELL=/bin/sh
NON_ROOT_USERNAME=nobody
NON_ROOT_GROUP=$(id -g $NON_ROOT_USERNAME)
COREUTILS_GROUPS=$(id -G)
There are hundreds of tests in the tests/ directories. You can use
tests/sample-test as a template, or one of the various Perl-based ones
in tests/misc.

View File

@@ -25,7 +25,6 @@ changelog_etc = \
ChangeLog-2007 \
ChangeLog-2008 \
build-aux/ChangeLog-2007 \
build-aux/update-copyright \
doc/ChangeLog-2007 \
lib/ChangeLog-2007 \
m4/ChangeLog-2007 \
@@ -53,7 +52,6 @@ EXTRA_DIST = \
build-aux/cvsu \
cfg.mk \
dist-check.mk \
gl/modules/getloadavg.diff \
maint.mk \
thanks-gen

116
NEWS
View File

@@ -1,5 +1,110 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 8.13 (2011-09-08) [stable]
** Bug fixes
chown and chgrp with the -v --from= options, now output the correct owner.
I.E. for skipped files, the original ownership is output, not the new one.
[bug introduced in sh-utils-2.0g]
cp -r could mistakenly change the permissions of an existing destination
directory. [bug introduced in coreutils-6.8]
cp -u -p would fail to preserve one hard link for each up-to-date copy
of a src-hard-linked name in the destination tree. I.e., if s/a and s/b
are hard-linked and dst/s/a is up to date, "cp -up s dst" would copy s/b
to dst/s/b rather than simply linking dst/s/b to dst/s/a.
[This bug appears to have been present in "the beginning".]
fts-using tools (rm, du, chmod, chgrp, chown, chcon) no longer use memory
proportional to the number of entries in each directory they process.
Before, rm -rf 4-million-entry-directory would consume about 1GiB of memory.
Now, it uses less than 30MB, no matter how many entries there are.
[this bug was inherent in the use of fts: thus, for rm the bug was
introduced in coreutils-8.0. The prior implementation of rm did not use
as much memory. du, chmod, chgrp and chown started using fts in 6.0.
chcon was added in coreutils-6.9.91 with fts support. ]
pr -T no longer ignores a specified LAST_PAGE to stop at.
[bug introduced in textutils-1.19q]
printf '%d' '"' no longer accesses out-of-bounds memory in the diagnostic.
[bug introduced in sh-utils-1.16]
split --number l/... no longer creates extraneous files in certain cases.
[bug introduced in coreutils-8.8]
timeout now sends signals to commands that create their own process group.
timeout is no longer confused when starting off with a child process.
[bugs introduced in coreutils-7.0]
unexpand -a now aligns correctly when there are spaces spanning a tabstop,
followed by a tab. In that case a space was dropped, causing misalignment.
We also now ensure that a space never precedes a tab.
[bug introduced in coreutils-5.3.0]
** Changes in behavior
chmod, chown and chgrp now output the original attributes in messages,
when -v or -c specified.
cp -au (where --preserve=links is implicit) may now replace newer
files in the destination, to mirror hard links from the source.
** New features
date now accepts ISO 8601 date-time strings with "T" as the
separator. It has long parsed dates like "2004-02-29 16:21:42"
with a space between the date and time strings. Now it also parses
"2004-02-29T16:21:42" and fractional-second and time-zone-annotated
variants like "2004-02-29T16:21:42.333-07:00"
md5sum accepts the new --strict option. With --check, it makes the
tool exit non-zero for any invalid input line, rather than just warning.
This also affects sha1sum, sha224sum, sha384sum and sha512sum.
split accepts a new --filter=CMD option. With it, split filters output
through CMD. CMD may use the $FILE environment variable, which is set to
the nominal output file name for each invocation of CMD. For example, to
split a file into 3 approximately equal parts, which are then compressed:
split -n3 --filter='xz > $FILE.xz' big
Note the use of single quotes, not double quotes.
That creates files named xaa.xz, xab.xz and xac.xz.
timeout accepts a new --foreground option, to support commands not started
directly from a shell prompt, where the command is interactive or needs to
receive signals initiated from the terminal.
** Improvements
cp -p now copies trivial NSFv4 ACLs on Solaris 10. Before, it would
mistakenly apply a non-trivial ACL to the destination file.
cp and ls now support HP-UX 11.11's ACLs, thanks to improved support
in gnulib.
df now supports disk partitions larger than 4 TiB on MacOS X 10.5
or newer and on AIX 5.2 or newer.
join --check-order now prints "join: FILE:LINE_NUMBER: bad_line" for an
unsorted input, rather than e.g., "join: file 1 is not in sorted order".
shuf outputs small subsets of large permutations much more efficiently.
For example `shuf -i1-$((2**32-1)) -n2` no longer exhausts memory.
stat -f now recognizes the GPFS, MQUEUE and PSTOREFS file system types.
timeout now supports sub-second timeouts.
** Build-related
Changes inherited from gnulib address a build failure on HP-UX 11.11
when using /opt/ansic/bin/cc.
Numerous portability and build improvements inherited via gnulib.
* Noteworthy changes in release 8.12 (2011-04-26) [stable]
** Bug fixes
@@ -1039,7 +1144,8 @@ GNU coreutils NEWS -*- outline -*-
join has significantly better performance due to better memory management
ls now uses constant memory when not sorting and using one_per_line format,
no matter how many files are in a given directory
no matter how many files are in a given directory. I.e., to list a directory
with very many files, ls -1U is much more efficient.
od now aligns fields across lines when printing multiple -t
specifiers, and no longer prints fields that resulted entirely from
@@ -1053,6 +1159,12 @@ GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 6.12 (2008-05-31) [stable]
** New features
cp, install, mv, and touch now preserve nanosecond resolution on
file timestamps, on platforms that have the 'utimensat' and
'futimens' system calls.
** Bug fixes
chcon, runcon: --help output now includes the bug-reporting address
@@ -1465,7 +1577,7 @@ GNU coreutils NEWS -*- outline -*-
"rm --interactive=never F" no longer prompts for an unwritable F
"rm -rf D" would emit an misleading diagnostic when failing to
"rm -rf D" would emit a misleading diagnostic when failing to
remove a symbolic link within the unwritable directory, D.
Introduced in coreutils-6.0. Similarly, when a cross-partition
"mv" fails because the source directory is unwritable, it now gives

View File

@@ -2,7 +2,7 @@
These notes intend to help people working on the checked-out sources.
These requirements do not apply when building from a distribution tarball.
See also HACKING for more detailed coreutils contribution guidelines.
See also HACKING for more detailed contribution guidelines.
* Requirements
@@ -78,11 +78,14 @@ each program. One way to do this is to use vc-dwim
"git-changelog-symlink-init" function into your shell, and then run
this function at the top-level directory of the package.
Edit the ChangeLog file that this command creates, creating a
Edit the (empty) ChangeLog file that this command creates, creating a
properly-formatted entry according to the GNU coding standards
<http://www.gnu.org/prep/standards/html_node/Change-Logs.html>.
Run the command "vc-dwim" and make sure its output looks good.
Make your changes.
Run the command "vc-dwim" and make sure its output (the diff of all
your changes) looks good.
Run "vc-dwim --commit".

View File

@@ -34,6 +34,10 @@ FIXME: enable excluded programs like arch? to get their manual pages?
&& make distcheck \
&& make -j$n check RUN_VERY_EXPENSIVE_TESTS=yes RUN_EXPENSIVE_TESTS=yes
If testing on systems with a non standard default shell, spurious failures
may occur. Often there are other shells available, and you can select
those by using for example, SHELL=bash in the commands above.
Note that the use of -j$n tells make to use approximately half of the
available processing units. If you use -jN, for larger N, some of the
expensive tests are likely to interfere with concurrent performance-measuring

View File

@@ -23,7 +23,6 @@ Adrian Bunk bunk@stusta.de
AIDA Shinra shinra@j10n.org
Akim Demaille demaille@inf.enst.fr
Alain Magloire alain@qnx.com
Alan Curry pacman@kosh.dhis.org
Alan Iwi iwi@atm.ox.ac.uk
Albert Chin-A-Young china@thewrittenword.com
Albert Hopkins ahopkins@dynacare.com
@@ -81,7 +80,6 @@ Bernd Melchers melchers@cis.fu-berlin.de
Bernhard Baehr bernhard.baehr@gmx.de
Bernhard Gabler bernhard@uni-koblenz.de
Bernhard Rosenkraenzer bero@redhat.de
Bernhard Voelker bernhard.voelker@siemens-enterprise.com
Bert Deknuydt Bert.Deknuydt@esat.kuleuven.ac.be
Bert Wesarg bert.wesarg@googlemail.com
Bill Brelsford wb@k2di.net
@@ -94,6 +92,7 @@ Brian Kimball bfk@footbag.org
Brian M. Carlson sandals@crustytoothpaste.ath.cx
Brian Silverman bsilverman@conceptxdesign.com
Brian Youmans 3diff@gnu.org
Britton Leo Kerin fsblk@aurora.uaf.edu
Bruce Robertson brucer@theodolite.dyndns.org
Carl Johnson carlj@cjlinux.home.org
Carl Lowenstein cdl@mpl.UCSD.EDU
@@ -140,6 +139,7 @@ David Alan Gilbert gilbertd@treblig.org
David Dyck dcd@tc.fluke.COM
David Eisner cradle@umd.edu
David Flynn dav@chess.plus.com
David Gast dgast@csulb.edu
David Godfrey dave@delta.demon.co.uk
David Luyer david_luyer@pacific.net.au
David Madore david.madore@ens.fr
@@ -262,6 +262,7 @@ Jan Moringen jan.moringen@uni-bielefeld.de
Jan Nieuwenhuizen janneke@gnu.org
Jan-Pawel Wrozstinski jpwroz@gmail.com
Janos Farkas chexum@shadow.banki.hu
Jari Aalto jari.aalto@cante.net
Jarkko Hietaniemi jhi@epsilon.hut.fi
Jarod Wilson jwilson@redhat.com
Jean Charles Delepine delepine@u-picardie.fr
@@ -278,6 +279,7 @@ Jesse Thilo jgt2@eecs.lehigh.edu
Jie Xu xuj@iag.net
Jim Blandy jimb@cyclic.com
Jim Dennis jimd@starshine.org
Joachim Schmitz jojo@schmitz-digital.de
Joakim Rosqvist dvljrt@cs.umu.se
Jochen Hein jochen@jochen.org
Joe Orton joe@manyfish.co.uk
@@ -297,6 +299,7 @@ John Stanley johnstops@verizon.net
John Summerfield summer@OS2.ami.com.au
Jon Peatfield J.S.Peatfield@damtp.cam.ac.uk
Joost van Baal joostvb@xs4all.nl
Jordi Pujol jordipujolp@gmail.com
Jorge Stolfi stolfi@ic.unicamp.br
Joseph S. Myers jsm28@cam.ac.uk
Josh Triplett josh@freedesktop.org
@@ -315,7 +318,6 @@ Kai-Uwe Rommel rommel@informatik.tu-muenchen.de
Kalle Olavi Niemitalo kon@iki.fi
Kamal Paul Nigam Kamal_Paul_Nigam@gs35.sp.cs.cmu.edu
Karl Eichwalder keichwa@gmx.net
Karl Heuer kwzh@gnu.org
Karl-Michael Schneider schneide@phil.uni-passau.de
Karsten Thygesen karthy@kom.auc.dk
Kaveh R. Ghazi ghazi@caip.rutgers.edu
@@ -450,12 +452,14 @@ Patrick Mauritz oxygene@studentenbude.ath.cx
Paul D. Smith psmith@gnu.org
Paul Ghaleb paul.ghaleb@st.com
Paul Jarc prj@po.cwru.edu
Paul Marinescu paul.marinescu@imperial.ac.uk
Paul Nevai nevai@ops.mps.ohio-state.edu
Paul Sauer paul@alexa.com
Paul Slootman paul@debian.org
Paul Townsend aab@purdue.edu
Paul Worrall paul@basilisk.uklinux.net
Pawel Prokop pablo@wizard.ae.krakow.pl
Peng Yu pengyu.ut@gmail.com
Per Cederqvist ceder@lysator.liu.se
Per Kristian Hove perhov@math.ntnu.no
Per Starbäck starback@stp.lingfil.uu.se
@@ -491,6 +495,7 @@ Richard J. Rauenzahn rrauenza@hairball.cup.hp.com
Richard Neill rn214@hermes.cam.ac.uk
Richard Sharman rsharman@magmacom.com
Rick Sladkey jrs@world.std.com
Rick Stanley rstanley@rsiny.com
Rik Faith faith@cs.unc.edu
Risto Kankkunen kankkune@lingsoft.fi
Rob Wortman wyrm@haell.com
@@ -587,6 +592,7 @@ Uwe H. Steinfeld usteinfeld@gmx.net
Vesselin Atanasov vesselin@bgnet.bg
Ville Skyttä ville.skytta@iki.fi
Vin Shelton acs@alumni.princeton.edu
Vincent Lefevre vincent@vinc17.org
Vineet Chadha chadha@acis.ufl.edu
Vitali Lovich vlovich@gmail.com
Vitaly A. Ostanin vyt@altlinux.org

105
bootstrap
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2011-03-03.12; # UTC
scriptversion=2011-08-11.17; # UTC
# Bootstrap this package from checked-out sources.
@@ -130,18 +130,7 @@ source_base=lib
m4_base=m4
doc_base=doc
tests_base=tests
# Extra files from gnulib, which override files from other sources.
gnulib_extra_files="
$build_aux/install-sh
$build_aux/missing
$build_aux/mdate-sh
$build_aux/texinfo.tex
$build_aux/depcomp
$build_aux/config.guess
$build_aux/config.sub
doc/INSTALL
"
gnulib_extra_files=''
# Additional gnulib-tool options to use. Use "\newline" to break lines.
gnulib_tool_option_extras=
@@ -229,6 +218,18 @@ case "$0" in
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
# Extra files from gnulib, which override files from other sources.
test -z "${gnulib_extra_files}" && \
gnulib_extra_files="
$build_aux/install-sh
$build_aux/missing
$build_aux/mdate-sh
$build_aux/texinfo.tex
$build_aux/depcomp
$build_aux/config.guess
$build_aux/config.sub
doc/INSTALL
"
if test "$vc_ignore" = auto; then
vc_ignore=
@@ -278,14 +279,29 @@ if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
exit 1
fi
# Ensure that lines starting with ! sort last, per gitignore conventions
# for whitelisting exceptions after a more generic blacklist pattern.
sort_patterns() {
sort -u "$@" | sed '/^!/ {
H
d
}
$ {
P
x
s/^\n//
}' | sed '/^$/d'
}
# 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
test -f $file || touch $file
echo "$str" | sort -u - $file | cmp - $file > /dev/null \
|| echo "$str" | sort -u - $file -o $file \
echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \
|| { echo "$str" | sort_patterns - $file > $file.bak \
&& mv $file.bak $file; } \
|| exit 1
}
@@ -405,18 +421,32 @@ check_versions() {
# Honor $APP variables ($TAR, $AUTOCONF, etc.)
appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
test "$appvar" = TAR && appvar=AMTAR
eval "app=\${$appvar-$app}"
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
echo "$me: Error: '$app' not found" >&2
ret=1
elif [ ! "$req_ver" = "-" ]; then
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
echo " '$app' version >= $req_ver is required" >&2
case $appvar in
GZIP) ;; # Do not use $GZIP: it contains gzip options.
*) eval "app=\${$appvar-$app}" ;;
esac
if [ "$req_ver" = "-" ]; then
# Merely require app to exist; not all prereq apps are well-behaved
# so we have to rely on $? rather than get_version.
$app --version >/dev/null 2>&1
if [ 126 -le $? ]; then
echo "$me: Error: '$app' not found" >&2
ret=1
fi
else
# Require app to produce a new enough version string.
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
echo "$me: Error: '$app' not found" >&2
ret=1
else
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
echo "$me: Error: '$app' version == $inst_ver is too old" >&2
echo " '$app' version >= $req_ver is required" >&2
ret=1
fi
fi
fi
done
@@ -640,10 +670,18 @@ symlink_to_dir()
cp -fp "$src" "$dst"
}
else
# Leave any existing symlink alone, if it already points to the source,
# so that broken build tools that care about symlink times
# aren't confused into doing unnecessary builds. Conversely, if the
# existing symlink's time stamp is older than the source, make it afresh,
# so that broken tools aren't confused into skipping needed builds. See
# <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
test -h "$dst" &&
src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
test "$src_i" = "$dst_i" || {
test "$src_i" = "$dst_i" &&
both_ls=`ls -dt "$src" "$dst"` &&
test "X$both_ls" = "X$dst$nl$src" || {
dot_dots=
case $src in
/*) ;;
@@ -762,20 +800,7 @@ slurp() {
echo "$me: $dir/$file overrides $1/$dir/$file"
else
copied=$copied$sep$file; sep=$nl
if test $file = gettext.m4; then
echo "$me: patching m4/gettext.m4 to remove need for intl/* ..."
rm -f $dir/$file
sed '
/^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
AC_DEFUN([AM_INTL_SUBDIR], [])
/^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
$a\
AC_DEFUN([gl_LOCK_EARLY], [])
' $1/$dir/$file >$dir/$file
else
cp_mark_as_generated $1/$dir/$file $dir/$file
fi
cp_mark_as_generated $1/$dir/$file $dir/$file
fi || exit
done

View File

@@ -25,7 +25,6 @@ avoided_gnulib_modules='
# gnulib modules used by this package.
gnulib_modules="
$avoided_gnulib_modules
$obsolete_gnulib_modules
acl
alignof
alloca
@@ -71,6 +70,7 @@ gnulib_modules="
faccessat
fadvise
fchdir
fclose
fcntl
fcntl-safer
fdl
@@ -101,7 +101,7 @@ gnulib_modules="
getopt-gnu
getpagesize
getpass-gnu
gettext-h
gettext
gettime
gettimeofday
getugroups
@@ -125,6 +125,7 @@ gnulib_modules="
inttypes
isapipe
isblank
largefile
lchmod
lchown
ldtoastr
@@ -138,6 +139,7 @@ gnulib_modules="
maintainer-makefile
malloc-gnu
manywarnings
mbrlen
mbrtowc
mbsalign
mbswidth
@@ -159,7 +161,6 @@ gnulib_modules="
nproc
obstack
parse-datetime
pathmax
perl
physmem
posix-shell
@@ -197,6 +198,7 @@ gnulib_modules="
sigaction
ssize_t
stat-macros
stat-size
stat-time
stdbool
stdlib-safer
@@ -207,13 +209,13 @@ gnulib_modules="
strsignal
strtod
strtoimax
strtol
strtoumax
symlink
sys_ioctl
sys_stat
sys_wait
termios
timer-time
timespec
tzset
uname
@@ -241,6 +243,7 @@ gnulib_modules="
xalloc
xfreopen
xgetcwd
xgetgroups
xgethostname
xmemcoll
xnanosleep
@@ -283,31 +286,6 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--keyword=proper_name_utf8:1,'"$see_manual"'\\\
'
# If "AM_GNU_GETTEXT(external" or "AM_GNU_GETTEXT([external]"
# appears in configure.ac, exclude some unnecessary files.
# Without grep's -E option (not portable enough, pre-configure),
# the following test is ugly. Also, this depends on the existence
# of configure.ac, not the obsolescent-named configure.in. But if
# you're using this infrastructure, you should care about such things.
gettext_external=0
grep '^[ ]*AM_GNU_GETTEXT(external\>' configure.ac > /dev/null &&
gettext_external=1
grep '^[ ]*AM_GNU_GETTEXT(\[external\]' configure.ac > /dev/null &&
gettext_external=1
if test $gettext_external = 1; then
# Gettext supplies these files, but we don't need them since
# we don't have an intl subdirectory.
excluded_files='
m4/glibc2.m4
m4/intdiv0.m4
m4/uintmax_t.m4
m4/ulonglong.m4
m4/visibility.m4
'
fi
gnulib_tool_option_extras="--tests-base=$bt/gnulib-tests --with-tests"
# Build prerequisites
@@ -320,7 +298,7 @@ gettext 0.17
git 1.4.4
gperf -
gzip -
makeinfo -
makeinfo 4.13
patch -
perl 5.5
rsync -

43
cfg.mk
View File

@@ -27,7 +27,7 @@ bootstrap-tools = autoconf,automake,gnulib,bison
# Now that we have better tests, make this the default.
export VERBOSE = yes
old_NEWS_hash = 656dc592d4ed57c83662be60caa1af9e
old_NEWS_hash = d491296a7e0e2269b2b96dc4bd5f77a8
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
@@ -128,13 +128,9 @@ sc_sun_os_names:
{ echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
exit 1; } || :
ALL_RECURSIVE_TARGETS += sc_tight_scope
sc_tight_scope:
@$(MAKE) -s -C src $@
ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
sc_check-AUTHORS:
@$(MAKE) -s -C src $@
@$(MAKE) -s -C src _sc_check-AUTHORS
# Look for lines longer than 80 characters, except omit:
# - program-generated long lines in diff headers,
@@ -209,7 +205,11 @@ sc_strftime_check:
{ echo N; \
info libc date calendar format 2>/dev/null|grep '^ `%.'\'\
| $(extract_char); } | sort > $@-info; \
diff -u $@-src $@-info || exit 1; \
if test $$(stat --format %s $@-info) != 2; then \
diff -u $@-src $@-info || exit 1; \
else \
echo '$(ME): skipping $@: libc info not installed' 1>&2; \
fi; \
rm -f $@-src $@-info; \
fi
@@ -219,6 +219,14 @@ sc_prohibit_tab_based_indentation:
halt='TAB in indentation; use only spaces' \
$(_sc_search_regexp)
# The SEE ALSO section of a man page should not be terminated with
# a period. Check the first line after each "SEE ALSO" line in man/*.x:
sc_prohibit_man_see_also_period:
@grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
| grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
{ echo '$(ME): do not end "SEE ALSO" section with a period' \
1>&2; exit 1; } || :
# Don't use "indent-tabs-mode: nil" anymore. No longer needed.
sc_prohibit_emacs__indent_tabs_mode__setting:
@prohibit='^( *[*#] *)?indent-tabs-mode:' \
@@ -262,6 +270,12 @@ sc_prohibit_verbose_version:
halt='use the print_ver_ function instead...' \
$(_sc_search_regexp)
# Use framework_failure_, not the old name without the trailing underscore.
sc_prohibit_framework_failure:
@prohibit='\<framework_''failure\>' \
halt='use framework_failure_ instead' \
$(_sc_search_regexp)
###########################################################
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
@@ -324,11 +338,21 @@ sc_prohibit_strncmp:
{ echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \
1>&2; exit 1; } || :
# Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation:
@if cppi --version >/dev/null 2>&1; then \
$(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
|| { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
exit 1; }; \
else \
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
fi
# Override the default Cc: used in generating an announcement.
announcement_Cc_ = $(translation_project_), \
coreutils@gnu.org, coreutils-announce@gnu.org
include $(srcdir)/dist-check.mk
-include $(srcdir)/dist-check.mk
update-copyright-env = \
UPDATE_COPYRIGHT_USE_INTERVALS=1 \
@@ -363,6 +387,9 @@ exclude_file_name_regexp--sc_prohibit_fail_0 = \
exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
^tests/pr/|(^gl/lib/reg.*\.c\.diff|Makefile(\.am)?|\.mk|^man/help2man)$$
exclude_file_name_regexp--sc_preprocessor_indentation = \
^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$
exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
^(src/system\.h|tests/du/2g)$$

View File

@@ -18,7 +18,7 @@
dnl Written by Jim Meyering.
AC_PREREQ([2.62])
AC_PREREQ([2.64])
# Make inter-release version strings look like, e.g., v6.9-219-g58ddd, which
# indicates that it is built from the 219th delta (in _some_ repository)
@@ -88,17 +88,22 @@ if test "$gl_gcc_warnings" = yes; then
nw="$nw -Wmissing-format-attribute" # copy.c
nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
nw="$nw -Winline" # system.h's readdir_ignoring_dot_and_dotdot
nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
# ?? -Wstrict-overflow
# Using -Wstrict-overflow is a pain, but the alternative is worse.
# For an example, see the code that provoked this report:
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33498
# Code like that still infloops with gcc-4.6.0 and -O2. Scary indeed.
gl_MANYWARN_ALL_GCC([ws])
gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
for w in $ws; do
gl_WARN_ADD([$w])
done
gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
gl_WARN_ADD([-Wsuggest-attribute=const])
gl_WARN_ADD([-Wsuggest-attribute=pure])
gl_WARN_ADD([-Wsuggest-attribute=noreturn])
# In spite of excluding -Wlogical-op above, it is enabled, as of
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
@@ -117,10 +122,14 @@ if test "$gl_gcc_warnings" = yes; then
# We use a slightly smaller set of warning options for lib/.
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
nw=
nw="$nw -Wstrict-overflow"
nw="$nw -Wuninitialized"
nw="$nw -Wunused-macros"
nw="$nw -Wmissing-prototypes"
nw="$nw -Wold-style-definition"
# FIXME: remove/reenable the following two, once gnulib is adjusted.
nw="$nw -Wsuggest-attribute=const"
nw="$nw -Wsuggest-attribute=pure"
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
AC_SUBST([GNULIB_WARN_CFLAGS])
@@ -416,7 +425,7 @@ esac
MAN=`echo "$optional_bin_progs "|sed 's/ /.1 /g;s/ $//'|tr -d '\\015\\012'`
# Change ginstall.1 to "install.h" in $MAN.
# Change "ginstall.1" to "install.1" in $MAN.
MAN=`for m in $MAN; do test $m = ginstall.1 && m=install.1; echo $m; done \
| tr '\015\012' ' '; echo`
@@ -443,7 +452,7 @@ AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
# translatable strings, we must use need-formatstring-macros here.
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT_VERSION([0.18.1])
# For a test of uniq: it uses the $LOCALE_FR envvar.
gt_LOCALE_FR

View File

@@ -128,7 +128,7 @@ find_upper_case_var = \
} \
END {$$m and (warn "$(ME): do not use upper case in \@var{...}\n"), exit 1}'
sc-lower-case-var:
$(AM_V_GEN)$(PERL) -e 1 \
&& $(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
$(AM_V_GEN)$(PERL) -e 1 || { echo $@: skipping test; exit 0; }; \
$(PERL) -lne $(find_upper_case_var) $(srcdir)/*.texi
check: check-texinfo

View File

@@ -1883,7 +1883,7 @@ Output at most @var{bytes} bytes of the input. Prefixes and suffixes on
Instead of the normal output, output only @dfn{string constants}: at
least @var{bytes} consecutive @acronym{ASCII} graphic characters,
followed by a zero byte (@acronym{ASCII} @sc{nul}).
Prefixes and suffixes on @code{bytes} are interpreted as for the
Prefixes and suffixes on @var{bytes} are interpreted as for the
@option{-j} option.
If @var{n} is omitted with @option{--strings}, the default is 3.
@@ -2830,6 +2830,18 @@ no @var{file} operand is specified and standard input is a FIFO or a pipe.
Likewise, the @option{-f} option has no effect for any
operand specified as @samp{-}, when standard input is a FIFO or a pipe.
With kernel inotify support, output is triggered by file changes
and is generally very prompt.
Otherwise, @command{tail} sleeps for one second between checks---
use @option{--sleep-interval=@var{n}} to change that default---which can
make the output appear slightly less responsive or bursty.
When using tail without inotify support, you can make it more responsive
by using a sub-second sleep interval, e.g., via an alias like this:
@example
alias tail='tail -s.1'
@end example
@item -F
@opindex -F
This option is the same as @option{--follow=name --retry}. That is, tail
@@ -2992,8 +3004,8 @@ The program accepts the following options. Also see @ref{Common options}.
Put @var{lines} lines of @var{input} into each output file.
For compatibility @command{split} also supports an obsolete
option syntax @option{-@var{lines}}. New scripts should use @option{-l
@var{lines}} instead.
option syntax @option{-@var{lines}}. New scripts should use
@option{-l @var{lines}} instead.
@item -b @var{size}
@itemx --bytes=@var{size}
@@ -3011,6 +3023,25 @@ possible without exceeding @var{size} bytes. Individual lines longer than
@var{size} bytes are broken into multiple files.
@var{size} has the same format as for the @option{--bytes} option.
@itemx --filter=@var{command}
@opindex --filter
With this option, rather than simply writing to each output file,
write through a pipe to the specified shell @var{command} for each output file.
@var{command} should use the $FILE environment variable, which is set
to a different output file name for each invocation of the command.
For example, imagine that you have a 1TiB compressed file
that, if uncompressed, would be too large to reside on disk,
yet you must split it into individually-compressed pieces
of a more manageable size.
To do that, you might run this command:
@example
xz -dc BIG.xz | split -b200G --filter='xz > $FILE.xz' - big-
@end example
Assuming a 10:1 compression ratio, that would create about fifty 20GiB files
with names @file{big-xaa.xz}, @file{big-xab.xz}, @file{big-xac.xz}, etc.
@item -n @var{chunks}
@itemx --number=@var{chunks}
@opindex -n
@@ -3671,6 +3702,13 @@ When verifying checksums, warn about improperly formatted MD5 checksum lines.
This option is useful only if all but a few lines in the checked input
are valid.
@itemx --strict
@opindex --strict
@cindex verifying MD5 checksums
When verifying checksums,
if one or more input line is invalid,
exit nonzero after all warnings have been issued.
@end table
@exitstatus
@@ -4109,8 +4147,8 @@ a temporary file, which is then used as an input in a subsequent merge.
A large value of @var{nmerge} may improve merge performance and decrease
temporary storage utilization at the expense of increased memory usage
and I/0. Conversely a small value of @var{nmerge} may reduce memory
requirements and I/0 at the expense of temporary storage consumption and
and I/O. Conversely a small value of @var{nmerge} may reduce memory
requirements and I/O at the expense of temporary storage consumption and
merge performance.
The value of @var{nmerge} must be at least 2. The default value is
@@ -7023,6 +7061,23 @@ Piping a colorized listing through a pager like @command{more} or
@command{less} usually produces unreadable results. However, using
@code{more -f} does seem to work.
@vindex LS_COLORS
@vindex SHELL @r{environment variable, and color}
Note that using the @option{--color} option may incur a noticeable
performance penalty when run in a directory with very many entries,
because the default settings require that @command{ls} @code{stat} every
single file it lists.
However, if you would like most of the file-type coloring
but can live without the other coloring options (e.g.,
executable, orphan, sticky, other-writable, capability), use
@command{dircolors} to set the @env{LS_COLORS} environment variable like this,
@example
eval $(dircolors -p | perl -pe \
's/^((CAP|S[ET]|O[TR]|M|E)\w+).*/$1 00/' | dircolors -)
@end example
and on a @code{dirent.d_type}-capable file system, @command{ls}
will perform only one @code{stat} call per command line argument.
@item -F
@itemx --classify
@itemx --indicator-style=classify
@@ -7899,8 +7954,11 @@ same or newer modification time. If time stamps are being preserved,
the comparison is to the source time stamp truncated to the
resolutions of the destination file system and of the system calls
used to update time stamps; this avoids duplicate work if several
@samp{cp -pu} commands are executed with the same source and
destination.
@samp{cp -pu} commands are executed with the same source and destination.
If @option{--preserve=links} is also specified (like with @samp{cp -au}
for example), that will take precedence. Consequently, depending on the
order that files are processed from the source, newer files in the destination
may be replaced, to mirror hard links in the source.
@item -v
@itemx --verbose
@@ -13873,10 +13931,10 @@ hour (@samp{00}@dots{}@samp{23})
@item %I
hour (@samp{01}@dots{}@samp{12})
@item %k
hour (@samp{ 0}@dots{}@samp{23}).
hour, space padded (@samp{ 0}@dots{}@samp{23}); equivalent to @samp{%_H}.
This is a @acronym{GNU} extension.
@item %l
hour (@samp{ 1}@dots{}@samp{12}).
hour, space padded (@samp{ 1}@dots{}@samp{12}); equivalent to @samp{%_I}.
This is a @acronym{GNU} extension.
@item %M
minute (@samp{00}@dots{}@samp{59})
@@ -15350,6 +15408,17 @@ three standard I/O streams associated with a program. Synopsis:
stdbuf @var{option}@dots{} @var{command}
@end example
@var{command} must start with the name of a program that
@enumerate
@item
uses the ISO C @code{FILE} streams for input/output (note the
programs @command{dd} and @command{cat} don't do that),
@item
does not adjust the buffering of its standard streams (note the
program @command{tee} is not in this category).
@end enumerate
Any additional @var{arg}s are passed as additional arguments to the
@var{command}.
@@ -15389,8 +15458,13 @@ This option is invalid with standard input.
@item 0
Disable buffering of the selected stream.
In this mode data is output immediately and only the
In this mode, data is output immediately and only the
amount of data requested is read from input.
Note the difference in function for input and output.
Disabling buffering for input will not influence the responsiveness
or blocking behavior of the stream input functions.
For example @code{fread} will still block until @code{EOF} or error,
even if the underlying @code{read} returns less data than requested.
@item @var{size}
Specify the size of the buffer to use in fully buffered mode.
@@ -15398,12 +15472,6 @@ Specify the size of the buffer to use in fully buffered mode.
@end table
NOTE: If @var{command} adjusts the buffering of its standard streams
(@command{tee} does for e.g.) then that will override corresponding settings
changed by @command{stdbuf}. Also some filters (like @command{dd} and
@command{cat} etc.) don't use streams for I/O, and are thus unaffected
by @command{stdbuf} settings.
@cindex exit status of @command{stdbuf}
Exit status:
@@ -15593,6 +15661,23 @@ The program accepts the following options. Also see @ref{Common options}.
Options must precede operands.
@table @samp
@itemx --foreground
@opindex --foreground
Don't create a separate background program group, so that
the managed @var{command} can use the foreground TTY normally.
This is needed to support timing out commands not started
directly from an interactive shell, in two situations.
@enumerate
@item
@var{command} is interactive and needs to read from the terminal for example
@item
the user wants to support sending signals directly to @var{command}
from the terminal (like Ctrl-C for example)
@end enumerate
Note in this mode of operation, any children of @var{command}
will not be timed out.
@item -k @var{duration}
@itemx --kill-after=@var{duration}
@opindex -k
@@ -15612,7 +15697,7 @@ or a number. Also see @xref{Signal specifications}.
@end table
@cindex time units
@var{duration} is an integer followed by an optional unit:
@var{duration} is a floating point number followed by an optional unit:
@display
@samp{s} for seconds (the default)
@samp{m} for minutes
@@ -15620,6 +15705,8 @@ or a number. Also see @xref{Signal specifications}.
@samp{d} for days
@end display
A duration of 0 disables the associated timeout.
Note that the actual timeout duration is dependent on system conditions,
which should be especially considered when specifying sub-second timeouts.
@cindex exit status of @command{timeout}
Exit status:

View File

@@ -93,10 +93,12 @@ heap_insert (struct heap *heap, void *item)
void *
heap_remove_top (struct heap *heap)
{
void *top;
if (heap->count == 0)
return NULL;
void *top = heap->array[1];
top = heap->array[1];
heap->array[1] = heap->array[heap->count--];
heapify_down (heap->array, heap->count, 1, heap->compare);

View File

@@ -34,7 +34,8 @@ struct randint_source;
struct randint_source *randint_new (struct randread_source *);
struct randint_source *randint_all_new (char const *, size_t);
struct randread_source *randint_get_source (struct randint_source const *);
struct randread_source *randint_get_source (struct randint_source const *)
_GL_ATTRIBUTE_PURE;
randint randint_genmax (struct randint_source *, randint genmax);
/* Consume random data from *S to generate a random number in the range

View File

@@ -19,16 +19,18 @@
#include <config.h>
#include "hash.h"
#include "randperm.h"
#include <limits.h>
#include <stdlib.h>
#include "xalloc.h"
/* Return the ceiling of the log base 2 of N. If N is zero, return
an unspecified value. */
static size_t
static size_t _GL_ATTRIBUTE_CONST
ceil_lg (size_t n)
{
size_t b = 0;
@@ -57,6 +59,94 @@ randperm_bound (size_t h, size_t n)
return bound;
}
/* Swap elements I and J in array V. */
static void
swap (size_t *v, size_t i, size_t j)
{
size_t t = v[i];
v[i] = v[j];
v[j] = t;
}
/* Structures and functions for a sparse_map abstract data type that's
used to effectively swap elements I and J in array V like swap(),
but in a more memory efficient manner (when the number of permutations
performed is significantly less than the size of the input). */
struct sparse_ent_
{
size_t index;
size_t val;
};
static size_t
sparse_hash_ (void const *x, size_t table_size)
{
struct sparse_ent_ const *ent = x;
return ent->index % table_size;
}
static bool
sparse_cmp_ (void const *x, void const *y)
{
struct sparse_ent_ const *ent1 = x;
struct sparse_ent_ const *ent2 = y;
return ent1->index == ent2->index;
}
typedef Hash_table sparse_map;
/* Initialize the structure for the sparse map,
when a best guess as to the number of entries
specified with SIZE_HINT. */
static sparse_map *
sparse_new (size_t size_hint)
{
return hash_initialize (size_hint, NULL, sparse_hash_, sparse_cmp_, free);
}
/* Swap the values for I and J. If a value is not already present
then assume it's equal to the index. Update the value for
index I in array V. */
static void
sparse_swap (sparse_map *sv, size_t* v, size_t i, size_t j)
{
struct sparse_ent_ *v1 = hash_delete (sv, &(struct sparse_ent_) {i,0});
struct sparse_ent_ *v2 = hash_delete (sv, &(struct sparse_ent_) {j,0});
/* FIXME: reduce the frequency of these mallocs. */
if (!v1)
{
v1 = xmalloc (sizeof *v1);
v1->index = v1->val = i;
}
if (!v2)
{
v2 = xmalloc (sizeof *v2);
v2->index = v2->val = j;
}
size_t t = v1->val;
v1->val = v2->val;
v2->val = t;
if (!hash_insert (sv, v1))
xalloc_die ();
if (!hash_insert (sv, v2))
xalloc_die ();
v[i] = v1->val;
}
static void
sparse_free (sparse_map *sv)
{
hash_free (sv);
}
/* 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. */
@@ -79,21 +169,66 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
default:
{
size_t i;
/* The algorithm is essentially the same in both
the sparse and non sparse case. In the sparse case we use
a hash to implement sparse storage for the set of n numbers
we're shuffling. When to use the sparse method was
determined with the help of this script:
v = xnmalloc (n, sizeof *v);
for (i = 0; i < n; i++)
v[i] = i;
#!/bin/sh
for n in $(seq 2 32); do
for h in $(seq 2 32); do
test $h -gt $n && continue
for s in o n; do
test $s = o && shuf=shuf || shuf=./shuf
num=$(env time -f "$s:${h},${n} = %e,%M" \
$shuf -i0-$((2**$n-2)) -n$((2**$h-2)) | wc -l)
test $num = $((2**$h-2)) || echo "$s:${h},${n} = failed" >&2
done
done
done
This showed that if sparseness = n/h, then:
sparseness = 128 => .125 mem used, and about same speed
sparseness = 64 => .25 mem used, but 1.5 times slower
sparseness = 32 => .5 mem used, but 2 times slower
Also the memory usage was only significant when n > 128Ki
*/
bool sparse = (n >= (128 * 1024)) && (n / h >= 32);
size_t i;
sparse_map *sv;
if (sparse)
{
sv = sparse_new (h * 2);
if (sv == NULL)
xalloc_die ();
v = xnmalloc (h, sizeof *v);
}
else
{
sv = NULL; /* To placate GCC's -Wuninitialized. */
v = xnmalloc (n, sizeof *v);
for (i = 0; i < n; i++)
v[i] = i;
}
for (i = 0; i < h; i++)
{
size_t j = i + randint_choose (r, n - i);
size_t t = v[i];
v[i] = v[j];
v[j] = t;
if (sparse)
sparse_swap (sv, v, i, j);
else
swap (v, i, j);
}
v = xnrealloc (v, h, sizeof *v);
if (sparse)
sparse_free (sv);
else
v = xnrealloc (v, h, sizeof *v);
}
break;
}

View File

@@ -1,4 +1,4 @@
#include "randint.h"
#include <stddef.h>
size_t randperm_bound (size_t, size_t);
size_t randperm_bound (size_t, size_t) _GL_ATTRIBUTE_CONST;
size_t *randperm_new (struct randint_source *, size_t, size_t);

View File

@@ -64,7 +64,7 @@
#endif
#ifndef NAME_OF_NONCE_DEVICE
#define NAME_OF_NONCE_DEVICE "/dev/urandom"
# define NAME_OF_NONCE_DEVICE "/dev/urandom"
#endif
/* The maximum buffer size used for reads of random data. Using the
@@ -162,7 +162,7 @@ get_nonce (void *buffer, size_t bufsize, size_t bytes_bound)
/* If there's no nonce device, use a poor approximation
by getting the time of day, etc. */
# define ISAAC_SEED(type, initialize_v) \
#define ISAAC_SEED(type, initialize_v) \
if (seeded < bufsize) \
{ \
type v; \

View File

@@ -22,7 +22,7 @@ index 2da5afe..562955a 100644
}
#endif /* _LIBC */
+static inline bool
+static inline bool _GL_ATTRIBUTE_PURE
+check_x_suffix (char const *s, size_t len)
+{
+ return len <= strspn (s, "X");
@@ -100,7 +100,7 @@ index 2da5afe..562955a 100644
- }
-#endif
- value += random_time_bits ^ __getpid ();
+ rand_src = randint_all_new (NULL, 8);
+ rand_src = randint_all_new (NULL, x_suffix_len);
+ if (! rand_src)
+ return -1;

View File

@@ -1,13 +0,0 @@
diff --git a/modules/getloadavg b/modules/getloadavg
index 2fbeb40..b79aaca 100644
--- a/modules/getloadavg
+++ b/modules/getloadavg
@@ -16,7 +16,7 @@ stdbool
fcntl-safer
configure.ac:
-gl_GETLOADAVG([$gl_source_base])
+gl_GETLOADAVG([lib])
gl_STDLIB_MODULE_INDICATOR([getloadavg])
Makefile.am:

View File

@@ -8,6 +8,7 @@ lib/randperm.h
Depends-on:
randint
xalloc
hash
configure.ac:

View File

@@ -1,30 +0,0 @@
Description:
gen_tempname, gen_tempname_len: create a private temporary file or directory.
Files:
lib/tempname.c
lib/tempname.h
m4/tempname.m4
Depends-on:
extensions
gettimeofday
randint
stdbool
stdint
sys_stat
sys_time
configure.ac:
gl_FUNC_GEN_TEMPNAME
Makefile.am:
Include:
"tempname.h"
License:
LGPL
Maintainer:
Eric Blake and Jim Meyering

18
gl/modules/tempname.diff Normal file
View File

@@ -0,0 +1,18 @@
--- /gnulib/modules/tempname 2011-06-17 11:41:46.070787376 +0200
+++ gl/modules/tempname 2011-06-17 11:43:49.571154551 +0200
@@ -1,2 +1,2 @@
Description:
-gen_tempname() function: create a private temporary file or directory.
+gen_tempname, gen_tempname_len: create a private temporary file or directory.
Files:
lib/tempname.c
@@ -10,6 +10,8 @@ Depends-on:
extensions
gettimeofday
lstat
+randint
+stdbool
stdint
sys_stat
sys_time

2
gnulib

Submodule gnulib updated: a81348d2e1...da1717b7f9

View File

@@ -17,6 +17,7 @@
/* Written by Paul Eggert. */
#include <config.h>
#include "buffer-lcm.h"
/* Return a buffer size suitable for doing I/O with files whose block

View File

@@ -1,2 +1,2 @@
#include <stddef.h>
size_t buffer_lcm (size_t, size_t, size_t);
size_t buffer_lcm (size_t, size_t, size_t) _GL_ATTRIBUTE_CONST;

View File

@@ -25,7 +25,6 @@
#include <unistd.h>
#include "group-member.h"
#include "stat-macros.h"
/* Return true if the current user has permission of type MODE

View File

@@ -71,7 +71,7 @@
if digit return -1, else 0
return 0 */
static inline int
static inline int _GL_ATTRIBUTE_PURE
fraccompare (char const *a, char const *b, char decimal_point)
{
if (*a == decimal_point && *b == decimal_point)
@@ -111,7 +111,7 @@ fraccompare (char const *a, char const *b, char decimal_point)
causes comparisons to act as if there is no decimal point
character, and likewise for THOUSANDS_SEP. */
static inline int
static inline int _GL_ATTRIBUTE_PURE
numcompare (char const *a, char const *b,
int decimal_point, int thousands_sep)
{

View File

@@ -23,7 +23,7 @@
/* Externally-visible name for numcompare. */
int
int _GL_ATTRIBUTE_PURE
strnumcmp (char const *a, char const *b,
int decimal_point, int thousands_sep)
{

View File

@@ -1,2 +1,2 @@
int strintcmp (char const *, char const *);
int strintcmp (char const *, char const *) _GL_ATTRIBUTE_PURE;
int strnumcmp (char const *, char const *, int, int);

View File

@@ -6,4 +6,5 @@ xfts_open (char * const *, int options,
int (*) (const FTSENT **, const FTSENT **));
bool
cycle_warning_required (FTS const *fts, FTSENT const *ent);
cycle_warning_required (FTS const *fts, FTSENT const *ent)
_GL_ATTRIBUTE_PURE;

View File

@@ -41,8 +41,6 @@ AC_DEFUN([coreutils_MACROS],
AC_DEFINE([ARGMATCH_DIE_DECL], [void usage (int _e)],
[Define to the declaration of the xargmatch failure function.])
# used by ls
AC_REQUIRE([gl_CLOCK_TIME])
# used by shred
AC_CHECK_FUNCS_ONCE([directio])
@@ -65,6 +63,8 @@ AC_DEFUN([coreutils_MACROS],
# Used by sort.c.
AC_CHECK_FUNCS_ONCE([nl_langinfo])
# Used by timeout.c
AC_CHECK_FUNCS_ONCE([setrlimit])
# Used by tail.c.
AC_CHECK_FUNCS([inotify_init],
@@ -93,14 +93,20 @@ AC_DEFUN([coreutils_MACROS],
cu_PREREQ_STAT_PROG
# for dd.c and shred.c
coreutils_saved_libs=$LIBS
LIB_FDATASYNC=
#
# Use fdatasync only if declared. On MacOS X 10.7, fdatasync exists but
# is not declared, and is ineffective.
LIB_FDATASYNC=
AC_SUBST([LIB_FDATASYNC])
AC_CHECK_DECLS_ONCE([fdatasync])
if test $ac_cv_have_decl_fdatasync = yes; then
coreutils_saved_libs=$LIBS
AC_SEARCH_LIBS([fdatasync], [rt posix4],
[test "$ac_cv_search_fdatasync" = "none required" ||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
AC_SUBST([LIB_FDATASYNC])
AC_CHECK_FUNCS([fdatasync])
LIBS=$coreutils_saved_libs
LIBS=$coreutils_saved_libs
fi
# Check whether libcap is usable -- for ls --color support
LIB_CAP=

View File

@@ -1,4 +1,4 @@
# stat-prog.m4 serial 6
# stat-prog.m4 serial 7
# Record the prerequisites of src/stat.c from the coreutils package.
# Copyright (C) 2002-2004, 2006, 2008-2011 Free Software Foundation, Inc.
@@ -53,7 +53,8 @@ AC_INCLUDES_DEFAULT
"
dnl Keep this long conditional in sync with the USE_STATVFS conditional
dnl in ../src/stat.c.
if test "$fu_cv_sys_stat_statvfs" = yes &&
if case "$fu_cv_sys_stat_statvfs$fu_cv_sys_stat_statvfs64" in
*yes*) ;; *) false;; esac &&
{ AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [$statvfs_includes])
test $ac_cv_member_struct_statvfs_f_basetype = yes ||
{ AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,, [$statvfs_includes])

View File

@@ -3,4 +3,4 @@ cat \- concatenate files and print on the standard output
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
\fBtac\fP(1).
\fBtac\fP(1)

View File

@@ -3,4 +3,4 @@ tac \- concatenate and print files in reverse
[DESCRIPTION]
.\" Add any additional description here
[SEE ALSO]
\fBrev\fP(1).
\fBrev\fP(1)

View File

@@ -138,7 +138,7 @@ bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
noinst_PROGRAMS = setuidgid getlimits
pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
pkglibexec_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
noinst_HEADERS = \
chown-core.h \
@@ -149,6 +149,7 @@ noinst_HEADERS = \
find-mount-point.h \
fs.h \
group-list.h \
ioblksize.h \
ls.h \
operand2sig.h \
prog-fprintf.h \
@@ -164,7 +165,7 @@ BUILT_SOURCES =
CLEANFILES = $(SCRIPTS) su
# Also remove these sometimes-built programs.
# For example, even when excluded, they're built via sc_check-AUTHORS.
# For example, even when excluded, they're built via _sc_check-AUTHORS.
CLEANFILES += $(no_install__progs)
AM_CPPFLAGS = -I$(top_srcdir)/lib
@@ -328,6 +329,7 @@ date_LDADD += $(LIB_CLOCK_GETTIME)
ginstall_LDADD += $(LIB_CLOCK_GETTIME)
ls_LDADD += $(LIB_CLOCK_GETTIME)
pr_LDADD += $(LIB_CLOCK_GETTIME)
timeout_LDADD += $(LIB_TIMER_TIME)
touch_LDADD += $(LIB_CLOCK_GETTIME)
# for gethrxtime
@@ -677,10 +679,10 @@ check-duplicate-no-install: tr
# translation inhibits printing of UTF-8 names, just skip this test.
au_dotdot = authors-dotdot
au_actual = authors-actual
.PHONY: sc_check-AUTHORS
sc_check-AUTHORS: $(all_programs)
.PHONY: _sc_check-AUTHORS
_sc_check-AUTHORS: $(all_programs)
@locale=en_US.UTF-8; \
LC_ALL=$$locale ./cat --version \
LC_ALL=$$locale ./cat --version \
| grep ' Torbjorn ' > /dev/null \
&& { echo "$@: skipping this check"; exit 0; }; \
rm -f $(au_actual) $(au_dotdot); \
@@ -702,46 +704,6 @@ sc_check-AUTHORS: $(all_programs)
sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
# The following rule is not designed to be portable,
# and relies on tools that not everyone has.
# Most functions in src/*.c should have static scope.
# Any that don't must be marked with `extern', but `main'
# and `usage' are exceptions: they're always extern, but
# do not need to be marked. Also functions starting with __
# are exempted due to possibly being added by the compiler
# (when compiled as a shared library for example).
#
# The second nm|grep checks for file-scope variables with `extern' scope.
.PHONY: sc_tight_scope
sc_tight_scope: $(bin_PROGRAMS)
@t=exceptions-$$$$; \
trap 's=$$?; rm -f $$t; exit $$s' 0; \
for sig in 1 2 3 13 15; do \
eval "trap 'v=`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \
done; \
src=`for f in $(SOURCES); do \
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
hdr=`for f in $(noinst_HEADERS); do \
test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`; \
( printf 'main\nusage\n_.*\n'; \
grep -h -A1 '^extern .*[^;]$$' $$src \
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
perl -lne '/^extern (?:enum )?\S+ \**(\S*) \(/ and print $$1' \
$$hdr; \
) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
nm -e *.$(OBJEXT) | sed -n 's/.* T //p' \
| sed 's/^_//' | grep -Ev -f $$t \
&& { echo the above functions should have static scope >&2; \
exit 1; } || : ; \
( printf '^program_name$$\n'; \
perl -lne '/^extern .*?\**(\w+);/ and print "^$$1\$$"' \
$$hdr *.h ) | $(ASSORT) -u > $$t; \
nm -e *.$(OBJEXT) | sed -n 's/.* [BD] //p' \
| sed 's/^_//' | grep -Ev -f $$t \
&& { echo the above variables should have static scope >&2; \
exit 1; } || :
# Use the just-built ./ginstall, when not cross-compiling.
if CROSS_COMPILING
cu_install_program = @INSTALL_PROGRAM@

View File

@@ -33,6 +33,7 @@
#include <sys/ioctl.h>
#include "system.h"
#include "ioblksize.h"
#include "error.h"
#include "fadvise.h"
#include "full-write.h"

View File

@@ -26,7 +26,6 @@
#include "chown-core.h"
#include "error.h"
#include "fts_.h"
#include "group-member.h"
#include "quote.h"
#include "root-dev-ino.h"
#include "xstrtol.h"

View File

@@ -137,10 +137,11 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode)
CHANGED describes what (if anything) has happened. */
static void
describe_change (const char *file, mode_t mode,
describe_change (const char *file, mode_t old_mode, mode_t mode,
enum Change_status changed)
{
char perms[12]; /* "-rwxrwxrwx" ls-style modes. */
char old_perms[12];
const char *fmt;
if (changed == CH_NOT_APPLIED)
@@ -152,21 +153,28 @@ describe_change (const char *file, mode_t mode,
strmode (mode, perms);
perms[10] = '\0'; /* Remove trailing space. */
strmode (old_mode, old_perms);
old_perms[10] = '\0'; /* Remove trailing space. */
switch (changed)
{
case CH_SUCCEEDED:
fmt = _("mode of %s changed to %04lo (%s)\n");
fmt = _("mode of %s changed from %04lo (%s) to %04lo (%s)\n");
break;
case CH_FAILED:
fmt = _("failed to change mode of %s to %04lo (%s)\n");
fmt = _("failed to change mode of %s from %04lo (%s) to %04lo (%s)\n");
break;
case CH_NO_CHANGE_REQUESTED:
fmt = _("mode of %s retained as %04lo (%s)\n");
break;
printf (fmt, quote (file),
(unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]);
return;
default:
abort ();
}
printf (fmt, quote (file),
(unsigned long int) (old_mode & CHMOD_MODE_BITS), &old_perms[1],
(unsigned long int) (mode & CHMOD_MODE_BITS), &perms[1]);
}
@@ -284,7 +292,7 @@ process_file (FTS *fts, FTSENT *ent)
: !chmod_succeeded ? CH_NOT_APPLIED
: !changed ? CH_NO_CHANGE_REQUESTED
: CH_SUCCEEDED);
describe_change (file_full_name, new_mode, ch_status);
describe_change (file_full_name, old_mode, new_mode, ch_status);
}
}

View File

@@ -102,17 +102,45 @@ uid_to_name (uid_t uid)
: umaxtostr (uid, buf));
}
/* Allocate a string representing USER and GROUP. */
static char *
user_group_str (char const *user, char const *group)
{
char *spec = NULL;
if (user)
{
if (group)
{
spec = xmalloc (strlen (user) + 1 + strlen (group) + 1);
stpcpy (stpcpy (stpcpy (spec, user), ":"), group);
}
else
{
spec = xstrdup (user);
}
}
else if (group)
{
spec = xstrdup (group);
}
return spec;
}
/* Tell the user how/if the user and group of FILE have been changed.
If USER is NULL, give the group-oriented messages.
CHANGED describes what (if anything) has happened. */
static void
describe_change (const char *file, enum Change_status changed,
char const *old_user, char const *old_group,
char const *user, char const *group)
{
const char *fmt;
char const *spec;
char *spec_allocated = NULL;
char *old_spec;
char *spec;
if (changed == CH_NOT_APPLIED)
{
@@ -121,35 +149,32 @@ describe_change (const char *file, enum Change_status changed,
return;
}
if (user)
{
if (group)
{
spec_allocated = xmalloc (strlen (user) + 1 + strlen (group) + 1);
stpcpy (stpcpy (stpcpy (spec_allocated, user), ":"), group);
spec = spec_allocated;
}
else
{
spec = user;
}
}
else
{
spec = group;
}
spec = user_group_str (user, group);
old_spec = user_group_str (user ? old_user : NULL, group ? old_group : NULL);
switch (changed)
{
case CH_SUCCEEDED:
fmt = (user ? _("changed ownership of %s to %s\n")
: group ? _("changed group of %s to %s\n")
fmt = (user ? _("changed ownership of %s from %s to %s\n")
: group ? _("changed group of %s from %s to %s\n")
: _("no change to ownership of %s\n"));
break;
case CH_FAILED:
fmt = (user ? _("failed to change ownership of %s to %s\n")
: group ? _("failed to change group of %s to %s\n")
: _("failed to change ownership of %s\n"));
if (old_spec)
{
fmt = (user ? _("failed to change ownership of %s from %s to %s\n")
: group ? _("failed to change group of %s from %s to %s\n")
: _("failed to change ownership of %s\n"));
}
else
{
fmt = (user ? _("failed to change ownership of %s to %s\n")
: group ? _("failed to change group of %s to %s\n")
: _("failed to change ownership of %s\n"));
free (old_spec);
old_spec = spec;
spec = NULL;
}
break;
case CH_NO_CHANGE_REQUESTED:
fmt = (user ? _("ownership of %s retained as %s\n")
@@ -160,9 +185,10 @@ describe_change (const char *file, enum Change_status changed,
abort ();
}
printf (fmt, quote (file), spec);
printf (fmt, quote (file), old_spec, spec);
free (spec_allocated);
free (old_spec);
free (spec);
}
/* Change the owner and/or group of the FILE to UID and/or GID (safely)
@@ -230,12 +256,10 @@ restricted_chown (int cwd_fd, char const *file,
}
}
{ /* FIXME: remove these curly braces when we assume C99. */
int saved_errno = errno;
close (fd);
errno = saved_errno;
return status;
}
int saved_errno = errno;
close (fd);
errno = saved_errno;
return status;
}
/* Change the owner and/or group of the file specified by FTS and ENT
@@ -459,8 +483,13 @@ change_file_owner (FTS *fts, FTSENT *ent,
: !symlink_changed ? CH_NOT_APPLIED
: !changed ? CH_NO_CHANGE_REQUESTED
: CH_SUCCEEDED);
char *old_usr = file_stats ? uid_to_name (file_stats->st_uid) : NULL;
char *old_grp = file_stats ? gid_to_name (file_stats->st_gid) : NULL;
describe_change (file_full_name, ch_status,
old_usr, old_grp,
chopt->user_name, chopt->group_name);
free (old_usr);
free (old_grp);
}
}

View File

@@ -68,13 +68,13 @@ struct Chown_option
void
chopt_init (struct Chown_option *);
void
void _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST
chopt_free (struct Chown_option *);
char *
gid_to_name (gid_t);
char *
char * _GL_ATTRIBUTE_PURE
uid_to_name (uid_t);
bool

View File

@@ -47,9 +47,11 @@
#include "hash.h"
#include "hash-triple.h"
#include "ignore-value.h"
#include "ioblksize.h"
#include "quote.h"
#include "same.h"
#include "savedir.h"
#include "stat-size.h"
#include "stat-time.h"
#include "utimecmp.h"
#include "utimens.h"
@@ -466,7 +468,7 @@ extent_copy (int src_fd, int dest_fd, char *buf, size_t buf_size,
performance hit that's probably noticeable only on trees deeper
than a few hundred levels. See use of active_dir_map in remove.c */
static bool
static bool _GL_ATTRIBUTE_PURE
is_ancestor (const struct stat *sb, const struct dir_list *ancestors)
{
while (ancestors != 0)
@@ -949,7 +951,9 @@ copy_reg (char const *src_name, char const *dst_name,
dest_errno = ENOTDIR;
}
else
omitted_permissions = 0;
{
omitted_permissions = 0;
}
if (dest_desc < 0)
{
@@ -975,7 +979,7 @@ copy_reg (char const *src_name, char const *dst_name,
if (!clone_ok)
{
error (0, errno, _("failed to clone %s from %s"),
quote (dst_name), quote (src_name));
quote_n (0, dst_name), quote_n (1, src_name));
return_val = false;
goto close_src_and_dst_desc;
}
@@ -1486,6 +1490,43 @@ restore_default_fscreatecon_or_die (void)
_("failed to restore the default file creation context"));
}
/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and
VERBOSE settings. Return true upon success. Otherwise, diagnose
the failure and return false.
If SRC_NAME is a symbolic link it will not be followed. If the system
doesn't support hard links to symbolic links, then DST_NAME will
be created as a symbolic link to SRC_NAME. */
static bool
create_hard_link (char const *src_name, char const *dst_name,
bool replace, bool verbose)
{
/* We want to guarantee that symlinks are not followed. */
bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0);
/* If the link failed because of an existing destination,
remove that file and then call link again. */
if (link_failed && replace && errno == EEXIST)
{
if (unlink (dst_name) != 0)
{
error (0, errno, _("cannot remove %s"), quote (dst_name));
return false;
}
if (verbose)
printf (_("removed %s\n"), quote (dst_name));
link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0);
}
if (link_failed)
{
error (0, errno, _("cannot create hard link %s to %s"),
quote_n (0, dst_name), quote_n (1, src_name));
return false;
}
return true;
}
/* Copy the file SRC_NAME to the file DST_NAME. The files may be of
any type. NEW_DST should be true if the file DST_NAME cannot
exist because its parent directory was just created; NEW_DST should
@@ -1626,6 +1667,25 @@ copy_internal (char const *src_name, char const *dst_name,
end up removing the source file. */
if (rename_succeeded)
*rename_succeeded = true;
/* However, we still must record that we've processed
this src/dest pair, in case this source file is
hard-linked to another one. In that case, we'll use
the mapping information to link the corresponding
destination names. */
earlier_file = remember_copied (dst_name, src_sb.st_ino,
src_sb.st_dev);
if (earlier_file)
{
/* Note we currently replace DST_NAME unconditionally,
even if it was a newer separate file. */
if (! create_hard_link (earlier_file, dst_name, true,
x->verbose))
{
goto un_backup;
}
}
return true;
}
}
@@ -1946,31 +2006,8 @@ copy_internal (char const *src_name, char const *dst_name,
}
else
{
/* We want to guarantee that symlinks are not followed. */
bool link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
dst_name, 0) != 0);
/* If the link failed because of an existing destination,
remove that file and then call link again. */
if (link_failed && errno == EEXIST)
{
if (unlink (dst_name) != 0)
{
error (0, errno, _("cannot remove %s"), quote (dst_name));
goto un_backup;
}
if (x->verbose)
printf (_("removed %s\n"), quote (dst_name));
link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
dst_name, 0) != 0);
}
if (link_failed)
{
error (0, errno, _("cannot create hard link %s to %s"),
quote_n (0, dst_name), quote_n (1, earlier_file));
goto un_backup;
}
if (! create_hard_link (earlier_file, dst_name, true, x->verbose))
goto un_backup;
return true;
}
@@ -2197,6 +2234,10 @@ copy_internal (char const *src_name, char const *dst_name,
if (x->verbose)
emit_verbose (src_name, dst_name, NULL);
}
else
{
omitted_permissions = 0;
}
/* Decide whether to copy the contents of the directory. */
if (x->one_file_system && device != 0 && device != src_sb.st_dev)
@@ -2272,11 +2313,8 @@ copy_internal (char const *src_name, char const *dst_name,
&& !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode)
&& x->dereference == DEREF_NEVER))
{
if (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0))
{
error (0, errno, _("cannot create link %s"), quote (dst_name));
goto un_backup;
}
if (! create_hard_link (src_name, dst_name, false, false))
goto un_backup;
}
else if (S_ISREG (src_mode)
|| (x->copy_as_regular && !S_ISLNK (src_mode)))
@@ -2533,7 +2571,7 @@ un_backup:
return false;
}
static bool
static bool _GL_ATTRIBUTE_PURE
valid_options (const struct cp_options *co)
{
assert (co != NULL);

View File

@@ -282,7 +282,7 @@ void dest_info_init (struct cp_options *);
void src_info_init (struct cp_options *);
void cp_options_default (struct cp_options *);
bool chown_failure_ok (struct cp_options const *);
bool chown_failure_ok (struct cp_options const *) _GL_ATTRIBUTE_PURE;
mode_t cached_umask (void);
#endif

View File

@@ -22,7 +22,6 @@
#include <sys/types.h>
#include "system.h"
#include "same.h"
#include "hash.h"
#include "cp-hash.h"

View File

@@ -187,7 +187,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-H follow command-line symbolic links in SOURCE\n\
"), stdout);
fputs (_("\
-l, --link link files instead of copying\n\
-l, --link hard link files instead of copying\n\
-L, --dereference always follow symbolic links in SOURCE\n\
"), stdout);
fputs (_("\

View File

@@ -225,6 +225,7 @@ static void
interrupt_handler (int sig)
{
delete_all_files (true);
signal (sig, SIG_DFL);
/* The signal has been reset to SIG_DFL, but blocked during this
handler. Force the default action of this signal once the
handler returns and the block is removed. */
@@ -1421,7 +1422,7 @@ main (int argc, char **argv)
act.sa_handler = interrupt_handler;
act.sa_mask = caught_signals;
act.sa_flags = SA_NODEFER | SA_RESETHAND;
act.sa_flags = 0;
for (i = 0; i < nsigs; i++)
if (sigismember (&caught_signals, sig[i]))

View File

@@ -179,8 +179,8 @@ FORMAT controls the output. Interpreted sequences are:\n\
%j day of year (001..366)\n\
"), stdout);
fputs (_("\
%k hour ( 0..23)\n\
%l hour ( 1..12)\n\
%k hour, space padded ( 0..23); same as %_H\n\
%l hour, space padded ( 1..12); same as %_I\n\
%m month (01..12)\n\
%M minute (00..59)\n\
"), stdout);
@@ -235,6 +235,18 @@ After any flags comes an optional field width, as a decimal number;\n\
then an optional modifier, which is either\n\
E to use the locale's alternate representations if available, or\n\
O to use the locale's alternate numeric symbols if available.\n\
"), stdout);
fputs (_("\
\n\
Examples:\n\
Convert seconds since the epoch (1970-01-01 UTC) to a date\n\
$ date --date='@2147483647'\n\
\n\
Show the time on the west coast of the US (use tzselect(1) to find TZ)\n\
$ TZ='America/Los_Angeles' date\n\
\n\
Show the local time for 9AM next Friday on the west coast of the US\n\
$ date --date='TZ=\"America/Los_Angeles\" 09:00 next Fri'\n\
"), stdout);
emit_ancillary_info ();
}

View File

@@ -27,7 +27,6 @@
#include "system.h"
#include "close-stream.h"
#include "error.h"
#include "fadvise.h"
#include "fd-reopen.h"
#include "gethrxtime.h"
#include "human.h"
@@ -46,7 +45,7 @@
proper_name ("Stuart Kemp")
/* Use SA_NOCLDSTOP as a proxy for whether the sigaction machinery is
present. SA_NODEFER and SA_RESETHAND are XSI extensions. */
present. */
#ifndef SA_NOCLDSTOP
# define SA_NOCLDSTOP 0
# define sigprocmask(How, Set, Oset) /* empty */
@@ -56,6 +55,11 @@
# endif
#endif
/* NonStop circa 2011 lacks SA_RESETHAND; see Bug#9076. */
#ifndef SA_RESETHAND
# define SA_RESETHAND 0
#endif
#ifndef SIGINFO
# define SIGINFO SIGUSR1
#endif
@@ -727,9 +731,6 @@ install_signal_handlers (void)
if (sigismember (&caught_signals, SIGINT))
{
/* POSIX 1003.1-2001 says SA_RESETHAND implies SA_NODEFER,
but this is not true on Solaris 8 at least. It doesn't
hurt to use SA_NODEFER here, so leave it in. */
act.sa_handler = interrupt_handler;
act.sa_flags = SA_NODEFER | SA_RESETHAND;
sigaction (SIGINT, &act, NULL);
@@ -1029,7 +1030,7 @@ write_output (void)
/* Return true if STR is of the form "PATTERN" or "PATTERNDELIM...". */
static bool
static bool _GL_ATTRIBUTE_PURE
operand_matches (char const *str, char const *pattern, char delim)
{
while (*pattern)
@@ -1109,7 +1110,7 @@ parse_integer (const char *str, bool *invalid)
/* OPERAND is of the form "X=...". Return true if X is NAME. */
static bool
static bool _GL_ATTRIBUTE_PURE
operand_is (char const *operand, char const *name)
{
return operand_matches (operand, name, '=');

View File

@@ -215,7 +215,7 @@ print_table (void)
{
size_t width = widths[field];
char *cell = table[row][field];
if (!cell)
if (!cell) /* Missing type column, or mount point etc. */
continue;
/* Note the DEV_FIELD used to be displayed on it's own line
@@ -227,9 +227,9 @@ print_table (void)
fputs (cell, stdout);
else
{
cell = ambsalign (table[row][field], &width,
alignments[field], MBA_UNIBYTE_FALLBACK);
fputs (cell, stdout);
cell = ambsalign (cell, &width, alignments[field], 0);
/* When ambsalign fails, output unaligned data. */
fputs (cell ? cell : table[row][field], stdout);
free (cell);
}
IF_LINT (free (table[row][field]));
@@ -241,7 +241,7 @@ print_table (void)
IF_LINT (free (table));
}
/* Optain the appropriate header entries. */
/* Obtain the appropriate header entries. */
static void
get_header (void)
@@ -321,7 +321,7 @@ get_header (void)
/* Is FSTYPE a type of file system that should be listed? */
static bool
static bool _GL_ATTRIBUTE_PURE
selected_fstype (const char *fstype)
{
const struct fs_type_list *fsp;
@@ -336,7 +336,7 @@ selected_fstype (const char *fstype)
/* Is FSTYPE a type of file system that should be omitted? */
static bool
static bool _GL_ATTRIBUTE_PURE
excluded_fstype (const char *fstype)
{
const struct fs_type_list *fsp;
@@ -417,7 +417,7 @@ add_uint_with_neg_flag (uintmax_t *dest, bool *dest_neg,
*dest = -*dest;
}
/* Optain a space listing for the disk device with absolute file name DISK.
/* Obtain a space listing for the disk device with absolute file name DISK.
If MOUNT_POINT is non-NULL, it is the name of the root of the
file system on DISK.
If STAT_FILE is non-null, it is the name of a file within the file

View File

@@ -456,7 +456,7 @@ to select a shell syntax are mutually exclusive"));
if (print_database)
{
char const *p = G_line;
while (p < G_line + sizeof G_line)
while (p - G_line < sizeof G_line)
{
puts (p);
p += strlen (p) + 1;

View File

@@ -49,6 +49,7 @@ TERM screen-256color
TERM screen-256color-bce
TERM screen-bce
TERM screen-w
TERM screen.Eterm
TERM screen.rxvt
TERM screen.linux
TERM terminator
@@ -163,6 +164,7 @@ EXEC 01;32
.mpeg 01;35
.m2v 01;35
.mkv 01;35
.webm 01;35
.ogm 01;35
.mp4 01;35
.m4v 01;35

View File

@@ -37,7 +37,7 @@
#include "human.h"
#include "quote.h"
#include "quotearg.h"
#include "same.h"
#include "stat-size.h"
#include "stat-time.h"
#include "stdio--.h"
#include "xfts.h"

View File

@@ -123,13 +123,17 @@ main (int argc, char **argv)
if (optind < argc && STREQ (argv[optind], "-"))
++optind;
while (optind < argc && strchr (argv[optind], '='))
if (putenv (argv[optind++]))
{
char *name = argv[optind - 1];
*(strchr (name, '=')) = '\0';
error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name));
}
char *eq;
while (optind < argc && (eq = strchr (argv[optind], '=')))
{
if (putenv (argv[optind]))
{
*eq = '\0';
error (EXIT_CANCELED, errno, _("cannot set %s"),
quote (argv[optind]));
}
optind++;
}
/* If no program is specified, print the environment and exit. */
if (argc <= optind)

View File

@@ -312,15 +312,17 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
usage, AUTHORS, (char const *) NULL);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle `--' here. */
if (argc > 1 && STREQ (argv[1], "--"))
unsigned int u_argc = argc;
if (1 < u_argc && STREQ (argv[1], "--"))
{
--argc;
--u_argc;
++argv;
}
if (argc <= 1)
if (u_argc <= 1)
{
error (0, 0, _("missing operand"));
usage (EXPR_INVALID);
@@ -391,7 +393,7 @@ printv (VALUE *v)
/* Return true if V is a null-string or zero-number. */
static bool
static bool _GL_ATTRIBUTE_PURE
null (VALUE *v)
{
switch (v->type)
@@ -422,7 +424,7 @@ null (VALUE *v)
/* Return true if CP takes the form of an integer. */
static bool
static bool _GL_ATTRIBUTE_PURE
looks_like_integer (char const *cp)
{
cp += (*cp == '-');
@@ -483,7 +485,7 @@ toarith (VALUE *v)
}
}
/* Extract a size_t value from a integer value I.
/* Extract a size_t value from an integer value I.
If the value is negative, return SIZE_MAX.
If the value is too large, return SIZE_MAX - 1. */
static size_t

View File

@@ -24,11 +24,9 @@
#include "system.h"
#include "extent-scan.h"
#include "fiemap.h"
#include "xstrtol.h"
#ifndef HAVE_FIEMAP
# include "fiemap.h"
#endif
/* Work around Linux kernel issues on BTRFS and EXT4 before 2.6.39.
FIXME: remove in 2013, or whenever we're pretty confident
@@ -50,7 +48,7 @@ extent_need_sync (void)
struct utsname name;
need_sync = 0; /* No workaround by default. */
#ifdef __linux__
# ifdef __linux__
if (uname (&name) != -1 && STRNCMP_LIT (name.release, "2.6.") == 0)
{
unsigned long val;
@@ -60,7 +58,7 @@ extent_need_sync (void)
need_sync = 1;
}
}
#endif
# endif
}
return need_sync;

View File

@@ -160,7 +160,7 @@ factor_using_pollard_rho (mpz_t n, int a_int)
mpz_t a;
mpz_t g;
mpz_t t1, t2;
int k, l, c, i;
int k, l, c;
debug ("[pollard-rho (%d)] ", a_int);
@@ -204,6 +204,7 @@ S2:
mpz_set (x1, x);
k = l;
l = 2 * l;
unsigned int i;
for (i = 0; i < k; i++)
{
mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n);

View File

@@ -51,8 +51,13 @@ struct fiemap
uint32_t fm_reserved;
/* Array of mapped extents(out). */
/* Array of mapped extents(out).
This is protected by the ifdef because it uses non standard
zero length arrays. Note C99 has the equivalent flexible arrays,
but we don't use those for maximum portability to older systems. */
# ifdef __linux__
struct fiemap_extent fm_extents[0];
# endif
};
/* The maximum offset can be mapped for a file. */

View File

@@ -32,7 +32,6 @@
#include "system.h"
#include "error.h"
#include "full-write.h"
#include "full-read.h"
#include "quote.h"
#include "safe-read.h"
@@ -390,7 +389,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0)
}
}
free_mem:;
free_mem:
for (i = 0; i < n_bufs; i++)
free (b[i]);
free (b);
@@ -422,8 +421,8 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide)
off_t diff;
enum Copy_fd_status err;
if ((current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) == -1
|| (end_pos = lseek (fd, (off_t) 0, SEEK_END)) == -1)
if ((current_pos = lseek (fd, 0, SEEK_CUR)) == -1
|| (end_pos = lseek (fd, 0, SEEK_END)) == -1)
{
error (0, errno, _("cannot lseek %s"), quote (filename));
return false;
@@ -438,7 +437,7 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide)
/* Seek back to `current' position, then copy the required
number of bytes from fd. */
if (lseek (fd, (off_t) 0, current_pos) == -1)
if (lseek (fd, 0, current_pos) == -1)
{
error (0, errno, _("%s: cannot lseek back to original position"),
quote (filename));
@@ -716,8 +715,8 @@ elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide)
If found, write from current position to OFF, inclusive.
Otherwise, just return true. */
off_t start_pos = lseek (fd, (off_t) 0, SEEK_CUR);
off_t end_pos = lseek (fd, (off_t) 0, SEEK_END);
off_t start_pos = lseek (fd, 0, SEEK_CUR);
off_t end_pos = lseek (fd, 0, SEEK_END);
if (0 <= start_pos && start_pos < end_pos)
{
/* If the file is empty, we're done. */

66
src/ioblksize.h Normal file
View File

@@ -0,0 +1,66 @@
/* I/O block size definitions for coreutils
Copyright (C) 1989, 1991-2011 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 3 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, see <http://www.gnu.org/licenses/>. */
/* Include this file _after_ system headers if possible. */
/* sys/stat.h will already have been included by system.h. */
#include "stat-size.h"
/* As of Mar 2009, 32KiB is determined to be the minimium
blksize to best minimize system call overhead.
This can be tested with this script with the results
shown for a 1.7GHz pentium-m with 2GB of 400MHz DDR2 RAM:
for i in $(seq 0 10); do
size=$((8*1024**3)) #ensure this is big enough
bs=$((1024*2**$i))
printf "%7s=" $bs
dd bs=$bs if=/dev/zero of=/dev/null count=$(($size/$bs)) 2>&1 |
sed -n 's/.* \([0-9.]* [GM]B\/s\)/\1/p'
done
1024=734 MB/s
2048=1.3 GB/s
4096=2.4 GB/s
8192=3.5 GB/s
16384=3.9 GB/s
32768=5.2 GB/s
65536=5.3 GB/s
131072=5.5 GB/s
262144=5.7 GB/s
524288=5.7 GB/s
1048576=5.8 GB/s
Note that this is to minimize system call overhead.
Other values may be appropriate to minimize file system
or disk overhead. For example on my current GNU/Linux system
the readahead setting is 128KiB which was read using:
file="."
device=$(df -P --local "$file" | tail -n1 | cut -d' ' -f1)
echo $(( $(blockdev --getra $device) * 512 ))
However there isn't a portable way to get the above.
In the future we could use the above method if available
and default to io_blksize() if not.
*/
enum { IO_BUFSIZE = 32*1024 };
static inline size_t
io_blksize (struct stat sb)
{
return MAX (IO_BUFSIZE, ST_BLKSIZE (sb));
}

View File

@@ -86,9 +86,15 @@ struct seq
struct line **lines;
};
/* The previous line read from each file. */
/* The previous line read from each file. */
static struct line *prevline[2] = {NULL, NULL};
/* The number of lines read from each file. */
static uintmax_t line_no[2] = {0, 0};
/* The input file names. */
static char *g_names[2];
/* This provides an extra line buffer for each file. We need these if we
try to read two consecutive lines into the same buffer, since we don't
want to overwrite the previous buffer before we check order. */
@@ -384,12 +390,23 @@ check_order (const struct line *prev,
size_t join_field = whatfile == 1 ? join_field_1 : join_field_2;
if (keycmp (prev, current, join_field, join_field) > 0)
{
/* Exclude any trailing newline. */
size_t len = current->buf.length;
if (0 < len && current->buf.buffer[len - 1] == '\n')
--len;
/* If the offending line is longer than INT_MAX, output
only the first INT_MAX bytes in this diagnostic. */
len = MIN (INT_MAX, len);
error ((check_input_order == CHECK_ORDER_ENABLED
? EXIT_FAILURE : 0),
0, _("file %d is not in sorted order"), whatfile);
0, _("%s:%ju: is not sorted: %.*s"),
g_names[whatfile - 1], line_no[whatfile - 1],
(int) len, current->buf.buffer);
/* If we get to here, the message was just a warning, but we
want only to issue it once. */
/* If we get to here, the message was merely a warning.
Arrange to issue it only once per file. */
issued_disorder_warning[whatfile-1] = true;
}
}
@@ -405,8 +422,7 @@ reset_line (struct line *line)
static struct line *
init_linep (struct line **linep)
{
struct line *line = xmalloc (sizeof *line);
memset (line, '\0', sizeof *line);
struct line *line = xcalloc (1, sizeof *line);
*linep = line;
return line;
}
@@ -437,6 +453,7 @@ get_line (FILE *fp, struct line **linep, int which)
freeline (line);
return false;
}
++line_no[which - 1];
xfields (line);
@@ -981,7 +998,6 @@ main (int argc, char **argv)
int prev_optc_status = MUST_BE_OPERAND;
int operand_status[2];
int joption_count[2] = { 0, 0 };
char *names[2];
FILE *fp1, *fp2;
int optc;
int nfiles = 0;
@@ -1101,7 +1117,7 @@ main (int argc, char **argv)
break;
case 1: /* Non-option argument. */
add_file_name (optarg, names, operand_status, joption_count,
add_file_name (optarg, g_names, operand_status, joption_count,
&nfiles, &prev_optc_status, &optc_status);
break;
@@ -1123,7 +1139,7 @@ main (int argc, char **argv)
/* Process any operands after "--". */
prev_optc_status = MUST_BE_OPERAND;
while (optind < argc)
add_file_name (argv[optind++], names, operand_status, joption_count,
add_file_name (argv[optind++], g_names, operand_status, joption_count,
&nfiles, &prev_optc_status, &optc_status);
if (nfiles != 2)
@@ -1149,20 +1165,20 @@ main (int argc, char **argv)
if (join_field_2 == SIZE_MAX)
join_field_2 = 0;
fp1 = STREQ (names[0], "-") ? stdin : fopen (names[0], "r");
fp1 = STREQ (g_names[0], "-") ? stdin : fopen (g_names[0], "r");
if (!fp1)
error (EXIT_FAILURE, errno, "%s", names[0]);
fp2 = STREQ (names[1], "-") ? stdin : fopen (names[1], "r");
error (EXIT_FAILURE, errno, "%s", g_names[0]);
fp2 = STREQ (g_names[1], "-") ? stdin : fopen (g_names[1], "r");
if (!fp2)
error (EXIT_FAILURE, errno, "%s", names[1]);
error (EXIT_FAILURE, errno, "%s", g_names[1]);
if (fp1 == fp2)
error (EXIT_FAILURE, errno, _("both files cannot be standard input"));
join (fp1, fp2);
if (fclose (fp1) != 0)
error (EXIT_FAILURE, errno, "%s", names[0]);
error (EXIT_FAILURE, errno, "%s", g_names[0]);
if (fclose (fp2) != 0)
error (EXIT_FAILURE, errno, "%s", names[1]);
error (EXIT_FAILURE, errno, "%s", g_names[1]);
if (issued_disorder_warning[0] || issued_disorder_warning[1])
exit (EXIT_FAILURE);

View File

@@ -21,7 +21,6 @@
#include <getopt.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/wait.h>
#include "system.h"
#include "error.h"
@@ -293,7 +292,7 @@ main (int argc, char **argv)
default:
usage (EXIT_FAILURE);
}
no_more_options:;
no_more_options:
if (signum < 0)
signum = SIGTERM;

View File

@@ -53,7 +53,6 @@
#include <stdio.h>
#include <assert.h>
#include <setjmp.h>
#include <grp.h>
#include <pwd.h>
#include <getopt.h>
#include <signal.h>
@@ -75,6 +74,14 @@
# endif
#endif
/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt, so don't
restart syscalls after a signal handler fires. This may cause
colors to get messed up on the screen if 'ls' is interrupted, but
that's the best we can do on such a platform. */
#ifndef SA_RESTART
# define SA_RESTART 0
#endif
#include "system.h"
#include <fnmatch.h>
@@ -95,7 +102,7 @@
#include "obstack.h"
#include "quote.h"
#include "quotearg.h"
#include "same.h"
#include "stat-size.h"
#include "stat-time.h"
#include "strftime.h"
#include "xstrtol.h"
@@ -2265,12 +2272,21 @@ get_funky_string (char **dest, const char **src, bool equals_end,
return state != ST_ERROR;
}
enum parse_state
{
PS_START = 1,
PS_2,
PS_3,
PS_4,
PS_DONE,
PS_FAIL
};
static void
parse_ls_color (void)
{
const char *p; /* Pointer to character being parsed */
char *buf; /* color_buf buffer pointer */
int state; /* State of parser */
int ind_no; /* Indicator number */
char label[3]; /* Indicator label */
struct color_ext_type *ext; /* Extension we are working on */
@@ -2287,12 +2303,12 @@ parse_ls_color (void)
advance. */
buf = color_buf = xstrdup (p);
state = 1;
while (state > 0)
enum parse_state state = PS_START;
while (true)
{
switch (state)
{
case 1: /* First label character */
case PS_START: /* First label character */
switch (*p)
{
case ':':
@@ -2313,32 +2329,32 @@ parse_ls_color (void)
ext->ext.string = buf;
state = (get_funky_string (&buf, &p, true, &ext->ext.len)
? 4 : -1);
? PS_4 : PS_FAIL);
break;
case '\0':
state = 0; /* Done! */
break;
state = PS_DONE; /* Done! */
goto done;
default: /* Assume it is file type label */
label[0] = *(p++);
state = 2;
state = PS_2;
break;
}
break;
case 2: /* Second label character */
case PS_2: /* Second label character */
if (*p)
{
label[1] = *(p++);
state = 3;
state = PS_3;
}
else
state = -1; /* Error */
state = PS_FAIL; /* Error */
break;
case 3: /* Equal sign after indicator label */
state = -1; /* Assume failure... */
case PS_3: /* Equal sign after indicator label */
state = PS_FAIL; /* Assume failure... */
if (*(p++) == '=')/* It *should* be... */
{
for (ind_no = 0; indicator_name[ind_no] != NULL; ++ind_no)
@@ -2348,29 +2364,36 @@ parse_ls_color (void)
color_indicator[ind_no].string = buf;
state = (get_funky_string (&buf, &p, false,
&color_indicator[ind_no].len)
? 1 : -1);
? PS_START : PS_FAIL);
break;
}
}
if (state == -1)
if (state == PS_FAIL)
error (0, 0, _("unrecognized prefix: %s"), quotearg (label));
}
break;
case 4: /* Equal sign after *.ext */
case PS_4: /* Equal sign after *.ext */
if (*(p++) == '=')
{
ext->seq.string = buf;
state = (get_funky_string (&buf, &p, false, &ext->seq.len)
? 1 : -1);
? PS_START : PS_FAIL);
}
else
state = -1;
state = PS_FAIL;
break;
case PS_FAIL:
goto done;
default:
abort ();
}
}
done:
if (state < 0)
if (state == PS_FAIL)
{
struct color_ext_type *e;
struct color_ext_type *e2;
@@ -2740,7 +2763,10 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
/* When coloring a directory (we may know the type from
direct.d_type), we have to stat it in order to indicate
sticky and/or other-writable attributes. */
|| (type == directory && print_with_color)
|| (type == directory && print_with_color
&& (is_colored (C_OTHER_WRITABLE)
|| is_colored (C_STICKY)
|| is_colored (C_STICKY_OTHER_WRITABLE)))
/* 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)
@@ -3891,7 +3917,7 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
reach its end, replacing each non-printable multibyte
character with a single question mark. */
{
DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
mbstate_t mbstate = { 0, };
do
{
wchar_t wc;
@@ -4129,7 +4155,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target)
{
name = f->linkname;
mode = f->linkmode;
linkok = f->linkok - 1;
linkok = f->linkok ? 0 : -1;
}
else
{
@@ -4570,7 +4596,7 @@ usage (int status)
printf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
fputs (_("\
List information about the FILEs (the current directory by default).\n\
Sort entries alphabetically if none of -cftuvSUX nor --sort.\n\
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.\n\
\n\
"), stdout);
fputs (_("\
@@ -4590,7 +4616,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-c with -lt: sort by, and show, ctime (time of last\n\
modification of file status information)\n\
with -l: show ctime and sort by name\n\
otherwise: sort by ctime\n\
otherwise: sort by ctime, newest first\n\
"), stdout);
fputs (_("\
-C list entries by columns\n\
@@ -4693,7 +4719,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
takes effect only outside the POSIX locale\n\
"), stdout);
fputs (_("\
-t sort by modification time\n\
-t sort by modification time, newest first\n\
-T, --tabsize=COLS assume tab stops at each COLS instead of 8\n\
"), stdout);
fputs (_("\

View File

@@ -122,12 +122,17 @@ static bool warn = false;
/* With --check, suppress the "OK" printed for each verified file. */
static bool quiet = false;
/* With --check, exit with a non-zero return code if any line is
improperly formatted. */
static bool strict = false;
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
STATUS_OPTION = CHAR_MAX + 1,
QUIET_OPTION
QUIET_OPTION,
STRICT_OPTION
};
static struct option const long_options[] =
@@ -138,6 +143,7 @@ static struct option const long_options[] =
{ "status", no_argument, NULL, STATUS_OPTION },
{ "text", no_argument, NULL, 't' },
{ "warn", no_argument, NULL, 'w' },
{ "strict", no_argument, NULL, STRICT_OPTION },
{ GETOPT_HELP_OPTION_DECL },
{ GETOPT_VERSION_OPTION_DECL },
{ NULL, 0, NULL, 0 }
@@ -186,6 +192,9 @@ The following three options are useful only when verifying checksums:\n\
--status don't output anything, status code shows success\n\
-w, --warn warn about improperly formatted checksum lines\n\
\n\
"), stdout);
fputs (_("\
--strict with --check, exit non-zero for any invalid input\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -355,7 +364,7 @@ split_3 (char *s, size_t s_len,
/* Return true if S is a NUL-terminated string of DIGEST_HEX_BYTES hex digits.
Otherwise, return false. */
static bool
static bool _GL_ATTRIBUTE_PURE
hex_digits (unsigned char const *s)
{
unsigned int i;
@@ -434,6 +443,7 @@ digest_check (const char *checkfile_name)
FILE *checkfile_stream;
uintmax_t n_misformatted_lines = 0;
uintmax_t n_properly_formatted_lines = 0;
uintmax_t n_improperly_formatted_lines = 0;
uintmax_t n_mismatched_checksums = 0;
uintmax_t n_open_or_read_failures = 0;
unsigned char bin_buffer_unaligned[DIGEST_BIN_BYTES + DIGEST_ALIGN];
@@ -501,6 +511,8 @@ digest_check (const char *checkfile_name)
checkfile_name, line_number,
DIGEST_TYPE_STRING);
}
++n_improperly_formatted_lines;
}
else
{
@@ -603,7 +615,8 @@ digest_check (const char *checkfile_name)
return (n_properly_formatted_lines != 0
&& n_mismatched_checksums == 0
&& n_open_or_read_failures == 0);
&& n_open_or_read_failures == 0
&& (!strict || n_improperly_formatted_lines == 0));
}
int
@@ -657,6 +670,9 @@ main (int argc, char **argv)
warn = false;
quiet = true;
break;
case STRICT_OPTION:
strict = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
@@ -694,6 +710,13 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
if (strict & !do_check)
{
error (0, 0,
_("the --strict option is meaningful only when verifying checksums"));
usage (EXIT_FAILURE);
}
if (!O_BINARY && binary < 0)
binary = 0;

View File

@@ -71,6 +71,9 @@ usage (int status)
Create a temporary file or directory, safely, and print its name.\n\
TEMPLATE must contain at least 3 consecutive `X's in last component.\n\
If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied.\n\
"), stdout);
fputs (_("\
Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\
"), stdout);
fputs ("\n", stdout);
fputs (_("\
@@ -341,7 +344,7 @@ main (int argc, char **argv)
puts (dest_name);
/* If we created a file, but then failed to output the file
name, we should clean up the mess before failing. */
if (!dry_run && (stdout_closed = true) && close_stream (stdout) != 0)
if (!dry_run && ((stdout_closed = true), close_stream (stdout) != 0))
{
int saved_errno = errno;
remove (dest_name);

View File

@@ -1257,7 +1257,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
/* Return the least common multiple of the sizes associated
with the format specs. */
static int
static int _GL_ATTRIBUTE_PURE
get_lcm (void)
{
size_t i;
@@ -1905,7 +1905,7 @@ it must be one character from [doxn]"),
ok &= (flag_dump_strings ? dump_strings () : dump ());
cleanup:;
cleanup:
if (have_read_stdin && fclose (stdin) == EOF)
error (EXIT_FAILURE, errno, _("standard input"));

View File

@@ -145,7 +145,7 @@ collapse_escapes (char const *strptr)
}
}
done:;
done:
delim_end = strout;
return backslash_at_end ? 1 : 0;

View File

@@ -25,11 +25,6 @@
#include "quote.h"
#include "quotearg.h"
#if ! (HAVE_MBRLEN && HAVE_MBSTATE_T)
# define mbrlen(s, n, ps) 1
# define mbstate_t int
#endif
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "pathchk"
@@ -196,7 +191,7 @@ portable_chars_only (char const *file, size_t filelen)
if (*invalid)
{
DECLARE_ZEROED_AGGREGATE (mbstate_t, mbstate);
mbstate_t mbstate = { 0, };
size_t charlen = mbrlen (invalid, filelen - validlen, &mbstate);
error (0, 0,
_("nonportable character %s in file name %s"),
@@ -211,7 +206,7 @@ portable_chars_only (char const *file, size_t filelen)
/* Return the address of the start of the next file name component in F. */
static char *
static char * _GL_ATTRIBUTE_PURE
component_start (char *f)
{
while (*f == '/')
@@ -221,7 +216,7 @@ component_start (char *f)
/* Return the size of the file name component F. F must be nonempty. */
static size_t
static size_t _GL_ATTRIBUTE_PURE
component_len (char const *f)
{
size_t len;

View File

@@ -82,7 +82,7 @@ static struct option const longopts[] =
/* Count and return the number of ampersands in STR. */
static size_t
static size_t _GL_ATTRIBUTE_PURE
count_ampersands (const char *str)
{
size_t count = 0;

View File

@@ -773,7 +773,7 @@ static struct option const long_options[] =
/* Return the number of columns that have either an open file or
stored lines. */
static int
static int _GL_ATTRIBUTE_PURE
cols_ready_to_print (void)
{
COLUMN *q;
@@ -1165,7 +1165,7 @@ main (int argc, char **argv)
print_files (n_files, file_names);
else
{
int i;
unsigned int i;
for (i = 0; i < n_files; i++)
print_files (1, &file_names[i]);
}
@@ -1887,7 +1887,7 @@ print_page (void)
print_a_FF = false;
}
if (last_page_number < page_number)
if (last_page_number < ++page_number)
return false; /* Stop printing with LAST_PAGE */
reset_status (); /* Change ON_HOLD to OPEN. */
@@ -2399,7 +2399,7 @@ print_header (void)
/* The translator must ensure that formatting the translation of
"Page %"PRIuMAX does not generate more than (sizeof page_text - 1)
bytes. */
sprintf (page_text, _("Page %"PRIuMAX), page_number++);
sprintf (page_text, _("Page %"PRIuMAX), page_number);
available_width = header_width_available - mbswidth (page_text, 0);
available_width = MAX (0, available_width);
lhs_spaces = available_width >> 1;

View File

@@ -160,7 +160,7 @@ FUNC_NAME (char const *s) \
char *end; \
TYPE val; \
\
if (*s == '\"' || *s == '\'') \
if ((*s == '\"' || *s == '\'') && *(s + 1)) \
{ \
unsigned char ch = *++s; \
val = ch; \
@@ -533,7 +533,7 @@ print_formatted (const char *format, int argc, char **argv)
default:
goto no_more_flag_characters;
}
no_more_flag_characters:;
no_more_flag_characters:
if (*f == '*')
{

View File

@@ -595,7 +595,7 @@ compare_occurs (const void *void_first, const void *void_second)
| Return !0 if WORD appears in TABLE. Uses a binary search. |
`------------------------------------------------------------*/
static int
static int _GL_ATTRIBUTE_PURE
search_table (WORD *word, WORD_TABLE *table)
{
int lowest; /* current lowest possible index */
@@ -797,7 +797,7 @@ find_occurs_in_text (void)
context_start = cursor;
/* If a end of line or end of sentence sequence is defined and
/* If an end of line or end of sentence sequence is defined and
non-empty, `next_context_start' will be recomputed to be the end of
each line or sentence, before each one is processed. If no such
sequence, then `next_context_start' is set at the end of the whole

View File

@@ -100,6 +100,7 @@
#include "quotearg.h" /* For quotearg_colon */
#include "randint.h"
#include "randread.h"
#include "stat-size.h"
/* Default number of times to overwrite. */
enum { DEFAULT_PASSES = 3 };
@@ -781,7 +782,7 @@ do_wipefd (int fd, char const *qname, struct randint_source *s,
}
/* If we know that we can't possibly shred the file, give up now.
Otherwise, we may go into a infinite loop writing data before we
Otherwise, we may go into an infinite loop writing data before we
find that we can't rewind the device. */
if ((S_ISCHR (st.st_mode) && isatty (fd))
|| S_ISFIFO (st.st_mode)
@@ -907,9 +908,9 @@ static char const nameset[] =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.";
/* Increment NAME (with LEN bytes). NAME must be a big-endian base N
number with the digits taken from nameset. Return true if
successful if not (because NAME already has the greatest possible
value. */
number with the digits taken from nameset. Return true if successful.
Otherwise, (because NAME already has the greatest possible value)
return false. */
static bool
incname (char *name, size_t len)
@@ -918,6 +919,10 @@ incname (char *name, size_t len)
{
char const *p = strchr (nameset, name[len]);
/* Given that NAME is composed of bytes from NAMESET,
P will never be NULL here. */
assert (p);
/* If this character has a successor, use it. */
if (p[1])
{
@@ -1098,7 +1103,7 @@ int
main (int argc, char **argv)
{
bool ok = true;
DECLARE_ZEROED_AGGREGATE (struct Options, flags);
struct Options flags = { 0, };
char **file;
int n_files;
int c;

View File

@@ -112,7 +112,7 @@ struct rlimit { size_t rlim_cur; };
/* Heuristic value for the number of lines for which it is worth creating
a subthread, during an internal merge sort. I.e., it is a small number
of "average" lines for which sorting via two threads is faster than
sorting via one on an "average" system. On an dual-core 2.0 GHz i686
sorting via one on an "average" system. On a dual-core 2.0 GHz i686
system with 3GB of RAM and 2MB of L2 cache, a file containing 128K
lines of gensort -a output is sorted slightly faster with --parallel=2
than with --parallel=1. By contrast, using --parallel=1 is about 10%
@@ -1846,7 +1846,7 @@ static char const unit_order[UCHAR_LIM] =
separators and a decimal point, but it may not contain leading blanks.
Negative numbers get negative orders; zero numbers have a zero order. */
static int
static int _GL_ATTRIBUTE_PURE
find_unit_order (char const *number)
{
bool minus_sign = (*number == '-');
@@ -2029,7 +2029,7 @@ compare_random (char *restrict texta, size_t lena,
char *restrict textb, size_t lenb)
{
/* XFRM_DIFF records the equivalent of memcmp on the transformed
data. This is used to break ties if there is an checksum
data. This is used to break ties if there is a checksum
collision, and this is good enough given the astronomically low
probability of a collision. */
int xfrm_diff = 0;
@@ -2385,7 +2385,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
size_t eword = key->eword + 1;
if (!sword)
sword++;
if (sword != eword)
if (!eword || sword < eword)
error (0, 0, _("key %lu is numeric and spans multiple fields"),
keynum);
}

View File

@@ -25,7 +25,9 @@
#include <assert.h>
#include <stdio.h>
#include <getopt.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "system.h"
#include "error.h"
@@ -33,8 +35,10 @@
#include "fcntl--.h"
#include "full-read.h"
#include "full-write.h"
#include "ioblksize.h"
#include "quote.h"
#include "safe-read.h"
#include "sig2str.h"
#include "xfreopen.h"
#include "xstrtol.h"
@@ -45,6 +49,21 @@
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
proper_name ("Richard M. Stallman")
/* Shell command to filter through, instead of creating files. */
static char const *filter_command;
/* Process ID of the filter. */
static int filter_pid;
/* Array of open pipes. */
static int *open_pipes;
static size_t open_pipes_alloc;
static size_t n_open_pipes;
/* Blocked signals. */
static sigset_t oldblocked;
static sigset_t newblocked;
/* Base name of output files. */
static char const *outbase;
@@ -90,6 +109,7 @@ enum Split_type
enum
{
VERBOSE_OPTION = CHAR_MAX + 1,
FILTER_OPTION,
IO_BLKSIZE_OPTION
};
@@ -103,14 +123,22 @@ static struct option const longopts[] =
{"unbuffered", no_argument, NULL, 'u'},
{"suffix-length", required_argument, NULL, 'a'},
{"numeric-suffixes", no_argument, NULL, 'd'},
{"filter", required_argument, NULL, FILTER_OPTION},
{"verbose", no_argument, NULL, VERBOSE_OPTION},
{"-io-blksize", required_argument, NULL,
IO_BLKSIZE_OPTION}, /* do not document */
IO_BLKSIZE_OPTION}, /* do not document */
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
/* Return true if the errno value, ERR, is ignorable. */
static inline bool
ignorable (int err)
{
return filter_command && err == EPIPE;
}
static void
set_suffix_length (uintmax_t n_units, enum Split_type split_type)
{
@@ -155,7 +183,7 @@ usage (int status)
Usage: %s [OPTION]... [INPUT [PREFIX]]\n\
"),
program_name);
fputs (_("\
fputs (_("\
Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default\n\
size is 1000 lines, and default PREFIX is `x'. With no INPUT, or when INPUT\n\
is -, read standard input.\n\
@@ -170,6 +198,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-C, --line-bytes=SIZE put at most SIZE bytes of lines per output file\n\
-d, --numeric-suffixes use numeric suffixes instead of alphabetic\n\
-e, --elide-empty-files do not generate empty output files with `-n'\n\
--filter=COMMAND write to shell COMMAND; file name is $FILE\n\
-l, --lines=NUMBER put NUMBER lines per output file\n\
-n, --number=CHUNKS generate CHUNKS output files. See below\n\
-u, --unbuffered immediately copy input to output with `-n r/...'\n\
@@ -181,7 +210,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_size_note ();
fputs (_("\n\
fputs (_("\n\
CHUNKS may be:\n\
N split into N files based on size of input\n\
K/N output Kth of N to stdout\n\
@@ -254,12 +283,125 @@ next_file_name (void)
/* Create or truncate a file. */
static int
create (const char* name)
create (const char *name)
{
if (verbose)
fprintf (stdout, _("creating file %s\n"), quote (name));
return open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
if (!filter_command)
{
if (verbose)
fprintf (stdout, _("creating file %s\n"), quote (name));
return open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
}
else
{
int fd_pair[2];
pid_t child_pid;
char const *shell_prog = getenv ("SHELL");
if (shell_prog == NULL)
shell_prog = "/bin/sh";
if (setenv ("FILE", name, 1) != 0)
error (EXIT_FAILURE, errno,
_("failed to set FILE environment variable"));
if (verbose)
fprintf (stdout, _("executing with FILE=%s\n"), quote (name));
if (pipe (fd_pair) != 0)
error (EXIT_FAILURE, errno, _("failed to create pipe"));
child_pid = fork ();
if (child_pid == 0)
{
/* This is the child process. If an error occurs here, the
parent will eventually learn about it after doing a wait,
at which time it will emit its own error message. */
int j;
/* We have to close any pipes that were opened during an
earlier call, otherwise this process will be holding a
write-pipe that will prevent the earlier process from
reading an EOF on the corresponding read-pipe. */
for (j = 0; j < n_open_pipes; ++j)
if (close (open_pipes[j]) != 0)
error (EXIT_FAILURE, errno, _("closing prior pipe"));
if (close (fd_pair[1]))
error (EXIT_FAILURE, errno, _("closing output pipe"));
if (fd_pair[0] != STDIN_FILENO)
{
if (dup2 (fd_pair[0], STDIN_FILENO) != STDIN_FILENO)
error (EXIT_FAILURE, errno, _("moving input pipe"));
if (close (fd_pair[0]) != 0)
error (EXIT_FAILURE, errno, _("closing input pipe"));
}
sigprocmask (SIG_SETMASK, &oldblocked, NULL);
execl (shell_prog, last_component (shell_prog), "-c",
filter_command, (char *) NULL);
error (EXIT_FAILURE, errno, _("failed to run command: \"%s -c %s\""),
shell_prog, filter_command);
}
if (child_pid == -1)
error (EXIT_FAILURE, errno, _("fork system call failed"));
if (close (fd_pair[0]) != 0)
error (EXIT_FAILURE, errno, _("failed to close input pipe"));
filter_pid = child_pid;
if (n_open_pipes == open_pipes_alloc)
open_pipes = x2nrealloc (open_pipes, &open_pipes_alloc,
sizeof *open_pipes);
open_pipes[n_open_pipes++] = fd_pair[1];
return fd_pair[1];
}
}
/* Close the output file, and do any associated cleanup.
If FP and FD are both specified, they refer to the same open file;
in this case FP is closed, but FD is still used in cleanup. */
static void
closeout (FILE *fp, int fd, pid_t pid, char const *name)
{
if (fp != NULL && fclose (fp) != 0 && ! ignorable (errno))
error (EXIT_FAILURE, errno, "%s", name);
if (fd >= 0)
{
if (fp == NULL && close (fd) < 0)
error (EXIT_FAILURE, errno, "%s", name);
int j;
for (j = 0; j < n_open_pipes; ++j)
{
if (open_pipes[j] == fd)
{
open_pipes[j] = open_pipes[--n_open_pipes];
break;
}
}
}
if (pid > 0)
{
int wstatus = 0;
if (waitpid (pid, &wstatus, 0) == -1 && errno != ECHILD)
error (EXIT_FAILURE, errno, _("waiting for child process"));
if (WIFSIGNALED (wstatus))
{
int sig = WTERMSIG (wstatus);
if (sig != SIGPIPE)
{
char signame[MAX (SIG2STR_MAX, INT_BUFSIZE_BOUND (int))];
if (sig2str (sig, signame) != 0)
sprintf (signame, "%d", sig);
error (sig + 128, 0,
_("with FILE=%s, signal %s from command: %s"),
name, signame, filter_command);
}
}
else if (WIFEXITED (wstatus))
{
int ex = WEXITSTATUS (wstatus);
if (ex != 0)
error (ex, 0, _("with FILE=%s, exit %d from command: %s"),
name, ex, filter_command);
}
else
{
/* shouldn't happen. */
error (EXIT_FAILURE, 0,
_("unknown status from command (0x%X)"), wstatus);
}
}
}
/* Write BYTES bytes at BP to an output file.
@@ -273,13 +415,12 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
{
if (!bp && bytes == 0 && elide_empty_files)
return;
if (output_desc >= 0 && close (output_desc) < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
closeout (NULL, output_desc, filter_pid, outfile);
next_file_name ();
if ((output_desc = create (outfile)) < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
}
if (full_write (output_desc, bp, bytes) != bytes)
if (full_write (output_desc, bp, bytes) != bytes && ! ignorable (errno))
error (EXIT_FAILURE, errno, "%s", outfile);
}
@@ -322,6 +463,12 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, uintmax_t max_files)
cwrite (new_file_flag, bp_out, w);
opened += new_file_flag;
new_file_flag = !max_files || (opened < max_files);
if (!new_file_flag && ignorable (errno))
{
/* If filter no longer accepting input, stop reading. */
n_read = 0;
break;
}
bp_out += w;
to_read -= w;
to_write = n_bytes;
@@ -459,6 +606,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
off_t chunk_end = chunk_size - 1;
off_t n_written = 0;
bool new_file_flag = true;
bool chunk_truncated = false;
if (k > 1)
{
@@ -480,6 +628,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
chunk_truncated = false;
eob = buf + n_read;
while (bp != eob)
@@ -504,7 +653,7 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
error (EXIT_FAILURE, errno, "%s", _("write error"));
}
else
else if (! k)
cwrite (new_file_flag, bp, to_write);
n_written += to_write;
bp += to_write;
@@ -516,7 +665,11 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
while (next || chunk_end <= n_written - 1)
{
if (!next && bp == eob)
break; /* replenish buf, before going to next chunk. */
{
/* replenish buf, before going to next chunk. */
chunk_truncated = true;
break;
}
chunk_no++;
if (k && chunk_no > k)
return;
@@ -525,13 +678,19 @@ lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
else
chunk_end += chunk_size;
if (chunk_end <= n_written - 1)
cwrite (true, NULL, 0);
{
if (! k)
cwrite (true, NULL, 0);
}
else
next = false;
}
}
}
if (chunk_truncated)
chunk_no++;
/* Ensure NUMBER files are created, which truncates
any existing files or notifies any consumers on fifos.
FIXME: Should we do this before EXIT_FAILURE? */
@@ -564,7 +723,8 @@ bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
if (full_write (STDOUT_FILENO, buf, n_read) != n_read
&& ! ignorable (errno))
error (EXIT_FAILURE, errno, "%s", quote ("-"));
start += n_read;
}
@@ -574,7 +734,8 @@ typedef struct of_info
{
char *of_name;
int ofd;
FILE* ofile;
FILE *ofile;
int opid;
} of_t;
enum
@@ -615,10 +776,15 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
In specialised cases the consumer can keep reading
from the fifo, terminating on conditions in the data
itself, or perhaps never in the case of `tail -f`.
I.E. for fifos it is valid to attempt this reopen. */
fd = open (files[i_check].of_name,
O_WRONLY | O_BINARY | O_APPEND | O_NONBLOCK);
}
I.E. for fifos it is valid to attempt this reopen.
We don't handle the filter_command case here, as create()
will exit if there are not enough files in that case.
I.E. we don't support restarting filters, as that would
put too much burden on users specifying --filter commands. */
fd = open (files[i_check].of_name,
O_WRONLY | O_BINARY | O_APPEND | O_NONBLOCK);
}
if (-1 < fd)
break;
@@ -639,12 +805,15 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
if (fclose (files[i_reopen].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_reopen].of_name);
files[i_reopen].ofile = NULL;
files[i_reopen].ofd = OFD_APPEND;
}
files[i_check].ofd = fd;
if (!(files[i_check].ofile = fdopen (fd, "a")))
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
files[i_check].opid = filter_pid;
filter_pid = 0;
}
return file_limit;
@@ -658,6 +827,8 @@ ofile_open (of_t *files, size_t i_check, size_t nfiles)
static void
lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
{
bool wrapped = false;
bool wrote = false;
bool file_limit;
size_t i_file;
of_t *files IF_LINT (= NULL);
@@ -678,6 +849,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
files[i_file].of_name = xstrdup (outfile);
files[i_file].ofd = OFD_NEW;
files[i_file].ofile = NULL;
files[i_file].opid = 0;
}
i_file = 0;
file_limit = false;
@@ -734,34 +906,55 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
{
/* Note writing to fd, rather than flushing the FILE gives
an 8% performance benefit, due to reduced data copying. */
if (full_write (files[i_file].ofd, bp, to_write) != to_write)
if (full_write (files[i_file].ofd, bp, to_write) != to_write
&& ! ignorable (errno))
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
}
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1)
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1
&& ! ignorable (errno))
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
if (! ignorable (errno))
wrote = true;
if (file_limit)
{
if (fclose (files[i_file].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
files[i_file].ofile = NULL;
files[i_file].ofd = OFD_APPEND;
}
if (next && ++i_file == n)
i_file = 0;
{
wrapped = true;
/* If no filters are accepting input, stop reading. */
if (! wrote)
goto no_filters;
wrote = false;
i_file = 0;
}
}
bp = bp_out;
}
}
no_filters:
/* Ensure all files created, so that any existing files are truncated,
and to signal any waiting fifo consumers.
Also, close any open file descriptors.
FIXME: Should we do this before EXIT_FAILURE? */
for (i_file = 0; !k && !elide_empty_files && i_file < n; i_file++)
if (!k)
{
file_limit |= ofile_open (files, i_file, n);
if (fclose (files[i_file].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
int ceiling = (wrapped ? n : i_file);
for (i_file = 0; i_file < n; i_file++)
{
if (i_file >= ceiling && !elide_empty_files)
file_limit |= ofile_open (files, i_file, n);
if (files[i_file].ofd >= 0)
closeout (files[i_file].ofile, files[i_file].ofd,
files[i_file].opid, files[i_file].of_name);
files[i_file].ofd = OFD_APPEND;
}
}
}
@@ -779,9 +972,9 @@ static void
parse_chunk (uintmax_t *k_units, uintmax_t *n_units, char *slash)
{
*slash = '\0';
if (xstrtoumax (slash+1, NULL, 10, n_units, "") != LONGINT_OK
if (xstrtoumax (slash + 1, NULL, 10, n_units, "") != LONGINT_OK
|| *n_units == 0)
error (EXIT_FAILURE, 0, _("%s: invalid number of chunks"), slash+1);
error (EXIT_FAILURE, 0, _("%s: invalid number of chunks"), slash + 1);
if (slash != optarg /* a leading number is specified. */
&& (xstrtoumax (optarg, NULL, 10, k_units, "") != LONGINT_OK
|| *k_units == 0 || *n_units < *k_units))
@@ -824,7 +1017,8 @@ main (int argc, char **argv)
int this_optind = optind ? optind : 1;
char *slash;
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u", longopts, NULL);
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u",
longopts, NULL);
if (c == -1)
break;
@@ -955,6 +1149,10 @@ main (int argc, char **argv)
elide_empty_files = true;
break;
case FILTER_OPTION:
filter_command = optarg;
break;
case IO_BLKSIZE_OPTION:
{
uintmax_t tmp_blk_size;
@@ -980,6 +1178,12 @@ main (int argc, char **argv)
}
}
if (k_units != 0 && filter_command)
{
error (0, 0, _("--filter does not process a chunk extracted to stdout"));
usage (EXIT_FAILURE);
}
/* Handle default case. */
if (split_type == type_undef)
{
@@ -1048,6 +1252,18 @@ main (int argc, char **argv)
buf = ptr_align (xmalloc (in_blk_size + 1 + page_size - 1), page_size);
/* When filtering, closure of one pipe must not terminate the process,
as there may still be other streams expecting input from us. */
if (filter_command)
{
struct sigaction act;
sigemptyset (&newblocked);
sigaction (SIGPIPE, NULL, &act);
if (act.sa_handler != SIG_IGN)
sigaddset (&newblocked, SIGPIPE);
sigprocmask (SIG_BLOCK, &newblocked, &oldblocked);
}
switch (split_type)
{
case type_digits:
@@ -1086,8 +1302,7 @@ main (int argc, char **argv)
if (close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, "%s", infile);
if (output_desc >= 0 && close (output_desc) < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
closeout (NULL, output_desc, filter_pid, outfile);
exit (EXIT_SUCCESS);
}

View File

@@ -20,7 +20,7 @@
/* Keep this conditional in sync with the similar conditional in
../m4/stat-prog.m4. */
#if (STAT_STATVFS \
#if ((STAT_STATVFS || STAT_STATVFS64) \
&& (HAVE_STRUCT_STATVFS_F_BASETYPE || HAVE_STRUCT_STATVFS_F_FSTYPENAME \
|| (! HAVE_STRUCT_STATFS_F_FSTYPENAME && HAVE_STRUCT_STATVFS_F_TYPE)))
# define USE_STATVFS 1
@@ -67,6 +67,7 @@
#include "mountlist.h"
#include "quote.h"
#include "quotearg.h"
#include "stat-size.h"
#include "stat-time.h"
#include "strftime.h"
#include "find-mount-point.h"
@@ -79,7 +80,11 @@
# if HAVE_STRUCT_STATVFS_F_NAMEMAX
# define SB_F_NAMEMAX(S) ((S)->f_namemax)
# endif
# define STATFS statvfs
# if ! STAT_STATVFS && STAT_STATVFS64
# define STATFS statvfs64
# else
# define STATFS statvfs
# endif
# define STATFS_FRSIZE(S) ((S)->f_frsize)
#else
# define HAVE_STRUCT_STATXFS_F_TYPE HAVE_STRUCT_STATFS_F_TYPE
@@ -288,6 +293,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "futexfs";
case S_MAGIC_GFS: /* 0x1161970 */
return "gfs/gfs2";
case S_MAGIC_GPFS: /* 0x47504653 */
return "gpfs";
case S_MAGIC_HFS: /* 0x4244 */
return "hfs";
case S_MAGIC_HPFS: /* 0xF995E849 */
@@ -322,6 +329,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "minix v2 (30 char.)";
case S_MAGIC_MINIX_V3: /* 0x4D5A */
return "minix3";
case S_MAGIC_MQUEUE: /* 0x19800202 */
return "mqueue";
case S_MAGIC_MSDOS: /* 0x4D44 */
return "msdos";
case S_MAGIC_NCP: /* 0x564C */
@@ -340,6 +349,8 @@ human_fstype (STRUCT_STATVFS const *statfsbuf)
return "ocfs2";
case S_MAGIC_PROC: /* 0x9FA0 */
return "proc";
case S_MAGIC_PSTOREFS: /* 0x6165676C */
return "pstorefs";
case S_MAGIC_QNX4: /* 0x002F */
return "qnx4";
case S_MAGIC_RAMFS: /* 0x858458F6 */
@@ -944,7 +955,7 @@ print_stat (char *pformat, size_t prefix_len, unsigned int m,
out_uint (pformat, prefix_len, ST_NBLOCKS (*statbuf));
break;
case 'o':
out_uint (pformat, prefix_len, statbuf->st_blksize);
out_uint (pformat, prefix_len, ST_BLKSIZE (*statbuf));
break;
case 'w':
{

View File

@@ -25,7 +25,6 @@
#include "system.h"
#include "error.h"
#include "filenamecat.h"
#include "posixver.h"
#include "quote.h"
#include "xreadlink.h"
#include "xstrtol.h"
@@ -194,15 +193,14 @@ set_LD_PRELOAD (void)
char *LD_PRELOAD;
/* Note this would auto add the appropriate search path for "libstdbuf.so":
gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBDIR
gcc stdbuf.c -Wl,-rpath,'$ORIGIN' -Wl,-rpath,$PKGLIBEXECDIR
However we want the lookup done for the exec'd command not stdbuf.
Since we don't link against libstdbuf.so add it to LIBDIR rather than
LIBEXECDIR, as we'll search for it in the "sys default" case below. */
Since we don't link against libstdbuf.so add it to PKGLIBEXECDIR
rather than to LIBDIR. */
char const *const search_path[] = {
program_path,
PKGLIBDIR,
"", /* sys default */
PKGLIBEXECDIR,
NULL
};
@@ -257,7 +255,7 @@ set_LD_PRELOAD (void)
static void
set_libstdbuf_options (void)
{
int i;
unsigned int i;
for (i = 0; i < ARRAY_CARDINALITY (stdbuf); i++)
{
@@ -356,7 +354,7 @@ main (int argc, char **argv)
/* Try to preload libstdbuf first from the same path as
stdbuf is running from. */
set_program_path (argv[0]);
set_program_path (program_name);
if (!program_path)
program_path = xstrdup (PKGLIBDIR); /* Need to init to non NULL. */
set_LD_PRELOAD ();

View File

@@ -730,7 +730,7 @@ main (int argc, char **argv)
{
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
DECLARE_ZEROED_AGGREGATE (struct termios, mode);
struct termios mode = { 0, };
enum output_type output_type;
int optc;
@@ -1003,7 +1003,7 @@ main (int argc, char **argv)
{
/* Initialize to all zeroes so there is no risk memcmp will report a
spurious difference in an uninitialized portion of the structure. */
DECLARE_ZEROED_AGGREGATE (struct termios, new_mode);
struct termios new_mode = { 0, };
if (tcsetattr (STDIN_FILENO, TCSADRAIN, &mode))
error (EXIT_FAILURE, errno, "%s", device_name);
@@ -1428,7 +1428,7 @@ screen_columns (void)
}
}
static tcflag_t *
static tcflag_t * _GL_ATTRIBUTE_PURE
mode_type_flag (enum mode_type type, struct termios *mode)
{
switch (type)
@@ -1789,7 +1789,7 @@ static struct speed_map const speeds[] =
{NULL, 0, 0}
};
static speed_t
static speed_t _GL_ATTRIBUTE_PURE
string_to_baud (const char *arg)
{
int i;
@@ -1800,7 +1800,7 @@ string_to_baud (const char *arg)
return (speed_t) -1;
}
static unsigned long int
static unsigned long int _GL_ATTRIBUTE_PURE
baud_to_value (speed_t speed)
{
int i;

View File

@@ -40,11 +40,10 @@ you must include <sys/types.h> before including this file
#include <unistd.h>
/* limits.h must come before pathmax.h because limits.h on some systems
undefs PATH_MAX, whereas pathmax.h sets PATH_MAX. */
#include <limits.h>
#include "pathmax.h"
#ifndef PATH_MAX
# define PATH_MAX 8192
#endif
#include "configmake.h"
@@ -133,77 +132,6 @@ enum
/* include here for SIZE_MAX. */
#include <inttypes.h>
/* Get or fake the disk device blocksize.
Usually defined by sys/param.h (if at all). */
#if !defined DEV_BSIZE && defined BSIZE
# define DEV_BSIZE BSIZE
#endif
#if !defined DEV_BSIZE && defined BBSIZE /* SGI */
# define DEV_BSIZE BBSIZE
#endif
#ifndef DEV_BSIZE
# define DEV_BSIZE 4096
#endif
/* Extract or fake data from a `struct stat'.
ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS. */
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
# define ST_BLKSIZE(statbuf) DEV_BSIZE
# if defined _POSIX_SOURCE || !defined BSIZE /* fileblocks.c uses BSIZE. */
# define ST_NBLOCKS(statbuf) \
((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0))
# else /* !_POSIX_SOURCE && BSIZE */
# define ST_NBLOCKS(statbuf) \
(S_ISREG ((statbuf).st_mode) \
|| S_ISDIR ((statbuf).st_mode) \
? st_blocks ((statbuf).st_size) : 0)
# endif /* !_POSIX_SOURCE && BSIZE */
#else /* HAVE_STRUCT_STAT_ST_BLOCKS */
/* Some systems, like Sequents, return st_blksize of 0 on pipes.
Also, when running `rsh hpux11-system cat any-file', cat would
determine that the output stream had an st_blksize of 2147421096.
Conversely st_blksize can be 2 GiB (or maybe even larger) with XFS
on 64-bit hosts. Somewhat arbitrarily, limit the `optimal' block
size to SIZE_MAX / 8 + 1. (Dividing SIZE_MAX by only 4 wouldn't
suffice, since "cat" sometimes multiplies the result by 4.) If
anyone knows of a system for which this limit is too small, please
report it as a bug in this code. */
# define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \
&& (statbuf).st_blksize <= SIZE_MAX / 8 + 1) \
? (statbuf).st_blksize : DEV_BSIZE)
# if defined hpux || defined __hpux__ || defined __hpux
/* HP-UX counts st_blocks in 1024-byte units.
This loses when mixing HP-UX and BSD file systems with NFS. */
# define ST_NBLOCKSIZE 1024
# else /* !hpux */
# if defined _AIX && defined _I386
/* AIX PS/2 counts st_blocks in 4K units. */
# define ST_NBLOCKSIZE (4 * 1024)
# else /* not AIX PS/2 */
# if defined _CRAY
# define ST_NBLOCKS(statbuf) \
(S_ISREG ((statbuf).st_mode) \
|| S_ISDIR ((statbuf).st_mode) \
? (statbuf).st_blocks * ST_BLKSIZE (statbuf) / ST_NBLOCKSIZE : 0)
# endif /* _CRAY */
# endif /* not AIX PS/2 */
# endif /* !hpux */
#endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
#ifndef ST_NBLOCKS
# define ST_NBLOCKS(statbuf) ((statbuf).st_blocks)
#endif
#ifndef ST_NBLOCKSIZE
# ifdef S_BLKSIZE
# define ST_NBLOCKSIZE S_BLKSIZE
# else
# define ST_NBLOCKSIZE 512
# endif
#endif
/* Redirection and wildcarding when done by the utility itself.
Generally a noop, but used in particular for native VMS. */
#ifndef initialize_main
@@ -467,19 +395,6 @@ enum
# define IF_LINT(Code) /* empty */
#endif
/* With -Dlint, avoid warnings from gcc about code like mbstate_t m = {0,};
by wasting space on a static variable of the same type, that is thus
guaranteed to be initialized to 0, and use that on the RHS. */
#define DZA_CONCAT0(x,y) x ## y
#define DZA_CONCAT(x,y) DZA_CONCAT0 (x, y)
#ifdef lint
# define DECLARE_ZEROED_AGGREGATE(Type, Var) \
static Type DZA_CONCAT (s0_, __LINE__); Type Var = DZA_CONCAT (s0_, __LINE__)
#else
# define DECLARE_ZEROED_AGGREGATE(Type, Var) \
Type Var = { 0, }
#endif
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __attribute__(x) /* empty */
@@ -524,7 +439,7 @@ enum
/* Compute the greatest common divisor of U and V using Euclid's
algorithm. U and V must be nonzero. */
static inline size_t
static inline size_t _GL_ATTRIBUTE_CONST
gcd (size_t u, size_t v)
{
do
@@ -542,7 +457,7 @@ gcd (size_t u, size_t v)
nonzero. There is no overflow checking, so callers should not
specify outlandish sizes. */
static inline size_t
static inline size_t _GL_ATTRIBUTE_CONST
lcm (size_t u, size_t v)
{
return u * (v / gcd (u, v));
@@ -606,9 +521,7 @@ emit_ancillary_info (void)
{
printf (_("\nReport %s bugs to %s\n"), last_component (program_name),
PACKAGE_BUGREPORT);
/* FIXME 2010: use AC_PACKAGE_URL once we require autoconf-2.64 */
printf (_("%s home page: <http://www.gnu.org/software/%s/>\n"),
PACKAGE_NAME, PACKAGE);
printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
stdout);
/* Don't output this redundant message for English locales.
@@ -644,51 +557,6 @@ bad_cast (char const *s)
return (char *) s;
}
/* As of Mar 2009, 32KiB is determined to be the minimium
blksize to best minimize system call overhead.
This can be tested with this script with the results
shown for a 1.7GHz pentium-m with 2GB of 400MHz DDR2 RAM:
for i in $(seq 0 10); do
size=$((8*1024**3)) #ensure this is big enough
bs=$((1024*2**$i))
printf "%7s=" $bs
dd bs=$bs if=/dev/zero of=/dev/null count=$(($size/$bs)) 2>&1 |
sed -n 's/.* \([0-9.]* [GM]B\/s\)/\1/p'
done
1024=734 MB/s
2048=1.3 GB/s
4096=2.4 GB/s
8192=3.5 GB/s
16384=3.9 GB/s
32768=5.2 GB/s
65536=5.3 GB/s
131072=5.5 GB/s
262144=5.7 GB/s
524288=5.7 GB/s
1048576=5.8 GB/s
Note that this is to minimize system call overhead.
Other values may be appropriate to minimize file system
or disk overhead. For example on my current GNU/Linux system
the readahead setting is 128KiB which was read using:
file="."
device=$(df -P --local "$file" | tail -n1 | cut -d' ' -f1)
echo $(( $(blockdev --getra $device) * 512 ))
However there isn't a portable way to get the above.
In the future we could use the above method if available
and default to io_blksize() if not.
*/
enum { IO_BUFSIZE = 32*1024 };
static inline size_t
io_blksize (struct stat sb)
{
return MAX (IO_BUFSIZE, ST_BLKSIZE (sb));
}
void usage (int status) ATTRIBUTE_NORETURN;
#define emit_cycle_warning(file_name) \

View File

@@ -215,7 +215,7 @@ tac_seekable (int input_fd, const char *file)
size_t match_length1 = match_length - 1; /* Speed optimization, non-regexp. */
/* Find the size of the input file. */
file_pos = lseek (input_fd, (off_t) 0, SEEK_END);
file_pos = lseek (input_fd, 0, SEEK_END);
if (file_pos < 1)
return true; /* It's an empty file. */
@@ -546,7 +546,7 @@ tac_file (const char *filename)
}
}
file_size = lseek (fd, (off_t) 0, SEEK_END);
file_size = lseek (fd, 0, SEEK_END);
ok = (file_size < 0 || isatty (fd)
? tac_nonseekable (fd, filename)

View File

@@ -159,8 +159,8 @@ struct File_spec
#if HAVE_INOTIFY
/* The events mask used with inotify on files. This mask is not used on
directories. */
const uint32_t inotify_wd_mask = (IN_MODIFY | IN_ATTRIB | IN_DELETE_SELF
| IN_MOVE_SELF);
static const uint32_t inotify_wd_mask = (IN_MODIFY | IN_ATTRIB
| IN_DELETE_SELF | IN_MOVE_SELF);
#endif
/* Keep trying to open a file even if it is inaccessible when tail starts
@@ -818,7 +818,7 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
error (0, errno, _("error reading %s"), quote (pretty_filename));
return 1;
}
read_pos += bytes_read;
*read_pos += bytes_read;
if (bytes_read <= n_bytes)
n_bytes -= bytes_read;
else

View File

@@ -35,7 +35,7 @@
This can be seen with `timeout 10 dd&` for example.
However if one brings this group to the foreground with the `fg`
command before the timer expires, the command will remain
in the sTop state as the shell doesn't send a SIGCONT
in the stop state as the shell doesn't send a SIGCONT
because the timeout process (group leader) is already running.
To get the command running again one can Ctrl-Z, and do fg again.
Note one can Ctrl-C the whole job when in this state.
@@ -52,13 +52,24 @@
#include <sys/wait.h>
#include "system.h"
#include "xstrtol.h"
#include "c-strtod.h"
#include "xstrtod.h"
#include "sig2str.h"
#include "operand2sig.h"
#include "cloexec.h"
#include "error.h"
#include "quote.h"
#if HAVE_SETRLIMIT
/* FreeBSD 5.0 at least needs <sys/types.h> and <sys/time.h> included
before <sys/resource.h>. Currently "system.h" includes <sys/time.h>. */
# include <sys/resource.h>
#endif
/* NonStop circa 2011 lacks both SA_RESTART and siginterrupt. */
#ifndef SA_RESTART
# define SA_RESTART 0
#endif
#define PROGRAM_NAME "timeout"
#define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady")
@@ -67,17 +78,69 @@ static int timed_out;
static int term_signal = SIGTERM; /* same default as kill command. */
static int monitored_pid;
static int sigs_to_ignore[NSIG]; /* so monitor can ignore sigs it resends. */
static unsigned long kill_after;
static double kill_after;
static bool foreground; /* whether to use another program group. */
/* for long options with no corresponding short option, use enum */
enum
{
FOREGROUND_OPTION = CHAR_MAX + 1
};
static struct option const long_options[] =
{
{"kill-after", required_argument, NULL, 'k'},
{"signal", required_argument, NULL, 's'},
{"foreground", no_argument, NULL, FOREGROUND_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
/* Start the timeout after which we'll receive a SIGALRM.
Round DURATION up to the next representable value.
Treat out-of-range values as if they were maximal,
as that's more useful in practice than reporting an error.
'0' means don't timeout. */
static void
settimeout (double duration)
{
/* timer_settime() provides potentially nanosecond resolution.
setitimer() is more portable (to Darwin for example),
but only provides microsecond resolution and thus is
a little more awkward to use with timespecs, as well as being
deprecated by POSIX. Instead we fallback to single second
resolution provided by alarm(). */
#if HAVE_TIMER_SETTIME
struct timespec ts = dtotimespec (duration);
struct itimerspec its = { {0, 0}, ts };
timer_t timerid;
if (timer_create (CLOCK_REALTIME, NULL, &timerid) == 0)
{
if (timer_settime (timerid, 0, &its, NULL) == 0)
return;
else
{
error (0, errno, _("warning: timer_settime"));
timer_delete (timerid);
}
}
else if (errno != ENOSYS)
error (0, errno, _("warning: timer_create"));
#endif
unsigned int timeint;
if (UINT_MAX <= duration)
timeint = UINT_MAX;
else
{
unsigned int duration_floor = duration;
timeint = duration_floor + (duration_floor < duration);
}
alarm (timeint);
}
/* send sig to group but not ourselves.
* FIXME: Is there a better way to achieve this? */
static int
@@ -106,12 +169,24 @@ cleanup (int sig)
{
/* Start a new timeout after which we'll send SIGKILL. */
term_signal = SIGKILL;
alarm (kill_after);
settimeout (kill_after);
kill_after = 0; /* Don't let later signals reset kill alarm. */
}
send_sig (0, sig);
/* Send the signal directly to the monitored child,
in case it has itself become group leader,
or is not running in a separate group. */
send_sig (monitored_pid, sig);
/* The normal case is the job has remained in our
newly created process group, so send to all processes in that. */
if (!foreground)
send_sig (0, sig);
if (sig != SIGKILL && sig != SIGCONT)
send_sig (0, SIGCONT);
{
send_sig (monitored_pid, SIGCONT);
if (!foreground)
send_sig (0, SIGCONT);
}
}
else /* we're the child or the child is not exec'd yet. */
_exit (128 + sig);
@@ -135,21 +210,25 @@ Start COMMAND, and kill it if still running after DURATION.\n\
Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
--foreground\n\
When not running timeout directly from a shell prompt,\n\
allow COMMAND to read from the TTY and receive TTY signals.\n\
In this mode, children of COMMAND will not be timed out.\n\
-k, --kill-after=DURATION\n\
also send a KILL signal if COMMAND is still running\n\
this long after the initial signal was sent.\n\
also send a KILL signal if COMMAND is still running\n\
this long after the initial signal was sent.\n\
-s, --signal=SIGNAL\n\
specify the signal to be sent on timeout.\n\
SIGNAL may be a name like `HUP' or a number.\n\
See `kill -l` for a list of signals\n"), stdout);
specify the signal to be sent on timeout.\n\
SIGNAL may be a name like `HUP' or a number.\n\
See `kill -l` for a list of signals\n"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
fputs (_("\n\
DURATION is an integer with an optional suffix:\n\
`s' for seconds(the default), `m' for minutes, `h' for hours or `d' for days.\n\
"), stdout);
DURATION is a floating point number with an optional suffix:\n\
`s' for seconds (the default), `m' for minutes, `h' for hours \
or `d' for days.\n"), stdout);
fputs (_("\n\
If the command times out, then exit with status 124. Otherwise, exit\n\
@@ -162,54 +241,51 @@ use the KILL (9) signal, since this signal cannot be caught.\n"), stdout);
exit (status);
}
/* Given a long integer value *X, and a suffix character, SUFFIX_CHAR,
/* Given a floating point value *X, and a suffix character, SUFFIX_CHAR,
scale *X by the multiplier implied by SUFFIX_CHAR. SUFFIX_CHAR may
be the NUL byte or `s' to denote seconds, `m' for minutes, `h' for
hours, or `d' for days. If SUFFIX_CHAR is invalid, don't modify *X
and return false. If *X would overflow an integer, don't modify *X
and return false. Otherwise return true. */
and return false. Otherwise return true. */
static bool
apply_time_suffix (unsigned long *x, char suffix_char)
apply_time_suffix (double *x, char suffix_char)
{
unsigned int multiplier = 1;
int multiplier;
switch (suffix_char)
{
case 0:
case 's':
return true;
case 'd':
multiplier *= 24;
case 'h':
multiplier *= 60;
multiplier = 1;
break;
case 'm':
if (multiplier > UINT_MAX / 60) /* 16 bit overflow */
return false;
multiplier *= 60;
multiplier = 60;
break;
case 'h':
multiplier = 60 * 60;
break;
case 'd':
multiplier = 60 * 60 * 24;
break;
default:
return false;
}
if (*x > UINT_MAX / multiplier)
return false;
*x *= multiplier;
return true;
}
static unsigned long
static double
parse_duration (const char* str)
{
unsigned long duration;
char *ep;
double duration;
const char *ep;
if (xstrtoul (str, &ep, 10, &duration, NULL)
/* Invalid interval. Note 0 disables timeout */
|| (duration > UINT_MAX)
/* Extra chars after the number and an optional s,m,h,d char. */
if (!xstrtod (str, &ep, &duration, c_strtod)
/* Nonnegative interval. */
|| ! (0 <= duration)
/* No extra chars after the number and an optional s,m,h,d char. */
|| (*ep && *(ep + 1))
/* Check any suffix char and update timeout based on the suffix. */
|| !apply_time_suffix (&duration, *ep))
@@ -227,7 +303,8 @@ install_signal_handlers (int sigterm)
struct sigaction sa;
sigemptyset (&sa.sa_mask); /* Allow concurrent calls to handler */
sa.sa_handler = cleanup;
sa.sa_flags = SA_RESTART; /* restart syscalls (like wait() below) */
sa.sa_flags = SA_RESTART; /* Restart syscalls if possible, as that's
more likely to work cleanly. */
sigaction (SIGALRM, &sa, NULL); /* our timeout. */
sigaction (SIGINT, &sa, NULL); /* Ctrl-C at terminal for example. */
@@ -240,7 +317,7 @@ install_signal_handlers (int sigterm)
int
main (int argc, char **argv)
{
unsigned long timeout;
double timeout;
char signame[SIG2STR_MAX];
int c;
@@ -267,6 +344,10 @@ main (int argc, char **argv)
usage (EXIT_CANCELED);
break;
case FOREGROUND_OPTION:
foreground = true;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
@@ -288,14 +369,15 @@ main (int argc, char **argv)
Note we don't just put the child in a separate group as
then we would need to worry about foreground and background groups
and propagating signals between them. */
setpgid (0, 0);
if (!foreground)
setpgid (0, 0);
/* Setup handlers before fork() so that we
handle any signals caused by child, without races. */
install_signal_handlers (term_signal);
signal (SIGTTIN, SIG_IGN); /* don't sTop if background child needs tty. */
signal (SIGTTOU, SIG_IGN); /* don't sTop if background child needs tty. */
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
signal (SIGTTIN, SIG_IGN); /* Don't stop if background child needs tty. */
signal (SIGTTOU, SIG_IGN); /* Don't stop if background child needs tty. */
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
monitored_pid = fork ();
if (monitored_pid == -1)
@@ -320,18 +402,16 @@ main (int argc, char **argv)
}
else
{
pid_t wait_result;
int status;
alarm (timeout);
settimeout (timeout);
/* We're just waiting for a single process here, so wait() suffices.
Note the signal() calls above on GNU/Linux and BSD at least,
essentially call the lower level sigaction() with the SA_RESTART flag
set, which ensures the following wait call will only return if the
child exits, not on this process receiving a signal. Also we're not
passing WUNTRACED | WCONTINUED to a waitpid() call and so will not get
indication that the child has stopped or continued. */
if (wait (&status) == -1)
while ((wait_result = waitpid (monitored_pid, &status, 0)) < 0
&& errno == EINTR)
continue;
if (wait_result < 0)
{
/* shouldn't happen. */
error (0, errno, _("error waiting for command"));
@@ -342,7 +422,25 @@ main (int argc, char **argv)
if (WIFEXITED (status))
status = WEXITSTATUS (status);
else if (WIFSIGNALED (status))
status = WTERMSIG (status) + 128; /* what sh does at least. */
{
int sig = WTERMSIG (status);
/* The following is not used as one cannot disable processing
by a filter in /proc/sys/kernel/core_pattern on Linux. */
#if 0 && HAVE_SETRLIMIT && defined RLIMIT_CORE
if (!timed_out)
{
/* exit with the signal flag set, but avoid core files. */
if (setrlimit (RLIMIT_CORE, &(struct rlimit) {0,0}) == 0)
{
signal (sig, SIG_DFL);
raise (sig);
}
else
error (0, errno, _("warning: disabling core dumps failed"));
}
#endif
status = sig + 128; /* what sh returns for signaled processes. */
}
else
{
/* shouldn't happen. */

View File

@@ -405,12 +405,18 @@ main (int argc, char **argv)
if (! getenv ("POSIXLY_CORRECT"))
{
struct tm const *tm = localtime (&newtime[0].tv_sec);
error (0, 0,
_("warning: `touch %s' is obsolete; use "
"`touch -t %04ld%02d%02d%02d%02d.%02d'"),
argv[optind],
tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
/* Technically, it appears that even a deliberate attempt to cause
the above localtime to return NULL will always fail because our
posixtime implementation rejects all dates for which localtime
would fail. However, skip the warning if it ever fails. */
if (tm)
error (0, 0,
_("warning: `touch %s' is obsolete; use "
"`touch -t %04ld%02d%02d%02d%02d.%02d'"),
argv[optind],
tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
optind++;

View File

@@ -364,7 +364,7 @@ is_equiv_class_member (unsigned char equiv_class, unsigned char c)
/* Return true if the character C is a member of the
character class CHAR_CLASS. */
static bool
static bool _GL_ATTRIBUTE_PURE
is_char_class_member (enum Char_class char_class, unsigned char c)
{
int result;
@@ -542,7 +542,7 @@ unquote (char const *s, struct E_string *es)
/* If CLASS_STR is a valid character class string, return its index
in the global char_class_name array. Otherwise, return CC_NO_CLASS. */
static enum Char_class
static enum Char_class _GL_ATTRIBUTE_PURE
look_up_char_class (char const *class_str, size_t len)
{
enum Char_class i;
@@ -844,7 +844,7 @@ find_bracketed_repeat (const struct E_string *es, size_t start_idx,
expression `\*[0-9]*\]', false otherwise. The string does not
match if any of its characters are escaped. */
static bool
static bool _GL_ATTRIBUTE_PURE
star_digits_closebracket (const struct E_string *es, size_t idx)
{
size_t i;
@@ -1555,7 +1555,7 @@ squeeze_filter (char *buf, size_t size, size_t (*reader) (char *, size_t))
{
/* A value distinct from any character that may have been stored in a
buffer as the result of a block-read in the function squeeze_filter. */
enum { NOT_A_CHAR = CHAR_MAX + 1 };
const int NOT_A_CHAR = INT_MAX;
int char_to_squeeze = NOT_A_CHAR;
size_t i = 0;

View File

@@ -27,8 +27,8 @@
#include "system.h"
#include "error.h"
#include "posixver.h"
#include "quote.h"
#include "stat-size.h"
#include "xstrtol.h"
/* The official name of this program (e.g., no `g' prefix). */

View File

@@ -379,13 +379,8 @@ unexpand (void)
{
column = next_tab_column;
/* Discard pending blanks, unless it was a single
blank just before the previous tab stop. */
if (! (pending == 1 && one_blank_before_tab_stop))
{
pending = 0;
one_blank_before_tab_stop = false;
}
if (pending)
pending_blank[0] = '\t';
}
else
{
@@ -404,8 +399,11 @@ unexpand (void)
/* Replace the pending blanks by a tab or two. */
pending_blank[0] = c = '\t';
pending = one_blank_before_tab_stop;
}
/* Discard pending blanks, unless it was a single
blank just before the previous tab stop. */
pending = one_blank_before_tab_stop;
}
}
else if (c == '\b')
@@ -425,6 +423,8 @@ unexpand (void)
if (pending)
{
if (pending > 1 && one_blank_before_tab_stop)
pending_blank[0] = '\t';
if (fwrite (pending_blank, 1, pending, stdout) != pending)
error (EXIT_FAILURE, errno, _("write error"));
pending = 0;

View File

@@ -206,7 +206,7 @@ size_opt (char const *opt, char const *msgid)
/* Given a linebuffer LINE,
return a pointer to the beginning of the line's field to be compared. */
static char *
static char * _GL_ATTRIBUTE_PURE
find_field (struct linebuffer const *line)
{
size_t count;

View File

@@ -120,6 +120,8 @@ Print newline, word, and byte counts for each FILE, and a total line if\n\
more than one FILE is specified. With no FILE, or when FILE is -,\n\
read standard input. A word is a non-zero-length sequence of characters\n\
delimited by white space.\n\
The options below may be used to select which counts are printed, always in\n\
the following order: newline, word, character, byte, maximum line length.\n\
-c, --bytes print the byte counts\n\
-m, --chars print the character counts\n\
-l, --lines print the newline counts\n\
@@ -234,8 +236,8 @@ wc (int fd, char const *file_x, struct fstatus *fstatus)
fstatus->failed = fstat (fd, &fstatus->st);
if (! fstatus->failed && S_ISREG (fstatus->st.st_mode)
&& (current_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1
&& (end_pos = lseek (fd, (off_t) 0, SEEK_END)) != -1)
&& (current_pos = lseek (fd, 0, SEEK_CUR)) != -1
&& (end_pos = lseek (fd, 0, SEEK_END)) != -1)
{
/* Be careful here. The current position may actually be
beyond the end of the file. As in the example above. */
@@ -285,7 +287,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus)
{
bool in_word = false;
uintmax_t linepos = 0;
DECLARE_ZEROED_AGGREGATE (mbstate_t, state);
mbstate_t state = { 0, };
bool in_shift = false;
# if SUPPORT_OLD_MBRTOWC
/* Back-up the state before each multibyte character conversion and
@@ -556,7 +558,7 @@ get_input_fstatus (int nfiles, char *const *file)
recorded in FSTATUS. Optimize the same special case that
get_input_fstatus optimizes. */
static int
static int _GL_ATTRIBUTE_PURE
compute_number_width (int nfiles, struct fstatus const *fstatus)
{
int width = 1;

View File

@@ -84,9 +84,6 @@ main (int argc, char **argv)
for (i = optind; i < argc; i++)
if (fputs (argv[i], stdout) == EOF
|| putchar (i == argc - 1 ? '\n' : ' ') == EOF)
{
error (0, errno, _("standard output"));
exit (EXIT_FAILURE);
}
error (EXIT_FAILURE, errno, _("standard output"));
}
}

39
tests/CuSkip.pm Normal file
View File

@@ -0,0 +1,39 @@
package CuSkip;
# Skip a test: emit diag to log and to stderr, and exit 77
# Copyright (C) 2011 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 3 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, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
our $ME = $0 || "<???>";
# Emit a diagnostic both to stderr and to $stderr_fileno_.
# FIXME: don't hard-code that value (9), since it's already defined in init.cfg.
sub skip ($)
{
my ($msg) = @_;
my $stderr_fileno_ = 9;
warn $msg;
open FH, ">&$stderr_fileno_"
or warn "$ME: failed to dup stderr\n";
print FH $msg;
close FH
or warn "$ME: failed to close FD $stderr_fileno_\n";
exit 77;
}
1;

View File

@@ -7,8 +7,10 @@ ASSORT = LC_ALL=C sort
EXTRA_DIST = \
Coreutils.pm \
CuSkip.pm \
CuTmpdir.pm \
check.mk \
d_type-check \
envvar-check \
filefrag-extent-compare \
fiemap-capable \
@@ -16,8 +18,8 @@ EXTRA_DIST = \
init.sh \
lang-default \
other-fs-tmpdir \
require-perl \
sample-test \
shell-or-perl \
$(pr_data)
root_tests = \
@@ -132,6 +134,7 @@ TESTS = \
rm/unread3 \
rm/unreadable \
rm/v-slash \
rm/many-dir-entries-vs-OOM \
chgrp/default-no-deref \
chgrp/deref \
chgrp/no-x \
@@ -160,7 +163,6 @@ TESTS = \
pr/pr-tests \
misc/df-P \
misc/pwd-option \
misc/pwd-unreadable-parent \
misc/chcon-fail \
misc/cut \
misc/wc \
@@ -247,12 +249,13 @@ TESTS = \
misc/sort-unique \
misc/sort-unique-segv \
misc/sort-version \
misc/split-a \
misc/split-bchunk \
misc/split-fail \
misc/split-l \
misc/split-lchunk \
misc/split-rchunk \
split/filter \
split/suffix-length \
split/b-chunk \
split/fail \
split/lines \
split/l-chunk \
split/r-chunk \
misc/stat-birthtime \
misc/stat-fmt \
misc/stat-hyphen \
@@ -274,6 +277,7 @@ TESTS = \
misc/tee-dash \
misc/test-diag \
misc/timeout \
misc/timeout-group \
misc/timeout-parameters \
misc/tr \
misc/tr-case-class \
@@ -319,6 +323,7 @@ TESTS = \
cp/dir-rm-dest \
cp/dir-slash \
cp/dir-vs-file \
cp/existing-perm-dir \
cp/existing-perm-race \
cp/fail-perm \
cp/fiemap-empty \
@@ -337,6 +342,7 @@ TESTS = \
cp/parent-perm-race \
cp/perm \
cp/preserve-2 \
cp/preserve-link \
cp/preserve-slink-time \
cp/proc-short-read \
cp/proc-zero-len \
@@ -425,6 +431,7 @@ TESTS = \
ls/rt-1 \
ls/stat-dtype \
ls/stat-failed \
ls/stat-free-color \
ls/stat-free-symlinks \
ls/stat-vs-dirent \
ls/symlink-slash \

View File

@@ -48,6 +48,16 @@ check-am: .built-programs
&& MAKEFLAGS= $(MAKE) -s built_programs.list) \
> $@-t && mv $@-t $@
## `$f' is set by the Automake-generated test harness to the path of the
## current test script stripped of VPATH components, and is used by the
## shell-or-perl script to determine the name of the temporary files to be
## used. Note that $f is a shell variable, not a make macro, so the use of
## `$$f' below is correct, and not a typo.
LOG_COMPILER = \
$(SHELL) $(srcdir)/shell-or-perl \
--test-name "$$f" --srcdir '$(srcdir)' \
--shell '$(SHELL)' --perl '$(PERL)' --
# Note that the first lines are statements. They ensure that environment
# variables that can perturb tests are unset or set to expected values.
# The rest are envvar settings that propagate build-related Makefile
@@ -58,22 +68,6 @@ TESTS_ENVIRONMENT = \
test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.; \
. $(srcdir)/envvar-check; \
TMPDIR=$$tmp__; export TMPDIR; \
exec 9>&2; \
shell_or_perl_() { \
if grep '^\#!/usr/bin/perl' "$$1" > /dev/null; then \
if $(PERL) -e 'use warnings' > /dev/null 2>&1; then \
grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=; \
$(PERL) -w$$T_ -I$(srcdir) -MCoreutils \
-M"CuTmpdir qw($$f)" -- "$$1"; \
else \
echo 1>&2 "$$tst: configure did not find a usable version of Perl," \
"so skipping this test"; \
(exit 77); \
fi; \
else \
$(SHELL) "$$1"; \
fi; \
}; \
export \
VERSION='$(VERSION)' \
LOCALE_FR='$(LOCALE_FR)' \
@@ -100,6 +94,6 @@ TESTS_ENVIRONMENT = \
REPLACE_GETCWD=$(REPLACE_GETCWD) \
; test -d /usr/xpg4/bin && PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'"$$PATH"; \
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
; shell_or_perl_
; 9>&2
VERBOSE = yes

View File

@@ -23,7 +23,7 @@ require_membership_in_two_groups_
set _ $groups; shift
g2=$2
mkdir d && touch f && ln -s ../f d/s || framework_failure
mkdir d && touch f && ln -s ../f d/s || framework_failure_
g_init=`stat --printf=%g f`

View File

@@ -31,7 +31,7 @@ chgrp -h $g2 symlink 2> /dev/null
set _ `ls -ln symlink`
g=$5
test "$g" = $g2 ||
skip_test_ "your system doesn't support changing the owner or group" \
skip_ "your system doesn't support changing the owner or group" \
"of a symbolic link."

View File

@@ -26,8 +26,8 @@ set _ $groups; shift
g1=$1
g2=$2
mkdir -p d/no-x/y || framework_failure
chmod u=rw d/no-x || framework_failure
mkdir -p d/no-x/y || framework_failure_
chmod u=rw d/no-x || framework_failure_
# This must exit nonzero.

View File

@@ -24,11 +24,11 @@ set _ $groups; shift
g1=$1
g2=$2
mkdir 1 2 3 || framework_failure
touch 1/1F 2/2F 3/3F || framework_failure
ln -s 1 1s || framework_failure
ln -s ../3 2/2s || framework_failure
chgrp -R $g1 1 2 3 || framework_failure
mkdir 1 2 3 || framework_failure_
touch 1/1F 2/2F 3/3F || framework_failure_
ln -s 1 1s || framework_failure_
ln -s ../3 2/2s || framework_failure_
chgrp -R $g1 1 2 3 || framework_failure_
chgrp --preserve-root -H -R $g2 1s 2 || fail=1

View File

@@ -21,8 +21,8 @@ print_ver_ chmod
umask 0
file=f
touch $file || framework_failure
chmod 444 $file || framework_failure
touch $file || framework_failure_
chmod 444 $file || framework_failure_
skip_if_setgid_
@@ -33,8 +33,8 @@ chmod -c g=rwx $file > empty || fail=1
test -s empty && fail=1
case "`cat out`" in
"mode of \`f' changed to 0774 "?rwxrwxr--?) ;;
*) fail=1 ;;
"mode of \`f' changed from 0744 "?rwxr--r--?" to 0774 "?rwxrwxr--?) ;;
*) cat out; fail=1 ;;
esac
Exit $fail

View File

@@ -20,7 +20,7 @@
print_ver_ chmod
file=f
touch $file || framework_failure
touch $file || framework_failure_
umask 005
for mode in =x =xX =Xx =x,=X =X,=x; do

View File

@@ -21,7 +21,7 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
touch f || framework_failure
touch f || framework_failure_
expected_u=-rwx------

View File

@@ -19,8 +19,8 @@
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
mkdir -p d/e || framework_failure
chmod 0 d/e d || framework_failure
mkdir -p d/e || framework_failure_
chmod 0 d/e d || framework_failure_
chmod u+rwx d d/e || fail=1

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