platform/upstream/coreutils.git
11 years agomaint: adjust instructions to run a single test
Pádraig Brady [Thu, 6 Dec 2012 09:29:34 +0000 (09:29 +0000)]
maint: adjust instructions to run a single test

* README: Adjust as per the recent changes introduced
when switching to non recursive make.

11 years agomaint: remove now auto-added entry from THANKS.in
Bernhard Voelker [Wed, 5 Dec 2012 10:47:18 +0000 (11:47 +0100)]
maint: remove now auto-added entry from THANKS.in

The syntax-check sc_THANKS_in_duplicates complained about
that excess entry.

* THANKS.in (Colin Watson): Remove entry, now that it will be
automatically included in the generated THANKS file.

11 years agomaint: remove a redundant odd sized alloc from factor.c
Pádraig Brady [Fri, 30 Nov 2012 15:08:31 +0000 (15:08 +0000)]
maint: remove a redundant odd sized alloc from factor.c

* src/factor.c (mp_factor_init): Init the pointers with NULL,
which xrealloc (or realloc) handles fine.

11 years agofactor: fix infinite loop on 32 bit powerpc
Colin Watson [Thu, 29 Nov 2012 19:37:30 +0000 (19:37 +0000)]
factor: fix infinite loop on 32 bit powerpc

Both Debian and Ubuntu builds of coreutils 8.20 hang while running the
test suite on powerpc, which is reproducible using 'factor 122'.

This turns out to be somewhat related to http://bugs.gnu.org/12754,
but not quite the same.  uintmax_t is 64 bits, but the cntlzw
instruction takes 32-bit operands, and the cntlzd option is only
available on 64-bit hardware.

* src/longlong.h: Add an _LP64 check around the PPC64 code,
so that this falls back to the C implementations.
* NEWS: Mention the fix.

11 years agocut: do not print extraneous delimiters in some unusual cases
Jim Meyering [Sat, 24 Nov 2012 19:36:15 +0000 (11:36 -0800)]
cut: do not print extraneous delimiters in some unusual cases

When printing output delimiters, and when a to-EOL range subsumes
at least one other range, cut would mistakenly print delimiters for
the subsumed range.  This bug was probably introduced via commit
v5.2.1-639-g847e066.
* src/cut.c (set_fields): Ignore any range that is subsumed by a
to-EOL range.  Also, move two declarations down.
* tests/misc/cut.pl: Add tests to exercise this.
* NEWS (Bug fixes): Mention it.
Reported by Marcel Böhme in http://bugs.gnu.org/12966

11 years agocut: treat -b2-,3- like -b2-, not like -b3-
Jim Meyering [Sat, 24 Nov 2012 07:09:10 +0000 (23:09 -0800)]
cut: treat -b2-,3- like -b2-, not like -b3-

* src/cut.c (set_fields): When two right-open-ended ranges are
specified, don't blindly let the latter one take precedence over
the former.  Instead, use the union of the ranges.
* tests/misc/cut.pl: Add tests to exercise this.
* NEWS (Bug fixes): Mention it.
Reported by Marcel Böhme in http://bugs.gnu.org/12966
Thanks to Berhard Voelker for catching log and NEWS typos.

11 years agodoc: cp: clarify behavior of the --preserve=xattr option
Bernhard Voelker [Sat, 24 Nov 2012 15:04:44 +0000 (16:04 +0100)]
doc: cp: clarify behavior of the --preserve=xattr option

* doc/coreutils.texi (cp invocation): Enhance documentation
of the --preserve=xattr option regarding the preservation
of ACLs, SELinux contexts and capabilities: the user may
notice this only when not specifying --preserve=mode
and --preserve=context, too, i.e., otherwise, these attributes
are preserved anyway.

11 years agodoc: update info cross reference to bash
Pádraig Brady [Fri, 26 Oct 2012 14:46:04 +0000 (15:46 +0100)]
doc: update info cross reference to bash

* doc/coreutils.texi (tee invocation): Reference
the bash manual rather than bashref, as the latter
is more likely to work on newer systems.

11 years agotests: use sub-second timeouts to speed up a timeout test
Pádraig Brady [Mon, 29 Oct 2012 00:46:04 +0000 (00:46 +0000)]
tests: use sub-second timeouts to speed up a timeout test

* tests/misc/timeout.sh: Take advantage of recent support for
sub-second timeouts to decrease runtime from about 6s to 2s.

11 years agodoc: clarify that renice is needed to adjust niceness
Pádraig Brady [Thu, 22 Nov 2012 14:25:46 +0000 (14:25 +0000)]
doc: clarify that renice is needed to adjust niceness

* doc/coreutils.texi (nice invocation): Ensure there is no
ambiguity in the summary in relation to nice being able
to adjust the niceness of an existing process.
Reference the renice command.
* man/nice.x: Reference renice (1)

11 years agotests: accept EEXIST from rm -d
Pádraig Brady [Thu, 22 Nov 2012 10:36:31 +0000 (10:36 +0000)]
tests: accept EEXIST from rm -d

* tests/rm/d-2.sh: EEXIST is a valid error on some systems.
Reported by Michael Felt on AIX 6.1

11 years agotests: don't rely on sed -i being available
Pádraig Brady [Thu, 22 Nov 2012 10:07:25 +0000 (10:07 +0000)]
tests: don't rely on sed -i being available

* tests/df/df-output.sh: sed --in-place is not generally available.
Also add a couple of simplifications from Bernhard Voelker.
Removing all spaces, rather than just leading spaces, suffices.
Searching for ' --output' in unadjusted df --help, suffices.

11 years agoseq: ensure correct output width for scientific notation input
Pádraig Brady [Fri, 23 Nov 2012 03:06:07 +0000 (03:06 +0000)]
seq: ensure correct output width for scientific notation input

* src/seq.c (scan_arg): Calculate the width more accurately
for numbers specified using scientific notation.
* tests/misc/seq.pl: Add tests for cases that were mishandled.
* NEWS: Mention the fix.
* THANKS.in: Reported by Marcel Böhme.
Fixes http://bugs.gnu.org/12959

11 years agodf: reorder default field list of --output option
Bernhard Voelker [Thu, 22 Nov 2012 14:40:54 +0000 (15:40 +0100)]
df: reorder default field list of --output option

As the inodes information is usually not so much of interest,
and some file systems including btrfs do not even provide it,
reading of the full df --output is easier when the block
statistic fields come just left of the last field, the mount
point.

* src/df.c (all_args_string): Move the inodes fields before
the block fields.
(usage): Likewise.
* tests/df/df-output.sh: Likewise.
* doc/coreutils.texi (df invocation): Likewise.  Additionally,
explicitly mention the default order of the --output option.

11 years agoinstall: fix security race
Paul Eggert [Wed, 21 Nov 2012 02:10:21 +0000 (18:10 -0800)]
install: fix security race

* NEWS: Document this.

11 years agoinstall: fix security race
Paul Eggert [Tue, 20 Nov 2012 21:15:34 +0000 (13:15 -0800)]
install: fix security race

* src/copy.c (copy_internal): Use DST_MODE_BITS, not SRC_MODE.
See Bernhard R. Link in <http://bugs.gnu.org/12947> and in
<http://bugs.debian.org/598018>.

11 years agonl: remove deprecated --page-increment option
Bernhard Voelker [Tue, 20 Nov 2012 10:06:46 +0000 (11:06 +0100)]
nl: remove deprecated --page-increment option

The above option has been deprecated since coreutils-7.5
by commit v7.4-129-g718b279.

* src/nl.c (PAGE_INCREMENT_OPTION_DEPRECATED): Remove enum.
(longopts): Remove "page-increment" entry.
(main): Remove PAGE_INCREMENT_OPTION_DEPRECATED case.
* NEWS (Changes in behavior): Mention the change.

Reported by Marcel Böhme in <http://bugs.gnu.org/12940>.

11 years agodoc: remove already implemented items from TODO
Bernhard Voelker [Sun, 11 Nov 2012 11:07:47 +0000 (12:07 +0100)]
doc: remove already implemented items from TODO

* TODO (renice): The renice program is part of util-linux for
years now. Remove entry.
(dd): The option status=none has been implemented in commit
v8.19-143-g7331ab5. Remove entry.

11 years agocut: do not accept the invalid range 0-
Bernhard Voelker [Sun, 18 Nov 2012 21:20:16 +0000 (22:20 +0100)]
cut: do not accept the invalid range 0-

The command "echo 12345 | cut -b 0-" prints an empty line while
it should fail with "fields and positions are numbered from 1".

* src/cut.c (set_fields): Add a diagnostic for the invalid open
range which starts with Zero, i.e., the range 0-.
* tests/misc/cut.pl: Add tests to ensure the range 0- fails for
fields (-f) and for positions (-b, -c).
* NEWS: Mention the fix.

Reported by Marcel Böhme in <http://bugs.gnu.org/12903>.

11 years agobuild: fix compilation failure on x32
Daniel Schepler [Sun, 18 Nov 2012 18:04:54 +0000 (10:04 -0800)]
build: fix compilation failure on x32

* src/factor.c [HAVE_ATTRIBUTE_MODE]: Fix typo in #if test:
s/HAVE_LONG_LONG/HAVE_LONG_LONG_INT/.  Otherwise, factor.c would
elicit assembler errors on x32: it was incorrectly defining DItype
to long instead of long long.  Patch and report in
http://bugs.debian.org/693337;  Mike Stone notified upstream.

11 years agomaint: reenable accidentally-disabled cppi-check syntax-check rule
Jim Meyering [Sun, 18 Nov 2012 17:51:48 +0000 (09:51 -0800)]
maint: reenable accidentally-disabled cppi-check syntax-check rule

* cfg.mk (exclude_file_name_regexp--sc_preprocessor_indentation): Fix
typo that disabled the sc_preprocessor_indentation syntax-check rule
by exempting all files.  s/__ll/_ll/  The typo was introduced in
commit v8.19-157-g759ebcb.

11 years agomaint: correct indentation of W_TYPE_SIZE-defining cpp directives
Jim Meyering [Sun, 18 Nov 2012 17:45:14 +0000 (09:45 -0800)]
maint: correct indentation of W_TYPE_SIZE-defining cpp directives

* src/factor.c: Indent cpp directives to reflect their nesting.

11 years agomaint: avoid i686-specific syntax-check failure
Jim Meyering [Sun, 18 Nov 2012 17:16:17 +0000 (09:16 -0800)]
maint: avoid i686-specific syntax-check failure

* cfg.mk (_gl_TS_unmarked_extern_vars): Define.

11 years agodoc: explain why dd is called "dd"
Paul Eggert [Sat, 17 Nov 2012 16:23:47 +0000 (08:23 -0800)]
doc: explain why dd is called "dd"

* doc/coreutils.texi (dd invocation): Mention JCL.

11 years agofactor: tidy up primes.h again
Paul Eggert [Sat, 17 Nov 2012 00:51:50 +0000 (16:51 -0800)]
factor: tidy up primes.h again

See Stefano Lattarini in <http://bugs.gnu.org/12899>.
* src/local.mk (BUILT_SOURCES): Put $(top_srcdir)/src/primes.h here
(MAINTAINERCLEANFILES): ... instead of here.

11 years agofactor: cleanup for primes.h
Paul Eggert [Tue, 13 Nov 2012 15:43:08 +0000 (07:43 -0800)]
factor: cleanup for primes.h

* .gitignore: Add src/primes.h back, since it's no longer
in the repository.

11 years agomaint: avoid unnecessary #include to fix syntax-check failure
Jim Meyering [Tue, 13 Nov 2012 06:03:01 +0000 (07:03 +0100)]
maint: avoid unnecessary #include to fix syntax-check failure

* src/factor.c: Remove unneeded #inclusion of"verify.h".
It's already included via system.h.

11 years agofactor: improve primes.h change
Paul Eggert [Tue, 13 Nov 2012 05:10:17 +0000 (21:10 -0800)]
factor: improve primes.h change

This follows suggestions by Jim Meyering in
<http://bugs.gnu.org/12841#34>.
* src/make-prime-list.c (print_wide_uint): Change "nested" argument
to "nesting", and use it to avoid outputting lines that are too long.
* src/primes.h: Remove from git.  This can be generated by a
maintainer.  It's nicer to do so on a host with at least 128-bit
arithmetic.

11 years agofactor: maintainer builds primes.h, not builder
Paul Eggert [Mon, 12 Nov 2012 16:32:04 +0000 (08:32 -0800)]
factor: maintainer builds primes.h, not builder

With this change, the maintainer builds primes.h and it is part of
the tarball.  primes.h's contents are not architecture-specific.
* .gitignore: Remove /src/primes.h.
* src/factor.c: Include verify.h.
(W): New constant.  Verify that uintmax_t lacks holes
and that W is no wider than the integers used to generate primes.h.
* src/local.mk (EXTRA_DIST): Add src/primes.h.
(BUILT_SOURCES, CLEANFILES): Remove src/primes.h.
($(top_srcdir)/src/primes.h): Rename from src/primes.h.
Do not depend on src/make-prime-list.  Instead, use sub-make to
build, so that we build primes.h only if it does not exist.
* src/make-prime-list.c: Include <limits.h>, for ULONG_MAX.
(wide_uint): Define to uintmax_t or unsigned __int128 if not #defined.
(struct prime, binvert, process_prime): Use it instead of uintmax_t.
(print_wide_uint): New function.  This generates the proper pinv
value regardless of the width of uintmax_t on the target, so long
as the width doesn't exceed that of the width of wide_uint on the
maintainer host that generated src/primes.h.
(output_primes): Use it.  Output WIDE_UINT_BITS, too.  Let the
target compute its own lim, since its uintmax_t may be narrower
than ours.
(SZ): Remove.
* src/primes.h: New file, generated with 128-bit integers and usable
on any host where uintmax_t's width is no greater than 128 bits.

11 years agofactor: port to systems with rpl_malloc
Paul Eggert [Mon, 12 Nov 2012 16:16:30 +0000 (08:16 -0800)]
factor: port to systems with rpl_malloc

* src/make-prime-list.c (malloc): Undef.  This fixes a problem on
AIX 8.20 reported by Michael Felt in <http://bugs.gnu.org/12841>.

11 years agotests: fix factor's tests to use coreutil's own sha1sum
Bernhard Voelker [Fri, 9 Nov 2012 14:09:05 +0000 (15:09 +0100)]
tests: fix factor's tests to use coreutil's own sha1sum

The test used the shasum utility which seems to belong to the
perl package. On SLES-10.4, perl doesn't include this yet:

  + seq 0 10000000
  + factor
  + shasum -c --status exp
  ./tests/factor/t00.sh: line 30: shasum: command not found
  + Exit 1

It is better to use our own stuff anyway.

* tests/factor/run.sh: s/shasum/sha1sum/. Additionally, add
sha1sum to the print_ver_ call.

11 years agodoc: chcon: add descriptions for three undocumented options
Benno Schulenberg [Mon, 15 Oct 2012 17:37:34 +0000 (19:37 +0200)]
doc: chcon: add descriptions for three undocumented options

These were missed in this related change v8.14-104-g44e20cd

* src/chcon.c (usage): Mention the two --preserve-root options.
* doc/coreutils.texi (chcon invocation): Plus the --dereferece option.

11 years agodoc: with cp -n, option -f is not redundant but ignored
Benno Schulenberg [Mon, 15 Oct 2012 11:06:37 +0000 (13:06 +0200)]
doc: with cp -n, option -f is not redundant but ignored

* src/cp.c (usage): Replace "redundant" with "ignored".
* doc/coreutils.texi (cp invocation): Likewise.

11 years agodf: port the new df test to POSIX sed, larger file systems
Paul Eggert [Fri, 9 Nov 2012 09:11:18 +0000 (01:11 -0800)]
df: port the new df test to POSIX sed, larger file systems

* tests/df/df-output.sh: For the test "df -B1K --output=size",
do not assume that the file system size fits in 9 bytes; it
might be larger than that, so omit leading space.  Also, use
portable 'sed' commands: POSIX says sed commands inside { } should
all end in newline.

11 years agodf: add a test for the --output option
Bernhard Voelker [Sun, 23 Sep 2012 20:29:25 +0000 (22:29 +0200)]
df: add a test for the --output option

* tests/df/df-output.sh: Add a test case.
* tests/local.mk (all_tests): Mention the test.
* cfg.mk (sc_file_system): Exempt the test from this syntax-check.

11 years agodf: document the new --output option
Bernhard Voelker [Sat, 29 Sep 2012 16:44:18 +0000 (18:44 +0200)]
df: document the new --output option

* src/df.c (usage): Add a short description of --output and its
available field names for use in the optional argument.
* doc/coreutils.texi (df invocation): Add the new option with more
details and a few examples.
* NEWS (New features): Mention the new option.
(Changes in behvaior): Mention the new placeholder for fields
in the "total" line.

11 years agodf: add --output to select which fields to display
Bernhard Voelker [Thu, 30 Aug 2012 12:58:22 +0000 (14:58 +0200)]
df: add --output to select which fields to display

This supports changing the order of the fields displayed,
and also allows the simultaneous display of inode and block fields.

src/df.c (get_dev): Factor out calling get_header to ...
(main): ... here.  Call print_table only if file_systems_processed.

src/df.c (Displayable fields): Rename DEV_FIELD to SOURCE_FIELD.
Rename TYPE_FIELD to FSTYPE_FIELD.  Rename FREE_FIELD to AVAIL_FIELD.
Rename MNT_FIELD to TARGET_FIELD.

* src/df.c (display_field_t): Turn loose enum definition of the
displayable fields into a typedef.  Add the inode fields ITOTAL_FIELD,
IUSED_FIELD, IAVAIL_FIELD, IPCENT_FIELD.
(field_data_t): Define structure to hold the display field, the
caption, the width and the alignment for each field of the above
type.
(field_data): Add array the values of field data for each display
field.
(headers, alignments, widths): Remove arrays.
(columns): Add a pointer to the storage for the array of the actual
output columns, i.e., fields.
(ncolumns): Add counter for the current output columns.
(alloc_table_row): Allocate the dynamic ncolumns value of strings.
(print_table): Loop over ncolumns instead of constant NFIELDS.  Rename
loop variable 'field' to 'col' to avoid ambiguity with the 'field'
element in the columns structure.  Adjust the condition for printing
the last column by comparing with the column number instead of the
field name (TARGET_FIELD).  Use the width and the alignment stored in
the columns data.
(alloc_field): Add new function to allocate a field in the columns
array.
(get_field_list): Add new function to fill the array of output columns
for each mode.
(get_header): Loop over ncolumns instead of constant NFIELDS.  Rename
the loop variable 'field' to 'col' to avoid ambiguity with the 'field'
element in the columns structure.  Remove the code for continuing the
loop if the current column is the file system type and print_type is not
active (which is now impossible).  Store the cell in the columns store
along with the new width.
(get_dev): Loop over ncolumns instead of the constant NFIELDS.  Rename
the loop variable 'field' to 'col' to avoid ambiguity with the 'field'
element in the columns structure; move the definition down to where it
is used first.  Add cases for the inode fields ITOTAL_FIELD,
IUSED_FIELD, IAVAIL_FIELD and IPCENT_FIELD.  Store the cell in the
columns store along with the new width.
(main): Use new get_field_list function to fill the list of output
columns.

* src/df.c (print_table): Instead of fputs()ing directly, apply
ambsalign on the last field, too.  Use the new MBA_NO_RIGHT_PAD flag
for this.

* src/df.c (TOTAL_OPTION): Add new enum value.
(long_options): Use it for the "total" option instead of 'c'.
(main): Likewise.

* src/df.c (get_dev): Remove condition to copy the fstype into the
FSTYPE_FIELD - based on whether print_type is non-Null.  Since the
introduction of get_field_list(), there are only fields added to
the columns array which have to be added.

* src/df.c (get_dev): Guard the summing up of the values for the
grand total: only do it if we have to print the total and if the
current invocation is not for processing it.

* src/df.c (main): Pass a hyphen "-" for the mount point name
to get_dev.
(get_dev): As the mount_point is now always there,
remove the condition and the else case for the TARGET_FIELD.
Instead, simply copy the mount_point.
All cells are now always present.  Therefore, add an assertion
statement if one was not.  Furthermore, hide the problematic
characters unconditionally.
(print_table): Remove the skipping of empty cells.
* tests/df/total-verify.sh: Accommodate to the new "-" in the
target field of the summary line.
* NEWS: Mention the change in behavior.

* src/df.c (field_type_t): Add new typedef of 3 enums to distinguish
between block, inode and other fields.
(field_data_t): Add field_type member of the above new type.
(field_data): Add default values for the above field_type,
indicating whether a field contains block values, inode values
or other, generic values.
(field_values_t): Add this struct to store the field values, used
by and factored out from get_dev to be able to define such a struct
for both the inode and the block values.
(get_field_values): Add this function to obtain the block values
and the inode values from the file system usage, used by and
factored out from get_dev.
(add_to_grand_total): Add this function to sum the values of the
current mount point up for the grand total, used by and factored
out from get_dev.
(get_dev): Move the definition of the variables fsu, buf, pct and
cell down to where they are used first to give them a better scope.
Factor out input_units, output_units, total, available,
negate_available, available_to_root, used and negate_used into the
above struct field_values_t.
Factor out the mapping of the fsu values to the above variables
into above function get_field_values.
Factor out the summing up of the grand total values into the
above function add_to_grand_total.
Define block_values and inode_values of the new type and call the
new get_field_values to fill them from the fsu values.
Call the above function add_to_grand_total for summing up the
values for the grand total.
Inside the loop over all fields, define a variable 'v' to point
to either the block_values or the inode_values, depending on the
current field's field_type.  Change the code in the cases
TOTAL_FIELD/ITOTAL_FIELD, USED_FIELD/IUSED_FIELD, AVAIL_FIELD/
IAVAIL_FIELD and PCENT_FIELD/IPCENT_FIELD to use the field values
where 'v' is pointing to, i.e., either the block_values or the
inode_values.

* src/df.c (main): Remove setting of grand_fsu.fsu_blocks in the
inode_format case as this is no longer needed and would lead to
wrong results once when mixed block/inode fields will be used.

* src/df.c (main): Cleanup the code at the end regarding
file_systems_processed to make the code clearer.

* src/df.c (inode_format): Remove variable.
(main): Remove initialization of the above variable.
In getopts loop, directly set the header_mode to INODES_MODE
instead of using the above variable.  Afterwards, remove the
mapping to INODES_MODE as it is already set.

* src/df.c (posix_format): Move variable ...
(main): ... to here.

* src/df.c (print_table): Enhance the comment about 2-line format
in cases where the SOURCE_FIELD exceeds 20 chars, as such
behavior has been removed long ago by commit v8.10-40-g99679ff.

* src/df.c (Display modes): Add OUTPUT_MODE, remove unused NMODES.
(display_field_t): Remove unnecessary NFIELDS.
(field_data_t): Add member 'arg' for the field name in the --output
argument.  Add member 'used' to remember if a field is already used
in the columns array.
(field_data): Add values for the above new members arg and used.
(all_args_string): Add variable which represents the argument for
the --output option which includes all fields.
(OUTPUT_OPTION): Add enum to identify the long --output option.
(long_options): Add optional-argument --output option.
(alloc_field): Assert that the field is not already used.
Mark the field as used.
(decode_output_arg): Add function to parse the comma-separated
field list passed to the --output option in order to add the
appropriate fields to the columns array.
(get_field_list): Add case for the new OUTPUT_MODE to add all
available fields to columns in the case the --output option
has been passed without any values.  Use the comma-separated
field list form to pass to decode_output_arg to keep the field
header mapping for the OUTPUT_MODE only on one place.
(main): Define format string msg_mut_excl to be used in the
following checks whether the use of --output and the other
option is mutually exclusive.
In the getopt_long loop, add a check to the case for the -i option
to issue an error message when it is used together with --output;
Likewise for -T and -P.
Add a new case for OUTPUT_OPTION, together with similar checks as
above and eventually passing the optarg to decode_output_arg.
After the getopt_long loop, consider the OUTPUT_MODE case in order
not to run into -h or -P mode.

* src/df.c (get_dev): Also xstrdup the dev_name, and free it
afterwards to silence a valgrind warning about definitely lost
memory.
(main): Free the columns store to silence valgrind, guarded by
the IF_LINT macro.

* src/df.c (main): Pass "total" as the mount point to get_dev if
the SOURCE_FIELD is not among the columns to output.
* tests/df/df-output.sh: Change the test to ensure the content of
the target field of the grand total line: if the source field is
present, then the target should be "-", else the target field should
be "target".
* NEWS (Changes in behavior): Enhance the exiting NEWS entry.
* doc/coreutils.texi (df invocation): Document the content of the
source and target field in the grand total line.

* src/df.c (main): Add another condition to the need_fs_type
parameter of read_file_system_list whether the FSTYPE_FIELD is
used or not.

* src/df.c (get_header): Indicate the block size used,
in the "size" header, when using --output without -h.
* tests/df/df-output.sh: Adjust for, and add an extra test for,
the new behavior.

11 years agomaint: fix factor's test file name pattern in .gitignore
Bernhard Voelker [Mon, 5 Nov 2012 19:35:13 +0000 (20:35 +0100)]
maint: fix factor's test file name pattern in .gitignore

* .gitignore: Adapt the entry for the files generated during
the factor tests (see v8.20-9-g1cace4a).

11 years agotimeout: add --preserve-status to always propagate the exit status
Ángel González [Mon, 29 Oct 2012 00:36:08 +0000 (00:36 +0000)]
timeout: add --preserve-status to always propagate the exit status

It's useful for commands that support running for an indeterminite
amount of time, to not return a specific timeout exit status (124),
and instead let the command handle the timeout signal and return
a status for the work done so far.

* doc/coreutils.texi (timeout invocation): Describe the new option.
* src/timeout.c (preserve_status): A new global boolean to
enable the --preserve-status behavior.
(usage): Describe the new option.
(main): Don't return EXIT_TIMEOUT of preserve_status is set.
* tests/misc/timeout.sh: Add a test for the new option.

11 years agomaint: fix the error message from sc_check-I18N-AUTHORS
Pádraig Brady [Sun, 4 Nov 2012 00:55:57 +0000 (00:55 +0000)]
maint: fix the error message from sc_check-I18N-AUTHORS

* cfk.mk (sc_check-I18N-AUTHORS): Fix the quoting so
you don't get a 'command not found' error.

11 years agobuild: avoid build failure on some HPPA systems
Pádraig Brady [Tue, 30 Oct 2012 02:02:05 +0000 (02:02 +0000)]
build: avoid build failure on some HPPA systems

* src/longlong.h: Restrict some HPPA assembly variants to PA RISC V2.0.
Note we also avoid this assembly for ilp32 runtimes, since even though
the assembly is accepted there, it's not safe as the context can get
clobbered between the 'add' and 'add,dc'.
This fixes a compile failure with newer HPPA systems with default
GCC CPU options.
Reported by John David Anglin

11 years agobuild: don't assume uintmax_t is 64 bits
Pádraig Brady [Tue, 30 Oct 2012 02:15:36 +0000 (02:15 +0000)]
build: don't assume uintmax_t is 64 bits

This was not seen to be an issue in practise,
but to make the code more robust, don't assume
uintmax_t is 64 bits.

* src/factor.c (W_TYPE_SIZE): Define based on integer limits.
* src/make-prime-list.c (output_primes): Define format width
based on integer limits.

11 years agobuild: don't rely on support for '%j' printf format
Pádraig Brady [Tue, 30 Oct 2012 02:12:23 +0000 (02:12 +0000)]
build: don't rely on support for '%j' printf format

* src/factor.c (print_uintmaxes): Replace with PRIuMAX.
* src/join.c (check_order): Likewise.
* cfg.mk (sc_check-j-printf-format): Add a syntax-check rule
to flag new cases of this.

11 years agobuild: don't rely on support for '%*j' printf format
Pádraig Brady [Mon, 29 Oct 2012 02:27:24 +0000 (02:27 +0000)]
build: don't rely on support for '%*j' printf format

* src/make-prime-list.c: Hardcode the uintmax_t width
to 16 hex digits (64 bit), to avoid this compile issue
on HPUS systems at least.

11 years agotests: fix syntax error in setuidgid_has_perm_
Bernhard Voelker [Thu, 1 Nov 2012 15:50:51 +0000 (16:50 +0100)]
tests: fix syntax error in setuidgid_has_perm_

An invalid sed expression lead to the following error:
  + sed -n 'ls/.* //p'
  sed: -e expression #1, char 2: extra characters after command
Use "one" instead of "el".
Bug introduced in v8.19-111-g51a4b04.

* init.cfg (setuidgid_has_perm_): s/ls/1s/.
* NEWS (Build-related): Mention the fix.

11 years agotests: shorten factor's inordinately-long test file names
Bernhard Voelker [Sat, 27 Oct 2012 11:24:18 +0000 (13:24 +0200)]
tests: shorten factor's inordinately-long test file names

Besides what the subject says, this commit moves the test data
for the factor tests from tests/local.mk into the directory
tests/factor/ where it belongs.

* tests/local.mk (EXTRA_DIST): Add new tests/factor/create-test.sh.
(p,q,t1,t2) Factor out the factor-related magic numbers.
(factor_tests): Rename the test names to t{00..36}.sh. Factor out
the triples of test data.
($(factor_tests)): Add dependency to new
tests/factor/create-factor.sh.
Call that script to generate the test scripts.
* tests/factor/run.sh: Turn this script into a template, and
therefore remove it's executable permission bit.
Add template variables START, END and CKSUM, replacing the code
to split the test data from the test script's file name.
Use the new template variables in the call to seq and for
creating the exp file.
* tests/factor/create-test.sh: Add new script to create the
test scripts from the template tests/factor/run.sh.
Use test data and magic numbers factored out from the above
files. Let the script also change the __TEMPLATE__ line in
run.sh to make clear that the test scripts are generated.
* cfg.mk (sc_tests_list_consistency): Exempt the new test.
(exclude_file_name_regexp--sc_prohibit_test_backticks):
Likewise.

Improved-by: Stefano Lattarini
Improved by: Jim Meyering

11 years agobuild: man page generation: degrade gracefully when perl is lacking
Stefano Lattarini [Tue, 11 Sep 2012 18:54:30 +0000 (20:54 +0200)]
build: man page generation: degrade gracefully when perl is lacking

Since commit v8.19-118-g57da212, our 'dist-hook' rule tweaked the
distributed Makefile.in to make each man page 'man/foo.1' depend
on the corresponding source 'src/foo.c' rather than the corresponding
program 'src/foo'.  That was done to accommodate systems without
perl, which cannot run help2man to regenerate the manpage after
its corresponding program has been built.

This seems a right and proper graceful degradation, in that the
man pages dependencies are still 100% correct in a git checkout,
while being more lax but "more portable" in a distribution tarball.
Alas, that is not the case in practice, as it turns out the tweaked
Makefile makes the building of man pages unreliable and potentially
incorrect!

In fact, assume that instead of the correct a dependency:

    man/ls.1: src/ls

we have the laxer one:

    man/ls.1: src/ls.c

and think of what happens if a user modifies, say, 'src/ls.c', and then
runs "make -j4" to rebuild everything.  The make process will see that
it has to rebuild the man page 'man/ls.1' (because its prerequisite
'src/ls.c' has changed), but won't see that it has to rebuild 'src/ls'
*before* re-running 'help2man' to generate that man page; so, if
'man/ls.1' is rebuilt before 'src/ls' (which can happen with concurrent
make), our user will get either a build error (if 'src/ls' did non
exist) or, worse, a man page with an up-to-date timestamp but an
out-of-date content.  And what's even worse in all of this is that
this problem will be present also for users who have perl installed:
this is not a "graceful degradation" at all!

In our situation, the best and simplest way to implement a graceful
degradation it to keep the correct dependencies for man pages (that
is, "man/ls.1: src/ls"), and if perl is not present, just generate
dummy man pages reporting that built-time issue and redirecting the
user back to either the info documentation or the '--help' output.

As a consequence of this change, we also stop distributing man pages,
since they will now be generated unconditionally.

* Makefile.am (do-not-require-help2man): Remove.
(dist-hook): Don't depend on it.
* man/local.mk: Remove an obsolete comment.
(EXTRA_DIST): Stop distributing generated man pages.
($(EXTRA_MANS)): This no longer needs to depend on $(all_programs).
(MAINTAINERCLEANFILES): $(ALL_MANS) Do not list it here, and ...
(CLEANFILES): ... list it here, instead.
(.x.1): Instead of warning if perl is missing, but then trying to run
'help2man' unconditionally, simply run ...
(run_help2man): ... the command referenced by this new variable, that
expands to a proper invocation of 'help2man' if perl is present, and
to an invocation of a shell script generating a dummy manpage if it
is not.
(EXTRA_DIST): Distribute that shell script.
* man/dummy-man: New shell script.
* NEWS (Build-related): Mention this.
Fixes coreutils http://bugs.gnu.org/12715.

11 years agomaint: tweak sc_check-I18N-AUTHORS
Jim Meyering [Thu, 25 Oct 2012 16:35:34 +0000 (18:35 +0200)]
maint: tweak sc_check-I18N-AUTHORS

* cfg.mk (sc_check-I18N-AUTHORS): Remove unnecessary subshell;
add a self-explanatory diagnostic.

11 years agomaint: remove an obsolete test comment
Jim Meyering [Thu, 25 Oct 2012 11:41:45 +0000 (13:41 +0200)]
maint: remove an obsolete test comment

* tests/du/bind-mount-dir-cycle.sh: Remove obsolete comment
spotted by Gilles Espinasse.

11 years agopr: fix -n to pad consistently and not crash
Pádraig Brady [Wed, 24 Oct 2012 09:55:13 +0000 (10:55 +0100)]
pr: fix -n to pad consistently and not crash

* src/pr.c: Replace the code to truncate the most significant
digits of line numbers, with much simpler string manipulation
that supports arbitrary widths.  Before this, specifying a
width >= 32 to -n would result in a divide by zero error.
Also remove the inconsistent padding with zeros and spaces, which
would result in zero padding for widths 12 and 15.
* tests/pr/pr-tests.pl: Added a test to ensure no zero padding,
and also a test for the divide by zero case.
* NEWS: Mentioned the fix
Reported by Ondrej Oprala

11 years agobuild: ensure factor links the iconv library
Pádraig Brady [Thu, 25 Oct 2012 09:59:23 +0000 (10:59 +0100)]
build: ensure factor links the iconv library

* src/local.mk (src_factor_LDADD): Append $(LIBICONV).
* crg.mk (sc_check-I18N-AUTHORS): A new syntax check rule
to ensure we add LIBICONV where appropriate.
* THANKS.in: Add the reporter.
Reported by Christian Jullien
Syntax check suggested by Jim Meyering

11 years agomaint: refactor tests/misc/pr.pl into tests/pr/pr-tests.pl
Pádraig Brady [Wed, 24 Oct 2012 22:18:23 +0000 (23:18 +0100)]
maint: refactor tests/misc/pr.pl into tests/pr/pr-tests.pl

* tests/misc/pr.pl: Refactor this test into ...
* tests/pr/pr-tests.pl: ... here.
* tests/local.mk: Remove the reference to the removed test
Improved by Jim Meyering

11 years agobuild: do not redefine _FORTIFY_SOURCE
Mike Frysinger [Tue, 23 Oct 2012 19:20:07 +0000 (15:20 -0400)]
build: do not redefine _FORTIFY_SOURCE

When _FORTIFY_SOURCE is defined by the compiler or via flags, as
it is on Gentoo, do not override it.  Otherwise we get many
redefinition warnings.

* configure.ac (FORTIFY_SOURCE): Check if _FORTIFY_SOURCE is defined.
This addresses http://bugs.gnu.org/12714

11 years agomaint: post-release administrivia
Pádraig Brady [Tue, 23 Oct 2012 16:27:19 +0000 (17:27 +0100)]
maint: post-release administrivia

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

11 years agoversion 8.20 v8.20
Pádraig Brady [Tue, 23 Oct 2012 15:48:48 +0000 (16:48 +0100)]
version 8.20

* NEWS: Record release date.

11 years agofactor: add comments
Jim Meyering [Tue, 23 Oct 2012 10:08:58 +0000 (12:08 +0200)]
factor: add comments

* src/factor.c (is_square): Use active voice in comment, not passive.
(factor): Add function-describing comment.
(mp_factor): Likewise.

11 years agobuild: avoid warnings about unused variables and macros
Pádraig Brady [Tue, 23 Oct 2012 10:59:04 +0000 (11:59 +0100)]
build: avoid warnings about unused variables and macros

src/factor.c (__GMP_DECLSPEC): Move back from longlong.h
to treat consistently with other stub macros.
(__GMP_GNUC_PREREQ): Reference to avoid -Wunused-macros warning.
(__GMP_DECLSPEC): Likewise.
(ASSERT): Likewise.
(__clz_tab): Likewise.
(factor_using_division): Mark a variable as unused.
(mulredc): Likewise.
(mulredc2): Likewise.
(divexact_21): Likewise.

11 years agobuild: avoid compile warnings in factor.c on some systems
Pádraig Brady [Tue, 23 Oct 2012 10:03:32 +0000 (11:03 +0100)]
build: avoid compile warnings in factor.c on some systems

* src/factor.c (factor_using_pollard_rho2): On some systems
(like sparc) we need to promote all addmod2() parameters
to uintmax_t to avoid warnings.

11 years agobuild: avoid build failure on some sparc systems
Pádraig Brady [Tue, 23 Oct 2012 10:00:24 +0000 (11:00 +0100)]
build: avoid build failure on some sparc systems

* src/longlong.h: Restrict some sparc assembly variants
to sparc V9. This was seen to be an issue with newer
sparc systems with default gcc CPU options.

11 years agotests: correctly restrict factor test without GMP
Pádraig Brady [Mon, 22 Oct 2012 12:03:27 +0000 (13:03 +0100)]
tests: correctly restrict factor test without GMP

* tests/misc/factor.pl: Correct the precedence and
regular expression in the command to check for GMP.

11 years agodoc: NEWS: the cp bug affects mv and install, too
Jim Meyering [Sun, 21 Oct 2012 09:56:44 +0000 (11:56 +0200)]
doc: NEWS: the cp bug affects mv and install, too

* NEWS (Bug fixes): Note that the copy-induced corruption but affects
mv (sometimes) and install, too.  Pointed out by Bernhard Voelker.

11 years agodoc: remove a stray parenthesis from 'cp --force' description
Benno Schulenberg [Mon, 15 Oct 2012 11:12:46 +0000 (13:12 +0200)]
doc: remove a stray parenthesis from 'cp --force' description

* doc/coreutils.texi (cp invocation): Remove Cheshire Cat.

11 years agobuild: update gnulib submodule to latest
Jim Meyering [Wed, 17 Oct 2012 09:21:12 +0000 (11:21 +0200)]
build: update gnulib submodule to latest

11 years agocp: avoid data-corrupting free-memory-read
Jim Meyering [Tue, 16 Oct 2012 15:43:49 +0000 (17:43 +0200)]
cp: avoid data-corrupting free-memory-read

* src/extent-scan.c (extent_scan_read): Reset our last_ei
pointer whenever the parent buffer might have just been freed.
* tests/cp/fiemap-extent-FMR.sh: New test.
* tests/local.mk (all_tests): Add it.
* NEWS (Bug fixes): Mention it.
Reported by Mike Gerth in http://bugs.gnu.org/12656, and with
help from Alan Curry.  Bug introduced in commit v8.10-60-g18f5a85.

11 years agodoc: improve HACKING guidelines
Nikolas Kallis [Sat, 13 Oct 2012 17:52:33 +0000 (19:52 +0200)]
doc: improve HACKING guidelines

* HACKING: Add "cd coreutils" after the git clone command.
Copyright-paperwork-exempt: Yes

11 years agofactor: fix integer validation and GMP fallback
Pádraig Brady [Mon, 8 Oct 2012 14:48:43 +0000 (15:48 +0100)]
factor: fix integer validation and GMP fallback

In the recent factor rewrite, the GMP code
wasn't actually used; just an error was printed
on integer overflow.  While fixing that it was noticed
that correct input validation wasn't done in all cases
when falling back to the GMP code.

* src/factor.c (print_factors) Fallback to GMP on overflow.
(strto2uintmax): Scan the string for invalid characters,
so that case can be detected independently of overflow.
Return an error when an empty string is passed.
Also allow leading spaces and '+' in input numbers.
* tests/misc/factor.pl: Ensure the GMP code is exercised
when compiled in. Also add a test to verify leading
spaces and '+' are allowed.

11 years agobuild: support older GMP versions
Pádraig Brady [Mon, 8 Oct 2012 10:38:41 +0000 (11:38 +0100)]
build: support older GMP versions

The new factor code introduced usage of mpz_inits() and
mpz_clears(), which are only available since GMP >= 5,
and will result in a compile error when missing.

* m4/gmp.m4 (cu_GMP): Define HAVE_DECL_MPZ_INITS appropriately.
* src/factor (mpz_inits): New function, defined where missing.
(mpz_clears): Likewise.

11 years agomaint: avoid warning from gcc's -Wunused-macros
Jim Meyering [Sun, 7 Oct 2012 08:37:25 +0000 (10:37 +0200)]
maint: avoid warning from gcc's -Wunused-macros

On some systems, -Wunused-macros would warn about two macros:
src/factor.c:148:0: warning: macro "__clz_tab" is not used
src/factor.c:126:0: warning: macro "UHWtype" is not used
* src/factor.c: Add a use to placate gcc.

11 years agobuild: avoid link failure when strerror is replaced
Jim Meyering [Fri, 5 Oct 2012 20:35:27 +0000 (22:35 +0200)]
build: avoid link failure when strerror is replaced

When building the new make-prime-list program on a system for which
strerror is defined to rpl_strerror, we'd get a link failure.
The problem is that we're including <config.h> for some definitions,
but do not want the rpl_ ones, since this particular program must
not be linked against gnulib (aka libcoreutils.a).  This did not
arise on Fedora 17 or 18, but did on Debian wheezy/sid.
* src/make-prime-list.c (strerror): #undef.
Build failure introduced by commit v8.19-152-gcf67e4c.

11 years agofactor: 25% speed-up, on output
Jim Meyering [Tue, 18 Sep 2012 06:26:17 +0000 (08:26 +0200)]
factor: 25% speed-up, on output

* src/factor.c (print_factors_single): Use fputs and umaxtostr
rather than printf with "%ju".  This reduced the time required
to compute and print the factors of the first 10^7 integers from
over 8 seconds to 5.75s.  Run this command:
seq $((10**7)) | env time factor > /dev/null

11 years agofactor: merge with preexisting factor; integrate tests; avoid warnings
Jim Meyering [Sun, 16 Sep 2012 20:31:04 +0000 (22:31 +0200)]
factor: merge with preexisting factor; integrate tests; avoid warnings

* src/factor.c: Renamed from factor-ng.c, with the following changes:
Adjust copyright header to be consistent with others.
Use xmalloc and xrealloc, to avoid segv upon OOM.
Switch back to using readtokens to handle input.
Diagnose invalid inputs.
s/fprintf+exit/error/
(print_factors): Add comments.
(strto2uintmax): Return strtol_error, not int.
(read_item): Remove, no longer used.
(main): Use atexit(close_stdout) so that we don't ignore failed write.
* cfg.mk: Exempt src/longlong.h from several tests.
Exempt run.sh from the test-list-consistency test.
Exempt make-prime-list.c from numerous tests, since we won't
be making it conform: it must not link with libcoreutils.a.
Exempt factor-ng.c from the no-upper-case error message test.
* AUTHORS (factor): Add Torbjörn and Niels.
* tests/local.mk (factor_tests): Encode the 37 tests.
($(factor_tests)): Rule to generate a test script for each test.
* tests/factor/run.sh: New script, marked as very expensive.
* .gitignore: Ignore new generated files.
* src/local.mk (src/primes.h): New rule.
(noinst_PROGRAMS): Add make-prime-list.
(noinst_HEADERS): Add longlong.h.
Remove all wheel-related rules and files.
* src/wheel-gen.pl: Remove file.

maint: mark set-but-not-used variables with ATTRIBUTE_UNUSED
* src/factor-ng.c (redcify, prime_p, isqrt2): Mark them, so we
don't have to disable -Wunused-but-set-variable.

maint: use __builtin_expect only if __GNUC__
* src/factor-ng.c (LIKELY, UNLIKELY) [__GNUC__]: Add #ifdef guard.

build: avoid warning about unused macro
* src/factor-ng.c (__GMP_DECLSPEC): Don't define here
* src/longlong.h (__GMP_DECLSPEC): Define if not already defined.

11 years agofactor: more improvements
Niels Möller [Wed, 19 Sep 2012 14:20:11 +0000 (16:20 +0200)]
factor: more improvements

* src/factor-ng.c: Import some improvements from
http://gmplib.org:8000/factoring
Co-authored-by: Torbjörn Granlund <tg@gmplib.org>
11 years agofactor: new much-improved implementation; not yet integrated
Torbjörn Granlund [Sun, 16 Sep 2012 20:27:20 +0000 (22:27 +0200)]
factor: new much-improved implementation; not yet integrated

* src/factor-ng.c: New file, from nt-factor.
* src/longlong.h: New file.
* NEWS (Improvements): Mention the upcoming improvements.
Co-authored-by: Niels Möller
11 years agomaint: make-prime-list: syntax conventions; be robust for large N
Jim Meyering [Thu, 4 Oct 2012 18:27:31 +0000 (20:27 +0200)]
maint: make-prime-list: syntax conventions; be robust for large N

* src/make-prime-list.c: Insert spaces before parens.
(main): Abort if the 8-delta value ever exceeds 255.

11 years agomaint: make-prime-list: do not ignore write failure
Jim Meyering [Sun, 23 Sep 2012 09:33:01 +0000 (11:33 +0200)]
maint: make-prime-list: do not ignore write failure

Even though this is just a helper program that is run solely to create
primes.h, it should not ignore a write failure.  Normally we would
simply call atexit (close_stdout), but we cannot do that from this
helper program, since it must be built before the generated header,
primes.h.  If we were to make the linking of make-prime-list depend
on libcoreutils.a, that would add all lib/*.o files to the list
of dependents of $(BUILT_HEADERS).  Then, since there is currently no
provision to ensure that a file like lib/stdio.h (another built header)
is built before the first lib/*.o file that also includes <stdio.h>,
some lib/*.o files would be built before lib/stdio.h and some after.
The former would provoke link failures due to undefined rpl_* functions.
* src/make-prime-list.c: Include <errno.h>.
(fclose): Undef, so that a definition to rpl_fclose does not
cause a link failure.
(main): Per the above, in this exceptional case, we check for fclose
and ferror failure manually, and don't worry about the ferror-only
failure case in which errno may not be relevant.

11 years agomaint: make-prime-list: avoid -Wsuggest-attribute=const warning
Jim Meyering [Wed, 19 Sep 2012 09:07:41 +0000 (11:07 +0200)]
maint: make-prime-list: avoid -Wsuggest-attribute=const warning

* src/make-prime-list.c: Include <config.h>.
(binvert): Add _GL_ATTRIBUTE_CONST.

11 years agofactor: prepare for the new factor program
Torbjörn Granlund [Sun, 16 Sep 2012 19:59:40 +0000 (21:59 +0200)]
factor: prepare for the new factor program

* src/make-prime-list.c: New file, from nt-factor.
Co-authored-by: Niels Möller <nisse@lysator.liu.se>
11 years agobuild: remove redundant dependency: $(PROGRAMS): lib/libcoreutils.a
Jim Meyering [Tue, 18 Sep 2012 19:57:38 +0000 (21:57 +0200)]
build: remove redundant dependency: $(PROGRAMS): lib/libcoreutils.a

* src/local.mk: Remove the above dependency.
A soon-to-be-added new program, make-prime-list, must not depend
on that, since it is used to create a BUILT_SOURCES file.
That dependency is already handled via the ..._LD_ADD variables,
and so that redundant dependency has so far been harmless.

11 years agodu: avoid abort on systems for which ->me_type is not malloc'd
Jim Meyering [Sun, 30 Sep 2012 12:28:47 +0000 (14:28 +0200)]
du: avoid abort on systems for which ->me_type is not malloc'd

On some systems (notably, BSD-based, like at least OpenBSD 4.9),
the me_type member does not come from the heap.
* src/du.c (fill_mount_table): Free the ->me_type member only
when it was malloc'd, i.e., when ->me_type_malloced is nonzero.
Bug introduced via commit v8.19-2-gcf7e1b5.
Reported as http://bugs.gnu.org/12542.

11 years agodoc: same correction, but now in texinfo documentation
Jim Meyering [Sat, 29 Sep 2012 12:56:13 +0000 (14:56 +0200)]
doc: same correction, but now in texinfo documentation

* doc/coreutils.texi (nice invocation): s/nicenesses/niceness values/

11 years agodoc: correct an old bit of ugliness in nice --help output
Jim Meyering [Fri, 28 Sep 2012 16:42:05 +0000 (18:42 +0200)]
doc: correct an old bit of ugliness in nice --help output

* src/nice.c (usage): s/Nicenesses/Niceness values/

11 years agodoc: disambiguate the niceness explanation in nice --help
Pádraig Brady [Fri, 28 Sep 2012 16:13:57 +0000 (17:13 +0100)]
doc: disambiguate the niceness explanation in nice --help

* src/nice.c (usage): Specify the entity (process) that
that relative terms are referring to.
* THANKS: Update.
Reported-by: David Diggles
11 years agocp: fix the --no-preserve=mode option
Ondrej Oprala [Tue, 7 Aug 2012 14:56:52 +0000 (16:56 +0200)]
cp: fix the --no-preserve=mode option

The --no-preserve=mode option did not do what its name implies:
it would mistakenly preserve permission mode bits.
* NEWS: Mention the fix.
* TODO: Remove an entry.
* src/copy.c (copy_reg): Add a condition to properly
handle the --no-preserve=mode option for files
(copy_internal): Add a condition to properly handle the
--no-preserve=mode option for directories.
* src/copy.h (struct cp_options): Add a new boolean.
* src/cp.c (cp_option_init,decode_preserve_arg): Set the
new boolean value according to specified options.
* src/install.c (struct cp_options): Initialize the new boolean.
* src/mv.c (struct cp_options): Initialize the new boolean.
* tests/cp/preserve-mode.sh: Add a new test.
* tests/cp/link-preserve.sh (-a --no-preserve=mode): Adjust the
expected perms: now, --no-preserve=mode overrides the --preserve=mode
that is inherent in -a, as it should.
* tests/local.mk: Add the new test to the list.

11 years agotimeout: handle signals more transparently
Pádraig Brady [Wed, 12 Sep 2012 02:21:11 +0000 (03:21 +0100)]
timeout: handle signals more transparently

This was originally attempted in commit v8.12-117-g5a647a0,
but reverted before release because of the unreliability
of disabling core dumps using setrlimit() on Linux kernels.
This new version instead uses prctl() where available to
more reliably disable core dumps for the timeout process.

* m4/jm-macros.m4: Define HAVE_SETRLIMIT and HAVE_PRCTL.
* src/timeout.c (disable_core_dumps): A new function
that disables coredumps using prctl or setrlimit if available.
(main): If the child exited with a signal and we can
disable core dumps, then raise that signal to the timeout
process itself, so that callers may also see the signal status.
Also print a message indicating when the monitored command
dumped core, as that information is lost in the signal
propagation through timeout.

11 years agodd: new option, status=none to suppress output statistics
Pozsár Balázs [Mon, 24 Sep 2012 01:39:09 +0000 (02:39 +0100)]
dd: new option, status=none to suppress output statistics

* src/dd.c (STATUS_NONE): A new bitmask combining all STATUS_
options, thus used to suppress all informational output.
(struct symbol_value statuses): Expose the "none" option,
corresponding to the STATUS_NONE bitmask above.
(print_stats): Return early if STATUS_NONE is specified.
Also move the call to gethrxtime() down so that it's only
called when needed.
(usage): Describe the new options.
* doc/coreutils.texi (dd invocation): Likewise.
* NEWS: Mention the new feature.
* tests/dd/misc.sh: Ensure the new option works.

11 years agotail,stat: improve support for vmhgfs
Jim Meyering [Wed, 19 Sep 2012 19:52:05 +0000 (21:52 +0200)]
tail,stat: improve support for vmhgfs

Teach tail -f that it must use polling on vmhgfs file systems, and
let stat -f --format=%T report the file system type name, "vmhgfs".
* src/stat.c (human_fstype): Add a case: vmhgfs, 0xbacbacbc, remote.
* NEWS (Improvements): Mention it.
* THANKS.in: Update.
Reported by Daniel Tschinder in http://bugs.gnu.org/12461.

11 years agobuild: move non-recursive-gnulib-prefix-hack to gnulib; update
Jim Meyering [Thu, 20 Sep 2012 15:47:25 +0000 (17:47 +0200)]
build: move non-recursive-gnulib-prefix-hack to gnulib; update

I've moved the non-recursive-gnulib-prefix-hack module to
gnulib, with two small improvements, so remove it from here
and update gnulib to the latest.
* gl/build-aux/prefix-gnulib-mk: Remove file.
* gl/m4/non-recursive-gnulib-prefix-hack.m4: Remove file.
* gl/modules/non-recursive-gnulib-prefix-hack: Remove file.
* gnulib: Update to latest.

11 years agorm: be even more careful when using a replacement errno value
Jim Meyering [Wed, 19 Sep 2012 07:35:12 +0000 (09:35 +0200)]
rm: be even more careful when using a replacement errno value

* src/remove.c (excise): The change in commit v8.19-107-gccbd3f3 made
the "rm -rf D" (for unreadable dir, D) diagnostic worse on Solaris 10:
  -rm: cannot remove 'D': Permission denied
  +rm: cannot remove 'D': File exists
That happened because unlinkat would fail with EEXIST there, given
an unreadable directory, which made the two tests, tests/rm/unread2
and tests/rm/unreadable fail.  Accommodate the EEXIST case, too.

11 years agomaint: fix a comment typo
Jim Meyering [Wed, 19 Sep 2012 05:52:25 +0000 (07:52 +0200)]
maint: fix a comment typo

* cfg.mk: Fix comment typo: s/recursive/non-recursive/ make

11 years agotests: cp/link-heap: avoid new failure on rawhide
Jim Meyering [Tue, 18 Sep 2012 21:05:42 +0000 (23:05 +0200)]
tests: cp/link-heap: avoid new failure on rawhide

* tests/cp/link-heap.sh: Increase virtual memory limit by 2000KiB --
from 20,000 to 22,000 KiB -- to avoid a new failure on rawhide.

11 years agomaint: make the tight-scope syntax-check rule work again
Jim Meyering [Tue, 18 Sep 2012 14:29:49 +0000 (16:29 +0200)]
maint: make the tight-scope syntax-check rule work again

* cfg.mk: Configure a few variable to make the tight-scope rule work.
* gnulib: Update submodule to latest.

11 years agodd: remove references to the word BLOCKS from help and texi docs
Benno Schulenberg [Tue, 18 Sep 2012 12:58:42 +0000 (14:58 +0200)]
dd: remove references to the word BLOCKS from help and texi docs

The renaming from BLOCKS to N was done in v8.15-38-g140eca1,
and documentation for N was added again in v8.17-26-g4f2e9d5
without noticing that.  Now, finally remove the word BLOCKS
from the documentation.

* src/dd.c (usage): Remove the word BLOCKS.
* doc/coreutils.texi (dd invocation): Likewise.

Improved by: Bernhard Voelker <mail@bernhard-voelker.de>

11 years agodoc: NEWS: mention the conversion to non-recursive make
Jim Meyering [Sun, 16 Sep 2012 19:46:17 +0000 (21:46 +0200)]
doc: NEWS: mention the conversion to non-recursive make

* NEWS (Build-related): Mention the non-recursive make improvement.
Improved by: Pádraig Brady

11 years agols: fix coloring of dangling symlinks in default listing mode
Pádraig Brady [Sun, 16 Sep 2012 03:10:50 +0000 (04:10 +0100)]
ls: fix coloring of dangling symlinks in default listing mode

When listing a directory containing dangling symlinks,
and not outputting a long format listing, and orphaned links
are set to no coloring in LS_COLORS, then the symlinks
would get no color rather than reverting to the standard
symlink color.  The issue was introduced in v8.13-19-g84457c4

* src/ls.c (print_color_indicator): Use the standard method
to check if coloring is specified for orphaned symlinks.
The existing method would consider 'or=00' or 'or=0' as significant
in LS_COLORS. Even 'or=' was significant as in that case the
string='or=' and the length=0.  Also apply the same change
for missing symlinks for consistency.
(gobble_file): Remove the simulation of linkok, which is only
tested in print_color_indicator() which now handles this directly
by keying on the LS_COLORS values correctly.
* tests/misc/ls-misc.pl: Add a test case.
* THANKS: Add the reporter.
* NEWS: Mention the fix.
Reported-by: David Matei
11 years agodoc: update seq description
Jim Meyering [Sat, 15 Sep 2012 06:09:18 +0000 (08:09 +0200)]
doc: update seq description

* doc/coreutils.texi (seq invocation): Update an example and mention
that with the new constraints, seq can print arbitrarily large numbers.

11 years agoseq: enable the fast integer printing code in more cases
Pádraig Brady [Fri, 14 Sep 2012 13:21:03 +0000 (14:21 +0100)]
seq: enable the fast integer printing code in more cases

* src/seq.c (main): Adjust the initial arbitrary precision
seq_fast enablement checks to be more maintainable, and
a little more general, by allowing single character
separators to use seq_fast.
Also check again after the number arguments are processed,
to see if we can still use seq_fast, which while not
allowing arbitarly large integers, it will handle
integers of the form 10E10 etc.
(seq_fast): Use a specified separator character,
rather than hardcoding '\n'.

11 years agobuild: do not rely on automake's AM_TESTS_ENVIRONMENT
Jim Meyering [Fri, 14 Sep 2012 17:38:33 +0000 (19:38 +0200)]
build: do not rely on automake's AM_TESTS_ENVIRONMENT

* tests/local.mk (TESTS_ENVIRONMENT): Rename from AM_TESTS_ENVIRONMENT,
since it is not honored in automake-1.11.3 after all.
This reverts commit v8.19-38-g34c9c8f.  For now, I'll leave
the following commit that made bootstrap.conf require 1.11.2.
Prompted by a report of test failure from Pádraig Brady.

11 years agobuild: don't prefix the RHS of "GPERF = ..." with "lib/"
Jim Meyering [Fri, 14 Sep 2012 16:19:39 +0000 (18:19 +0200)]
build: don't prefix the RHS of "GPERF = ..." with "lib/"

* gl/build-aux/prefix-gnulib-mk (prefix_assignment): Exempt
the RHS of a "GPERF = ..." assignment from lib/ prefixing.

11 years agoseq: 70x faster for non-negative whole numbers and incr==1
Jim Meyering [Thu, 13 Sep 2012 16:09:49 +0000 (18:09 +0200)]
seq: 70x faster for non-negative whole numbers and incr==1

Handle non-negative whole numbers robustly and efficiently when
the increment is 1 and when no format-changing option is specified.
On the correctness front, for very large numbers, seq now works fine:

    $ b=1000000000000000000000000000
    $ src/seq ${b}09 ${b}11
    100000000000000000000000000009
    100000000000000000000000000010
    100000000000000000000000000011

while the old one would infloop, printing garbage:

    $ seq ${b}09 ${b}11 | head -2
    99999999999999999997315645440
    99999999999999999997315645440

The new code is much more efficient, too:
Old vs new: 55.81s vs 0.82s

  $ env time --f=%e seq $((10**8)) > /dev/null
  55.81
  $ env time --f=%e src/seq $((10**8)) > /dev/null
  0.82

* seq.c (incr): New function, inspired by the one in cat.c.
(cmp, seq_fast): New functions, inspired by code in nt-factor
by Torbjörn Granlund and Niels Möller.
(trim_leading_zeros): New function, without which cmp would malfunction.
(all_digits_p): New function.
(main): Hoist the format_str-vs-equal_width check to precede first
treatment of operands, and insert code to call seq_fast when possible.
* NEWS (Bug fixes): Mention the correctness fix.
(Improvements): Mention the speed-up.
* tests/misc/seq.pl: Exercise the new code.

Improved by: Bernhard Voelker.
http://thread.gmane.org/gmane.comp.gnu.coreutils.general/3340

11 years agotests: reenable "make -C tests ..." commands
Jim Meyering [Fri, 14 Sep 2012 07:25:33 +0000 (09:25 +0200)]
tests: reenable "make -C tests ..." commands

The README-documented way to run individual tests was invalidated
by the conversion of tests/ to non-recursive make.  Add a GNUmakefile
shim to reenable that usage.
* tests/GNUmakefile: New file, so that "make -C tests ..." works
like it did before the conversion of tests/ to non-recursive build.
Reported by Bernhard Voelker.
* Makefile.am (EXTRA_DIST): Add it.
* cfg.mk (sc_prohibit_tab_based_indentation): Also exempt any
GNUmakefile from this syntax-check.