Compare commits

...

120 Commits
v8.6 ... v8.8

Author SHA1 Message Date
Jim Meyering
518b92a5e3 version 8.8
* NEWS: Record release date.
2010-12-22 17:43:50 +01:00
Jim Meyering
b795e60844 csplit: update gnulib for Solaris 8,9 snprintf fix 2010-12-22 14:33:11 +01:00
Jim Meyering
887d530e62 maint: correct test-related comments
* tests/mv/i-3: Adjust comment to match just-changed code.
Spotted by Pádraig Brady.
* tests/init.cfg (retry_delay_): Correct spelling of function name
in usage example.
2010-12-22 11:52:11 +01:00
Jim Meyering
51f60a6237 tests: adjust preceding change to handle general WERROR_CFLAGS values
* gnulib-tests/Makefile.am (test_xvasprintf_CFLAGS):
(test_lock_CFLAGS, test_tls_CFLAGS): Avoid a syntax error when
$(WERROR_CFLAGS) expands to more than one token.
2010-12-22 11:10:23 +01:00
Paul Eggert
056caf4857 tests: do not assume compiler knows -Wxxx flags
* gnulib-tests/Makefile.am (test_xvasprintf_CFLAGS):
(test_lock_CFLAGS, test_tls_CFLAGS): Do not append GCC-specific
flags like -Wno-format-security unless the GCC-specific flag
-Werror is also specified.  This avoids a "make check" failure on
Solaris when using Sun C 5.8.
2010-12-22 01:48:54 -08:00
Jim Meyering
a300cfd43c tests: mv/i-3: avoid false-positive failure on a slow/busy system
* tests/mv/i-3: Quadruple the timeout duration.
Without this, I saw an expired timeout on a heavily-loaded system.
2010-12-22 10:29:30 +01:00
Jim Meyering
7ca55ef3d1 tests: avoid new false-positive failure on at least FreeBSD 8.1
* tests/mv/trailing-slash: Accommodate different diagnostic
on FreeBSD 8.1.
2010-12-21 09:30:55 +01:00
Paul Eggert
960fc61624 who: omit useless definitions of MAXHOSTNAMELEN
This prevents a compilation failure on Solaris 8, GCC 4.4.2, with
"configure --enable-gcc-warnings".
* src/who.c (MAXHOSTNAMELEN): Remove; no longer needed.
* src/pinky.c: Likewise.
2010-12-20 17:43:05 -08:00
Pádraig Brady
41159f9604 maint: fix a typo in sort --parallel help message
Also fix up Chen Guo's contacts
* src/sort.c (usage): Add a missing "of"
* THANKS: Add Chen Guo
* .mailmap: Add Chen Guo's UCLA address
2010-12-20 10:56:04 +00:00
Jim Meyering
4a423bedea build: update gnulib: ACL-vs-Solaris 8 portability etc. 2010-12-20 10:55:39 +01:00
Paul Eggert
5947491895 tests: sync init.sh from gnulib
* tests/init.sh (setup_): Initialize fail=0 before invoking mktempd_.
Ensure that IFS is defined initially.
(mktempd_): Remove fail=0 initialization; no longer needed.
2010-12-18 20:03:21 -08:00
Pádraig Brady
0eaa993ae6 wc: fix a possible hang with --files0-from
* src/wc.c (main): exit when we get a read error on
the --files0-from file, rather than retrying and
spinning the CPU
2010-12-19 00:40:27 +00:00
Pádraig Brady
e66948c3b5 cp: ensure backups are created when -T specified
* src/cp.c (do_copy): When -T is specified, initialize
the NEW_DST and SB variables, which are checked when
running: cp -T --force --backup file file
* tests/cp/backup-1: Add the -T case
2010-12-19 00:36:29 +00:00
Pádraig Brady
0e181024c0 sort: use at most 8 threads by default
* src/sort.c (main): If --parallel isn't specified,
restrict the number of threads to 8 by default.
If the --parallel option is specified, then
allow any number of threads to be set, independent
of the number of processors on the system.
* doc/coreutils.texi (sort invocation): Document the changes
to determining the number of threads to use.
Mention the memory overhead when using multiple threads.
* tests/misc/sort-spinlock-abuse: Allow single core
systems that support pthreads.
* tests/misc/sort-stale-thread-mem: Likewise.
* tests/misc/sort-unique-segv: Likewise.
* NEWS: Mention the change in behaviour.
2010-12-19 00:33:45 +00:00
Jim Meyering
eea8e7530b doc: split: add examples showing how to use the new option
* doc/coreutils.texi (split invocation): Add examples.
2010-12-18 08:04:46 +01:00
Jim Meyering
6d488ca041 tests: avoid spurious du/bigtime failure
* tests/du/bigtime: Map nonzero block count to 0.
Reported by Assaf Gordon.
* THANKS: Update.
2010-12-18 08:04:46 +01:00
Paul Eggert
c67a96c4c1 tests: set fail=0 by default
* tests/init.sh (setup_): Set fail=0.  This was the intent as per
<http://lists.gnu.org/archive/html/bug-coreutils/2010-12/msg00058.html>
but the assignment in mktempd_ is ineffective, since mktempd_
is used inside `` and its assignments are in a subshell.
2010-12-17 22:40:20 -08:00
Jim Meyering
561f8be2c9 build: update gnulib submodule to latest 2010-12-17 08:19:26 +01:00
Paul Eggert
8e81a99c26 sort: do not generate thousands of subprocesses for 16-way merge
Without this change, tests/misc/sort-compress-hang would consume
more than 10,000 process slots on my RHEL 5.5 x86-64 server,
making it likely for other applications to fail due to lack of
process slots.  With this change, the same benchmark causes 'sort'
to consume at most 19 process slots.  The change also improved
wall-clock time by 2% and user+system time by 14% on that benchmark.
* NEWS: Document this.
* src/sort.c (MAX_PROCS_BEFORE_REAP): Remove.
(reap_exited): Renamed from reap_some; this is a more accurate name,
since "some" incorrectly implies that it reaps at least one process.
All uses changed.
(reap_some): New function: it *does* reap at least one process.
(pipe_fork): Do not allow more than NMERGE + 2 subprocesses.
(mergefps, sort): Omit check for exited processes: no longer needed,
and anyway the code consumed too much CPU per line when 2 < nprocs.
2010-12-16 22:32:06 -08:00
Paul Eggert
1b31ce6982 sort: fix hang with sort --compress
* NEWS: Document this.
* src/sort.c (UNCOMPRESSED, UNREAPED, REAPED): New constants.
(struct tempnode): New member 'state', to hold these constants.
The pid member is now undefined if state == UNCOMPRESSED.
(struct sortfile): Replace member 'pid' with member 'temp'.
(uintptr): Remove.
(proctab_hasher, proctab_comparator, register_proc, delete_proc):
Proctab entries are now struct tempnode *, not pid_t, to handle
the case where multiple tempnode objects correspond to the same
pid.  This avoids a race condition that can cause a hang.
(register_proc): Arg is now struct tempnode *, not pid_t.  All
callers changed.
(delete_proc): Set tempnode state to REAPED.
(create_temp_file): No need to set pid member here; it's now
done when the pid is known.
(maybe_create_temp, create_temp): Remove PPID arg.  Return struct
tempnode *, not char *.  All callers changed.
(maybe_create_temp): Set node state to UNCOMPRESSED or UNREAPED.
No need to set node->pid to 0.
(open_temp): Replace NAME and PID args with a single TEMP arg.
All callers changed.  Wait only for unreaped children.
(zaptemp): Wait for decompressor to finish before removing its
temporary-file input.  This avoids .nfsXXXX hassles with NFS
and fixes a race (leading to a hang) regardless of NFS.
(open_input_files): Adjust to new way of dealing with temp files
and their subprocesses.
* tests/Makefile.am (TESTS): Add misc/sort-compress-hang.
* tests/misc/sort-compress-hang: New file.
2010-12-16 13:55:31 -08:00
Paul Eggert
f3c584d1e0 sort: don't dump core when merging from input twice
* NEWS: Document this.
* src/sort.c (avoid_trashing_input): The previous fix to this
function didn't fix all the problems with this code.  Replace it
with something simpler: just copy the input file.  This doesn't
change the number of files, so return void instead of the updated
file count.  Caller changed.
* tests/misc/sort-merge-fdlimit: Test for the bug.
2010-12-16 00:04:32 -08:00
Jim Meyering
33a5de5a0e doc: tail: semi-deprecate --sleep-interval and --max-unchanged-stats
Those options are useful only on systems that lack inotify support
and in the unusual event that a system with inotify support must
resort to polling.
* src/tail.c (usage): Note that the --max-unchanged-stats=N and
--sleep-interval=N options are rarely useful on systems with
inotify support.
* doc/coreutils.texi (tail invocation): Likewise.
2010-12-14 20:13:05 +01:00
Paul Eggert
14ad7a2550 sort: fix very-unlikely buffer overrun when merging to input file
* src/sort.c (avoid_trashing_input): Fix a typo that could cause a
buffer overrun in theory.  In practice this is extremely unlikely,
as it requires running out of file descriptors in a small merge,
presumably because some other process is hogging all the OS's file
descriptors.
2010-12-14 11:10:45 -08:00
Paul Eggert
8f40ed634c sort: document --compress reaper fixes
* NEWS: Document the --compress reaper fixes installed yesterday.
2010-12-14 10:22:04 -08:00
Paul Eggert
dcb3f60d0a tests: default to /tmp as the temporary directory
* tests/check.mk (TESTS_ENVIRONMENT): Default TMPDIR to /tmp,
rather than to the working directory; this is more common in
practice, which makes the tests more real-worldish; and it is
often faster.  Also, it avoids some problems with NFS cleanups.
* tests/misc/sort-compress: Remove unnecessary code setting TMPDIR.
* tests/misc/sort-compress-proc: Likewise.  Do the final sleep
only if TMPDIR is relative, which should be rarely given the
change to TESTS_ENVIRONMENT.
2010-12-14 10:08:04 -08:00
Paul Eggert
0da4d84300 sort: fix some --compress reaper bugs
* src/sort.c (uintptr): New type.
(enum procstate, struct procnode, update_proc): Remove.
(proctab_hasher, proctab_comparator, register_proc, wait_proc):
(reap_some): The proctab is now simply a hash of process-IDs
rather than of pointers to objects with reference counts and
states; this is smaller and faster and easier to understand.
(nprocs): Now pid_t, not size_t, since one cannot have more than
PID_MAX children.
(reap): If the argument is -1, wait; if 0 (a new value), do not.
Delete pid from proctab as needed.  Ignore children that are not
in proctab, as they are from the program that exec'ed us and are
irrelevant to our success or failure.
(delete_proc, reap_all): New functions.
(open_temp): Register the child.
(sort): Clean up all children afterwards; without this patch,
'sort' sometimes missed failures in children due to race conditions.
* tests/Makefile.am (TESTS): Add misc/sort-compress-proc.
* tests/misc/sort-compress-proc: New file, to test for the
bugs fixed above.
2010-12-13 23:23:47 -08:00
Paul Eggert
6d36bd4c64 tests: typo fix
* tests/misc/sort-stale-thread-mem: Fix typo in comment.
2010-12-13 10:02:43 -08:00
Jim Meyering
0c70708db7 tests: tweak basic-1 to use warn_ rather than literal "exit 77"
* tests/install/basic-1 (just_built_dd): Use warn_, rather than
cat and exit 77.
2010-12-13 08:29:42 +01:00
Jim Meyering
8351407f87 tests: mark new test as very expensive
* tests/misc/sort-stale-thread-mem: Don't initialize fail=0 here;
that is done in init.sh.  This avoids a syntax-check failure.
Invoke "Exit $fail" at end, too.
Mark as a very expensive test.
2010-12-13 08:28:19 +01:00
Paul Eggert
b212633c41 tests: test for access to stale thread memory
* tests/misc/sort-stale-thread-mem: New tests.
* tests/Makefile.am (TESTS): Add it.
2010-12-12 13:38:49 -08:00
Jim Meyering
45ff91af2e tests: avoid FP failure when run under valgrind
* tests/misc/printenv: Filter out LD_PRELOAD, as the comment
said, not LD_LIBRARY.
2010-12-11 18:44:57 +01:00
Jim Meyering
ad61335bf8 sort: avoid segfault when using two or more threads
This change does not fix the actual bug.  That was done by commit
c9db0ac6, "sort: preallocate merge tree nodes to heap".  The fix
was to store each "node" structure on the heap, not on the stack.
Otherwise, a node from one thread's stack could be used in another
thread after the first thread had expired (via pthread_join).
This bug was very hard to trigger when using spinlocks, but
easier once we began using mutexes.
* NEWS (Bug fixes): Mention it.
For details, see http://debbugs.gnu.org/7597.
2010-12-11 11:52:24 +01:00
Jim Meyering
9a9d69e9e4 sort: syntax cleanup
* src/sort.c (xfopen, debug_key, sortlines, sort, main): Adjust
formatting: fix misplaced braces, use consistent spacing,
split a 2-stmt line.
2010-12-11 11:29:38 +01:00
Paul Eggert
27e997d0eb sort: integer overflow checks in thread counts, etc.
* src/sort.c (specify_nthreads, merge_tree_init, init_node):
(queue_init, sortlines, struct thread_args, sort, main):
Use size_t, not unsigned long int, for thread counts, since thread
counts are now used to compute sizes.
(specify_nthreads): Check for size_t overflow.
(merge_tree_init, sort): Shorten name of local variable, for
readability.
(merge_tree_init): Move constants next to each other in product,
so that the constant folding is easier to see.
(init_node): Now static.  Add 'restrict' only where it might
be helpful for compiler optimization.
(queue_init): 2nd arg is now nthreads, not "reserve", which is
a bit harder to follow.  All uses changed.
(struct thread_args): Rename lo_child to is_lo_child, so that
it's obvious to the reader when we're talking about this boolean
as opposed to the new lo_child member of the other structure.
All uses changed.
(sort): Remove unused local variable end_node.
(main): Don't allow large thread counts to cause undefined behavior
later, due to integer overflow.
2010-12-11 00:29:13 -08:00
Chen Guo
c9db0ac6de sort: preallocate merge tree nodes to heap.
* src/sort.c: (merge_tree_init) New function. Allocates memory for
merge tree nodes.
(merge_tree_destory) New function.
(init_node) New function.
(sortlines) Refactor node creation code to init_node. Remove now
superfluous arguments. All callers changed.
(sort) Initialize/destory merge tree. Refactor root node creation
to merge_tree_init.
2010-12-11 00:29:13 -08:00
Paul Eggert
d1f7003556 sort: comment fix
* src/sort.c: Comment fix re spin locks.
2010-12-11 00:29:13 -08:00
Chen Guo
621876ff44 sort: use mutexes, not spinlocks (avoid busy loop on blocked output)
Running a command like this on a multi-core system
  sort < big-file | less
would peg all processors at near 100% utilization.
* src/sort.c: (struct merge_node) Change member lock to mutex.
All uses changed.
* tests/Makefile.am (XFAIL_TESTS): Remove definition, now that
this test passes once again.  I.e., the sort-spinlock-abuse test
no longer fails.
* NEWS (Bug reports): Mention this.
Reported by DJ Lucas in http://debbugs.gnu.org/7489.
2010-12-11 00:29:13 -08:00
Pádraig Brady
195c455d0a split: fix a case where --elide-empty causes invalid chunking
When -n l/N is used and long lines are present that both
span partitions and multiple buffers, one would get
inconsistent chunk sizes.

* src/split.c (main): Add a new undocumented ---io-blksize option
to support full testing with varied buffer sizes.
(cwrite): Refactor most handling of --elide-empty to here.
(bytes_split): Remove handling of --elide-empty.
(lines_chunk_split): Likewise.  The specific issue here
was the first handling of elide_empty_files interfered
with the replenishing of the input buffer.
* test/misc/split-lchunk: Add -e and the new ---io-blksize
combinations to the test.
2010-12-08 23:36:17 +00:00
Jim Meyering
a1629ba1ec tests: remove useless definition of $SORT in sort-compress
* tests/misc/sort-compress (SORT): Remove unused definition.
2010-12-05 17:07:35 +01:00
Jim Meyering
231d8719f1 tests: make it harder to lose a race in spinlock-abuse
* tests/misc/sort-spinlock-abuse: On a busy system, with only 12
pauses of length 0.1 seconds, the buggy (busy-spinlock blocked)
sort would fail to accumulate 1 second of CPU time, and hence
would mistakenly pass.  Increase from 12 to 50.
2010-12-04 11:52:21 +01:00
Paul Eggert
cd00fa6ee1 sort: merge_queue -> queue
* src/sort.c (struct thread_args, sortlines_thread, sortlines, sort):
Rename "merge_queue" to "queue", for consistency with other functions
that just use the name "queue" for these things.
2010-12-03 23:43:31 -08:00
Paul Eggert
fb282c7b30 sort: clarify queue_check_insert
* src/sort.c (queue_check_insert): Clarify body a bit, and remove
no-longer-needed comment.
2010-12-03 23:43:31 -08:00
Paul Eggert
fb41e82c77 sort: fix problems with merge node dest pointer
* src/sort.c (mergelines_node): Return void, not size_t.  All
callers changed.  Change *node->dest here, not in caller.
Do not change node->dest: it's not needed and could cause problems
on (mostly theoretical) hosts that do not allow adding integers to
null pointers.
(queue_check_insert_parent): Omit MERGED parameter; no longer needed.
All callers changed.
2010-12-03 23:43:31 -08:00
Paul Eggert
f2d977aff1 sort: simplify write_unique
* src/sort.c (write_unique): Simplify slightly so that there is
just one call to write_line, not two.
2010-12-03 23:43:31 -08:00
Paul Eggert
6f4279421d sort: put queue arg first
* src/sort.c (queue_check_insert, queue_check_insert_parent): Make
the queue arg first, for consistency with other functions such as
queue_insert that put the queue arg first.  Rename from
check_insert and update_parent, respectively.  All callers
changed.
2010-12-03 23:43:30 -08:00
Paul Eggert
f35f4b3396 sort: tune struct_merge_node slightly
* src/sort.c (struct merge_node): 'lock' is now the actual lock,
not a pointer to the lock; there's no need for indirection here.
Make 'level' unsigned int instead of size_t, since it is a
bit-shift count; also, move it next to a bool so that it's more
likely to take less space.  All uses changed.
(sortlines, sort): Spell out initialization instead of using an
initializer.  This makes the initializer a bit easier to understand,
and avoids unnecessary stores into the spin lock.
2010-12-03 23:43:30 -08:00
Paul Eggert
eb989f4b75 sort: Clarify comments
* src/sort.c: Improve comments a bit.
2010-12-03 23:43:30 -08:00
Paul Eggert
b6ef652e50 tests: cleanup rm -rf fails under NFS
This problem was observed on RHEL 5.5 x86-64 when running as a
client of a NetApp FAS2050.
* tests/cp/cp-mv-backup: Don't leave a file descriptor open to
a file in a directory that will be cleaned up with "rm -rf".
Under NFS, when the rm unlinks that file, it is instead renamed
to .nfsXXXX and then rm cannot remove the parent directory,
and the test fails.
* tests/cp/same-file: Likewise.
2010-12-03 11:09:27 -08:00
Paul Eggert
b5a25a996d cp: fix bug with fine-grained src to nearby coarse-grained dest
The actual fix is in gnulib's lib/utimecmp.c.
* NEWS: Document fix.
2010-12-03 09:56:32 -08:00
Paul Eggert
038fcfcf1b build: update gnulib submodule to latest 2010-12-03 09:53:02 -08:00
Paul Eggert
0ec869e8be sort: fix bug on 64-bit hosts with at least 32768 processors
* src/sort.c (MAX_MERGE): Avoid integer overflow when on a machine
with (say) 32-bit int and 64-bit size_t and when level == 15.
Without this fix, on such a machine with 32768 or more processors,
the level computation could overflow on large input, and this
would result in division by zero.
2010-12-01 21:51:15 -08:00
Jim Meyering
a5207bb139 tests: add test for parallel sort -u segfault bug
* tests/misc/sort-unique-segv: New file.
* tests/Makefile.am (TESTS): Add it.
2010-12-01 08:15:42 +01:00
Paul Eggert
3afda5f007 sort -u: fix a thread-race pointer corruption bug
* src/sort.c (write_unique): Save the entire "struct line", not
just a pointer to one.  Otherwise, with a multi-thread run,
sometimes, with some inputs, fillbuf would would win a race
and clobber a "saved->text" pointer in one thread just before
it was dereferenced in a comparison in another thread.
* NEWS (Bug fixes): Mention it.
2010-12-01 07:13:06 +01:00
Jim Meyering
43d1112d01 tests: don't let the OMP_NUM_THREADS envvar affect sort tests
* tests/envvar-check (vars): Add OMP_NUM_THREADS.
2010-11-27 16:32:10 +01:00
Jim Meyering
fbb47bf424 tests: test for parallel sort spinlock abuse
* tests/misc/sort-spinlock-abuse: New file.
* tests/Makefile.am (TESTS): Add it.
(XFAIL_TESTS): Mark this as an expected-to-fail (for now) test.
2010-11-27 16:32:06 +01:00
Pádraig Brady
b8cd747cc8 tsort: suppress a valgrind memory leak warning
* src/tsort.c (tsort): Unconditionally invoking the free()
doesn't increase scalability, so do it only with -Dlint
2010-11-27 03:27:49 +00:00
Pádraig Brady
67f7ed3e3a maint: update the valgrind support script
* README-valgrind: Include the "noinst" programs in
those wrapped by valgrind.  Update $PATH in check.mk
rather than Makefile.am.  Make wrapper scripts
work when suppressions not setup.  Keep lines < 80 chars.
2010-11-24 13:39:47 +00:00
Paul Eggert
013d95af11 cp: give a better diagnostic for nonexistent dest/
This patch was written by Jim Meyering and myself.
* src/copy.c (copy_reg): Turn EISDIR to ENOTDIR to improve the
quality of diagnostics for commands like "cp a nosuch/".  Reported
by Марк Коренберг and Alan Curry in the thread starting at:
http://lists.gnu.org/archive/html/bug-coreutils/2010-11/msg00178.html
* THANKS: Update.
* tests/mv/trailing-slash: Add a test.
2010-11-22 00:04:50 -08:00
Chen Guo
be107398e5 split: add --number to generate a particular number of files
* src/split.c (usage, long_options, main): New options --number,
--unbuffered, --elide-empty-files.
(set_suffix_length): New function to auto increase suffix length
to handle a specified number of files.
(create): New function.  Refactored from cwrite() and ofile_open().
(bytes_split): Add max_files argument to support byte chunking.
(lines_chunk_split): New function.  Split file into chunks of lines.
(bytes_chunk_extract): New function.  Extract a chunk of file.
(of_info): New struct.  Used by functions lines_rr and ofile_open
to keep track of file descriptors associated with output files.
(ofile_open): New function.  Shuffle file descriptors when there
are more output files than available file descriptors.
(lines_rr): New function to distribute lines round-robin to files.
(chunk_parse): New function.  Parses K/N syntax.
* tests/misc/split-bchunk: New test for byte chunking.
* tests/misc/split-lchunk: New test for line delimited chunking.
* tests/misc/split-rchunk: New test for round-robin chunking.
* tests/Makefile.am: Reference new tests.
* tests/misc/split-fail: Add failure scenarios for new options.
* tests/misc/split-l: Fix a typo. s/ln/split/.
* doc/coreutils.texi (split invocation): Document --number.
* NEWS: Mention the new feature.
* .mailmap: Map new email address for shortlog.

Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-11-22 01:45:15 +00:00
Jim Meyering
dadca988af build: update gnulib to fix a syntax error in a test 2010-11-19 14:29:32 +01:00
Jim Meyering
c2bdd17856 maint: avoid NEWS-related syntax-check failure
* NEWS: Add 2nd blank line to separate latest changes from
those of 8.7, to avoid syntax-check failure.
2010-11-18 21:16:27 +01:00
Paul Eggert
a71c22fdf0 od: fix bugs in displaying floating-point values
* NEWS: Describe patch.
* bootstrap.conf (gnulib_modules): Add ftoastr.
* src/od.c: Include ftoastr.h, not float.h.
(FLT_DIG, DBL_DIG): Remove.  No need to verify LDBL_DIG.
(FMT_BYTES_ALLOCATED): No need to worry about floating point now,
since this format is no longer used for floating point.
(PRINT_FIELDS): New macro, with most of the guts of the old PRINT_TYPE.
(PRINT_TYPE): Rewrite to use PRINT_FIELDS.
(PRINT_FLOATTYPE): New macro.  This uses the new functions from
ftoastr.
(print_float, print_double, print_long_double): Reimplement
using PRINT_FLOATTYPE.
(decode_one_format): Calculate field widths based on ftoastr-supplied
macros.
* tests/Makefile.am (TESTS): Add misc/od-float.
* tests/misc/od-float: New file.
2010-11-18 09:51:04 -08:00
Paul Eggert
cf90729e09 build: update gnulib submodule to latest 2010-11-18 09:33:49 -08:00
Jim Meyering
c1b41c5c3b maint: syntax-check: prevent new $VERBOSE/--version tests
* cfg.mk (sc_prohibit_verbose_version): New rule.
2010-11-18 06:29:54 +01:00
Jim Meyering
ae5cfc9f12 tests: convert tests/misc/selinux manually 2010-11-17 21:46:57 +01:00
Jim Meyering
8f9be76b0d tests: convert the multi-prog $VERBOSE/--version uses
E.g.,

-test "$VERBOSE" = yes && { env -- pwd --version; readlink --version; }
+print_ver_ pwd readlink

-test "$VERBOSE" = yes && { stdbuf --version; mv --version; }
+print_ver_ stdbuf mv

Use this command:
git grep -l 'VERBOSE.*--version'|xargs perl -ni \
  -e '/^test "\$VERBOSE" = yes && { .*--version/ or print,next;' \
  -e 's/env -- //g;' \
  -e 's/test "\$VERBOSE" = yes && { /print_ver_ /;' \
  -e ' s/(\w+) --version;/$1/g; s/ *}$//; print'
2010-11-17 21:46:25 +01:00
Jim Meyering
a8c8484ee1 tests: convert "... env -- prog --version" uses
E.g.,

-test "$VERBOSE" = yes && env -- pwd --version
+print_ver_ pwd

git grep -l 'VERBOSE.*--version'|xargs perl -pi -e \
  's/test "\$VERBOSE" = yes && env -- (\w+) --version/print_ver_ $1/'
2010-11-17 21:46:22 +01:00
Jim Meyering
293c37b906 tests: substitute the single-program $VERBOSE/--version uses
Automatically make all of the changes like this:

  -test "$VERBOSE" = yes && chgrp --version
  +print_ver_ chgrp

git grep -l 'VERBOSE.*--version'|xargs perl -pi -e \
  's/test "\$VERBOSE" = yes && (\w+) --version/print_ver_ $1/'
2010-11-17 21:45:51 +01:00
Jim Meyering
5c0275e953 tests: factor out VERBOSE-only --version-printing code
* tests/init.cfg (print_ver_): New function.
2010-11-17 21:34:54 +01:00
Jim Meyering
11d3389f5a tests: remove test-lib.sh; now all tests use gnulib's init.sh
* tests/test-lib.sh: Remove file.  No longer used.
* tests/Makefile.am (EXTRA_DIST): Remove it here, too.
* tests/sample-test: Correct a comment.
2010-11-17 20:48:57 +01:00
Jim Meyering
fbcc100f5b tests: convert remaining uses of test-lib.sh to init.sh
RHS='. "\${srcdir=.}/init.sh"; path_prepend_ ../src'
git grep -l test-lib.sh \
  | xargs perl -pi -e 's,^\. \$srcdir/test-lib\.sh$,'"$RHS",
2010-11-17 20:48:57 +01:00
Jim Meyering
ff7f0ff85c tests: convert 'if test "$VERBOSE" = yes; then' to test ... && 2010-11-17 20:48:57 +01:00
Jim Meyering
f38becab02 tests: convert first batch of tests from test-lib.sh to init.sh
Initially, I did this,
git grep -l srcdir/test-lib.sh|xargs perl -p0i -e '~180-byte script'
but that line would have been much longer than the maximum permitted
by coreutils' commit hook, and wasn't readable besides, so here's a
more readable version:

lhs=$(printf '%s\\n' \
'if test "$VERBOSE" = yes; then' \
'  set -x' \
'  touch --version' \
'fi' \
'' \
'. $srcdir/test-lib.sh' \
  | sed 's/\$/\\\$/g;s/touch/(\\w+)/')

rhs=$(printf '%s\\n' \
'. "${srcdir=.}/init.sh"; path_prepend_ ../src' \
'test "$VERBOSE" = yes && FIXME --version' \
  | sed 's/\$/\\\$/g;s/FIXME/\$1/')

git grep -l srcdir/test-lib.sh|xargs perl -p0i -e "s,$lhs,$rhs,"
2010-11-17 20:48:57 +01:00
Jim Meyering
30b74dfff1 tests: move a comment so automated conversion works 2010-11-17 20:48:57 +01:00
Jim Meyering
01a27b9054 maint: add a NEWS-checking syntax-check rule
* cfg.mk (sc_NEWS_two_empty_lines): New syntax-check rule.
2010-11-17 20:48:56 +01:00
Pádraig Brady
79adacc431 build: add patch as a bootstrap dependency
* bootstrap.conf (buildreq): require `patch` as it's used
by gnulib-tool to apply local diffs to gnulib modules
2010-11-16 07:39:06 +00:00
Pádraig Brady
9ad13ad14a split: fail immediately if impossible to create a large file
* src/split.c (main): Error if -[bC] value > OFF_T_MAX
* tests/misc/split-fail: Adjust for the new lower limits
2010-11-16 00:50:09 +00:00
Pádraig Brady
c8d570c2b3 truncate: fix a very unlikely case for undiagnosed errors
src/truncate.c (main): Use a bool to store if an error occurred,
rather than an int, to protect against overflow.
(do_ftruncate): Likewise.   Also change 0/false to mean failure
rather than success.
2010-11-16 00:47:36 +00:00
Pádraig Brady
0d1ba34494 maint: fix a new -Wpointer-sign gcc warning
* src/csplit.c (max_out): Fix a new warning introduced with
commit 6568b173, 2010-11-10, "csplit: do not rely on..."
2010-11-16 00:38:12 +00:00
Pádraig Brady
f9cfda6ad2 build: enable the -Wpointer-sign gcc warning
... when configured with the --enable-gcc-warnings option.
This follows on from commit 34ef0a01, 2010-10-14,
"sort: fix unportable cast of unsigned char * -> char *"

* configure.ac: -Wall implicitly enables this warning
so remove the explicit disabling.
2010-11-16 00:05:41 +00:00
Pádraig Brady
b19733bb42 maint: add a missed fadvise-tests module
* gl/modules/fadvise-tests: Add the module previously missed
in commit 63b5e816, 2010-07-14, "fadvise: new module ...".
* gl/tests/test-fadvise.c: Add a comment as to why we don't
check return values.
2010-11-15 14:56:24 +00:00
Paul Eggert
f70c7b785b doc: tweak NEWS and coreutils.texi
* doc/coreutils.texi (stat invocation): Add sentence-ending period.
* NEWS: Correct stat change description: s/floating point //.
* cfg.mk (old_NEWS_hash): Update, to match this NEWS change.
2010-11-13 22:02:29 +01:00
Jim Meyering
ee6f187b18 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-11-13 17:37:18 +01:00
Jim Meyering
e143ba52c4 version 8.7
* NEWS: Record release date.
2010-11-13 17:21:08 +01:00
Jim Meyering
d2e0f3602e build: update gnulib...
...to fix the failing update-copyright test,
and for the openat portability fix.
2010-11-13 15:45:56 +01:00
Jim Meyering
2d5b3329a2 build: update gnulib for linux 2.6.9 nanosleep workaround
Also, do the following to avoid "make syntax-check" failure
induced by new rules.
* .x-sc_bindtextdomain: Exempt files with an #ifdef'd "main".
* Makefile.am: Add this file.
2010-11-13 11:41:02 +01:00
Jim Meyering
ff5fc553f9 maint: remove fstimeprec (variable precision time stamp) support
The implementation of variable-precision time stamps relied
on heuristics that made the output subtly nondeterministic,
or at least hard to reproduce:
http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/21531/focus=21538
So, for now at least, we're removing that feature.
* bootstrap.conf (gnulib_modules): Remove fstimeprec.
* gl/lib/fstimeprec.c, gl/lib/fstimeprec.h: Remove files.
* gl/modules/fstimeprec, gl/modules/fstimeprec-tests: Likewise.
* gl/tests/test-fstimeprec.c: Remove file.
2010-11-13 11:41:02 +01:00
Jim Meyering
4a8e9bf14c stat: do not provide variable precision time stamps
* src/stat.c: Don't include fstimeprec.c.
(out_epoch_sec): Don't call fstimeprec.
* NEWS: Update description.
* doc/coreutils.texi: Likewise.
2010-11-13 11:40:52 +01:00
Paul Eggert
6568b173db csplit: do not rely on undefined behavior in printf formats
* doc/coreutils.texi (csplit invocation): Say that %d and %i are
aliases for %u.
* src/csplit.c (FLAG_THOUSANDS, FLAG_ALTERNATIVE): New constants.
(get_format_flags): Now take char const * and int * and return
size_t.  It now stores info about the flags instead of merely
scanning them.  Also, it handles '0' correctly.  Drop support for
the undocumented '+' and ' ' flags since the value is unsigned.
Add support for the (undocumented) "'" flag.  All uses changed.
(get_format_width, get_format_prec): Remove.
(check_format_conv_type): Renamed from get_format_conv_type, with
a different signature.  It now converts the format to one that is
compatible with unsigned int, and checks flags.  All uses changed.
(max_out): Have snprintf compute the number of bytes needed rather
than attempting to do it ourselves (which doesn't work portably
with outlandish formats such as %4294967296d).
(check_format_conv_type, main): Check for overflow in size
calculations.  Don't assume size_t fits in unsigned int.
* tests/misc/csplit: Check for proper handling of flags, with
%0#6.3x.  Coreutils 8.6 mishandles this somewhat-weird example.
2010-11-11 08:16:24 +01:00
Pádraig Brady
0339eb4598 csplit: fix a memory leak per input buffer
* src/csplit.c (free_buffer): Also free the line offsets buffers
(remove_line): Also free the containing structure
* tests/misc/csplit-heap: A new test to trigger with leaks of
this magnitude.
* tests/Makefile.am: Reference the new test
* NEWS: Mention the fix
Reported by David Hofstee
2010-11-11 01:40:12 +00:00
Jim Meyering
7727908335 tests: fix comments and --version invocation in new test
* tests/misc/csplit-1000: Fix comments and --version invocation.
2010-11-10 22:08:05 +01:00
Jim Meyering
0cfd4f2161 csplit: avoid buffer overrun when writing more than 999 files
Without this fix, seq 1000 | csplit - /./ '{*}' would write
the NUL-terminated file name, xx1000, into a buffer of size 6.
* src/csplit.c (main): Use properly sized file name buffer.
* NEWS (Bug fixes): Mention it.
* tests/misc/csplit-1000: New test to trigger the bug.
* tests/Makefile.am (TESTS): Add misc/csplit-1000.
2010-11-10 14:28:03 +01:00
Pádraig Brady
425503c807 tests: avoid portability problem with dash vs. symlinked ttys
* tests/mv/i-3: Adjust so that the symlink is resolved
before redirecting to the background command, as otherwise
the stdin descriptor passed to the command will fail the
isatty() or ttyname() test.
2010-11-09 12:43:20 +00:00
Pádraig Brady
4a14a80bd1 tests: avoid portability problem with dash vs. local v=$splittable_val
* tests/init.cfg (retry_delay_): Adjust awk script to print a single
floating point value, rather than many.
2010-11-08 11:26:08 +01:00
Jim Meyering
dd45755406 tests: don't disqualify FreeBSD 8.1's /bin/sh just yet,
because dash-0.5.6-2.fc14.x86_64 would also be disqualified.
This reverts part of yesterday's commit 6c058b2d, "tests: avoid
failure due to bug in FreeBSD 8.1's /bin/sh".  Note that the offending
aspect of those shells is not officially a bug, since "local" is not
specified by POSIX.  However, it is very unintuitive that prepending
"local" to an existing, standards-compliant assignment would evoke
such a fundamental change in semantics.
* tests/init.sh: Remove snippet requiring sane "local" support.
Upstream dash bug report:
http://thread.gmane.org/gmane.comp.shells.dash/419
2010-11-07 21:08:37 +01:00
Paul Eggert
ca9aa75960 stat: do not rely on undefined behavior in printf formats
* src/stat.c (digits, printf_flags): New static vars.
(make_format): New function.
(out_string, out_int, out_uint, out_uint_o, out_uint_x):
(out_minus_zero): Use it to avoid undefined behavior when invoking
printf.
(print_it): Check for invalid conversion specifications such as
%..X and %1-X, which would otherwise rely on undefined behavior
when invoking printf.
* tests/misc/stat-nanoseconds: Check that the "I" printf flag
doesn't mess up in the C locale, as it formerly did on non-GNU
hosts.
2010-11-06 18:09:44 -07:00
Jim Meyering
6c058b2dab tests: avoid failure due to bug in FreeBSD 8.1's /bin/sh
* tests/init.sh: Arrange not to accept FreeBSD 8.1's /bin/sh, since
it fails this test: /bin/sh -c 'f(){ local s=$IFS; test -n "$s"; }; f'
* tests/init.cfg (sanitize_path_): Stop-gap measure to work around
a bug in FreeBSD 8.1's /bin/sh.  We'll un-do this change once all
300+ tests use init.sh.
2010-11-06 15:24:53 +01:00
Jim Meyering
3261914da1 build: update gnulib to latest for strtod and icc fixes 2010-11-06 15:24:53 +01:00
Paul Eggert
c7375c236c stat: use e.g. %.3X instead of %X.%3:X for sub-second precision
* NEWS: Document this.
* doc/coreutils.texi (stat invocation): Likewise.
* gl/lib/fstimeprec.c, gl/lib/fstimeprec.h, gl/modules/fstimeprec:
* gl/modules/fstimeprec-tests, gl/tests/test-fstimeprec.c:
New files.
* bootstrap.conf (gnulib_modules): Add fstimeprec.
* src/stat.c: Include fstimeprec.h.  Don't include xstrtol.h.
(decimal_point, decimal_point_len): New static vars.
(main): Initialize them.
(epoch_sec, out_ns): Remove.
(out_int, out_uint): Now returns whatever printf returned.
(out_minus_zero, out_epoch_secs): New functions.
(print_stat): Use out_epoch_sec instead of out_ns and epoch_sec.
(print_stat, print_it, usage): Remove the %:X-style formats.
* tests/misc/stat-nanoseconds: Set TZ=UTC0 to avoid problems
with weird time zones.  Use a time stamp near the Epoch so that we
don't have to worry about leap seconds.  Redo test cases to match
new behavior.
* tests/touch/60-seconds: Change %Y.%:Y to %.9Y, to adjust to
new behavior.
2010-11-06 15:24:49 +01:00
Eric Blake
312549b627 cp: NEWS entry for previous fix
Resolves bug#7324

* NEWS: Document the extent of the Solaris crash.
2010-11-04 10:51:01 -06:00
Eric Blake
7b4e77352d cp, mv, touch: fix file time manipulation on Solaris 10
* gnulib: Update to latest, for futimens fix.
* .gitignore: Ignore another recent gnulib-generated file.
2010-11-04 08:34:07 -06:00
Jim Meyering
1369fe9284 build: update gnulib to latest 2010-11-03 13:11:21 +01:00
Jim Meyering
db42ae787d stat: revert %X-%Y-%Z change; use e.g., %:X to print fractional seconds
This reverts part of the recent commit 9069af45,
"stat: print timestamps to full resolution", which made %X, %Y, %Z
print floating point numbers.  We prefer to retain portability of
%X, %Y and %Z uses, while still providing access to full-resolution
time stamps via modified format strings.  Also make the new
%W consistent.
* src/stat.c: Include "xstrtol.h".
(print_it): Accept a new %...:[XYZ] format directive,
e.g., %:X, to print the nanoseconds portion of the corresponding time.
For example, %3.3:Y prints the zero-padded, truncated, milliseconds
part of the time of last modification.
(print_it): Update print_func signature to match.
(neg_to_zero): New helper function.
(epoch_time): Remove function; replace with...
(epoch_sec): New function; use timetostr.
(out_ns): New function.  Use "09" only when no other modifier
is specified.
(print_statfs): Change type of "m" to unsigned int,
now that it must accommodate values larger than 255.
(print_stat): Likewise.
Map :X to a code of 'X' + 256.  Likewise for Y, Z and W.
(usage): Update.
* tests/touch/60-seconds: Use %Y.%:Y in place of %Y.
* tests/misc/stat-nanoseconds: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Changes in behavior): Mention this.
With improvements by Pádraig Brady.
Thanks to Andreas Schwab for raising the issue.
2010-11-03 13:10:50 +01:00
Nix
272f8bf0ac tests: fix a false positive for 32 bit on 64 bit hosts
* tests/ls/stat-free-symlinks: strace currently outputs an
informational message about arch difference to stdout.
Therefore we need to strip that before comparison.
2010-11-01 16:02:39 +00:00
Patrick W. Plusnick II
30e207fa46 maint: remove an unnecessary FIXME comment
* src/seq.c (terminator): This does not need to be specifiable
via an option.  Remove the FIXME comment.
2010-10-28 15:22:08 +02:00
Pádraig Brady
883ac22239 cp: make --attributes-only override --reflink completely
* doc/coreutils.texi (cp invocation): Change the description slightly
so as users might not immediately discount using this option.
Mention that --reflink is overridden by the other linking options and
--attributes-only, and give an example where this might be useful.
* src/copy.c (copy_internal): Bypass the reflink if
--attributes-only is specifed.
* tests/cp/reflink-perm: Ensure both --reflink modes are
overridden by --attributes-only.
* NEWS: Mention the change in behavior.
Reported by Jim Meyering.
2010-10-27 11:18:51 +01:00
Jim Meyering
0d792d061e tests: mention that btrfs also causes failure of misc/ls-time
* tests/misc/ls-time: Mention that this test also fails on btrfs,
at least until http://bugzilla.redhat.com/591068 is addressed.
2010-10-26 18:14:50 +02:00
Eric Blake
3e1905baf4 maint: update THANKS
* THANKS: Update.
2010-10-25 11:51:45 -06:00
Tobias Quathamer
7930367a34 date: correct typos in date --help
* src/date.c (usage): Use "e.g." correctly.
2010-10-25 11:45:27 -06:00
Pádraig Brady
c84ddbaa33 tail: support rechecking currently missing remote dirs
src/tail.c (main): As an optimization, don't bother checking
for stdin or remote files, when ---disable-inotify is specified.
To improve the fix in commit 61b77891, set the disable_inotify
flag when we fall back to polling, so that we recheck remote files.
NEWS: Mention the fix
2010-10-25 15:41:53 +01:00
Paul Eggert
7d93a082b6 du: don't print junk when diagnosing out-of-range time stamps
* src/du.c (show_date): Fix call to fputs with a buffer that
contains some uninitialized data.
* tests/Makefile.am (TESTS): Add du/big-timestamp.
* tests/du/bigtime: New file, which checks for the bug.
2010-10-23 17:24:38 -07:00
Rodrigo Campos
d5d82ecf3b doc: add a cross reference from cat's man page to "tac"
* man/cat.x: See also "tac".
2010-10-20 08:35:50 +02:00
Jim Meyering
10a0bdfa98 tests: trigger and test for md5sum's new diagnostics
* tests/misc/md5sum: Test for new diagnostics.
2010-10-19 09:35:44 +02:00
Benno Schulenberg
407806b27f md5sum: print a summary warning for improperly formatted lines
And remove the now-superfluous totals from the other two warnings,
so the plurals will also work in other languages than English.

* src/md5sum.c (digest_check): Change as above.
* tests/misc/md5sum (check-quiet2): Adjust accordingly.
2010-10-19 09:32:38 +02:00
Jim Meyering
3c7112104d build: enable -Werror for gnulib-tests, too
* gnulib: Update to latest for warning-free tests.
* gnulib-tests/Makefile.am (AM_CFLAGS): Uncomment $(WERROR_CFLAGS),
now that these tests are warning-free.
2010-10-18 07:28:36 +02:00
Jim Meyering
840e8c9cfb maint: update bootstrap from gnulib
* bootstrap: Update from gnulib.
2010-10-17 15:56:01 +02:00
Jim Meyering
b1b23d894b .gitignore: anchor patterns
* .gitignore: Anchor most patterns.  Remove .tarball-version.
* doc/.gitignore: Anchor all patterns.
Remove getdate.texi and get_date.texi.
2010-10-17 15:55:13 +02:00
Jim Meyering
766ec503f7 tests: sort-float: avoid spurious test failure on ppc/ppc64
* tests/misc/sort-float: On systems with DBL_MIN < LDBL_MIN,
this test would fail because the expected output was not sorted.
Detect that case, and if needed, reverse those two values.
2010-10-17 09:18:57 +02:00
Andreas Schwab
9c589e694f fold: fix fadvise hint
* src/fold.c (fold_file): Apply fadvise to istream, not stdin.
This bug would have inhibited the fadvise optimization when not
reading from standard input.
2010-10-16 13:32:04 +02:00
Jim Meyering
6728401351 post-release administrivia
* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.
2010-10-15 17:06:56 +02:00
426 changed files with 3375 additions and 3020 deletions

140
.gitignore vendored
View File

@@ -7,79 +7,77 @@
._bootmp
.gdb-history
.kludge-stamp
.tarball-version
.version
ABOUT-NLS
ChangeLog
GNUmakefile
/ABOUT-NLS
/ChangeLog
/GNUmakefile
/INSTALL
/THANKS-to-translators
/aclocal.m4
/autom4te.cache
/build-aux/.gitignore
/build-aux/compile
/build-aux/config.guess
/build-aux/config.sub
/build-aux/depcomp
/build-aux/install-sh
/build-aux/mdate-sh
/build-aux/missing
/build-aux/texinfo.tex
/build-aux/ylwrap
/config.cache
/config.log
/config.status
/configure
/coreutils-*.tar.gz
/coreutils-*.tar.gz.sig
/coreutils-*.tar.xz
/coreutils-*.tar.xz.sig
/gnulib-tests
/lib/.cvsignore
/lib/.gitignore
/lib/arg-nonnull.h
/lib/arpa
/lib/binary-io.h
/lib/c++defs.h
/lib/charset.alias
/lib/config.h
/lib/config.hin
/lib/configmake.h
/lib/glthread
/lib/libcoreutils.a
/lib/link-warning.h
/lib/printf.c
/lib/progname.c
/lib/progname.h
/lib/selinux
/lib/stamp-h1
/lib/unistr
/lib/uniwidth
/lib/unused-parameter.h
/lib/warn-on-use.h
/m4/.cvsignore
/m4/.gitignore
/maint.mk
/man/*.1
/po/*.gmo
/po/*.po
/po/.gitignore
/po/.reference
/po/LINGUAS
/po/Makefile.in
/po/Makevars
/po/POTFILES
/po/checksums
/po/coreutils.pot
/po/stamp-po
/src/version.c
/src/version.h
/stamp-h1
/tests/*/*.log
/tests/t?
/tests/test-suite.log
ID
INSTALL
Makefile
Makefile.in
TAGS
THANKS-to-translators
aclocal.m4
autom4te.cache
build-aux/.gitignore
build-aux/compile
build-aux/config.guess
build-aux/config.sub
build-aux/depcomp
build-aux/install-sh
build-aux/mdate-sh
build-aux/missing
build-aux/texinfo.tex
build-aux/ylwrap
config.cache
config.h
config.hin
config.log
config.status
configure
coreutils-*.tar.bz2
coreutils-*.tar.bz2.sig
coreutils-*.tar.gz
coreutils-*.tar.gz.sig
coreutils-*.tar.xz
coreutils-*.tar.xz.sig
gnulib-tests
lib/.cvsignore
lib/.gitignore
lib/arg-nonnull.h
lib/arpa
lib/binary-io.h
lib/c++defs.h
lib/charset.alias
lib/configmake.h
lib/glthread
lib/libcoreutils.a
lib/link-warning.h
lib/printf.c
lib/progname.c
lib/progname.h
lib/selinux
lib/unistr
lib/uniwidth
lib/unused-parameter.h
lib/warn-on-use.h
m4/.cvsignore
m4/.gitignore
maint.mk
man/*.1
po/*.gmo
po/*.po
po/.gitignore
po/.reference
po/LINGUAS
po/Makefile.in
po/Makevars
po/POTFILES
po/checksums
po/coreutils.pot
po/stamp-po
src/version.c
src/version.h
stamp-h1
tests/*/*.log
tests/t?
tests/test-suite.log

View File

@@ -8,3 +8,5 @@ Paul R. Eggert <eggert@cs.ucla.edu> <eggert@CS.UCLA.EDU>
Evan Hunt <ethanol@armory.com> Evan Hunt <jim@meyering.net>
<P@draigBrady.com> <P@draigBrady.com (trivial change)>
Pádraig Brady <p@draigbrady.com> <p@draigBrady.com>
<chen.guo.0625@gmail.com> <chenguo4@yahoo.com>
<chen.guo.0625@gmail.com> <chenguo4@ucla.edu>

View File

@@ -1 +1 @@
8.5
8.7

7
.x-sc_bindtextdomain Normal file
View File

@@ -0,0 +1,7 @@
^gl/lib/randint\.c$
^gl/tests/test-di-set\.c$
^gl/tests/test-fadvise\.c$
^gl/tests/test-ino-map\.c$
^gl/tests/test-mbsalign\.c$
^gl/tests/test-rand-isaac\.c$
^lib/euidaccess-stat\.c$

View File

@@ -41,6 +41,7 @@ changelog_etc = \
syntax_check_exceptions = \
.x-sc_GPL_version \
.x-sc_bindtextdomain \
.x-sc_error_message_uppercase \
.x-sc_file_system \
.x-sc_obsolete_symbols \

71
NEWS
View File

@@ -1,5 +1,76 @@
GNU coreutils NEWS -*- outline -*-
* Noteworthy changes in release 8.8 (2010-12-22) [stable]
** Bug fixes
cp -u no longer does unnecessary copying merely because the source
has finer-grained time stamps than the destination.
od now prints floating-point numbers without losing information, and
it no longer omits spaces between floating-point columns in some cases.
sort -u with at least two threads could attempt to read through a
corrupted pointer. [bug introduced in coreutils-8.6]
sort with at least two threads and with blocked output would busy-loop
(spinlock) all threads, often using 100% of available CPU cycles to
do no work. I.e., "sort < big-file | less" could waste a lot of power.
[bug introduced in coreutils-8.6]
sort with at least two threads no longer segfaults due to use of pointers
into the stack of an expired thread. [bug introduced in coreutils-8.6]
sort --compress no longer mishandles subprocesses' exit statuses,
no longer hangs indefinitely due to a bug in waiting for subprocesses,
and no longer generates many more than NMERGE subprocesses.
sort -m -o f f ... f no longer dumps core when file descriptors are limited.
** Changes in behavior
sort will not create more than 8 threads by default due to diminishing
performance gains. Also the --parallel option is no longer restricted
to the number of available processors.
** New features
split accepts the --number option to generate a specific number of files.
* Noteworthy changes in release 8.7 (2010-11-13) [stable]
** Bug fixes
cp, install, mv, and touch no longer crash when setting file times
on Solaris 10 Update 9 [Solaris PatchID 144488 and newer expose a
latent bug introduced in coreutils 8.1, and possibly a second latent
bug going at least as far back as coreutils 5.97]
csplit no longer corrupts heap when writing more than 999 files,
nor does it leak memory for every chunk of input processed
[the bugs were present in the initial implementation]
tail -F once again notices changes in a currently unavailable
remote directory [bug introduced in coreutils-7.5]
** Changes in behavior
cp --attributes-only now completely overrides --reflink.
Previously a reflink was needlessly attempted.
stat's %X, %Y, and %Z directives once again print only the integer
part of seconds since the epoch. This reverts a change from
coreutils-8.6, that was deemed unnecessarily disruptive.
To obtain a nanosecond-precision time stamp for %X use %.X;
if you want (say) just 3 fractional digits, use %.3X.
Likewise for %Y and %Z.
stat's new %W format directive would print floating point seconds.
However, with the above change to %X, %Y and %Z, we've made %W work
the same way as the others.
* Noteworthy changes in release 8.6 (2010-10-15) [stable]
** Bug fixes

View File

@@ -16,26 +16,34 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Convert Makefile.am files:
# find tests -name Makefile.am | xargs grep -wl PATH|xargs perl -pi -e \
# 's,src(\$\(PATH_SEPARATOR\)\$\$PATH),src/vg$1,'
# find tests -name check.mk | xargs grep -wl PATH |
# xargs perl -pi -e 's,src(\$\(PATH_SEPARATOR\)),src/vg$1,'
# To restore:
# find tests -name Makefile.am|xargs grep -wl PATH|xargs perl -pi -e 's,src/vg,src,'
# find tests -name check.mk | xargs grep -wl PATH |
# xargs perl -pi -e 's,src/vg,src,'
#
# Create this symlink for suppressions (this is no longer necessary,
# with Linux kernel 2.6.9 and valgrind-2.2.0):
# ln -s $PWD/.vg-suppressions /tmp/cu-vg
# Create src/vg:
coreutils=$(echo 'spy:;@echo $(all_programs)' | (cd src; make -f Makefile -f - spy | tr -s '\n ' ' '))
coreutils=$(echo 'spy:;@echo $(all_programs) $(noinst_PROGRAMS)' |
(cd src; make -f Makefile -f - spy | tr -s '\n ' ' '))
mkdir -p src/vg
pwd=`pwd`
srcdir=$pwd/src
_path='export PATH='$srcdir':${PATH#*:}'
pre='#!/bin/sh\n'"$_path"'\n'
n=15
vg='exec /usr/bin/valgrind --suppressions=/tmp/cu-vg --log-fd=3 --leak-check=yes --track-fds=yes --leak-check=full --num-callers='$n
n=15 # stack trace depth
log_fd=3 # One can redirect this to file like 3>vg.log
test -e /tmp/cu-vg && suppressions='--supressions=/tmp/cu-vg'
vg="exec /usr/bin/valgrind $suppressions --log-fd=$log_fd \
--leak-check=yes --track-fds=yes --leak-check=full --num-callers=$n"
cat <<EOF > src/vg/gen
for i in $coreutils; do
printf "$pre$vg -- \$i"' "\$@"\n' > \$i

4
THANKS
View File

@@ -62,6 +62,7 @@ Arnold Robbins arnold@skeeve.com
Arthur Pool pool@commerce.uq.edu.au
Arun Sharma arun.sharma@intel.com
Arvind Autar Autar022@planet.nl
Assaf Gordon assafgordon@gmail.com
Augey Mikus mikus@dqc.org
Aurelien Jarno aurel32@debian.org
Austin Donnelly Austin.Donnelly@cl.cam.ac.uk
@@ -105,6 +106,7 @@ Carlos Canau Carlos.Canau@relay.puug.pt
Charles Karney karney@pppl.gov
Charles Randall crandall@matchlogic.com
Chas. Owens chas.owens@gmail.com
Chen Guo chen.guo.0625@gmail.com
Chip Salzenberg chip@valinux.com
Chris Clayton chris2553@googlemail.com
Chris Faylor cgf@cygnus.com
@@ -362,6 +364,7 @@ M. P. Suzuki mpsuzuki@hiroshima-u.ac.jp
Maciej Kwapulinski pikpok@univ.gda.pl
Manas Garg manas@cygsoft.com
Manfred Hollstein manfred@s-direktnet.de
Марк Коренберг socketpair@gmail.com
Marc Boucher marc@mbsi.ca
Marc Haber mh+debian-bugs@zugschlus.de
Marc Lehman schmorp@schmorp.de
@@ -593,6 +596,7 @@ Tim Mooney mooney@dogbert.cc.ndsu.NoDak.edu
Tim Ryan Tim_Ryan@bnz.co.nz
Tim Smithers mouse@dmouse.com.au
Tim Waugh twaugh@redhat
Tobias Quathamer toddy@debian.org
Tobias Stoeckmann tobias@bugol.de
Toby Peterson toby@opendarwin.org
Todd A. Jacobs tjacobs@codegnome.org

View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
scriptversion=2010-10-05.15; # UTC
scriptversion=2010-10-08.16; # UTC
# Bootstrap this package from checked-out sources.
@@ -80,6 +80,10 @@ gnulib_modules=
# Any gnulib files needed that are not in modules.
gnulib_files=
# A function to be called to edit gnulib.mk right after it's created.
# Override it via your own definition in bootstrap.conf.
gnulib_mk_hook() { :; }
# A function to be called after everything else in this script.
# Override it via your own definition in bootstrap.conf.
bootstrap_epilogue() { :; }
@@ -257,6 +261,21 @@ insert_sorted_if_absent() {
|| exit 1
}
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
# insert_sorted_if_absent.
insert_vc_ignore() {
vc_ignore_file="$1"
pattern="$2"
case $vc_ignore_file in
*.gitignore)
# A .gitignore entry that does not start with `/' applies
# recursively to subdirectories, so prepend `/' to every
# .gitignore entry.
pattern=`echo "$pattern" | sed s,^,/,`;;
esac
insert_sorted_if_absent "$vc_ignore_file" "$pattern"
}
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
found_aux_dir=no
grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
@@ -275,7 +294,7 @@ if test ! -d $build_aux; then
mkdir $build_aux
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
insert_sorted_if_absent $dot_ig $build_aux
insert_vc_ignore $dot_ig $build_aux
done
fi
@@ -394,7 +413,7 @@ fi
if ! printf "$buildreq" | check_versions; then
echo >&2
if test -f README-prereq; then
echo "See README-prereq for notes on obtaining the prerequisite programs" >&2
echo "See README-prereq for how to get the prerequisite programs" >&2
else
echo "Please install the prerequisite programs" >&2
fi
@@ -561,7 +580,7 @@ symlink_to_dir()
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
ig=$parent/$dot_ig
insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'`
done
fi
@@ -678,7 +697,8 @@ slurp() {
for file in `ls -a $1/$dir`; do
case $file in
.|..) continue;;
.*) continue;; # FIXME: should all file names starting with "." be ignored?
# FIXME: should all file names starting with "." be ignored?
.*) continue;;
esac
test -d $1/$dir/$file && continue
for excluded_file in $excluded_files; do
@@ -687,10 +707,12 @@ slurp() {
if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
sed "$remove_intl" $1/$dir/$file | cmp - $dir/$gnulib_mk > /dev/null || {
sed "$remove_intl" $1/$dir/$file |
cmp - $dir/$gnulib_mk > /dev/null || {
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
rm -f $dir/$gnulib_mk &&
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
gnulib_mk_hook $dir/$gnulib_mk
}
elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
version_controlled_file $dir $file; then
@@ -718,18 +740,25 @@ slurp() {
test $dot_ig = x && continue
ig=$dir/$dot_ig
if test -n "$copied"; then
insert_sorted_if_absent $ig "$copied"
insert_vc_ignore $ig "$copied"
# If an ignored file name ends with .in.h, then also add
# the name with just ".h". Many gnulib headers are generated,
# e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
# Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
insert_sorted_if_absent $ig "$f"
f=`echo "$copied" |
sed '
s/\.in\.h$/.h/
s/\.sin$/.sed/
s/\.y$/.c/
s/\.gperf$/.h/
'
`
insert_vc_ignore $ig "$f"
# For files like sys_stat.in.h and sys_time.in.h, record as
# ignorable the directory we might eventually create: sys/.
f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
insert_sorted_if_absent $ig "$f"
insert_vc_ignore $ig "$f"
fi
done
done

View File

@@ -88,6 +88,7 @@ gnulib_modules="
fsusage
fsync
ftello
ftoastr
fts
getgroups
gethrxtime
@@ -315,6 +316,7 @@ git 1.4.4
gperf -
gzip -
makeinfo -
patch -
perl 5.5
rsync -
tar -

15
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 = 27e765279d5735f99114b57fa097e6bd
old_NEWS_hash = e2a254a0d4c81397994ea10a15663ac3
# Add an exemption for sc_makefile_at_at_check.
_makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
@@ -164,6 +164,13 @@ sc_man_file_correlation:
@$(MAKE) -s -C src all_programs
@$(MAKE) -s -C man $@
# Ensure that the end of each release's section is marked by two empty lines.
sc_NEWS_two_empty_lines:
@sed -n 4,/Noteworthy/p $(srcdir)/NEWS \
| perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1' \
|| { echo '$(ME): use two empty lines to separate NEWS sections' \
1>&2; exit 1; } || :; \
# Perl-based tests used to exec perl from a #!/bin/sh script.
# Now they all start with #!/usr/bin/perl and the portability
# infrastructure is in tests/Makefile.am. Make sure no old-style
@@ -244,6 +251,12 @@ sc_prohibit_sleep:
halt='prefer xnanosleep over other sleep interfaces' \
$(_sc_search_regexp)
# Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
sc_prohibit_verbose_version:
@prohibit='test "\$$VERBOSE" = yes && .* --version' \
halt='use the print_ver_ function instead...' \
$(_sc_search_regexp)
###########################################################
_p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
_pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*

View File

@@ -98,7 +98,6 @@ if test "$gl_gcc_warnings" = yes; then
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-pointer-sign]) # Too many warnings for now
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
# In spite of excluding -Wlogical-op above, it is enabled, as of

46
doc/.gitignore vendored
View File

@@ -1,24 +1,22 @@
constants.texi
coreutils.aux
coreutils.cp
coreutils.cps
coreutils.dvi
coreutils.fl
coreutils.fn
coreutils.html
coreutils.info
coreutils.ky
coreutils.log
coreutils.op
coreutils.pdf
coreutils.pg
coreutils.toc
coreutils.tp
coreutils.vr
fdl.texi
gendocs_template
get_date.texi
getdate.texi
parse-datetime.texi
stamp-vti
version.texi
/constants.texi
/coreutils.aux
/coreutils.cp
/coreutils.cps
/coreutils.dvi
/coreutils.fl
/coreutils.fn
/coreutils.html
/coreutils.info
/coreutils.ky
/coreutils.log
/coreutils.op
/coreutils.pdf
/coreutils.pg
/coreutils.toc
/coreutils.tp
/coreutils.vr
/fdl.texi
/gendocs_template
/parse-datetime.texi
/stamp-vti
/version.texi

View File

@@ -104,7 +104,7 @@
* shuf: (coreutils)shuf invocation. Shuffling text files.
* sleep: (coreutils)sleep invocation. Delay for a specified time.
* sort: (coreutils)sort invocation. Sort text files.
* split: (coreutils)split invocation. Split into fixed-size pieces.
* split: (coreutils)split invocation. Split into pieces.
* stat: (coreutils)stat invocation. Report file(system) status.
* stdbuf: (coreutils)stdbuf invocation. Modify stdio buffering.
* stty: (coreutils)stty invocation. Print/change terminal settings.
@@ -2624,7 +2624,7 @@ These commands output pieces of the input.
@menu
* head invocation:: Output the first part of files.
* tail invocation:: Output the last part of files.
* split invocation:: Split a file into fixed-size pieces.
* split invocation:: Split a file into pieces.
* csplit invocation:: Split a file into context-determined pieces.
@end menu
@@ -2821,6 +2821,7 @@ Historical implementations of @command{tail} have required that
@var{number} be an integer. However, GNU @command{tail} accepts
an arbitrary floating point number (using a period before any
fractional digits).
When @command{tail} uses inotify, this polling-related option is ignored.
@itemx --pid=@var{pid}
@opindex --pid
@@ -2855,7 +2856,8 @@ still associated with the same device/inode-number pair as before.
When following a log file that is rotated, this is approximately the
number of seconds between when tail prints the last pre-rotation lines
and when it prints the lines that have accumulated in the new log file.
This option is meaningful only when following by name.
This option is meaningful only when polling (i.e., without inotify)
and when following by name.
@itemx -n @var{k}
@itemx --lines=@var{k}
@@ -2920,15 +2922,15 @@ mean either @samp{tail ./+4} or @samp{tail -n +4}.
@node split invocation
@section @command{split}: Split a file into fixed-size pieces
@section @command{split}: Split a file into pieces.
@pindex split
@cindex splitting a file into pieces
@cindex pieces, splitting a file into
@command{split} creates output files containing consecutive sections of
@var{input} (standard input if none is given or @var{input} is
@samp{-}). Synopsis:
@command{split} creates output files containing consecutive or interleaved
sections of @var{input} (standard input if none is given or @var{input}
is @samp{-}). Synopsis:
@example
split [@var{option}] [@var{input} [@var{prefix}]]
@@ -2941,10 +2943,9 @@ left over for the last section), into each output file.
The output files' names consist of @var{prefix} (@samp{x} by default)
followed by a group of characters (@samp{aa}, @samp{ab}, @dots{} by
default), such that concatenating the output files in traditional
sorted order by file name produces
the original input file. If the output file names are exhausted,
@command{split} reports an error without deleting the output files
that it did create.
sorted order by file name produces the original input file (except
@option{-r}). If the output file names are exhausted, @command{split}
reports an error without deleting the output files that it did create.
The program accepts the following options. Also see @ref{Common options}.
@@ -2976,6 +2977,41 @@ 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.
@item -n @var{chunks}
@itemx --number=@var{chunks}
@opindex -n
@opindex --number
Split @var{input} to @var{chunks} output files where @var{chunks} may be:
@example
@var{n} generate @var{n} files based on current size of @var{input}
@var{k}/@var{n} only output @var{k}th of @var{n} to stdout
l/@var{n} generate @var{n} files without splitting lines
l/@var{k}/@var{n} likewise but only output @var{k}th of @var{n} to stdout
r/@var{n} like @samp{l} but use round robin distribution
r/@var{k}/@var{n} likewise but only output @var{k}th of @var{n} to stdout
@end example
Any excess bytes remaining after dividing the @var{input}
into @var{n} chunks, are assigned to the last chunk.
Any excess bytes appearing after the initial calculation are discarded
(except when using @samp{r} mode).
All @var{n} files are created even if there are fewer than @var{n} lines,
or the @var{input} is truncated.
For @samp{l} mode, chunks are approximately @var{input} size / @var{n}.
The @var{input} is partitioned into @var{n} equal sized portions, with
the last assigned any excess. If a line @emph{starts} within a partition
it is written completely to the corresponding file. Since lines
are not split even if they overlap a partition, the files written
can be larger or smaller than the partition size, and even empty
if a line is so long as to completely overlap the partition.
For @samp{r} mode, the size of @var{input} is irrelevant,
and so can be a pipe for example.
@item -a @var{length}
@itemx --suffix-length=@var{length}
@opindex -a
@@ -2988,6 +3024,23 @@ Use suffixes of length @var{length}. The default @var{length} is 2.
@opindex --numeric-suffixes
Use digits in suffixes rather than lower-case letters.
@item -e
@itemx --elide-empty-files
@opindex -e
@opindex --elide-empty-files
Suppress the generation of zero-length output files. This can happen
with the @option{--number} option if a file is (truncated to be) shorter
than the number requested, or if a line is so long as to completely
span a chunk. The output file sequence numbers, always run consecutively
even when this option is specified.
@item -u
@itemx --unbuffered
@opindex -u
@opindex --unbuffered
Immediately copy input to output in @option{--number r/...} mode,
which is a much slower mode of operation.
@itemx --verbose
@opindex --verbose
Write a diagnostic just before each output file is opened.
@@ -2996,6 +3049,67 @@ Write a diagnostic just before each output file is opened.
@exitstatus
Here are a few examples to illustrate how the
@option{--number} (@option{-n}) option works:
Notice how, by default, one line may be split onto two or more:
@example
$ seq -w 6 10 > k; split -n3 k; head xa?
==> xaa <==
06
07
==> xab <==
08
0
==> xac <==
9
10
@end example
Use the "l/" modifier to suppress that:
@example
$ seq -w 6 10 > k; split -nl/3 k; head xa?
==> xaa <==
06
07
==> xab <==
08
09
==> xac <==
10
@end example
Use the "r/" modifier to distribute lines in a round-robin fashion:
@example
$ seq -w 6 10 > k; split -nr/3 k; head xa?
==> xaa <==
06
09
==> xab <==
07
10
==> xac <==
08
@end example
You can also extract just the Kth chunk.
This extracts and prints just the 7th "chunk" of 33:
@example
$ seq 100 > k; split -nl/7/33 k
20
21
22
@end example
@node csplit invocation
@section @command{csplit}: Split a file into context-determined pieces
@@ -3082,7 +3196,8 @@ specified, the suffix string must include exactly one
@code{printf(3)}-style conversion specification, possibly including
format specification flags, a field width, a precision specifications,
or all of these kinds of modifiers. The format letter must convert a
binary integer argument to readable form; thus, only @samp{d}, @samp{i},
binary unsigned integer argument to readable form. The format letters
@samp{d} and @samp{i} are aliases for @samp{u}, and the
@samp{u}, @samp{o}, @samp{x}, and @samp{X} conversions are allowed. The
entire @var{suffix} is given (with the current output file number) to
@code{sprintf(3)} to form the file name suffixes for each of the
@@ -4075,10 +4190,11 @@ disks and controllers.
@item --parallel=@var{n}
@opindex --parallel
@cindex multithreaded sort
Limit the number of sorts run in parallel to @var{n}. By default,
@var{n} is set to the number of available processors, and values
greater than that are reduced to that limit. Also see
@ref{nproc invocation}.
Set the number of sorts run in parallel to @var{n}. By default,
@var{n} is set to the number of available processors, but limited
to 8, as there are diminishing performance gains after that.
Note also that using @var{n} threads increases the memory usage by
a factor of log @var{n}. Also see @ref{nproc invocation}.
@item -u
@itemx --unique
@@ -7614,12 +7730,11 @@ implementations that dereference symbolic links by default.
@cindex COW
@cindex clone
@cindex copy on write
Perform a lightweight, copy-on-write (COW) copy.
Copying with this option can succeed only on some file systems.
Once it has succeeded, beware that the source and destination files
share the same disk data blocks as long as they remain unmodified.
Perform a lightweight, copy-on-write (COW) copy, if supported by the
file system. Once it has succeeded, beware that the source and destination
files share the same disk data blocks as long as they remain unmodified.
Thus, if a disk I/O error affects data blocks of one of the files,
the other suffers the exact same fate.
the other suffers the same fate.
The @var{when} value can be one of the following:
@@ -7633,6 +7748,15 @@ If the copy-on-write operation is not supported then fall back
to the standard copy behaviour.
@end table
This option is overridden by the @option{--link}, @option{--symbolic-link}
and @option{--attributes-only} options, thus allowing it to be used
to configure the default data copying behavior for @command{cp}.
For example, with the following alias, @command{cp} will use the
minimum amount of space supported by the file system.
@example
alias cp='cp --reflink=auto --sparse=always'
@end example
@item --remove-destination
@opindex --remove-destination
@@ -10698,7 +10822,7 @@ The valid @var{format} directives for files with @option{--format} and
@item %u - User ID of owner
@item %U - User name of owner
@item %w - Time of file birth, or @samp{-} if unknown
@item %W - Time of file birth as seconds since Epoch, or @samp{-}
@item %W - Time of file birth as seconds since Epoch, or @samp{0}
@item %x - Time of last access
@item %X - Time of last access as seconds since Epoch
@item %y - Time of last modification
@@ -10707,6 +10831,30 @@ The valid @var{format} directives for files with @option{--format} and
@item %Z - Time of last change as seconds since Epoch
@end itemize
The @samp{%W}, @samp{%X}, @samp{%Y}, and @samp{%Z} formats accept a
precision preceded by a period to specify the number of digits to
print after the decimal point. For example, @samp{%.3X} outputs the
last access time to millisecond precision. If a period is given but no
precision, @command{stat} uses 9 digits, so @samp{%.X} is equivalent to
@samp{%.9X}. When discarding excess precision, time stamps are truncated
toward minus infinity.
@example
zero pad:
$ stat -c '[%015Y]' /usr
[000001288929712]
space align:
$ stat -c '[%15Y]' /usr
[ 1288929712]
$ stat -c '[%-15Y]' /usr
[1288929712 ]
precision:
$ stat -c '[%.3Y]' /usr
[1288929712.114]
$ stat -c '[%.Y]' /usr
[1288929712.114951834]
@end example
The mount point printed by @samp{%m} is similar to that output
by @command{df}, except that:
@itemize @bullet

10
gl/modules/fadvise-tests Normal file
View File

@@ -0,0 +1,10 @@
Files:
tests/test-fadvise.c
Depends-on:
configure.ac:
Makefile.am:
TESTS += test-fadvise
check_PROGRAMS += test-fadvise

View File

@@ -21,6 +21,13 @@
#include "fadvise.h"
/* We ignore any errors as these hints are only advisory.
* There is the chance one can pass invalid ADVICE, which will
* not be indicated, but given the simplicity of the interface
* this is unlikely. Also not returning errors allows the
* unconditional passing of descriptors to non standard files,
* which will just be ignored if unsupported. */
int
main (void)
{

2
gnulib

Submodule gnulib updated: 78c0415acc...fe2a2304a8

View File

@@ -1,17 +1,20 @@
include gnulib.mk
AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) # $(WERROR_CFLAGS)
AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) $(WERROR_CFLAGS)
# A few tests are inherently warning-evoking.
# Since we require -Werror, exempt the few offenders.
# In the typical case where we use -Werror, exempt the few offenders.
# test-xvasprintf.c: In function 'test_xasprintf':
# test-xvasprintf.c:100: error: format not a string literal and no \
# format arguments [-Wformat-security]
test_xvasprintf_CFLAGS = $(AM_CFLAGS) -Wno-format-security
test_xvasprintf_CFLAGS = $(AM_CFLAGS) \
`test -n '$(WERROR_CFLAGS)' && echo ' -Wno-format-security'`
# test-lock.c: In function 'lock_mutator_thread':
# test-lock.c:148: error: cast from function call of type 'pthread_t' to \
# non-matching type 'void *' [-Wbad-function-cast]
test_lock_CFLAGS = $(AM_CFLAGS) -Wno-bad-function-cast
test_tls_CFLAGS = $(AM_CFLAGS) -Wno-bad-function-cast
test_lock_CFLAGS = $(AM_CFLAGS) \
`test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'`
test_tls_CFLAGS = $(AM_CFLAGS) \
`test -n '$(WERROR_CFLAGS)' && echo ' -Wno-bad-function-cast'`

View File

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

View File

@@ -603,6 +603,12 @@ copy_reg (char const *src_name, char const *dst_name,
}
}
}
/* Improve quality of diagnostic when a nonexistent dst_name
ends in a slash and open fails with errno == EISDIR. */
if (dest_desc < 0 && dest_errno == EISDIR
&& *dst_name && dst_name[strlen (dst_name) - 1] == '/')
dest_errno = ENOTDIR;
}
else
omitted_permissions = 0;
@@ -622,7 +628,8 @@ copy_reg (char const *src_name, char const *dst_name,
goto close_src_and_dst_desc;
}
if (x->reflink_mode)
/* --attributes-only overrides --reflink. */
if (data_copy_required && x->reflink_mode)
{
bool clone_ok = clone_file (dest_desc, source_desc) == 0;
if (clone_ok || x->reflink_mode == REFLINK_ALWAYS)

View File

@@ -604,6 +604,8 @@ do_copy (int n_files, char **file, const char *target_directory,
error (0, 0, _("extra operand %s"), quote (file[2]));
usage (EXIT_FAILURE);
}
/* Update NEW_DST and SB, which may be checked below. */
ignore_value (target_directory_operand (file[n_files -1], &sb, &new_dst));
}
else if (!target_directory)
{

View File

@@ -418,6 +418,13 @@ get_new_buffer (size_t min_size)
static void
free_buffer (struct buffer_record *buf)
{
struct line *l;
for (l = buf->line_start; l;)
{
struct line *n = l->next;
free (l);
l = n;
}
free (buf->buffer);
buf->buffer = NULL;
}
@@ -542,6 +549,7 @@ remove_line (void)
if (prev_buf)
{
free_buffer (prev_buf);
free (prev_buf);
prev_buf = NULL;
}
@@ -1173,81 +1181,64 @@ parse_patterns (int argc, int start, char **argv)
}
}
static unsigned int
get_format_flags (char **format_ptr)
{
unsigned int count = 0;
for (; **format_ptr; (*format_ptr)++)
/* Names for the printf format flags ' and #. These can be ORed together. */
enum { FLAG_THOUSANDS = 1, FLAG_ALTERNATIVE = 2 };
/* Scan the printf format flags in FORMAT, storing info about the
flags into *FLAGS_PTR. Return the number of flags found. */
static size_t
get_format_flags (char const *format, int *flags_ptr)
{
int flags = 0;
for (size_t count = 0; ; count++)
{
switch (**format_ptr)
switch (format[count])
{
case '-':
case '0':
break;
case '+':
case ' ':
count |= 1;
case '\'':
flags |= FLAG_THOUSANDS;
break;
case '#':
count |= 2; /* Allow for 0x prefix preceding an `x' conversion. */
flags |= FLAG_ALTERNATIVE;
break;
default:
*flags_ptr = flags;
return count;
}
}
return count;
}
static size_t
get_format_width (char **format_ptr)
{
unsigned long int val = 0;
if (ISDIGIT (**format_ptr)
&& (xstrtoul (*format_ptr, format_ptr, 10, &val, NULL) != LONGINT_OK
|| SIZE_MAX < val))
error (EXIT_FAILURE, 0, _("invalid format width"));
/* Allow for enough octal digits to represent the value of UINT_MAX,
even if the field width is less than that. */
return MAX (val, (sizeof (unsigned int) * CHAR_BIT + 2) / 3);
}
static size_t
get_format_prec (char **format_ptr)
{
if (**format_ptr != '.')
return 0;
(*format_ptr)++;
if (! ISDIGIT (**format_ptr))
return 0;
else
{
unsigned long int val;
if (xstrtoul (*format_ptr, format_ptr, 10, &val, NULL) != LONGINT_OK
|| SIZE_MAX < val)
error (EXIT_FAILURE, 0, _("invalid format precision"));
return val;
}
}
/* Check that the printf format conversion specifier *FORMAT is valid
and compatible with FLAGS. Change it to 'u' if it is 'd' or 'i',
since the format will be used with an unsigned value. */
static void
get_format_conv_type (char **format_ptr)
check_format_conv_type (char *format, int flags)
{
unsigned char ch = *(*format_ptr)++;
unsigned char ch = *format;
int compatible_flags = FLAG_THOUSANDS;
switch (ch)
{
case 'd':
case 'i':
case 'o':
*format = 'u';
break;
case 'u':
break;
case 'o':
case 'x':
case 'X':
compatible_flags = FLAG_ALTERNATIVE;
break;
case 0:
@@ -1262,45 +1253,46 @@ get_format_conv_type (char **format_ptr)
error (EXIT_FAILURE, 0,
_("invalid conversion specifier in suffix: \\%.3o"), ch);
}
if (flags & ~ compatible_flags)
error (EXIT_FAILURE, 0,
_("invalid flags in conversion specification: %%%c%c"),
(flags & ~ compatible_flags & FLAG_ALTERNATIVE ? '#' : '\''), ch);
}
/* Return the maximum number of bytes that can be generated by
applying FORMAT to an unsigned int value. If the format is
invalid, diagnose the problem and exit. */
static size_t
max_out (char *format)
{
size_t out_count = 0;
bool percent = false;
while (*format)
{
if (*format++ != '%')
out_count++;
else if (*format == '%')
{
format++;
out_count++;
}
else
{
if (percent)
error (EXIT_FAILURE, 0,
_("too many %% conversion specifications in suffix"));
percent = true;
out_count += get_format_flags (&format);
{
size_t width = get_format_width (&format);
size_t prec = get_format_prec (&format);
out_count += MAX (width, prec);
}
get_format_conv_type (&format);
}
}
for (char *f = format; *f; f++)
if (*f == '%' && *++f != '%')
{
if (percent)
error (EXIT_FAILURE, 0,
_("too many %% conversion specifications in suffix"));
percent = true;
int flags;
f += get_format_flags (f, &flags);
while (ISDIGIT (*f))
f++;
if (*f == '.')
while (ISDIGIT (*++f))
continue;
check_format_conv_type (f, flags);
}
if (! percent)
error (EXIT_FAILURE, 0,
_("missing %% conversion specification in suffix"));
return out_count;
int maxlen = snprintf (NULL, 0, format, UINT_MAX);
if (! (0 <= maxlen && maxlen <= SIZE_MAX))
xalloc_die ();
return maxlen;
}
int
@@ -1341,7 +1333,7 @@ main (int argc, char **argv)
case 'n':
if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
|| val > INT_MAX)
|| MIN (INT_MAX, SIZE_MAX) < val)
error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
digits = val;
break;
@@ -1372,10 +1364,14 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
if (suffix)
filename_space = xmalloc (strlen (prefix) + max_out (suffix) + 2);
else
filename_space = xmalloc (strlen (prefix) + digits + 2);
size_t prefix_len = strlen (prefix);
size_t max_digit_string_len
= (suffix
? max_out (suffix)
: MAX (INT_STRLEN_BOUND (unsigned int), digits));
if (SIZE_MAX - 1 - prefix_len < max_digit_string_len)
xalloc_die ();
filename_space = xmalloc (prefix_len + max_digit_string_len + 1);
set_input_file (argv[optind++]);

View File

@@ -163,7 +163,7 @@ FORMAT controls the output. Interpreted sequences are:\n\
"), stdout);
fputs (_("\
%C century; like %Y, except omit last two digits (e.g., 20)\n\
%d day of month (e.g, 01)\n\
%d day of month (e.g., 01)\n\
%D date; same as %m/%d/%y\n\
%e day of month, space padded; same as %_d\n\
"), stdout);
@@ -212,8 +212,8 @@ FORMAT controls the output. Interpreted sequences are:\n\
%Y year\n\
"), stdout);
fputs (_("\
%z +hhmm numeric timezone (e.g., -0400)\n\
%:z +hh:mm numeric timezone (e.g., -04:00)\n\
%z +hhmm numeric time zone (e.g., -0400)\n\
%:z +hh:mm numeric time zone (e.g., -04:00)\n\
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)\n\
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30)\n\
%Z alphabetic time zone abbreviation (e.g., EDT)\n\

View File

@@ -351,8 +351,9 @@ show_date (const char *format, struct timespec when)
if (! tm)
{
char buf[INT_BUFSIZE_BOUND (intmax_t)];
error (0, 0, _("time %s is out of range"), timetostr (when.tv_sec, buf));
fputs (buf, stdout);
char *when_str = timetostr (when.tv_sec, buf);
error (0, 0, _("time %s is out of range"), when_str);
fputs (when_str, stdout);
return;
}

View File

@@ -143,7 +143,7 @@ fold_file (char const *filename, size_t width)
return false;
}
fadvise (stdin, FADVISE_SEQUENTIAL);
fadvise (istream, FADVISE_SEQUENTIAL);
while ((c = getc (istream)) != EOF)
{

View File

@@ -431,6 +431,7 @@ static bool
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_mismatched_checksums = 0;
uintmax_t n_open_or_read_failures = 0;
@@ -489,6 +490,8 @@ digest_check (const char *checkfile_name)
&& ! (is_stdin && STREQ (filename, "-"))
&& hex_digits (hex_digest)))
{
++n_misformatted_lines;
if (warn)
{
error (0, 0,
@@ -571,27 +574,26 @@ digest_check (const char *checkfile_name)
{
if (!status_only)
{
if (n_misformatted_lines != 0)
error (0, 0,
ngettext ("WARNING: %" PRIuMAX " line is improperly formatted",
"WARNING: %" PRIuMAX " lines are improperly formatted",
select_plural (n_misformatted_lines)),
n_misformatted_lines);
if (n_open_or_read_failures != 0)
error (0, 0,
ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX
" listed file could not be read",
"WARNING: %" PRIuMAX " of %" PRIuMAX
" listed files could not be read",
select_plural (n_properly_formatted_lines)),
n_open_or_read_failures, n_properly_formatted_lines);
ngettext ("WARNING: %" PRIuMAX " listed file could not be read",
"WARNING: %" PRIuMAX " listed files could not be read",
select_plural (n_open_or_read_failures)),
n_open_or_read_failures);
if (n_mismatched_checksums != 0)
{
uintmax_t n_computed_checksums =
(n_properly_formatted_lines - n_open_or_read_failures);
error (0, 0,
ngettext ("WARNING: %" PRIuMAX " of %" PRIuMAX
" computed checksum did NOT match",
"WARNING: %" PRIuMAX " of %" PRIuMAX
" computed checksums did NOT match",
select_plural (n_computed_checksums)),
n_mismatched_checksums, n_computed_checksums);
}
error (0, 0,
ngettext ("WARNING: %" PRIuMAX " computed checksum did NOT match",
"WARNING: %" PRIuMAX " computed checksums did NOT match",
select_plural (n_mismatched_checksums)),
n_mismatched_checksums);
}
}

View File

@@ -24,6 +24,7 @@
#include <sys/types.h>
#include "system.h"
#include "error.h"
#include "ftoastr.h"
#include "quote.h"
#include "xfreopen.h"
#include "xprintf.h"
@@ -34,21 +35,9 @@
#define AUTHORS proper_name ("Jim Meyering")
#include <float.h>
/* The default number of input bytes per output line. */
#define DEFAULT_BYTES_PER_BLOCK 16
/* The number of decimal digits of precision in a float. */
#ifndef FLT_DIG
# define FLT_DIG 7
#endif
/* The number of decimal digits of precision in a double. */
#ifndef DBL_DIG
# define DBL_DIG 15
#endif
#if HAVE_UNSIGNED_LONG_LONG_INT
typedef unsigned long long int unsigned_long_long_int;
#else
@@ -92,17 +81,15 @@ enum output_format
enum
{
FMT_BYTES_ALLOCATED =
MAX ((sizeof "%*.99" - 1
(sizeof "%*.99" - 1
+ MAX (sizeof "ld",
MAX (sizeof PRIdMAX,
MAX (sizeof PRIoMAX,
MAX (sizeof PRIuMAX,
sizeof PRIxMAX))))),
sizeof "%*.99Le")
sizeof PRIxMAX)))))
};
/* Ensure that our choice for FMT_BYTES_ALLOCATED is reasonable. */
verify (LDBL_DIG <= 99);
verify (MAX_INTEGRAL_TYPE_SIZE * CHAR_BIT / 3 <= 99);
/* Each output format specification (from `-t spec' or from
@@ -401,10 +388,10 @@ implies 32. By default, od uses -A o -t oS -w16.\n\
/* Define the print functions. */
#define PRINT_TYPE(N, T) \
#define PRINT_FIELDS(N, T, FMT_STRING, ACTION) \
static void \
N (size_t fields, size_t blank, void const *block, \
char const *fmt_string, int width, int pad) \
char const *FMT_STRING, int width, int pad) \
{ \
T const *p = block; \
size_t i; \
@@ -412,11 +399,22 @@ N (size_t fields, size_t blank, void const *block, \
for (i = fields; blank < i; i--) \
{ \
int next_pad = pad * (i - 1) / fields; \
xprintf (fmt_string, pad_remaining - next_pad + width, *p++); \
int adjusted_width = pad_remaining - next_pad + width; \
T x = *p++; \
ACTION; \
pad_remaining = next_pad; \
} \
}
#define PRINT_TYPE(N, T) \
PRINT_FIELDS (N, T, fmt_string, xprintf (fmt_string, adjusted_width, x))
#define PRINT_FLOATTYPE(N, T, FTOASTR, BUFSIZE) \
PRINT_FIELDS (N, T, fmt_string ATTRIBUTE_UNUSED, \
char buf[BUFSIZE]; \
FTOASTR (buf, sizeof buf, 0, 0, x); \
xprintf ("%*s", adjusted_width, buf))
PRINT_TYPE (print_s_char, signed char)
PRINT_TYPE (print_char, unsigned char)
PRINT_TYPE (print_s_short, short int)
@@ -424,11 +422,13 @@ PRINT_TYPE (print_short, unsigned short int)
PRINT_TYPE (print_int, unsigned int)
PRINT_TYPE (print_long, unsigned long int)
PRINT_TYPE (print_long_long, unsigned_long_long_int)
PRINT_TYPE (print_float, float)
PRINT_TYPE (print_double, double)
PRINT_TYPE (print_long_double, long double)
PRINT_FLOATTYPE (print_float, float, ftoastr, FLT_BUFSIZE_BOUND)
PRINT_FLOATTYPE (print_double, double, dtoastr, DBL_BUFSIZE_BOUND)
PRINT_FLOATTYPE (print_long_double, long double, ldtoastr, LDBL_BUFSIZE_BOUND)
#undef PRINT_TYPE
#undef PRINT_FLOATTYPE
static void
dump_hexl_mode_trailer (size_t n_bytes, const char *block)
@@ -586,13 +586,11 @@ decode_one_format (const char *s_orig, const char *s, const char **next,
enum size_spec size_spec;
unsigned long int size;
enum output_format fmt;
const char *pre_fmt_string;
void (*print_function) (size_t, size_t, void const *, char const *,
int, int);
const char *p;
char c;
int field_width;
int precision;
assert (tspec != NULL);
@@ -772,34 +770,31 @@ this system doesn't provide a %lu-byte floating point type"),
}
size_spec = fp_type_size[size];
struct lconv const *locale = localeconv ();
size_t decimal_point_len =
(locale->decimal_point[0] ? strlen (locale->decimal_point) : 1);
switch (size_spec)
{
case FLOAT_SINGLE:
print_function = print_float;
/* FIXME - should we use %g instead of %e? */
pre_fmt_string = "%%*.%de";
precision = FLT_DIG;
field_width = FLT_STRLEN_BOUND_L (decimal_point_len);
break;
case FLOAT_DOUBLE:
print_function = print_double;
pre_fmt_string = "%%*.%de";
precision = DBL_DIG;
field_width = DBL_STRLEN_BOUND_L (decimal_point_len);
break;
case FLOAT_LONG_DOUBLE:
print_function = print_long_double;
pre_fmt_string = "%%*.%dLe";
precision = LDBL_DIG;
field_width = LDBL_STRLEN_BOUND_L (decimal_point_len);
break;
default:
abort ();
}
field_width = precision + 8;
sprintf (tspec->fmt_string, pre_fmt_string, precision);
assert (strlen (tspec->fmt_string) < FMT_BYTES_ALLOCATED);
break;
case 'a':

View File

@@ -37,10 +37,6 @@
proper_name ("David MacKenzie"), \
proper_name ("Kaveh Ghazi")
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 64
#endif
char *ttyname (int);
/* If true, display the hours:minutes since each user has touched

View File

@@ -46,7 +46,6 @@ static char const *separator;
/* The string output after all numbers have been output.
Usually "\n" or "\0". */
/* FIXME: make this an option. */
static char const terminator[] = "\n";
static struct option const long_options[] =

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,7 @@
#include <config.h>
#include <assert.h>
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
@@ -33,6 +34,7 @@
#include "full-read.h"
#include "full-write.h"
#include "quote.h"
#include "safe-read.h"
#include "xfreopen.h"
#include "xstrtol.h"
@@ -43,8 +45,6 @@
proper_name_utf8 ("Torbjorn Granlund", "Torbj\303\266rn Granlund"), \
proper_name ("Richard M. Stallman")
#define DEFAULT_SUFFIX_LENGTH 2
/* Base name of output files. */
static char const *outbase;
@@ -56,7 +56,7 @@ static char *outfile;
static char *outfile_mid;
/* Length of OUTFILE's suffix. */
static size_t suffix_length = DEFAULT_SUFFIX_LENGTH;
static size_t suffix_length;
/* Alphabet of characters to use in suffix. */
static char const *suffix_alphabet = "abcdefghijklmnopqrstuvwxyz";
@@ -65,17 +65,25 @@ static char const *suffix_alphabet = "abcdefghijklmnopqrstuvwxyz";
static char *infile;
/* Descriptor on which output file is open. */
static int output_desc;
static int output_desc = -1;
/* If true, print a diagnostic on standard error just before each
output file is opened. */
static bool verbose;
/* If true, don't generate zero length output files. */
static bool elide_empty_files;
/* If true, in round robin mode, immediately copy
input to output, which is much slower, so disabled by default. */
static bool unbuffered;
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
{
VERBOSE_OPTION = CHAR_MAX + 1
VERBOSE_OPTION = CHAR_MAX + 1,
IO_BLKSIZE_OPTION
};
static struct option const longopts[] =
@@ -83,14 +91,45 @@ static struct option const longopts[] =
{"bytes", required_argument, NULL, 'b'},
{"lines", required_argument, NULL, 'l'},
{"line-bytes", required_argument, NULL, 'C'},
{"number", required_argument, NULL, 'n'},
{"elide-empty-files", no_argument, NULL, 'e'},
{"unbuffered", no_argument, NULL, 'u'},
{"suffix-length", required_argument, NULL, 'a'},
{"numeric-suffixes", no_argument, NULL, 'd'},
{"verbose", no_argument, NULL, VERBOSE_OPTION},
{"-io-blksize", required_argument, NULL,
IO_BLKSIZE_OPTION}, /* do not document */
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
};
static void
set_suffix_length (uintmax_t n_units)
{
#define DEFAULT_SUFFIX_LENGTH 2
size_t suffix_needed = 0;
size_t alphabet_len = strlen (suffix_alphabet);
bool alphabet_slop = (n_units % alphabet_len) != 0;
while (n_units /= alphabet_len)
suffix_needed++;
suffix_needed += alphabet_slop;
if (suffix_length) /* set by user */
{
if (suffix_length < suffix_needed)
{
error (EXIT_FAILURE, 0,
_("the suffix length needs to be at least %zu"),
suffix_needed);
}
return;
}
else
suffix_length = MAX (DEFAULT_SUFFIX_LENGTH, suffix_needed);
}
void
usage (int status)
{
@@ -117,7 +156,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
-b, --bytes=SIZE put SIZE bytes per output file\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\
-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\
"), DEFAULT_SUFFIX_LENGTH);
fputs (_("\
--verbose print a diagnostic just before each\n\
@@ -126,6 +168,15 @@ 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\
CHUNKS may be:\n\
N split into N files based on size of input\n\
K/N output Kth of N to stdout\n\
l/N split into N files without splitting lines\n\
l/K/N output Kth of N to stdout without splitting lines\n\
r/N like `l' but use round robin distribution\n\
r/K/N likewise but only output Kth of N to stdout\n\
"), stdout);
emit_ancillary_info ();
}
exit (status);
@@ -187,6 +238,17 @@ next_file_name (void)
}
}
/* Create or truncate a file. */
static int
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));
}
/* Write BYTES bytes at BP to an output file.
If NEW_FILE_FLAG is true, open the next output file.
Otherwise add to the same output file already in use. */
@@ -196,17 +258,12 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
{
if (new_file_flag)
{
if (!bp && bytes == 0 && elide_empty_files)
return;
if (output_desc >= 0 && close (output_desc) < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
next_file_name ();
if (verbose)
fprintf (stdout, _("creating file %s\n"), quote (outfile));
output_desc = open (outfile,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
| S_IROTH | S_IWOTH));
if (output_desc < 0)
if ((output_desc = create (outfile)) < 0)
error (EXIT_FAILURE, errno, "%s", outfile);
}
if (full_write (output_desc, bp, bytes) != bytes)
@@ -217,13 +274,14 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
Use buffer BUF, whose size is BUFSIZE. */
static void
bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, uintmax_t max_files)
{
size_t n_read;
bool new_file_flag = true;
size_t to_read;
uintmax_t to_write = n_bytes;
char *bp_out;
uintmax_t opened = 0;
do
{
@@ -239,6 +297,7 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
if (to_read) /* do not write 0 bytes! */
{
cwrite (new_file_flag, bp_out, to_read);
opened += new_file_flag;
to_write -= to_read;
new_file_flag = false;
}
@@ -248,14 +307,21 @@ bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize)
{
size_t w = to_write;
cwrite (new_file_flag, bp_out, w);
opened += new_file_flag;
new_file_flag = !max_files || (opened < max_files);
bp_out += w;
to_read -= w;
new_file_flag = true;
to_write = n_bytes;
}
}
}
while (n_read == bufsize);
/* Ensure NUMBER files are created, which truncates
any existing files or notifies any consumers on fifos.
FIXME: Should we do this before EXIT_FAILURE? */
while (opened++ < max_files)
cwrite (true, NULL, 0);
}
/* Split into pieces of exactly N_LINES lines.
@@ -361,6 +427,331 @@ line_bytes_split (size_t n_bytes)
free (buf);
}
/* -n l/[K/]N: Write lines to files of approximately file size / N.
The file is partitioned into file size / N sized portions, with the
last assigned any excess. If a line _starts_ within a partition
it is written completely to the corresponding file. Since lines
are not split even if they overlap a partition, the files written
can be larger or smaller than the partition size, and even empty
if a line is so long as to completely overlap the partition. */
static void
lines_chunk_split (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
off_t file_size)
{
assert (n && k <= n && n <= file_size);
const off_t chunk_size = file_size / n;
uintmax_t chunk_no = 1;
off_t chunk_end = chunk_size - 1;
off_t n_written = 0;
bool new_file_flag = true;
if (k > 1)
{
/* Start reading 1 byte before kth chunk of file. */
off_t start = (k - 1) * chunk_size - 1;
if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
error (EXIT_FAILURE, errno, "%s", infile);
n_written = start;
chunk_no = k - 1;
chunk_end = chunk_no * chunk_size - 1;
}
while (n_written < file_size)
{
char *bp = buf, *eob;
size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
n_read = MIN (n_read, file_size - n_written);
if (n_read < bufsize && errno)
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
eob = buf + n_read;
while (bp != eob)
{
size_t to_write;
bool next = false;
/* Begin looking for '\n' at last byte of chunk. */
off_t skip = MIN (n_read, MAX (0, chunk_end - n_written));
char *bp_out = memchr (bp + skip, '\n', n_read - skip);
if (bp_out++)
next = true;
else
bp_out = eob;
to_write = bp_out - bp;
if (k == chunk_no)
{
/* We don't use the stdout buffer here since we're writing
large chunks from an existing file, so it's more efficient
to write out directly. */
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
error (EXIT_FAILURE, errno, "%s", _("write error"));
}
else
cwrite (new_file_flag, bp, to_write);
n_written += to_write;
bp += to_write;
n_read -= to_write;
new_file_flag = next;
/* A line could have been so long that it skipped
entire chunks. So create empty files in that case. */
while (next || chunk_end <= n_written - 1)
{
if (!next && bp == eob)
break; /* replenish buf, before going to next chunk. */
chunk_no++;
if (k && chunk_no > k)
return;
if (chunk_no == n)
chunk_end = file_size - 1; /* >= chunk_size. */
else
chunk_end += chunk_size;
if (chunk_end <= n_written - 1)
cwrite (true, NULL, 0);
else
next = false;
}
}
}
/* Ensure NUMBER files are created, which truncates
any existing files or notifies any consumers on fifos.
FIXME: Should we do this before EXIT_FAILURE? */
while (!k && chunk_no++ <= n)
cwrite (true, NULL, 0);
}
/* -n K/N: Extract Kth of N chunks. */
static void
bytes_chunk_extract (uintmax_t k, uintmax_t n, char *buf, size_t bufsize,
off_t file_size)
{
off_t start;
off_t end;
assert (k && n && k <= n && n <= file_size);
start = (k - 1) * (file_size / n);
end = (k == n) ? file_size : k * (file_size / n);
if (lseek (STDIN_FILENO, start, SEEK_CUR) < 0)
error (EXIT_FAILURE, errno, "%s", infile);
while (start < end)
{
size_t n_read = full_read (STDIN_FILENO, buf, bufsize);
n_read = MIN (n_read, end - start);
if (n_read < bufsize && errno)
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
if (full_write (STDOUT_FILENO, buf, n_read) != n_read)
error (EXIT_FAILURE, errno, "%s", quote ("-"));
start += n_read;
}
}
typedef struct of_info
{
char *of_name;
int ofd;
FILE* ofile;
} of_t;
enum
{
OFD_NEW = -1,
OFD_APPEND = -2
};
/* Rotate file descriptors when we're writing to more output files than we
have available file descriptors.
Return whether we came under file resource pressure.
If so, it's probably best to close each file when finished with it. */
static bool
ofile_open (of_t *files, size_t i_check, size_t nfiles)
{
bool file_limit = false;
if (files[i_check].ofd <= OFD_NEW)
{
int fd;
size_t i_reopen = i_check ? i_check - 1 : nfiles - 1;
/* Another process could have opened a file in between the calls to
close and open, so we should keep trying until open succeeds or
we've closed all of our files. */
while (true)
{
if (files[i_check].ofd == OFD_NEW)
fd = create (files[i_check].of_name);
else /* OFD_APPEND */
{
/* Attempt to append to previously opened file.
We use O_NONBLOCK to support writing to fifos,
where the other end has closed because of our
previous close. In that case we'll immediately
get an error, rather than waiting indefinitely.
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);
}
if (-1 < fd)
break;
if (!(errno == EMFILE || errno == ENFILE))
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
file_limit = true;
/* Search backwards for an open file to close. */
while (files[i_reopen].ofd < 0)
{
i_reopen = i_reopen ? i_reopen - 1 : nfiles - 1;
/* No more open files to close, exit with E[NM]FILE. */
if (i_reopen == i_check)
error (EXIT_FAILURE, errno, "%s", files[i_check].of_name);
}
if (fclose (files[i_reopen].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_reopen].of_name);
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);
}
return file_limit;
}
/* -n r/[K/]N: Divide file into N chunks in round robin fashion.
When K == 0, we try to keep the files open in parallel.
If we run out of file resources, then we revert
to opening and closing each file for each line. */
static void
lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
{
bool file_limit;
size_t i_file;
of_t *files;
uintmax_t line_no;
if (k)
line_no = 1;
else
{
if (SIZE_MAX < n)
error (exit_failure, 0, "%s", _("memory exhausted"));
files = xnmalloc (n, sizeof *files);
/* Generate output file names. */
for (i_file = 0; i_file < n; i_file++)
{
next_file_name ();
files[i_file].of_name = xstrdup (outfile);
files[i_file].ofd = OFD_NEW;
files[i_file].ofile = NULL;
}
i_file = 0;
file_limit = false;
}
while (true)
{
char *bp = buf, *eob;
/* Use safe_read() rather than full_read() here
so that we process available data immediately. */
size_t n_read = safe_read (STDIN_FILENO, buf, bufsize);
if (n_read == SAFE_READ_ERROR)
error (EXIT_FAILURE, errno, "%s", infile);
else if (n_read == 0)
break; /* eof. */
eob = buf + n_read;
while (bp != eob)
{
size_t to_write;
bool next = false;
/* Find end of line. */
char *bp_out = memchr (bp, '\n', eob - bp);
if (bp_out)
{
bp_out++;
next = true;
}
else
bp_out = eob;
to_write = bp_out - bp;
if (k)
{
if (line_no == k && unbuffered)
{
if (full_write (STDOUT_FILENO, bp, to_write) != to_write)
error (EXIT_FAILURE, errno, "%s", _("write error"));
}
else if (line_no == k && fwrite (bp, to_write, 1, stdout) != 1)
{
clearerr (stdout); /* To silence close_stdout(). */
error (EXIT_FAILURE, errno, "%s", _("write error"));
}
if (next)
line_no = (line_no == n) ? 1 : line_no + 1;
}
else
{
/* Secure file descriptor. */
file_limit |= ofile_open (files, i_file, n);
if (unbuffered)
{
/* 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)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
}
else if (fwrite (bp, to_write, 1, files[i_file].ofile) != 1)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
if (file_limit)
{
if (fclose (files[i_file].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", files[i_file].of_name);
files[i_file].ofd = OFD_APPEND;
}
if (next && ++i_file == n)
i_file = 0;
}
bp = bp_out;
}
}
/* 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++)
{
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);
}
}
#define FAIL_ONLY_ONE_WAY() \
do \
{ \
@@ -369,21 +760,41 @@ line_bytes_split (size_t n_bytes)
} \
while (0)
/* Parse K/N syntax of chunk options. */
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
|| *n_units == 0)
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))
error (EXIT_FAILURE, 0, _("%s: invalid chunk number"), optarg);
}
int
main (int argc, char **argv)
{
struct stat stat_buf;
enum
{
type_undef, type_bytes, type_byteslines, type_lines, type_digits
type_undef, type_bytes, type_byteslines, type_lines, type_digits,
type_chunk_bytes, type_chunk_lines, type_rr
} split_type = type_undef;
size_t in_blk_size; /* optimal block size of input file device */
size_t in_blk_size = 0; /* optimal block size of input file device */
char *buf; /* file i/o buffer */
size_t page_size = getpagesize ();
uintmax_t k_units = 0;
uintmax_t n_units;
static char const multipliers[] = "bEGKkMmPTYZ0";
int c;
int digits_optind = 0;
off_t file_size;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -395,15 +806,16 @@ main (int argc, char **argv)
/* Parse command line options. */
infile = bad_cast ( "-");
infile = bad_cast ("-");
outbase = bad_cast ("x");
while (1)
while (true)
{
/* This is the argv-index of the option we will read next. */
int this_optind = optind ? optind : 1;
char *slash;
c = getopt_long (argc, argv, "0123456789C:a:b:dl:", longopts, NULL);
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:u", longopts, NULL);
if (c == -1)
break;
@@ -432,6 +844,13 @@ main (int argc, char **argv)
error (0, 0, _("%s: invalid number of bytes"), optarg);
usage (EXIT_FAILURE);
}
/* If input is a pipe, we could get more data than is possible
to write to a single file, so indicate that immediately
rather than having possibly future invocations fail. */
if (OFF_T_MAX < n_units)
error (EXIT_FAILURE, EFBIG,
_("%s: invalid number of bytes"), optarg);
break;
case 'l':
@@ -456,6 +875,38 @@ main (int argc, char **argv)
error (0, 0, _("%s: invalid number of bytes"), optarg);
usage (EXIT_FAILURE);
}
if (OFF_T_MAX < n_units)
error (EXIT_FAILURE, EFBIG,
_("%s: invalid number of bytes"), optarg);
break;
case 'n':
if (split_type != type_undef)
FAIL_ONLY_ONE_WAY ();
/* skip any whitespace */
while (isspace (to_uchar (*optarg)))
optarg++;
if (strncmp (optarg, "r/", 2) == 0)
{
split_type = type_rr;
optarg += 2;
}
else if (strncmp (optarg, "l/", 2) == 0)
{
split_type = type_chunk_lines;
optarg += 2;
}
else
split_type = type_chunk_bytes;
if ((slash = strchr (optarg, '/')))
parse_chunk (&k_units, &n_units, slash);
else if (xstrtoumax (optarg, NULL, 10, &n_units, "") != LONGINT_OK
|| n_units == 0)
error (EXIT_FAILURE, 0, _("%s: invalid number of chunks"), optarg);
break;
case 'u':
unbuffered = true;
break;
case '0':
@@ -491,6 +942,22 @@ main (int argc, char **argv)
suffix_alphabet = "0123456789";
break;
case 'e':
elide_empty_files = true;
break;
case IO_BLKSIZE_OPTION:
{
uintmax_t tmp_blk_size;
if (xstrtoumax (optarg, NULL, 10, &tmp_blk_size,
multipliers) != LONGINT_OK
|| tmp_blk_size == 0 || SIZE_MAX - page_size < tmp_blk_size)
error (0, 0, _("%s: invalid IO block size"), optarg);
else
in_blk_size = tmp_blk_size;
}
break;
case VERBOSE_OPTION:
verbose = true;
break;
@@ -513,10 +980,12 @@ main (int argc, char **argv)
if (n_units == 0)
{
error (0, 0, _("invalid number of lines: 0"));
error (0, 0, _("%s: invalid number of lines"), "0");
usage (EXIT_FAILURE);
}
set_suffix_length (n_units);
/* Get out the filename arguments. */
if (optind < argc)
@@ -537,18 +1006,36 @@ main (int argc, char **argv)
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
quote (infile));
/* Binary I/O is safer when bytecounts are used. */
/* Binary I/O is safer when byte counts are used. */
if (O_BINARY && ! isatty (STDIN_FILENO))
xfreopen (NULL, "rb", stdin);
/* No output file is open now. */
output_desc = -1;
/* Get the optimal block size of input device and make a buffer. */
if (fstat (STDIN_FILENO, &stat_buf) != 0)
error (EXIT_FAILURE, errno, "%s", infile);
in_blk_size = io_blksize (stat_buf);
if (in_blk_size == 0)
in_blk_size = io_blksize (stat_buf);
file_size = stat_buf.st_size;
if (split_type == type_chunk_bytes || split_type == type_chunk_lines)
{
off_t input_offset = lseek (STDIN_FILENO, 0, SEEK_CUR);
if (input_offset < 0)
error (EXIT_FAILURE, 0, _("%s: cannot determine file size"),
quote (infile));
file_size -= input_offset;
/* Overflow, and sanity checking. */
if (OFF_T_MAX < n_units)
{
char buffer[INT_BUFSIZE_BOUND (uintmax_t)];
error (EXIT_FAILURE, EFBIG, _("%s: invalid number of chunks"),
umaxtostr (n_units, buffer));
}
/* increase file_size to n_units here, so that we still process
any input data, and create empty files for the rest. */
file_size = MAX (file_size, n_units);
}
buf = ptr_align (xmalloc (in_blk_size + 1 + page_size - 1), page_size);
@@ -560,13 +1047,30 @@ main (int argc, char **argv)
break;
case type_bytes:
bytes_split (n_units, buf, in_blk_size);
bytes_split (n_units, buf, in_blk_size, 0);
break;
case type_byteslines:
line_bytes_split (n_units);
break;
case type_chunk_bytes:
if (k_units == 0)
bytes_split (file_size / n_units, buf, in_blk_size, n_units);
else
bytes_chunk_extract (k_units, n_units, buf, in_blk_size, file_size);
break;
case type_chunk_lines:
lines_chunk_split (k_units, n_units, buf, in_blk_size, file_size);
break;
case type_rr:
/* Note, this is like `sed -n ${k}~${n}p` when k > 0,
but the functionality is provided for symmetry. */
lines_rr (k_units, n_units, buf, in_blk_size);
break;
default:
abort ();
}

View File

@@ -149,6 +149,16 @@ statfs (char const *filename, struct fs_info *buf)
#define hextobin(c) ((c) >= 'a' && (c) <= 'f' ? (c) - 'a' + 10 : \
(c) >= 'A' && (c) <= 'F' ? (c) - 'A' + 10 : (c) - '0')
static char const digits[] = "0123456789";
/* Flags that are portable for use in printf, for at least one
conversion specifier; make_format removes unportable flags as
needed for particular specifiers. The glibc 2.2 extension "I" is
listed here; it is removed by make_format because it has undefined
behavior elsewhere and because it is incompatible with
out_epoch_sec. */
static char const printf_flags[] = "'-+ #0I";
#define PROGRAM_NAME "stat"
#define AUTHORS proper_name ("Michael Meskes")
@@ -182,6 +192,10 @@ static bool interpret_backslash_escapes;
"" for --printf=FMT, "\n" for --format=FMT (-c). */
static char const *trailing_delim = "";
/* The representation of the decimal point in the current locale. */
static char const *decimal_point;
static size_t decimal_point_len;
/* Return the type of the specified file system.
Some systems have statfvs.f_basetype[FSTYPSZ] (AIX, HP-UX, and Solaris).
Others have statvfs.f_fstypename[_VFS_NAMELEN] (NetBSD 3.0).
@@ -462,56 +476,168 @@ human_time (struct timespec t)
return str;
}
static char * ATTRIBUTE_WARN_UNUSED_RESULT
epoch_time (struct timespec t)
/* PFORMAT points to a '%' followed by a prefix of a format, all of
size PREFIX_LEN. The flags allowed for this format are
ALLOWED_FLAGS; remove other printf flags from the prefix, then
append SUFFIX. */
static void
make_format (char *pformat, size_t prefix_len, char const *allowed_flags,
char const *suffix)
{
static char str[INT_STRLEN_BOUND (time_t) + sizeof ".NNNNNNNNN"];
/* Note that time_t can technically be a floating point value, such
that casting to [u]intmax_t could lose a fractional value or
suffer from overflow. However, most porting targets have an
integral time_t; also, we know of no file systems that store
valid time values outside the bounds of intmax_t even if that
value were represented as a floating point. Besides, the cost of
converting to struct tm just to use nstrftime (str, len, "%s.%N",
tm, 0, t.tv_nsec) is pointless, since nstrftime would have to
convert back to seconds as time_t. */
if (TYPE_SIGNED (time_t))
sprintf (str, "%" PRIdMAX ".%09ld", (intmax_t) t.tv_sec, t.tv_nsec);
else
sprintf (str, "%" PRIuMAX ".%09ld", (uintmax_t) t.tv_sec, t.tv_nsec);
return str;
char *dst = pformat + 1;
char const *src;
char const *srclim = pformat + prefix_len;
for (src = dst; src < srclim && strchr (printf_flags, *src); src++)
if (strchr (allowed_flags, *src))
*dst++ = *src;
while (src < srclim)
*dst++ = *src++;
strcpy (dst, suffix);
}
static void
out_string (char *pformat, size_t prefix_len, char const *arg)
{
strcpy (pformat + prefix_len, "s");
make_format (pformat, prefix_len, "-", "s");
printf (pformat, arg);
}
static void
static int
out_int (char *pformat, size_t prefix_len, intmax_t arg)
{
strcpy (pformat + prefix_len, PRIdMAX);
printf (pformat, arg);
make_format (pformat, prefix_len, "'-+ 0", PRIdMAX);
return printf (pformat, arg);
}
static void
static int
out_uint (char *pformat, size_t prefix_len, uintmax_t arg)
{
strcpy (pformat + prefix_len, PRIuMAX);
printf (pformat, arg);
make_format (pformat, prefix_len, "'-0", PRIuMAX);
return printf (pformat, arg);
}
static void
out_uint_o (char *pformat, size_t prefix_len, uintmax_t arg)
{
strcpy (pformat + prefix_len, PRIoMAX);
make_format (pformat, prefix_len, "-#0", PRIoMAX);
printf (pformat, arg);
}
static void
out_uint_x (char *pformat, size_t prefix_len, uintmax_t arg)
{
strcpy (pformat + prefix_len, PRIxMAX);
make_format (pformat, prefix_len, "-#0", PRIxMAX);
printf (pformat, arg);
}
static int
out_minus_zero (char *pformat, size_t prefix_len)
{
make_format (pformat, prefix_len, "'-+ 0", ".0f");
return printf (pformat, -0.25);
}
/* Output the number of seconds since the Epoch, using a format that
acts like printf's %f format. */
static void
out_epoch_sec (char *pformat, size_t prefix_len, struct stat const *statbuf,
struct timespec arg)
{
char *dot = memchr (pformat, '.', prefix_len);
size_t sec_prefix_len = prefix_len;
int width = 0;
int precision = 0;
bool frac_left_adjust = false;
if (dot)
{
sec_prefix_len = dot - pformat;
pformat[prefix_len] = '\0';
if (ISDIGIT (dot[1]))
{
long int lprec = strtol (dot + 1, NULL, 10);
precision = (lprec <= INT_MAX ? lprec : INT_MAX);
}
else
{
precision = 9;
}
if (precision && ISDIGIT (dot[-1]))
{
/* If a nontrivial width is given, subtract the width of the
decimal point and PRECISION digits that will be output
later. */
char *p = dot;
*dot = '\0';
do
--p;
while (ISDIGIT (p[-1]));
long int lwidth = strtol (p, NULL, 10);
width = (lwidth <= INT_MAX ? lwidth : INT_MAX);
if (1 < width)
{
p += (*p == '0');
sec_prefix_len = p - pformat;
int w_d = (decimal_point_len < width
? width - decimal_point_len
: 0);
if (1 < w_d)
{
int w = w_d - precision;
if (1 < w)
{
char *dst = pformat;
for (char const *src = dst; src < p; src++)
{
if (*src == '-')
frac_left_adjust = true;
else
*dst++ = *src;
}
sec_prefix_len =
(dst - pformat
+ (frac_left_adjust ? 0 : sprintf (dst, "%d", w)));
}
}
}
}
}
int divisor = 1;
for (int i = precision; i < 9; i++)
divisor *= 10;
int frac_sec = arg.tv_nsec / divisor;
int int_len;
if (TYPE_SIGNED (time_t))
{
bool minus_zero = false;
if (arg.tv_sec < 0 && arg.tv_nsec != 0)
{
int frac_sec_modulus = 1000000000 / divisor;
frac_sec = (frac_sec_modulus - frac_sec
- (arg.tv_nsec % divisor != 0));
arg.tv_sec += (frac_sec != 0);
minus_zero = (arg.tv_sec == 0);
}
int_len = (minus_zero
? out_minus_zero (pformat, sec_prefix_len)
: out_int (pformat, sec_prefix_len, arg.tv_sec));
}
else
int_len = out_uint (pformat, sec_prefix_len, arg.tv_sec);
if (precision)
{
int prec = (precision < 9 ? precision : 9);
int trailing_prec = precision - prec;
int ilen = (int_len < 0 ? 0 : int_len);
int trailing_width = (ilen < width && decimal_point_len < width - ilen
? width - ilen - decimal_point_len - prec
: 0);
printf ("%s%.*d%-*.*d", decimal_point, prec, frac_sec,
trailing_width, trailing_prec, 0);
}
}
/* Print the context information of FILENAME, and return true iff the
context could not be obtained. */
@@ -539,7 +665,8 @@ out_file_context (char *pformat, size_t prefix_len, char const *filename)
/* Print statfs info. Return zero upon success, nonzero upon failure. */
static bool ATTRIBUTE_WARN_UNUSED_RESULT
print_statfs (char *pformat, size_t prefix_len, char m, char const *filename,
print_statfs (char *pformat, size_t prefix_len, unsigned int m,
char const *filename,
void const *data)
{
STRUCT_STATVFS const *statfsbuf = data;
@@ -711,9 +838,19 @@ print_mount_point:
return fail;
}
/* Map a TS with negative TS.tv_nsec to {0,0}. */
static inline struct timespec
neg_to_zero (struct timespec ts)
{
if (0 <= ts.tv_nsec)
return ts;
struct timespec z = {0, 0};
return z;
}
/* Print stat info. Return zero upon success, nonzero upon failure. */
static bool
print_stat (char *pformat, size_t prefix_len, char m,
print_stat (char *pformat, size_t prefix_len, unsigned int m,
char const *filename, void const *data)
{
struct stat *statbuf = (struct stat *) data;
@@ -815,31 +952,26 @@ print_stat (char *pformat, size_t prefix_len, char m,
}
break;
case 'W':
{
struct timespec t = get_stat_birthtime (statbuf);
if (t.tv_nsec < 0)
out_string (pformat, prefix_len, "-");
else
out_string (pformat, prefix_len, epoch_time (t));
}
out_epoch_sec (pformat, prefix_len, statbuf,
neg_to_zero (get_stat_birthtime (statbuf)));
break;
case 'x':
out_string (pformat, prefix_len, human_time (get_stat_atime (statbuf)));
break;
case 'X':
out_string (pformat, prefix_len, epoch_time (get_stat_atime (statbuf)));
out_epoch_sec (pformat, prefix_len, statbuf, get_stat_atime (statbuf));
break;
case 'y':
out_string (pformat, prefix_len, human_time (get_stat_mtime (statbuf)));
break;
case 'Y':
out_string (pformat, prefix_len, epoch_time (get_stat_mtime (statbuf)));
out_epoch_sec (pformat, prefix_len, statbuf, get_stat_mtime (statbuf));
break;
case 'z':
out_string (pformat, prefix_len, human_time (get_stat_ctime (statbuf)));
break;
case 'Z':
out_string (pformat, prefix_len, epoch_time (get_stat_ctime (statbuf)));
out_epoch_sec (pformat, prefix_len, statbuf, get_stat_ctime (statbuf));
break;
case 'C':
fail |= out_file_context (pformat, prefix_len, filename);
@@ -897,7 +1029,8 @@ print_esc_char (char c)
Return zero upon success, nonzero upon failure. */
static bool ATTRIBUTE_WARN_UNUSED_RESULT
print_it (char const *format, char const *filename,
bool (*print_func) (char *, size_t, char, char const *, void const *),
bool (*print_func) (char *, size_t, unsigned int,
char const *, void const *),
void const *data)
{
bool fail = false;
@@ -920,12 +1053,17 @@ print_it (char const *format, char const *filename,
{
case '%':
{
size_t len = strspn (b + 1, "#-+.I 0123456789");
size_t len = strspn (b + 1, printf_flags);
char const *fmt_char = b + len + 1;
fmt_char += strspn (fmt_char, digits);
if (*fmt_char == '.')
fmt_char += 1 + strspn (fmt_char + 1, digits);
len = fmt_char - (b + 1);
unsigned int fmt_code = *fmt_char;
memcpy (dest, b, len + 1);
b = fmt_char;
switch (*fmt_char)
switch (fmt_code)
{
case '\0':
--b;
@@ -941,7 +1079,7 @@ print_it (char const *format, char const *filename,
putchar ('%');
break;
default:
fail |= print_func (dest, len + 1, *fmt_char, filename, data);
fail |= print_func (dest, len + 1, fmt_code, filename, data);
break;
}
break;
@@ -1215,14 +1353,14 @@ The valid format sequences for files (without --file-system):\n\
fputs (_("\
%u User ID of owner\n\
%U User name of owner\n\
%w Time of file birth, or - if unknown\n\
%W Time of file birth as seconds since Epoch, or - if unknown\n\
%x Time of last access\n\
%X Time of last access as seconds since Epoch\n\
%y Time of last modification\n\
%Y Time of last modification as seconds since Epoch\n\
%z Time of last change\n\
%Z Time of last change as seconds since Epoch\n\
%w Time of file birth, human-readable; - if unknown\n\
%W Time of file birth, seconds since Epoch; 0 if unknown\n\
%x Time of last access, human-readable\n\
%X Time of last access, seconds since Epoch\n\
%y Time of last modification, human-readable\n\
%Y Time of last modification, seconds since Epoch\n\
%z Time of last change, human-readable\n\
%Z Time of last change, seconds since Epoch\n\
\n\
"), stdout);
@@ -1267,6 +1405,10 @@ main (int argc, char *argv[])
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
struct lconv const *locale = localeconv ();
decimal_point = (locale->decimal_point[0] ? locale->decimal_point : ".");
decimal_point_len = strlen (decimal_point);
atexit (close_stdout);
while ((c = getopt_long (argc, argv, "c:fLt", long_options, NULL)) != -1)

View File

@@ -286,7 +286,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
with --follow=name, reopen a FILE which has not\n\
changed size after N (default %d) iterations\n\
to see if it has been unlinked or renamed\n\
(this is the usual case of rotated log files)\n\
(this is the usual case of rotated log files).\n\
With inotify, this option is rarely useful.\n\
"),
DEFAULT_N_LINES,
DEFAULT_MAX_N_UNCHANGED_STATS_BETWEEN_OPENS
@@ -300,7 +301,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
"), stdout);
fputs (_("\
-s, --sleep-interval=N with -f, sleep for approximately N seconds\n\
(default 1.0) between iterations\n\
(default 1.0) between iterations.\n\
With inotify, this option is rarely useful.\n\
-v, --verbose always output headers giving file names\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -2169,7 +2171,8 @@ main (int argc, char **argv)
FIXME: when using inotify, and a directory for a watched file
is recreated, then we don't recheck any new file when
follow_mode == Follow_name */
if (tailable_stdin (F, n_files) || any_remote_file (F, n_files))
if (!disable_inotify && (tailable_stdin (F, n_files)
|| any_remote_file (F, n_files)))
disable_inotify = true;
if (!disable_inotify)
@@ -2189,6 +2192,7 @@ main (int argc, char **argv)
error (0, errno, _("inotify cannot be used, reverting to polling"));
}
#endif
disable_inotify = true;
tail_forever (F, n_files, sleep_interval);
}

View File

@@ -129,8 +129,8 @@ SIZE may also be prefixed by one of the following modifying characters:\n\
exit (status);
}
/* return 1 on error, 0 on success */
static int
/* return true on success, false on error. */
static bool
do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
rel_mode_t rel_mode)
{
@@ -140,7 +140,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
if ((block_mode || (rel_mode && rsize < 0)) && fstat (fd, &sb) != 0)
{
error (0, errno, _("cannot fstat %s"), quote (fname));
return 1;
return false;
}
if (block_mode)
{
@@ -152,7 +152,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
" * %" PRIdMAX " byte blocks for file %s"),
(intmax_t) ssize, (intmax_t) blksize,
quote (fname));
return 1;
return false;
}
ssize *= blksize;
}
@@ -165,7 +165,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
if (!S_ISREG (sb.st_mode) && !S_TYPEISSHM (&sb))
{
error (0, 0, _("cannot get the size of %s"), quote (fname));
return 1;
return false;
}
if (sb.st_size < 0)
{
@@ -173,7 +173,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
this would ever go negative. */
error (0, 0, _("%s has unusable, apparently negative size"),
quote (fname));
return 1;
return false;
}
}
@@ -193,7 +193,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
{
error (0, 0, _("overflow rounding up size of file %s"),
quote (fname));
return 1;
return false;
}
nsize = overflow;
}
@@ -203,7 +203,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
{
error (0, 0, _("overflow extending size of file %s"),
quote (fname));
return 1;
return false;
}
nsize = fsize + ssize;
}
@@ -218,21 +218,22 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t rsize,
error (0, errno,
_("failed to truncate %s at %" PRIdMAX " bytes"), quote (fname),
(intmax_t) nsize);
return 1;
return false;
}
return 0;
return true;
}
int
main (int argc, char **argv)
{
bool got_size = false;
bool errors = false;
off_t size IF_LINT ( = 0);
off_t rsize = -1;
rel_mode_t rel_mode = rm_abs;
mode_t omode;
int c, errors = 0, fd = -1, oflags;
int c, fd = -1, oflags;
char const *fname;
initialize_main (&argc, &argv);
@@ -374,7 +375,7 @@ main (int argc, char **argv)
{
error (0, errno, _("cannot open %s for writing"),
quote (fname));
errors++;
errors = true;
}
continue;
}
@@ -382,11 +383,11 @@ main (int argc, char **argv)
if (fd != -1)
{
errors += do_ftruncate (fd, fname, size, rsize, rel_mode);
errors |= !do_ftruncate (fd, fname, size, rsize, rel_mode);
if (close (fd) != 0)
{
error (0, errno, _("closing %s"), quote (fname));
errors++;
errors = true;
}
}
}

View File

@@ -487,6 +487,11 @@ tsort (const char *file)
/* T5. Output front of queue. */
puts (head->str);
#ifdef lint
/* suppress valgrind "definitely lost" warnings. */
void *head_str = (void *) head->str;
free (head_str);
#endif
head->str = NULL; /* Avoid printing the same string twice. */
n_strings--;

View File

@@ -726,8 +726,8 @@ main (int argc, char **argv)
switch (ai_err)
{
case AI_ERR_READ:
error (0, errno, _("%s: read error"), quote (files_from));
skip_file = true;
error (EXIT_FAILURE, errno, _("%s: read error"),
quote (files_from));
continue;
case AI_ERR_MEM:
xalloc_die ();

View File

@@ -49,10 +49,6 @@
proper_name ("David MacKenzie"), \
proper_name ("Michael Stone")
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 64
#endif
#ifdef RUN_LVL
# define UT_TYPE_RUN_LVL(U) UT_TYPE_EQ (U, RUN_LVL)
#else

View File

@@ -16,7 +16,6 @@ EXTRA_DIST = \
other-fs-tmpdir \
require-perl \
sample-test \
test-lib.sh \
$(pr_data)
root_tests = \
@@ -150,6 +149,7 @@ TESTS = \
misc/xstrtol \
tail-2/pid \
misc/od \
misc/od-float \
misc/mktemp \
misc/arch \
misc/pr \
@@ -172,6 +172,8 @@ TESTS = \
misc/chroot-fail \
misc/comm \
misc/csplit \
misc/csplit-1000 \
misc/csplit-heap \
misc/date-sec \
misc/dircolors \
misc/df \
@@ -226,6 +228,8 @@ TESTS = \
misc/sort \
misc/sort-benchmark-random \
misc/sort-compress \
misc/sort-compress-hang \
misc/sort-compress-proc \
misc/sort-continue \
misc/sort-debug-keys \
misc/sort-debug-warn \
@@ -235,15 +239,22 @@ TESTS = \
misc/sort-merge-fdlimit \
misc/sort-month \
misc/sort-rand \
misc/sort-spinlock-abuse \
misc/sort-stale-thread-mem \
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 \
misc/stat-birthtime \
misc/stat-fmt \
misc/stat-hyphen \
misc/stat-mount \
misc/stat-nanoseconds \
misc/stat-printf \
misc/stat-slash \
misc/stdbuf \
@@ -346,6 +357,7 @@ TESTS = \
du/2g \
du/8gb \
du/basic \
du/bigtime \
du/deref \
du/deref-args \
du/exclude \

View File

@@ -49,7 +49,8 @@ built_programs = \
# variables to test scripts.
TESTS_ENVIRONMENT = \
. $(srcdir)/lang-default; \
tmp__=$$TMPDIR; test -d "$$tmp__" || tmp__=.; \
tmp__=$${TMPDIR-/tmp}; \
test -d "$$tmp__" && test -w "$$tmp__" || tmp__=.; \
. $(srcdir)/envvar-check; \
TMPDIR=$$tmp__; export TMPDIR; \
exec 9>&2; \

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_membership_in_two_groups_

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_membership_in_two_groups_
set _ $groups; shift

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_membership_in_two_groups_
set _ $groups; shift

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_membership_in_two_groups_
skip_if_root_

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_membership_in_two_groups_
set _ $groups; shift

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_membership_in_two_groups_
set _ $groups; shift

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
umask 0
file=f

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
file=f
touch $file || framework_failure

View File

@@ -18,12 +18,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
touch f || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
mkdir -p d/e || framework_failure
chmod 0 d/e d || framework_failure

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
skip_if_root_
mkdir -p d/no-x/y a/b || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
# Before coreutils-5.92, this would mistakenly succeed,

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
umask 0
mkdir d || framework_failure

View File

@@ -16,14 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
chmod --version
chown --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp chmod chown
chmod -f 0 no-such 2> out && fail=1
chgrp -f 0 no-such 2>> out && fail=1

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
ln -s non-existent dangle || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
touch file
chmod 755 file

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chmod --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chmod
# Each line in this list is a set of arguments, followed by :,

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chgrp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chgrp
require_root_
touch f || framework_failure

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chown --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chown
ln -s no-such dangle || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chown --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chown
skip_if_root_
mkdir d && ln -s / d/slink-to-root

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
chown --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ chown
id_u=`id -u` || framework_failure
test -n "$id_u" || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir a b c || framework_failure
ln -s ../t a/1 || framework_failure

View File

@@ -17,16 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Make sure we get English translations.
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ mv getfacl setfacl
if test "$VERBOSE" = yes; then
set -x
mv --version
getfacl --version
setfacl --version
fi
. $srcdir/test-lib.sh
require_acl_
# Skip this test if cp was built without ACL support:

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
suffix=.b
file=b1.$$
@@ -34,8 +30,8 @@ echo test > $file || fail=1
# Specify both version control and suffix so the environment variables
# (possibly set by the user running these tests) aren't used.
cp --force --backup=simple --suffix=$suffix $file $file \
|| fail=1
cp --force --backup=simple --suffix=$suffix $file $file || fail=1
cp -T --force --backup=simple --suffix=$suffix $file $file || fail=1
test -f $file || fail=1
test -f $file_backup || fail=1

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir x y || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
echo a > a || framework_failure
echo a-tilde > a~ || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
ls --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ ls
require_root_
working_umask_or_skip_

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir src-dir dest-dir || framework_failure
echo f > f || framework_failure

View File

@@ -19,12 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
require_root_
require_selinux_

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir a b c d || framework_failure
ln -s ../c a || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir -p a b/a/c || framework_failure
touch a/c || framework_failure

View File

@@ -16,14 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
# Ensure that ls sorts the same way for everyone.
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
umask 022
@@ -34,7 +28,7 @@ umask 022
actual=actual
expected=expected
exec 1> $actual
exec 3>&1 1> $actual
for prog in cp mv; do
for initial_files in 'x' 'x y' 'x y y~' 'x y y.~1~' 'x y y~ y.~1~'; do
@@ -91,6 +85,8 @@ EOF
sed 's/: x/:/' $expected-tmp |cat $expected-tmp - > $expected
exec 1>&3 3>&-
compare $expected $actual || fail=1
Exit $fail

View File

@@ -18,13 +18,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
mv --version
fi
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp mv
. $srcdir/test-lib.sh
require_root_
cwd=`pwd`

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
mv --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ mv
working_umask_or_skip_

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
touch f slink-target || framework_failure
ln -s slink-target slink || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir d e || framework_failure

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir dir1 dir2 || framework_failure
touch dir1/file || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir dir || framework_failure
touch file || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
require_membership_in_two_groups_

View File

@@ -15,12 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
skip_if_root_
chmod g-s . || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
require_local_dir_

View File

@@ -21,12 +21,8 @@
# Now it gives this:
# cp: can't copy a directory `dir' into itself `dir/dir'
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir a dir || framework_failure

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
touch src || framework_failure
touch dest || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
expensive_
require_ulimit_

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
ln -s no-such-file dangling-slink || framework_failure

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
touch a || framework_failure
ln a b || framework_failure

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir a b
msg=bar

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
mkdir b
msg=bar

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
msg=bar
echo $msg > a

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
working_umask_or_skip_
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
require_local_dir_

View File

@@ -16,13 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
mv --version
fi
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp mv
. $srcdir/test-lib.sh
very_expensive_
umask 037

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
# cp -p gives ENOTSUP on NFS on Linux 2.6.9 at least
require_local_dir_

View File

@@ -16,7 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
require_root_
# Some of the tests expect a umask that grants group and/or world read access.
@@ -58,11 +60,6 @@ t1() {
"$nameless_uid" "$@"
}
if test "x$VERBOSE" = xyes; then
set -x
cp --version
fi
nameless_uid=`$PERL -le 'foreach my $i (1000..16*1024-1) { getpwuid $i or (print $i), exit }'`
nameless_gid1=`$PERL -le 'foreach my $i (1000..16*1024) { getgrgid $i or (print $i), exit }'`
nameless_gid2=`$PERL -le 'foreach my $i ('"$nameless_gid1"'+1..16*1024) { getgrgid $i or (print $i), exit }'`

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
grep '^#define HAVE_UTIMENSAT 1' "$CONFIG_HEADER" > /dev/null ||
grep '^#define HAVE_LUTIMES 1' "$CONFIG_HEADER" > /dev/null ||

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
kall=/proc/kallsyms

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
touch empty || framework_failure

View File

@@ -20,12 +20,8 @@
# though now such usage evokes a warning:
# cp: `slink': WARNING: using -r to copy symbolic links is not portable
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
echo abc > foo || framework_failure
ln -s foo slink || framework_failure

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
cleanup_() { rm -rf "$other_partition_tmpdir"; }
. "$abs_srcdir/other-fs-tmpdir"

View File

@@ -16,12 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
: > time_check
@@ -39,8 +35,11 @@ test "$mode" = "-rwxrwxrwx" || fail=1
test copy -nt file && fail=1
# Ensure that --attributes-only overrides --reflink completely
echo > file2 # file with data
cp --reflink=auto --preserve --attributes-only file2 empty_copy || fail=1
test -s empty_copy && fail=1
cp --reflink=always --preserve --attributes-only file2 empty_copy || fail=1
test -s empty_copy && fail=1
Exit $fail

View File

@@ -17,12 +17,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ cp
# Unset CDPATH. Otherwise, output from the `cd dir' command
# can make this test fail.
@@ -46,7 +42,7 @@ test $hard_link_to_symlink_does_the_deref = yes \
actual=actual-$$
expected=expected-$$
exec 1> $actual
exec 3>&1 1> $actual
# FIXME: This should be bigger: like more than 8k
contents=XYZ
@@ -220,6 +216,7 @@ cat <<\EOF | sed "$remove_these_sed" > $expected
EOF
exec 1>&3 3>&-
compare $expected $actual 1>&2 || fail=1

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