Jim Meyering [Tue, 22 Jul 2003 16:32:33 +0000 (16:32 +0000)]
(.x.1): Substitute 's,$t/$*,$*,' on output of
help2man, to avoid having `rm.td/rm' appear in rm.1. Reported by
Thomas Luzat. See http://bugs.debian.org/202413 for details.
Jim Meyering [Tue, 22 Jul 2003 11:56:24 +0000 (11:56 +0000)]
Begin to address this comment: What if someone wants to
extract the 1,000,000-th field of some huge input file?
The first step is to rearrange things so that the values
in the printable_field array are all 0/1 rather than 0/1/2.
(RANGE_START_SENTINEL): Remove.
Store range-start indices in a hash table, rather than
overloading the `printable_field' array.
(range_start_ht): New global.
(hash_int, hash_compare_ints, is_range_start_index): New functions.
(print_kth): Use is_range_start_index; don't test printable_field.
(set_fields): Detect overflow.
(set_fields): Insert each range-start index into range_start_ht.
(main): Call set_fields only once, and only after
output_delimiter_specified and (if required) range_start_ht have
been defined.
Jim Meyering [Sun, 20 Jul 2003 15:45:29 +0000 (15:45 +0000)]
(write_counts): Add a comment.
(wc): Rename `file' parameter.
Set new local, `file', to be the file name, or (when it's NULL)
_("standard output") so that all uses of `file' use the proper value.
Use STREQ, not strcmp.
Jim Meyering [Sun, 20 Jul 2003 15:24:21 +0000 (15:24 +0000)]
wc count field widths now are heuristically adjusted depending
on the input size, if known. If only one count is printed, it
is guaranteed to be printed without leading spaces.
Previously, wc did not align the count fields if
POSIXLY_CORRECT was set, but POSIX did not actually require
this undesirable behavior, so it has been removed.
Jim Meyering [Sun, 20 Jul 2003 15:22:25 +0000 (15:22 +0000)]
(number_width): New var.
(posixly_correct): Remove.
(struct fstatus): New struct.
(write_counts): Output fields of width number_width.
Do not worry about POSIXLY_CORRECT.
Use null file, not empty-string file, to denote stdin,
since "" is a valid file name on some hosts.
(wc, wc_file): New arg fstatus. Use it to avoid invoking fstat
if possible.
(wc): Avoid problems if end_pos - current_pos overflows.
Do not print odd message if stdin has a read error.
(get_input_fstatus, compute_number_width): New functions.
(main): Use them to implement the new behavior.
Ignore POSIXLY_CORRECT.
Jim Meyering [Sat, 19 Jul 2003 11:19:12 +0000 (11:19 +0000)]
Use `id -u' to see if we're running as root,
rather than trying go write to an write-protected file.
When running as root, ensure $NON_ROOT_USERNAME is valid.
When running as root with `require-non-root', ensure that `.'
is writable by $NON_ROOT_USERNAME, then reinvoke $0 set-user-ID
to $NON_ROOT_USERNAME. If `.' is not writable, then skip the test.
Jim Meyering [Sat, 19 Jul 2003 08:08:56 +0000 (08:08 +0000)]
Likewise. Include "closeout.h" right after config.h,
to test that it can stand by itself. Include "exitfail.h".
Clients should set exit_failure instead.
(EXIT_FAILURE): Remove; no longer needed. Do not include <stdlib.h>.
Jim Meyering [Fri, 18 Jul 2003 08:38:43 +0000 (08:38 +0000)]
(usage): Don't call close_stdout here.
(main): Use close_stdout via atexit.
Now `su --version > /dev/full' fails, as it should.
Somehow, the change of 2000-05-07 that purports to fix this
was not checked in.