Jim Meyering [Tue, 16 Dec 1997 15:09:19 +0000 (15:09 +0000)]
(struct bin_str): Make len int, not unsigned, to avoid
bogus comparison < 0.
(quote_filename): Add forward decl.
(decode_switches): -b, -e, -N, -Q are now mutually exclusive.
(print_dir): Quote directory name as per quoting options.
(print_long_format): Don't count color changes as part of file name.
(quote_filename): Revamp interface: now accepts stream to output to
and filename, and returns length of quoted filename.
This removes duplicated code and should make errors less likely.
Also, no longer mallocs storage. All callers changed.
Don't quote ' ' if -Q.
(OUTCHAR): New macro.
(SAVECHAR, SAVE_2_CHARS): Remove.
(print_name_with_quoting): New stack arg. All callers changed.
(print_color_indicator): Cast ext len to size_t to avoid warning
with GCC 2.8.
(length_of_file_name_and_frills): Rewrite to use quote_filename.
This fixes bug when computing file name length with -e.
1997-12-14 Paul Eggert <eggert@twinsun.com>
Add shell style quoting, and make it the default.
* NEWS, doc/fileutils.texi: Describe -e, which is now the default.
Describe change to --dired output.
* src/ls.c (quote_shell): New var.
(long_options, decode_switches, usage): New option -e or --quote-shell.
(dired_dump_obstack): New arg STYLE.
(main): Pass quoting style to dired_dump_obstack.
(decode_switches): -N now clears quote_as_string.
(quote_filename): Add shell style quoting.
Jim Meyering [Sat, 13 Dec 1997 22:49:33 +0000 (22:49 +0000)]
Change --help output to tell the truth: that for of=FILE,
FILE *is* truncated. Reported by Miles Bader.
Remove incomplete, usage-like comment at top of file.
Jim Meyering [Sat, 13 Dec 1997 16:22:58 +0000 (16:22 +0000)]
(do_move): If rename fails for any reason (not just when
errno == EXDEV), then revert to trying copy-then-unlink. This is
necessary to allow moving files within certain types of Linux NFS
mounted filesystems. Reported by Marty Leisner.
Jim Meyering [Thu, 11 Dec 1997 08:40:10 +0000 (08:40 +0000)]
(do_link): Don't require --force when target exists and
using --backup. This changes makes ln consistent with cp and mv in
this respect. Suggestion from Eli Zaretskii.
Jim Meyering [Sun, 30 Nov 1997 10:25:21 +0000 (10:25 +0000)]
(<limits.h>): Include if HAVE_LIMITS_H.
(CHAR_BIT, TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM, INT_MAX, UINT_MAX):
New macros.
(ST_NBLOCKS): Now counts actual blocks, not 512-byte blocks.
(ST_NBLOCKSIZE): New macro.
Jim Meyering [Sun, 30 Nov 1997 10:25:16 +0000 (10:25 +0000)]
(<inttypes.h>): Include if HAVE_INTTYPES_H.
("human.h"): Include.
(<limits.h>): Don't include; system.h does it now.
(INT_MAX): Remove.
(longdiff): Remove bogus definition that uses subtraction;
it gives the wrong answer when overflows occur.
(convert_blocks): Remove.
(output_units): New variable;
replaces booleans kilobyte_blocks and megabyte_blocks.
(human_readable_base): New variable.
(long_options, usage): Add -h or --human-readable and -H or --si.
(decode_switches): Adjust to renamed option variables.
Use -H if BLOCKSIZE is SI. Add -h, -H.
(print_dir): Count blocks using uintmax_t, not int.
(gobble_file): Now returns uintmax_t, not int.
Don't convert blocks to 512 byte units, as this might overflow;
let caller handle the problem. Deduce what caller will print
by invoking human_readable.
(print_long_format, print_file_name_and_frills): Don't assume
inode number, block count, file size fit in unsigned long.
Use human_readable to do block count conversion and to print
file sizes.
(prep_non_filename_text): Print decimal string for time if
localtime fails due to enormous time_t.
Jim Meyering [Sun, 30 Nov 1997 10:25:07 +0000 (10:25 +0000)]
(<inttypes.h>): Include if HAVE_INTTYPES_H.
("human.h"): Include.
(LONGEST_HUMAN_READABLE, enum Output_units): Remove.
(count_entry): Now returns uintmax_t, not long.
(human_readable_base): Renamed from opt_human_readable; value is now
zero or positive integer, not just zero or nonzero.
(output_units): Now an integer giving output size.
(tot_size): Now uintmax_t, not long.
(long_options, usage): Add --si or -H.
(main): Adjust to renamed option variables.
Use -H if BLOCKSIZE is SI. Add -H.
(human_readable): Remove; rewritten and now in lib/human.c.
(print_size): Rewrite in terms of human_readable.
Accept extra arg to be printed after size; all callers changed.
Jim Meyering [Sun, 30 Nov 1997 10:25:02 +0000 (10:25 +0000)]
(<inttypes.h>): Include if HAVE_INTTYPES_H.
("human.h"): Include.
(LONGEST_HUMAN_READABLE_1K_BYTE_BLOCKS): Remove.
(human_readable_base): Renamed from human_blocks; value is now
zero or positive integer, not just zero or nonzero.
(output_units): New variable;
replaces booleans kilobyte_blocks and megabyte_blocks.
(long_options): Add --si or -H.
(print_header): Adjust to renamed option variables.
(human_readable_1k_blocks): Remove.
(show_dev): Count blocks using uintmax_t, not long.
Calculate percentages using double, not long; this still isn't
perfect as it suffers double rounding, but it's more likely to
round correctly in practice than using long did.
Adjust to renamed option variables.
Use new human_readable library function to format uintmax_t values.
(usage): Add -H, --si.
(main): Adjust to renamed option variables.
Use -H if BLOCKSIZE is SI. Add -H.
Jim Meyering [Sun, 30 Nov 1997 10:24:58 +0000 (10:24 +0000)]
(<inttypes.h>): Include if HAVE_INTTYPES_H.
("human.h"): Include.
(input_blocksize, output_blocksize, conversion_blocksize):
Now size_t instead of long. 0 means unset.
(skip_records, seek_record, max_records): Now uintmax_t, not long.
(w_partial, w_full, r_partial, r_full, r_truncate):
Now uintmax_t instead of unsigned.
(print_stats): Print counts as uintmax_t, not unsigned.
(main, skip): Check for overflow when computing file offsets.
(skip): Records count arg is uintmax_t, not long; blocksize arg is
size_t, not long. Try lseek even on non regular files, as per comment.
(oc, col): Now size_t, not int.
(copy): No need to check max_records >= 0 any more, as the
default value is now effectively infinity.
Cast lseek arg to off_t.
(copy, copy_with_block): conversion_blocksize - col can never
be negative now, since it's unsigned, so rewrite loops to
avoid problems with unsigned.
(scanargs): Parse numeric args using uintmax_t, not int.
Check for overflow when converting block size args to size_t.
Blocksize options are now unsigned, and are now 0 when not set yet.
(parse_integer): Return uintmax_t, not int; accept new int * arg
to store error indicator, since all returned values are now valid.
Check for overflow when scanning integer.
Jim Meyering [Sun, 30 Nov 1997 10:24:54 +0000 (10:24 +0000)]
(<inttypes.h>): Include if HAVE_INTTYPES_H.
(hash_insert2): Cast inode number to uintmax_t; this prevents
negative remainders if the inode number is negative and ino_t
is longer than unsigned.
Jim Meyering [Sun, 30 Nov 1997 10:24:50 +0000 (10:24 +0000)]
(copy_reg): Store file size as off_t, not long.
Do not assume st_size has been normalized to 512 byte blocks,
or that it fits in size_t after dividing by the blocksize.
Jim Meyering [Sun, 30 Nov 1997 10:24:41 +0000 (10:24 +0000)]
(savedir): Check for size zero before invoking
malloc; this can occur if st_size arg overflows on conversion to
unsigned int. All callers now cast st_size arg to unsigned int.
Jim Meyering [Sun, 30 Nov 1997 10:24:24 +0000 (10:24 +0000)]
Do all calculations using uintmax_t.
Include <inttypes.h> if available.
(adjust_blocks, CONVERT_BLOCKS): Remove.
(get_fs_usage): Set new member fsu_blocksize, and do not convert
numbers to 512-byte block units; this avoids overflow here.
Cast lseek arg to off_t, not long.
Jim Meyering [Sun, 30 Nov 1997 10:24:20 +0000 (10:24 +0000)]
(st_blocks): long -> off_t.
Avoid arithmetic overflow when size is near max.
Depend on _POSIX_SOURCE and BSIZE, not _POSIX_VERSION, for
compatibility with system.h.
(BSIZE): Remove definition, since if BSIZE is not defined
we're never invoked.