platform/upstream/coreutils.git
12 years agodoc: mention the improved sort memory allocation
Pádraig Brady [Thu, 12 Jul 2012 14:02:19 +0000 (15:02 +0100)]
doc: mention the improved sort memory allocation

* NEWS: Mention the improvement.

12 years agodoc: fix errors and warnings with Texinfo 5
Stefano Lattarini [Thu, 12 Jul 2012 14:08:34 +0000 (15:08 +0100)]
doc: fix errors and warnings with Texinfo 5

Or rather, with the development version 4.13.90, which will eventually
become Texinfo 5.0.

* doc/coreutils.texi: Use '@item' instead of '@itemx' in several places,
as Texinfo 5 refuses to process an '@itemx' that is not preceded by an
'@item'.  Ensure that node extended names in menus and sectioning are
consistent, and that ordering and presence of nodes in menus and in the
actual text are consistent as well.

Fixes http://bugs.gnu.org/11828

12 years agodf: warn if soon-to-be-removed --megabyte option is used
Bernhard Voelker [Wed, 11 Jul 2012 15:27:20 +0000 (17:27 +0200)]
df: warn if soon-to-be-removed --megabyte option is used

* src/df.c (MEGABYTES_OPTION): Add enum and mark it for removal
in August 2013.
(long_options): Use MEGABYTES_OPTION for --megabytes option.
(main): Add a case for it and issue a deprecation warning if
the long form is used.  Document the short -m option to
exist only for BSD compatibility.

12 years agosort: by default, do not exceed 3/4 of physical memory
Paul Eggert [Tue, 10 Jul 2012 23:14:33 +0000 (16:14 -0700)]
sort: by default, do not exceed 3/4 of physical memory

* src/sort.c (default_sort_size): Do not exceed 3/4 of total memory.
See Jeff Janes's bug report in
<http://lists.gnu.org/archive/html/coreutils/2012-06/msg00018.html>.

12 years agotests: sort-merge-fdlimit: reduce the limit by one
Pádraig Brady [Wed, 4 Jul 2012 10:02:20 +0000 (12:02 +0200)]
tests: sort-merge-fdlimit: reduce the limit by one

* tests/misc/sort-merge-fdlimit: As a consequence of commit
v8.17-34-g59daf05, we can reduce the descriptor limit by one.

12 years agodoc: document leap seconds better
Paul Eggert [Thu, 5 Jul 2012 23:11:49 +0000 (16:11 -0700)]
doc: document leap seconds better

* doc/coreutils.texi (touch invocation, Time conversion specifiers)
(Options for date, Examples of date): Index "leap seconds" and
improve their documentation a bit.

12 years agodoc: fix spacing
Paul Eggert [Thu, 5 Jul 2012 22:47:21 +0000 (15:47 -0700)]
doc: fix spacing

* doc/coreutils.texi: Use right amount of spacing after punctuation.

12 years agodate: fails to diagnose invalid input
Jim Meyering [Wed, 4 Jul 2012 11:01:56 +0000 (13:01 +0200)]
date: fails to diagnose invalid input

date -d "$(printf '\xb0')" would print 00:00:00 with today's date
rather than diagnosing the invalid input.  Now it reports this:
date: invalid date '\260'
* gnulib: Update submodule to latest for fixed parse-datetime.y.
* tests/misc/date [invalid-high-bit-set]: New test.
* NEWS (Bug fixes): Mention it.
* bootstrap, tests/init.sh: Also update to latest.
Reported by Peter Evans in http://bugs.gnu.org/11843

12 years agomaint: add syntax-check rule to help avoid misuse of EXIT_FAILURE
Jim Meyering [Tue, 3 Jul 2012 18:14:56 +0000 (20:14 +0200)]
maint: add syntax-check rule to help avoid misuse of EXIT_FAILURE

* cfg.mk (sc_some_programs_must_avoid_exit_failure): New rule,
to help us avoid using EXIT_FAILURE in programs like sort, ls, nohup,
timeout, env, etc. that use different exit codes in many cases.

12 years agomaint: fix minor bugs in helper program, setuidgid
Jim Meyering [Tue, 3 Jul 2012 18:13:09 +0000 (20:13 +0200)]
maint: fix minor bugs in helper program, setuidgid

* src/setuidgid.c (main): Fix two error-before-usage calls not to exit.
Exit with status SETUIDGID_FAILURE (not EXIT_FAILURE) consistently.

12 years agosort: fix exit-status typo
Paul Eggert [Mon, 2 Jul 2012 23:19:28 +0000 (16:19 -0700)]
sort: fix exit-status typo

* src/sort.c (stream_open): EXIT_FAILURE -> SORT_FAILURE.
Suggested by Pádraig Brady in <http://bugs.gnu.org/11816#34>.

12 years agosort: simplify -o handling to avoid fdopen, assert
Paul Eggert [Mon, 2 Jul 2012 22:47:03 +0000 (15:47 -0700)]
sort: simplify -o handling to avoid fdopen, assert

* src/sort.c (outfd): Remove.  All uses replaced by STDOUT_FILENO.
(stream_open): When writing, use stdout rather than fdopen.
(move_fd_or_die): Renamed from dup2_or_die, with the added functionality
of closing its first argument.  All uses changed.
(avoid_trashing_input): Special case for !outfile no longer needed.
(check_output): Arrange for standard output to go to the file,
rather than storing the fd in outfd.

12 years agosort: avoid redundant processing with inaccessible inputs or output
Pádraig Brady [Sun, 1 Jul 2012 00:14:42 +0000 (01:14 +0100)]
sort: avoid redundant processing with inaccessible inputs or output

* src/sort.c (check_inputs): A new function to verify all inputs
are accessible before further processing.
(check_output): A new function to open or create a specified
output file, before futher processing.
(stream_open): Adjust to truncating the previously opened
output file rather than opening directly.
(avoid_trashing_input): Optimize to stat the output file
descriptor, rather than the file name.
(main): Call the new functions to check accessibility of
inputs and output, before processing starts.
* tests/misc/sort: Adjust to the changed error message.
* tests/misc/sort-merge-fdlimit: Account for the earlier opened
file descriptor of the specified output file.
* tests/misc/sort-exit-early: A new test to exercise the improvements.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the improvement.

Suggested-by: Bernhard Voelker
12 years agomaint: sc_prohibit_fail_0: update a stale comment
Pádraig Brady [Mon, 2 Jul 2012 18:40:01 +0000 (20:40 +0200)]
maint: sc_prohibit_fail_0: update a stale comment

* cfg.mk (sc_prohibit_fail_0): Following on from
commit v8.0-79-g71c2f88, update the comment to match.

12 years agomaint: avoid a -Wunsed-but-set warning on some systems
Pádraig Brady [Sat, 30 Jun 2012 23:04:37 +0000 (00:04 +0100)]
maint: avoid a -Wunsed-but-set warning on some systems

* src/stty.c (main): Mark speed_was_set as possibly unused,
as is the case when CIBAUD is undefined (on ppc64 GNU/Linux
for example).
Reported-by: Stefano Lattarini
12 years agomaint: avoid false-positive syntax-check failure due to fail=0 in .texi
Jim Meyering [Sat, 30 Jun 2012 16:29:38 +0000 (18:29 +0200)]
maint: avoid false-positive syntax-check failure due to fail=0 in .texi

* cfg.mk (exclude_file_name_regexp--sc_prohibit_fail_0): Exempt
all .texi files.

12 years agostat,tail: recognize new file system type: aufs
Jim Meyering [Sat, 30 Jun 2012 16:19:53 +0000 (18:19 +0200)]
stat,tail: recognize new file system type: aufs

* src/stat.c (human_fstype) [__linux__]: Add a 'case' for the new
remote file system type: aufs (0x61756673).
* NEWS (New features): Mention stat -f.
(Bug fixes): Mention it for tail -f.
Reported by Michael Mol in http://bugs.gnu.org/11823

12 years agodoc: improve sample backup script
Jim Meyering [Fri, 29 Jun 2012 08:45:31 +0000 (10:45 +0200)]
doc: improve sample backup script

* doc/coreutils.texi (cp invocation): Make the backup script exit
with an accurate reflection of any failure.
Also, add --preserve=all.

Improved-by: Bernhard Voelker
12 years agomaint: avoid a static analysis warning in csplit
Pádraig Brady [Tue, 26 Jun 2012 10:13:45 +0000 (11:13 +0100)]
maint: avoid a static analysis warning in csplit

The Canalyze static code analyzer correctly surmised
that there is a use-after-free bug in free_buffer()
at the line "struct line *n = l->next", if that
function is called multiple times.

This is not a runtime issue since a list of lines
will not be present in the !lines_found case.

* src/csplit.c (free_buffer): Set list head to NULL so
that this function can be called multiple times.
(load_buffer): Remove a redundant call to free_buffer().

Reported-by: Xu Zhongxing
12 years agodoc: document multiplier for dd number options like count=N
Bernhard Voelker [Thu, 21 Jun 2012 11:23:35 +0000 (13:23 +0200)]
doc: document multiplier for dd number options like count=N

* src/dd.c (usage): Add "N" to the description of multipliers.
* doc/coreutils.texi (dd invocation): Likewise.

12 years agosplit: ensure output doesn't overwrite input
Pádraig Brady [Fri, 22 Jun 2012 08:32:34 +0000 (09:32 +0100)]
split: ensure output doesn't overwrite input

* src/split.c (create): Check if output file is the
same inode as the input file.
* tests/split/guard-input: New test case.
* tests/Makefile.am: Reference new test case.
* NEWS: Mention the fix.

Improved-by: Jim Meyering
Reported-by: François Pinard
12 years agomaint: refactor common mode bits used to create files
Pádraig Brady [Fri, 22 Jun 2012 10:17:38 +0000 (11:17 +0100)]
maint: refactor common mode bits used to create files

* src/system.h (MODE_RW_UGO): The new refactored define (666).
* src/mkfifo.c: Use the new define.
* src/mknod.c: Likewise.
* src/split.c: Likewise.
* src/system.h: Likewise.
* src/touch.c: Likewise.
* src/truncate.c: Likewise.

Suggested-by: Jim Meyering
12 years agomaint: suppress echoing of sc_THANKS_in_duplicates implementation
Pádraig Brady [Fri, 22 Jun 2012 09:56:25 +0000 (10:56 +0100)]
maint: suppress echoing of sc_THANKS_in_duplicates implementation

* cfg.mk (sc_THANKS_in_duplicates): Suppress the echoing of these
commands run during `make syntax-check`

12 years agomaint: sort: style adjustment to help clarify size determination
Bernhard Voelker [Wed, 20 Jun 2012 05:57:31 +0000 (07:57 +0200)]
maint: sort: style adjustment to help clarify size determination

* src/sort.c (default_sort_size): Move physmem code "down" to first use.

12 years agostty: portability: accommodate CIL
Jim Meyering [Tue, 12 Jun 2012 14:13:43 +0000 (16:13 +0200)]
stty: portability: accommodate CIL

* src/stty.c (main): Declare locals "mode" and "new_mode" to be static
to ensure that each is initialized to zero, *including* all padding.
While gcc clears padding of a local automatic initialized to "{ 0, }",
CIL does not, and the C99 standard is not clear on this issue.
Reported by Edward Schwartz.  See http://bugs.gnu.org/11675 for details.

12 years agomaint: remove su testing artifact
Sami Kerola [Sat, 9 Jun 2012 20:32:17 +0000 (22:32 +0200)]
maint: remove su testing artifact

* tests/misc/help-version: Remove expected su exit code.

12 years agobuild: update gnulib to latest; correct comment grammar
Jim Meyering [Thu, 24 May 2012 10:32:41 +0000 (12:32 +0200)]
build: update gnulib to latest; correct comment grammar

* tests/misc/help-version: Fix comment grammar:
s/all these/all of these/
* gl/lib/tempname.c.diff: Likewise.

12 years agomaint: migrate strncpy-prohibiting rule to gnulib
Jim Meyering [Fri, 25 May 2012 15:18:05 +0000 (17:18 +0200)]
maint: migrate strncpy-prohibiting rule to gnulib

* cfg.mk (sc_prohibit_strncpy): Remove rule.
Now it's in gnulib.

12 years agomaint: prohibit use of strncpy
Jim Meyering [Thu, 24 May 2012 14:21:34 +0000 (16:21 +0200)]
maint: prohibit use of strncpy

* cfg.mk (sc_prohibit_strncpy): New syntax-check rule.
Exempt pinky.c and who.c, at least for now.

12 years agosu: remove program (util-linux is now the best source for it)
Jim Meyering [Fri, 25 May 2012 16:10:25 +0000 (18:10 +0200)]
su: remove program (util-linux is now the best source for it)

* README: Omit "su" from list of programs.
* src/su.c: Remove file.
* src/Makefile.am: Remove su-related rules and variables.
* tests/misc/su-fail: Remove test.
* tests/Makefile.am (TESTS): Remove misc/su-fail.
* tests/misc/invalid-opt: Remove su-related code.
* src/.gitignore: Remove su.
* man/su.x: Remove file.
* man/Makefile.am (su.1): Remove rule.
* po/POTFILES.in: Remove su.c from the list.
* TODO: Remove ancient entry.
* NEWS (Changes in behavior): Mention it.
* doc/coreutils.texi: Remove su-related description.
* AUTHORS: Remove su.
* m4/lib-check.m4 (cu_LIB_CHECK): Remove file/macro.
* configure.ac: Remove su-related code and sole use of cu_LIB_CHECK.
* scripts/git-hooks/commit-msg: Remove su from this list, too.

12 years agomaint: detect a new type of duplicate in THANKS.in
Jim Meyering [Wed, 6 Jun 2012 10:46:27 +0000 (12:46 +0200)]
maint: detect a new type of duplicate in THANKS.in

* cfg.mk (sc_THANKS_in_duplicates): New rule.

12 years agomaint: mark new diagnostic for translation
Jim Meyering [Tue, 5 Jun 2012 20:38:26 +0000 (22:38 +0200)]
maint: mark new diagnostic for translation

* src/head.c (elide_tail_lines_seekable): Mark new diagnostic.
I will look at the results of "make syntax-check", I will look...

12 years agohead: with --lines=-N (-n-N) reset file pointer on seekable input
Jim Meyering [Tue, 5 Jun 2012 10:24:49 +0000 (12:24 +0200)]
head: with --lines=-N (-n-N) reset file pointer on seekable input

* src/head.c (elide_tail_lines_seekable): Reset file pointer
after printing up to an end-relative line-counted offset.
Anoop Sharma reported the problem and suggested the fix.
* tests/misc/head-pos: Add coverage via a very similar, existing test.
Also add coverage for a previously untested block of code.
* tests/misc/head-elide-tail ($READ_BUFSIZE): Update to 8192, to
match the value of BUFSIZ I see today on Fedora 17/x86_64 (unrelated
to this fix).
* NEWS (Bug fixes): Mention it.

Improved-by: Pádraig Brady
12 years agostat,tail: recognize new file system type: panfs
Jim Meyering [Fri, 1 Jun 2012 07:14:25 +0000 (09:14 +0200)]
stat,tail: recognize new file system type: panfs

* src/stat.c (human_fstype) [__linux__]: Add a 'case' for the new
remote file system type: panfs (0xAAD7AAEA).
* NEWS (New features): Mention stat -f.
(Bug fixes): Mention it for tail -f.
Reported by Travis Gummels in http://bugzilla.redhat.com/827199

12 years agomaint: fix typos in test comments and old ChangeLog files
Jim Meyering [Tue, 29 May 2012 15:36:10 +0000 (17:36 +0200)]
maint: fix typos in test comments and old ChangeLog files

Culprits identified and fixed automatically using these commands:
git ls-files|misspellings -f -|perl -nl \
  -e '/^(.*?)\[(\d+)\]: (\w+) -> "(.*?)"$/ or next;' \
  -e '($file,$n,$l,$r)=($1,$2,$3,$4); $q="'\''"; $r=~s/$q/$q\\$q$q/g;'\
  -e 'print "sed -i $q${n}s!$l!$r!$q $file"' | bash
using http://github.com/lyda/misspell-check
* old/fileutils/ChangeLog: Fix typos.
* old/textutils/ChangeLog: Likewise.
* tests/misc/truncate-fail-diag: Likewise.

12 years agocksum: line-buffer the printed checksums
Pádraig Brady [Mon, 28 May 2012 01:43:06 +0000 (02:43 +0100)]
cksum: line-buffer the printed checksums

This utility was inadvertently omitted from commit v8.0-34-g710fe41
* src/cksum.c (main): Set stdout to line buffered mode, to ensure
parallel running instances don't intersperse their output.
* NEWS: Mention the fix.
* THANKS.in: Add Anoop.
Reported by Anoop Sharma.

12 years agomaint: remove comment that suggested to remove support for mktemp -V
Jim Meyering [Sun, 20 May 2012 15:19:10 +0000 (17:19 +0200)]
maint: remove comment that suggested to remove support for mktemp -V

* src/mktemp.c (main): Don't suggest to remove support for -V, an
undocumented alias for --version, since that would introduce a
gratuitous incompatibility with the original mktemp program.

12 years agodircolors: add st/st-256color terminal types
Mike Frysinger [Thu, 17 May 2012 04:00:11 +0000 (00:00 -0400)]
dircolors: add st/st-256color terminal types

See http://st.suckless.org/
* src/dircolors.hin: Add st and st-256color.
Reported-by: Jeroen Roovers <jer@gentoo.org>, via
Mike Frysinger <vapier@gentoo.org> in http://bugs.gnu.org/11498

12 years agoid,groups: use gidtostr/uidtostr to avoid casts
Jim Meyering [Sun, 1 Jan 2012 21:31:41 +0000 (22:31 +0100)]
id,groups: use gidtostr/uidtostr to avoid casts

* src/id.c (gidtostr, uidtostr): Define macros.
(gidtostr_ptr, uidtostr_ptr): Define safer functions.
Use gidtostr and uidtostr to print GID and UID without
need/risk of casts.
* src/group-list.c: Likewise.

12 years agotests: use $AWK, not awk
Jim Meyering [Wed, 16 May 2012 05:46:51 +0000 (07:46 +0200)]
tests: use $AWK, not awk

* tests/cp/sparse-fiemap: Don't hard-code "awk".  Use $AWK.
* tests/init.cfg: Likewise.
* tests/misc/sort-rand: Likewise.

12 years agomaint: tell xgettext that fputs arg "93% of..." is not a C format string
Jim Meyering [Wed, 16 May 2012 05:26:36 +0000 (07:26 +0200)]
maint: tell xgettext that fputs arg "93% of..." is not a C format string

* src/fmt.c (usage): Add a comment to tell
xgettext that the "% o" in fputs argument string of "...93% of..."
is not a C format string.  Reported by Toomas Soome, Göran Uddeborg,
Petr Pisar, Primoz PETERLIN and Chusslove Illich via
http://bugs.gnu.org/11470

12 years agomaint: add assertions to placate static analysis tools
Jim Meyering [Mon, 14 May 2012 13:44:41 +0000 (15:44 +0200)]
maint: add assertions to placate static analysis tools

A static analysis tool (http://labs.oracle.com/projects/parfait/)
produced some false positive diagnostics.  Add assertions to help
it understand that the code is correct.
* src/stty.c: Include <assert.h>.
(display_changed): Add an assertion to placate parfait.
(display_all): Likewise.
* src/sort.c: Include <assert.h>.
(main): Add an assertion to placate parfait.
* src/fmt.c: Include <assert.h>.
(get_paragraph): Add an assertion to placate parfait.

12 years agostat: report the correct block size for file system usage
Pádraig Brady [Tue, 15 May 2012 18:56:21 +0000 (19:56 +0100)]
stat: report the correct block size for file system usage

struct statfs has the f_frsize member since Linux 2.6,
so use that rather than f_bsize which can be different.
Note the related df change mentioned in NEWS is handled
in gnulib by using statvfs() rather than statfs()
on Linux > 2.6.36 (where statvfs doesn't hang) and the
same method as stat for Linux 2.6 kernels earlier than that.
stat(1) doesn't use statvfs() on GNU/Linux as the f_type
member isn't available there.
Note the change to not use statvfs() on GNU/Linux was introduced
in gnulib commit eda39b8 16-08-2003.

* m4/stat-prog.m4 (cu_PREREQ_STAT_PROG): Check for the f_frsize
member in the statfs structure.
* src/stat.c: Use (struct statfs).f_frsize if available.
* NEWS (Bug fixes): Mention this stat fix, and the related df fix
coming in the next gnulib update.
* THANKS.in: Add Nikolaus.

Reported and Tested by Nikolaus Rath

12 years agols: color each symlink-to-relative-name in / properly
Jim Meyering [Thu, 10 May 2012 17:43:00 +0000 (19:43 +0200)]
ls: color each symlink-to-relative-name in / properly

In order for ls --color to color each symlink, it must form the name
of each referent and then stat it to see if the link is dangling, to
a directory, to a file, etc.  When the symlink is to a relative name,
ls must concatenate the starting directory name and that relative name.
When, in addition, the starting directory was "/" or "/some-name",
the result was ill-formed, and the subsequent stat would usually fail,
making the caller color it as a dangling symlink.
* src/ls.c (make_link_name): Don't botch the case in which
dir_name(NAME) == "/" and LINKNAME is relative.
* tests/ls/root-rel-symlink-color: New file.  Test for the above.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
Reported by Mike Frysinger in http://bugs.gnu.org/11453
Bug introduced by commit v8.16-23-gbcb9078.

12 years agomaint: post-release administrivia
Jim Meyering [Thu, 10 May 2012 17:43:00 +0000 (19:43 +0200)]
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

12 years agoversion 8.17 v8.17
Jim Meyering [Thu, 10 May 2012 17:16:52 +0000 (19:16 +0200)]
version 8.17

* NEWS: Record release date.

12 years agotests: misc/tty-eof: increase timeout to avoid unwarranted failure
Jim Meyering [Thu, 10 May 2012 14:20:38 +0000 (16:20 +0200)]
tests: misc/tty-eof: increase timeout to avoid unwarranted failure

* tests/misc/tty-eof: Increase timeout from 1s to 10s, to avoid
unwarranted failure under heavy load.
* tests/Makefile.am (TESTS): Move misc/tty-eof "up" to nearer the
beginning of the list (from near the middle) so that it is started
earlier in parallel test runs.  Otherwise, it would frequently be
among the last two tests to complete.

12 years agostat,tail: recognize new FS types: bdevfs, inodefs, qnx6
Jim Meyering [Thu, 10 May 2012 13:46:08 +0000 (15:46 +0200)]
stat,tail: recognize new FS types: bdevfs, inodefs, qnx6

* src/stat.c (human_fstype) [__linux__]: Add 'case's for these local
file system types: bdevfs (0x62646576), inodefs (0x42494E4D),
qnx6 (0x68191122).
Now that the kernel has a name for S_MAGIC_BINFMTFS, use
theirs in place of our S_MAGIC_BINFMT_MISC.
* NEWS (New features): Mention it.

12 years agoscripts: encourage use of shorter "bugs.gnu.org" in bug URLs
Jim Meyering [Thu, 10 May 2012 08:24:02 +0000 (10:24 +0200)]
scripts: encourage use of shorter "bugs.gnu.org" in bug URLs

* scripts/git-hooks/commit-msg: Also ding debbugs.gnu.org URLs.

12 years agomaint: handle file sizes more reliably
Paul Eggert [Thu, 10 May 2012 06:53:16 +0000 (23:53 -0700)]
maint: handle file sizes more reliably

Problem reported by Samuel Thibault in <http://bugs.gnu.org/11424>.
* NEWS: Document this.
* src/dd.c (skip): Handle skipping past EOF on shared or typed
memory objects the same way as with regular files.
(dd_copy): It's OK to truncate shared memory objects.
* src/du.c (duinfo_add): Check for overflow.
(print_only_size): Report overflow.
(process_file): Ignore negative file sizes in the --apparent-size case.
* src/od.c (skip): Fix comment about st_size.
* src/split.c (main):
* src/truncate.c (do_ftruncate, main):
On files where st_size is not portable, fall back on using lseek
with SEEK_END to determine the size.  Although strictly speaking
POSIX says the behavior is implementation-defined, in practice
if lseek returns a nonnegative value it's a reasonable one to
use for the file size.
* src/system.h (usable_st_size): Symlinks have reliable st_size too.
* tests/misc/truncate-dir-fail: Don't assume that getting the size
of a dir is not allowed, as it's now allowed on many platforms,
e.g., GNU/Linux.

12 years agostat: don't report negative file size as huge positive number
Paul Eggert [Thu, 10 May 2012 06:32:02 +0000 (23:32 -0700)]
stat: don't report negative file size as huge positive number

* src/stat.c (print_stat): Use out_int, not out_uint for stat.st_size.
* NEWS (Bug fixes): Mention it.

12 years agosplit: avoid apparent infloop when splitting /dev/zero w/-n on the Hurd
Jim Meyering [Mon, 7 May 2012 07:32:00 +0000 (09:32 +0200)]
split: avoid apparent infloop when splitting /dev/zero w/-n on the Hurd

* src/split.c (main): Use stat.st_size only for regular files.
Samuel Thibault reported in http://bugs.gnu.org/11424 that the
/dev/zero-splitting tests would appear to infloop on GNU/Hurd,
because /dev/zero's st_size is LONG_MAX.  It was only a problem
when using the --number (-n) option.
* NEWS (Bug fixes): Mention it.
This bug was introduced with the --number option, via
commit v8.7-25-gbe10739

12 years agobuild: update gnulib submodule to latest; also bootstrap and init.sh
Jim Meyering [Tue, 8 May 2012 09:05:29 +0000 (11:05 +0200)]
build: update gnulib submodule to latest; also bootstrap and init.sh

* bootstrap: Update from gnulib.
* tests/init.sh: Likewise.

12 years agodoc: clarify dd conv=sparse usage with devices
Pádraig Brady [Tue, 8 May 2012 12:18:45 +0000 (13:18 +0100)]
doc: clarify dd conv=sparse usage with devices

* doc/coreutils.texi (dd invocation): Clarify that NUL blocks
are not copied for devices either, and give examples of where
it might be useful.

12 years agomaint: new function: usable_st_size
Jim Meyering [Mon, 7 May 2012 09:20:45 +0000 (11:20 +0200)]
maint: new function: usable_st_size

12 years agomaint: fix common spelling errors
Kevin Lyda [Tue, 17 Apr 2012 23:38:04 +0000 (00:38 +0100)]
maint: fix common spelling errors

These were identified using: https://github.com/lyda/misspell-check
executed like: git ls-files | misspellings -f -

* src/cat.c: Correct a spelling error.
* src/comm.c: Likewise.
* src/expr.c: Likewise.
* src/pr.c: Likewise.
* src/tac.c: Likewise.
* src/test.c: Likewise.
* src/ChangeLog-2005: Likewise.
* src/ChangeLog-2007: Likewise.
* src/NEWS: Likewise.
* src/doc/coreutils.texi: Likewise.
* src/lib/ChangeLog-2007: Likewise.
* src/man/help2man: Likewise.
* src/old/fileutils/ChangeLog-1997: Likewise.
* src/old/fileutils/NEWS: Likewise.
* src/old/sh-utils/ChangeLog.0: Likewise.
* src/old/textutils/ChangeLog: Likewise.
* src/tests/misc/comm: Likewise.
* src/tests/misc/uniq: Likewise.
* src/tests/mv/dir2dir: Likewise.
* src/cfg.mk (old_NEWS_hash): update with `make update-NEWS-hash`

12 years agotests: avoid LD_PRELOAD lookup error for dlsym
Jim Meyering [Mon, 7 May 2012 20:01:20 +0000 (22:01 +0200)]
tests: avoid LD_PRELOAD lookup error for dlsym

* tests/cp/nfs-removal-race: Link with -ldl.

12 years agocp: handle a race condition more sensibly
Jim Meyering [Fri, 4 May 2012 14:42:31 +0000 (16:42 +0200)]
cp: handle a race condition more sensibly

* src/copy.c (copy_reg): In a narrow race (stat sees dest, yet
open-without-O_CREAT fails with ENOENT), retry the open with O_CREAT.
* tests/cp/nfs-removal-race: New file.
* tests/Makefile.am (TESTS): Add it.
* NEWS (Bug fixes): Mention it.
Reported by Philipp Thomas and Neil F. Brown in
http://bugs.gnu.org/11100

12 years agodoc: NEWS: note when the id/groups bug was introduced
Jim Meyering [Sun, 6 May 2012 21:02:51 +0000 (23:02 +0200)]
doc: NEWS: note when the id/groups bug was introduced

* NEWS (Bug fixes): Note the first affected release.
The id bug was introduced by commit v8.0-112-g719a95a.

12 years agobuild: update gnulib submodule to latest
Jim Meyering [Fri, 4 May 2012 09:02:59 +0000 (11:02 +0200)]
build: update gnulib submodule to latest

12 years agomaint: rely on gnulib's new sys_resource module
Jim Meyering [Fri, 4 May 2012 09:18:28 +0000 (11:18 +0200)]
maint: rely on gnulib's new sys_resource module

* bootstrap.conf (gnulib_modules): Add sys_resource.
* src/sort.c: Remove #if HAVE_SYS_RESOURCE_H guard around inclusion
of <sys/resource.h> and move the inclusion "up" into the alphabetized
list of its peers.  This also avoids a failure of the
sc_prohibit_always_true_header_tests syntax-check rule.
* m4/jm-macros.m4 (gl_CHECK_ALL_HEADERS): Remove sys/resource.h.

12 years agocp,mv,install: provide POSIX_FADV_SEQUENTIAL hint to input
Pádraig Brady [Tue, 1 May 2012 20:50:49 +0000 (21:50 +0100)]
cp,mv,install: provide POSIX_FADV_SEQUENTIAL hint to input

This was inadvertently omitted from v8.5-104-g47076e3,
and gives the same 5% speedup when copying from an SSD.

* src/copy.c (copy_internal): Apply the FADVISE_SEQUENTIAL hint.

12 years agomaint: prohibit an operator at end of line
Jim Meyering [Mon, 30 Apr 2012 08:37:14 +0000 (10:37 +0200)]
maint: prohibit an operator at end of line

Many coding standards, including GNU's, advocate that when
splitting a line near a binary operator, one should put the
operator at the beginning of the continued line, rather than
at the end of the preceding one.  This is for readability:
such operators are relatively important to readability, and
they are more apparent at the beginning of a line than
at the varying-column end of line,
* cfg.mk (sc_prohibit_operator_at_end_of_line): New rule.
Exempt test.c and head.c.

12 years agomaint: adjust comments to avoid FP match on binary-operator-at-EOL
Jim Meyering [Mon, 30 Apr 2012 08:55:18 +0000 (10:55 +0200)]
maint: adjust comments to avoid FP match on binary-operator-at-EOL

* src/ls.c (print_long_format): Reformat comment to avoid "=="
at end of line.
Also, "sortkey" is not a word: s/sortkey/sort key/.
* src/ioblksize.h: Likewise, for "|" from a shell snippet.
* src/runcon.c: Likewise, for "|" in grammar-like usage.

12 years agomaint: with split lines, don't leave an operator at end of line
Jim Meyering [Sun, 1 Jan 2012 00:46:34 +0000 (01:46 +0100)]
maint: with split lines, don't leave an operator at end of line

* src/copy.c (copy_reg): Split an expression before a binary operator,
not after it.
* src/cut.c (set_fields): Likewise.
* src/id.c (main): Likewise.
* src/install.c (setdefaultfilecon): Likewise.
* src/join.c (ignore_case): Likewise.
* src/pr.c (cols_ready_to_print, init_parameters, print_page): Likewise.
* src/stty.c (set_window_size): Likewise.
* src/wc.c (SUPPORT_OLD_MBRTOWC): Likewise.
* src/who.c (scan_entries): Likewise.
* src/test.c (binary_operator): Join a split line.
* src/extent-scan.c (extent_scan_read): Move an ">" from end of line
to beginning of the following.
Likewise for two other expressions.

12 years agocat,cp,mv,install,split: Set the minimum IO block size used to 64KiB
Pádraig Brady [Thu, 21 Jul 2011 07:25:49 +0000 (08:25 +0100)]
cat,cp,mv,install,split: Set the minimum IO block size used to 64KiB

* NEWS: Mention the change in behavior.
* src/ioblksize.h: Add updated test results and
increase value from 32KiB to 64KiB.

12 years agoid: -Zn/-Zr: avoid an invalid diagnostic
Jim Meyering [Fri, 27 Apr 2012 19:30:52 +0000 (21:30 +0200)]
id: -Zn/-Zr: avoid an invalid diagnostic

* src/id.c (main): Using -Z with -r or -n would fail with "id: cannot
print only names or real IDs in default format", in spite of that "-Z",
which specifies a non-default format.  Now, it succeeds and ignores
the -n or -r option.  The error was that the test for default_format
was not updated when I added the new --context (-Z) option in
commit v6.9-33-g5320d0f.

12 years agoid: don't call getcon unnecessarily
Jim Meyering [Fri, 27 Apr 2012 19:24:03 +0000 (21:24 +0200)]
id: don't call getcon unnecessarily

* src/id.c (main): Invocations like "id" and "id -G" would call getcon
to determine the current security context even though that result would
not be used.  Similarly, when POSIXLY_CORRECT is set.  Rearrange
conditionals and hoist the POSIXLY_CORRECT test so that we call
getcon only when necessary.

12 years agomaint: id: minor factorization
Jim Meyering [Fri, 27 Apr 2012 18:44:58 +0000 (20:44 +0200)]
maint: id: minor factorization

* src/id.c (main): Factor out uses of "argc - optind".
Move option-consistency checks to precede the potential getcon call.

12 years agoid,groups: with no user name, print only real and/or effective IDs,
Jim Meyering [Fri, 27 Apr 2012 11:28:32 +0000 (13:28 +0200)]
id,groups: with no user name, print only real and/or effective IDs,

... i.e., don't use the getpw* functions.

Before this change, running groups or id with no user name argument
would include a group name or ID from /etc/passwd.  Thus, under unusual
circumstances (default group is changed, but has not taken effect for a
given session), those programs could print a name or ID that is neither
real nor effective.

To demonstrate, run this:

    echo 'for i in 1 2; do id -G; sleep 1.5; done' \
      |su -s /bin/sh ftp - &
    sleep 1; perl -pi -e 's/^(ftp:x:\d+):(\d+)/$1:9876/' /etc/passwd

Those id -G commands printed the following:

    50
    50 9876

With this change, they print this:

    50
    50

Similarly, running those programs set-GID could make them
print one ID too many.

* src/group-list.c (print_group_list): When username is NULL, pass
egid, not getpwuid(ruid)->pw_gid), to xgetgroups, per the API
requirements of xgetgroups callee, mgetgroups.
When not using the password database, don't call getpwuid.
* NEWS (Bug fixes): Mention it.
* tests/misc/id-setgid: New file.
* tests/Makefile.am (TESTS): Add it.
(root_tests): It's a root-only test, so add it here, too.
Originally reported by Brynnen Owen as http://bugs.gnu.org/7320.
Raised again by Marc Mengel in http://bugzilla.redhat.com/816708.

12 years agomaint: sync up required autoconf version in bootstrap.conf
Stefano Lattarini [Sun, 22 Apr 2012 22:41:05 +0000 (23:41 +0100)]
maint: sync up required autoconf version in bootstrap.conf

* bootstrap.conf ($buildreq): Require autoconf 2.64, not 2.62.  This is
consistent with what is required by AC_PREREQ in configure.ac.

12 years agodoc: fix a grammar nit
Jim Meyering [Fri, 16 Mar 2012 07:31:28 +0000 (08:31 +0100)]
doc: fix a grammar nit

* doc/coreutils.texi (split invocation): s/are/is/ in "P or Q are".

12 years agotests: factor out expensive "pairs" code of misc/stty
Bernhard Voelker [Tue, 10 Apr 2012 08:10:50 +0000 (10:10 +0200)]
tests: factor out expensive "pairs" code of misc/stty

* tests/Makefile.am (TESTS): Add misc/stty-pairs.
* tests/init.cfg (stty_reversible_init_): New function.
(stty_reversible_query_): New function.
* tests/misc/stty: Factor out expensive "pairs" code into new test.
Use new stty_reversible_* functions instead of evaluating static
REV_* variables.
* tests/misc/stty-pairs: Add new test.  Code added from misc/stty.
Mark this as an expensive test.  Skip 'parenb' and 'cread' options,
as these tests are known to fail.  Like in misc/stty, also use
the new stty_reversible_* functions.

12 years agotests: add iutf8 option to misc/stty
Bernhard Voelker [Thu, 5 Apr 2012 06:01:43 +0000 (08:01 +0200)]
tests: add iutf8 option to misc/stty

* tests/misc/stty: Add iutf8 to the list of REV_* options.
That option has been implemented in commit v5.2.1-193-g733e79e.

12 years agomaint: tac: use memcpy, not strcpy
Jim Meyering [Thu, 19 Apr 2012 09:32:04 +0000 (11:32 +0200)]
maint: tac: use memcpy, not strcpy

* src/tac.c (main): Use memcpy, not strcpy, since we know the length.

12 years agomaint: ls: use stpncpy/stpcpy, not strncpy/strcpy
Jim Meyering [Wed, 18 Apr 2012 12:49:22 +0000 (14:49 +0200)]
maint: ls: use stpncpy/stpcpy, not strncpy/strcpy

* src/ls.c (gobble_file): Move a decl "down".
(make_link_name): Do not hard-code '/'.  Use IS_ABSOLUTE_FILE_NAME
and dir_len instead.
Use stpcpy/stpncpy in place of strncpy/strcpy.

12 years agomaint: modernize/clean-up a small function in ls.c
Jim Meyering [Wed, 18 Apr 2012 11:36:11 +0000 (13:36 +0200)]
maint: modernize/clean-up a small function in ls.c

* src/ls.c (make_link_name): Adjust comment style to refer to VARIABLE
names, not 'variable'.
Move each of two declarations "down" to first use.
Compare pointer to NULL, not to 0.
Don't reuse local, "linkbuf" for a different purpose.

12 years agodoc: tweak README-hacking
Jim Meyering [Wed, 18 Apr 2012 18:16:39 +0000 (20:16 +0200)]
doc: tweak README-hacking

* README-hacking: Don't say "...on your hard drive".
That is unnecessary, and now, borderline anachronistic.

12 years agodoc: use @xref{... only at start of a sentence
Jim Meyering [Mon, 16 Apr 2012 18:26:41 +0000 (20:26 +0200)]
doc: use @xref{... only at start of a sentence

* doc/coreutils.texi: Correct many misuses of @xref.

12 years agomaint: replace a use of strcpy in chmod.c with memcpy
Jim Meyering [Mon, 16 Apr 2012 13:12:02 +0000 (15:12 +0200)]
maint: replace a use of strcpy in chmod.c with memcpy

* src/chmod.c (main): Use memcpy rather than strcpy,
since we already have the length handy.

12 years agodoc: remove a little direntry redundancy
Karl Berry [Sat, 14 Apr 2012 08:06:32 +0000 (10:06 +0200)]
doc: remove a little direntry redundancy

* doc/coreutils.texi (Basics direntry): Remove 3rd "Common options."

12 years agofmt: accept new --goal=WIDTH (-g) option
Bruce Korb [Fri, 6 Apr 2012 00:13:14 +0000 (17:13 -0700)]
fmt: accept new --goal=WIDTH (-g) option

Accept -g for BSD/Plan9 compatibility.
* NEWS (New features): Mention it.
* tests/fmt/goal-option: New test.
* tests/fmt/long-line: Rename from tests/fmt-long-line.
* tests/fmt/base: Rename from tests/misc/fmt.
* doc/coreutils.texi: Document it.
* src/fmt.c (main): Accept the new option
(check_for_goals): new function to implement the operands
Based on BSD's and Plan-9's fmt programs.

12 years agocp: change --attributes-only to not truncate existing files
Pádraig Brady [Thu, 12 Apr 2012 11:47:30 +0000 (12:47 +0100)]
cp: change --attributes-only to not truncate existing files

* src/copy.c (copy_reg): Don't truncate an existing file,
to support copying attributes between existing files.
The original use case only considered creating new files,
and it would be a very unusual use case to be relying
on the truncating behavior.
* doc/coreutils.texi (cp invocation): Mention the non
truncating behavior.
* tests/cp/attr-existing: A new test to ensure O_TRUNC skipped.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the change in behavior.

12 years agotests: avoid unnecessary subshells in misc/stty
Andreas Schwab [Wed, 4 Apr 2012 13:06:17 +0000 (15:06 +0200)]
tests: avoid unnecessary subshells in misc/stty

* tests/misc/stty: Don't waste a subshell to perform this:
eval rev=\$REV_$opt.  Fix rev1,rev2 assignments similarly.

12 years agobuild: update gnulib submodule to latest
Jim Meyering [Wed, 4 Apr 2012 12:05:44 +0000 (14:05 +0200)]
build: update gnulib submodule to latest

12 years agotests: correct reversed args to "compare"
Jim Meyering [Wed, 4 Apr 2012 12:29:44 +0000 (14:29 +0200)]
tests: correct reversed args to "compare"

* tests/misc/sort-discrim: Correct reversed args to "compare".
This nit was masked by a bug in maint.mk that effectively disabled
many of the syntax-check rules.

12 years agotests: new syntax-check rule to prohibit use of `...` in tests/
Jim Meyering [Wed, 4 Apr 2012 10:34:22 +0000 (12:34 +0200)]
tests: new syntax-check rule to prohibit use of `...` in tests/

* cfg.mk (sc_prohibit_test_backticks): New rule.  Exempt 3 files.

12 years agotests: remove nearly all remaining backticks
Jim Meyering [Tue, 3 Apr 2012 19:42:48 +0000 (21:42 +0200)]
tests: remove nearly all remaining backticks

* tests/rm/isatty: Remove now-unneeded "# `" line.
* tests/misc/ls-time: Likewise.
* tests/misc/date-sec: Remove stray "`" in comment.
* tests/du/long-sloop: Likewise.
* tests/mv/part-symlink: Replace multi-line `...` by $(...).
* tests/mv/sticky-to-xpart: Likewise.
* tests/rm/fail-2eperm: Likewise.
* tests/ls/nameless-uid: Likewise.
* tests/cp/perm: Likewise.
* tests/cp/preserve-gid: Likewise.
* tests/cp/same-file: Likewise.

12 years agotests: use perl's qx!...! rather than `...`
Jim Meyering [Tue, 3 Apr 2012 19:34:57 +0000 (21:34 +0200)]
tests: use perl's qx!...! rather than `...`

* tests/misc/expr: As above.
* tests/misc/ls-misc: Likewise.
* tests/misc/pwd-long: Likewise.
* tests/misc/uniq: Likewise.

12 years agotests: convert nearly all `...` expressions to $(...)
Jim Meyering [Tue, 3 Apr 2012 18:32:44 +0000 (20:32 +0200)]
tests: convert nearly all `...` expressions to $(...)

Exempt init.sh because it runs before we're assured to have a
shell that groks $(...).  Exempt *.mk because "$" would have to
be doubled, and besides, any `...` expression in a .mk file is
almost certainly evaluated before init.sh is run.  Finally, also
exempt the perl-based tests, because perl's `...` cannot be
converted to $(...).  Do that by running this command:

git grep -l '`.*`' tests \
  | grep -Ev 'init\.sh|\.mk$' | xargs grep -Lw perl \
  | xargs perl -pi -e 's/`(.*?)`/\$($1)/g'

One minor fix-up change was required after that, due to how
quoting differs:
diff --git a/tests/chmod/equals b/tests/chmod/equals
-    expected_perms=$(eval 'echo \$expected_'$dest)
+    expected_perms=$(eval 'echo $expected_'$dest)

Another was to make these required quoting adjustments:
diff --git a/tests/misc/stty b/tests/misc/stty
...
-  rev=$(eval echo "\\\$REV_$opt")
+  rev=$(eval echo "\$REV_$opt")
...
-      rev1=$(eval echo "\\\$REV_$opt1")
-      rev2=$(eval echo "\\\$REV_$opt2")
+      rev1=$(eval echo "\$REV_$opt1")
+      rev2=$(eval echo "\$REV_$opt2")

Also, transform two files that were needlessly excluded above:
(both use perl, but are mostly bourne shell)

  perl -pi -e 's/`(.*?)`/\$($1)/g' \
    tests/du/long-from-unreadable tests/init.cfg

12 years agotests: convert one `...` expression manually
Jim Meyering [Tue, 3 Apr 2012 18:04:20 +0000 (20:04 +0200)]
tests: convert one `...` expression manually

* tests/ls/stat-vs-dirent: Manually convert `(...)` to $(...),
to avoid automatically producing an invalid result.

12 years agotests: fix quoting bug in misc/nohup
Jim Meyering [Sun, 18 Mar 2012 01:33:53 +0000 (02:33 +0100)]
tests: fix quoting bug in misc/nohup

* tests/misc/nohup: Fix invalid quoting.

12 years agodoc: identify/refer to source of each fixed bug in log and in NEWS
Jim Meyering [Tue, 3 Apr 2012 14:14:32 +0000 (16:14 +0200)]
doc: identify/refer to source of each fixed bug in log and in NEWS

* HACKING (Commit log requirements): Describe our policy: when you
fix a bug, put the "git describe" string of the bug-introducing commit
in your commit log and put the "fixed-in-release version number"
in the NEWS blurb.

12 years agotests: avoid spurious misc/expr failure on AIX 6.1
Jim Meyering [Mon, 2 Apr 2012 20:32:57 +0000 (22:32 +0200)]
tests: avoid spurious misc/expr failure on AIX 6.1

* tests/misc/expr: Avoid spurious failure on AIX 6.1 due to
differing regexp diagnostic.  Reported by Michael Felt.

12 years agochmod: undo previous change
Paul Eggert [Wed, 28 Mar 2012 20:26:12 +0000 (13:26 -0700)]
chmod: undo previous change

It's not portable; see <http://bugs.gnu.org/11108#17>.
* src/chmod.c, NEWS: Undo previous change.

12 years agochmod: fix symlink race condition
Paul Eggert [Tue, 27 Mar 2012 17:02:59 +0000 (10:02 -0700)]
chmod: fix symlink race condition

* NEWS: Document this.
* src/chmod.c (process_file): Don't follow symlink if we
think the file is not a symlink.

12 years agotests: remove temporary skip for sort-stale-thread-mem failure
Jim Meyering [Mon, 26 Mar 2012 18:56:44 +0000 (20:56 +0200)]
tests: remove temporary skip for sort-stale-thread-mem failure

* tests/misc/sort-stale-thread-mem: Invoke framework_failure_, now,
hoping that valgrind is fixed (or we add exclusions) before the
next release.

12 years agomaint: post-release administrivia
Jim Meyering [Mon, 26 Mar 2012 12:15:35 +0000 (14:15 +0200)]
maint: post-release administrivia

* NEWS: Add header line for next release.
* .prev-version: Record previous version.
* cfg.mk (old_NEWS_hash): Auto-update.

12 years agoversion 8.16 v8.16
Jim Meyering [Mon, 26 Mar 2012 12:06:43 +0000 (14:06 +0200)]
version 8.16

* NEWS: Record release date.

12 years agotests: work around F17-valgrind sort-stale-thread-mem failure
Jim Meyering [Mon, 26 Mar 2012 11:52:58 +0000 (13:52 +0200)]
tests: work around F17-valgrind sort-stale-thread-mem failure

* tests/misc/sort-stale-thread-mem: Skip upon known failure.