Compare commits

..

83 Commits
v8.7 ... 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
413 changed files with 2616 additions and 2753 deletions

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.6
8.7

46
NEWS
View File

@@ -1,5 +1,43 @@
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
@@ -23,10 +61,10 @@ GNU coreutils NEWS -*- outline -*-
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 floating point time stamp for %X use %.X;
if you want (say) just 3 fractional digits, use %.3X. Likewise
for %Y and %Z.
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

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

3
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

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 = 594c508078596fb65a3db2c0f4437386
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

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
@@ -4076,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
@@ -10721,7 +10836,7 @@ 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
@samp{%.9X}. When discarding excess precision, time stamps are truncated
toward minus infinity.
@example

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: a14bd22364...fe2a2304a8

View File

@@ -3,15 +3,18 @@ include gnulib.mk
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

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

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

@@ -1275,7 +1275,7 @@ max_out (char *format)
error (EXIT_FAILURE, 0,
_("too many %% conversion specifications in suffix"));
percent = true;
unsigned int flags;
int flags;
f += get_format_flags (f, &flags);
while (ISDIGIT (*f))
f++;

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

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

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

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 \
@@ -228,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 \
@@ -237,11 +239,17 @@ 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 \

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

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

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 file || framework_failure
ln -s file 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
require_sparse_support_
# Create a sparse file.

View File

@@ -20,12 +20,8 @@
# This test would fail due to a bug introduced in 4.0y.
# The bug was fixed in 4.0z.
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_
touch a b c || 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
mkfifo fifo ||
skip_test_ "fifos not supported"

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

@@ -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 dir || framework_failure
ln -s dir symlink || 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
ln -s no-such dangle || framework_failure
echo hi > 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
dd --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ dd
truncate -s 8192 in || framework_failure
dd if=in oflag=direct of=out 2> /dev/null \

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
dd --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ dd
tmp_in=dd-in.$$
tmp_in2=dd-in2.$$

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
dd --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ dd
echo abcde > in

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
dd --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ dd
# 2 short reads -> 1 full write + 1 partial write
cat <<\EOF > exp-reblock || 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
dd --version
fi
. $srcdir/test-lib.sh
. "${srcdir=.}/init.sh"; path_prepend_ ../src
print_ver_ dd
# need write access to local device
# (even though we don't actually write anything)

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